sendWhoIs method

  1. @override
Future<void> sendWhoIs({
  1. int lowLimit = -1,
  2. int highLimit = -1,
  3. int network = 0xFFFF,
})
override

Sends a Who-Is to discover devices.

lowLimit and highLimit limit the device instance range (-1 for no limit). network selects the broadcast: 0xFFFF global (default), 0 local network only, or a remote network number. Listen to iAmEvents for the answers.

Implementation

@override
Future<void> sendWhoIs({
  int lowLimit = -1,
  int highLimit = -1,
  int network = 0xFFFF,
}) async {
  _checkStarted();
  requests.add(const FakeBacnetRequest('sendWhoIs'));
  for (final device in _devices.values) {
    final id = device.deviceId;
    if (!device.online ||
        device.communication == BacnetCommunicationState.disable ||
        (lowLimit >= 0 && id < lowLimit) ||
        (highLimit >= 0 && id > highLimit)) {
      continue;
    }
    _bound.add(id);
    unawaited(
      Future<void>.delayed(latency + device.latency, () {
        if (_events.isClosed) return;
        _events.add(
          IAmEvent(
            deviceId: id,
            net: 0,
            mac: [10, 0, (id >> 8) & 0xFF, id & 0xFF, 0xBA, 0xC0],
            len: 0,
            maxApdu: device.maxApdu,
            vendorId: device.vendorId,
            segmentation: device.segmentation,
          ),
        );
      }),
    );
  }
}