public async void PacketReceived(XBeePacket receivedPacket) { if (!_node.discovering) { return; } RemoteXBeeDevice rdevice = null; byte[] commandValue = _node.GetRemoteDeviceData((XBeeAPIPacket)receivedPacket); rdevice = await _node.ParseDiscoveryAPIData(commandValue, _node.xbeeDevice); // If a device with a specific id is being search and it is // already found, return it. if (_id != null) { if (rdevice != null && _id.Equals(rdevice.NodeID)) { lock (_node.deviceList) { _node.deviceList.Add(rdevice); } // If the local device is 802.15.4 wait until the 'end' command is received. if (_node.xbeeDevice.XBeeProtocol != XBeeProtocol.RAW_802_15_4) { _node.discovering = false; } } } else if (rdevice != null) { _node.notifyDeviceDiscovered(_listeners, rdevice); } }