Skip to content

who_is / _discover returns 0 devices on WiFi network — worked for ~5 hours then stopped permanently #577

@nishad1092

Description

@nishad1092

Environment

Field Value
BAC0 version 2025.09.15 (Lite)
bacpypes3 version 0.0.104
Python version 3.x (async API)
OS (client) macOS
OS (device) Raspberry Pi OS
Network WiFi /24 subnet, consumer router

Description

Discovery worked fine for approximately 5 hours, then permanently stopped
finding devices without any code or network changes. Restarting does not
help — discovery always returns 0 devices now.

What still works throughout:

  • Direct unicast reads via bacnet.read()
  • Ping between devices ✅
  • Raw UDP port 47808 reachable in both directions ✅ - tested through nc -u -l 47808 and echo "test" | nc -u 192.168.178.xxx 47808 from both devices

Code

async with BAC0.start(ip=local_ip, port=port) as bacnet:

    found = await discover_devices(bacnet)
    if not found:
        print("No devices found.")
        return

    device_map = []
    for device_id, device_addr in found:
        name = await bacnet.read(f"{device_addr} device {device_id} objectName")
        objects = await get_device_objects(bacnet, device_id, device_addr)
        device_map.append((device_id, device_addr, objects))

    await poll_devices(bacnet, device_map)


async def discover_devices(bacnet):
    # Method 1: _discover
    try:
        await bacnet._discover(global_broadcast=True)
        await asyncio.sleep(5)
        devices = bacnet.discoveredDevices
        if devices:
            return [(int(k[0]), str(k[1]).split(":")[0]) for k in devices]
    except Exception:
        pass

    # Method 2: who_is fallback
    try:
        iam_results = await bacnet.who_is()
        await asyncio.sleep(5)
        if iam_results:
            return [(int(i.iAmDeviceIdentifier[1]), str(i.pduSource).split(":")[0])
                    for i in iam_results]
    except Exception:
        pass

    return []

Output

INFO | Using ip : <local_ip>/24 on port 47808 | broadcast : <broadcast_ip>
INFO | Using default JSON configuration file
INFO | Device instance (id) : <auto_generated>
WARNING | Request timed out for what_is_network_number, no response
INFO | Discovery done. Found 0 devices on 0 BACnet networks.
_discover found nothing, trying who_is...
No devices found.

Questions

  1. Why does discovery silently fail while unicast reads continue working?
  2. Is there a known condition where who_is / _discover stops working
    after extended runtime?
  3. Is there a recommended fallback when broadcast discovery returns empty?

Secondary Bug — JSON Config Silently Overrides deviceId

When passing deviceId explicitly to BAC0.lite(), a default JSON config
file overrides it:

INFO | Using default JSON configuration file
INFO | Device instance (id) : <wrong_id>   ← ignores deviceId passed in code

The file path is never logged, making it hard to locate and fix.

Request: log the config file path, and let explicit constructor parameters
take precedence over the file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions