discoverLocalNetworkServices

suspend fun discoverLocalNetworkServices(context: Context, timeoutMs: Long = 3500): NsdDiscoveryResult

Discovers mDNS/DNS-SD services on the local network via NsdManager for a bounded time.

Iterates the MDNS_SERVICE_TYPES, counting responders per type. This characterizes the user's local network (smart TVs, printers, cast targets) without connecting to any service.

Privacy: high — local network device presence can identify a home/office network and nearby devices. On Android 13+ this typically requires the NEARBY_WIFI_DEVICES permission (see ltechnologies.onionphone.androwatch.permission.PermissionKind.LocalNetwork); the caller is responsible for the gate.

Return

Aggregated NsdDiscoveryResult; a zeroed result with discoverySuccess=false if NSD is unavailable.

Parameters

context

Context used to obtain NsdManager.

timeoutMs

Per-service-type discovery window in milliseconds.