Skip to content

Commit

Permalink
fix #53: check that 64-bit address is not unknown before obtaining the
Browse files Browse the repository at this point in the history
remote XBee device from the network

#53

Signed-off-by: Ruben Moral <[email protected]>
  • Loading branch information
rubenmoral committed Jan 10, 2017
1 parent 2a4945c commit e7b006b
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,10 @@ public RemoteXBeeDevice getRemoteXBeeDeviceFromPacket(XBeeAPIPacket packet) thro
ReceivePacket receivePacket = (ReceivePacket)apiPacket;
addr64 = receivePacket.get64bitSourceAddress();
addr16 = receivePacket.get16bitSourceAddress();
remoteDevice = network.getDevice(addr64);
if (addr64 != XBee64BitAddress.UNKNOWN_ADDRESS)
remoteDevice = network.getDevice(addr64);
else if (addr16 != XBee16BitAddress.UNKNOWN_ADDRESS)
remoteDevice = network.getDevice(addr16);
break;
case RX_64:
RX64Packet rx64Packet = (RX64Packet)apiPacket;
Expand Down Expand Up @@ -744,7 +747,8 @@ public RemoteXBeeDevice getRemoteXBeeDeviceFromPacket(XBeeAPIPacket packet) thro
// If the origin is not in the network, add it.
if (remoteDevice == null) {
remoteDevice = createRemoteXBeeDevice(addr64, addr16, null);
network.addRemoteDevice(remoteDevice);
if (addr64 != XBee64BitAddress.UNKNOWN_ADDRESS || addr16 != XBee16BitAddress.UNKNOWN_ADDRESS)
network.addRemoteDevice(remoteDevice);
}

return remoteDevice;
Expand Down

0 comments on commit e7b006b

Please sign in to comment.