BACnet4J icon indicating copy to clipboard operation
BACnet4J copied to clipboard

RemoteDeviceDiscoverer can't find all devices connected

Open wangdong2023 opened this issue 11 months ago • 0 comments

Hi, we are using RemoteDeviceDiscoverer to find all connected bacnet devices, but some are missing from time to time. We are listening on 0.0.0.0/24, and sending WhoIs to broad cast address.

We use wireshark to capture the network, the devices all answered to the WhoIs request.

Is this reported before? What could go wrong?

` private synchronized LocalDevice getLocalDevice() { try { int deviceId = new Random().nextInt(10000); log.info("Local device id {}", deviceId); localDevice = new LocalDevice(deviceId, new DefaultTransport(ipNetwork)); // e.g. ip 0.0.0.0, broadcast address 192.168.0.255 localDevice.initialize(); } catch (Exception e) { log.error(e.getMessage(), e); throw new CustomizeException(e.getMessage()); }

  return localDevice;

} private List<RemoteDevice> getAllRemoteDevices(LocalDevice localDevice) throws InterruptedException { RemoteDeviceDiscoverer remoteDeviceDiscoverer = new RemoteDeviceDiscoverer(localDevice, remoteDevice -> { log.info("found {} {}", remoteDevice.getInstanceNumber(), remoteDevice.getAddress().getMacAddress().getDescription()); }); remoteDeviceDiscoverer.start();

    Thread.sleep(3000);

    List<RemoteDevice> remoteDevices = remoteDeviceDiscoverer.getRemoteDevices();

    remoteDeviceDiscoverer.stop();
    log.info("Found {} devices: ips are {}", remoteDevices.size(), remoteDevices.stream().map(rd -> rd.getAddress().getMacAddress().getDescription()).collect(Collectors.joining(",")));
    return remoteDevices;
}

`

wangdong2023 avatar Dec 13 '24 15:12 wangdong2023