Skip to content

Commit beb31ce

Browse files
committed
addresses: fix several address comparisons using '==' instead of 'equals'
Signed-off-by: Ruben Moral <Ruben.Moral@digi.com>
1 parent e7b006b commit beb31ce

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

library/src/main/java/com/digi/xbee/api/AbstractXBeeDevice.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ public IConnectionInterface getConnectionInterface() {
432432
public void readDeviceInfo() throws TimeoutException, XBeeException {
433433
byte[] response = null;
434434
// Get the 64-bit address.
435-
if (xbee64BitAddress == null || xbee64BitAddress == XBee64BitAddress.UNKNOWN_ADDRESS) {
435+
if (xbee64BitAddress == null || xbee64BitAddress.equals(XBee64BitAddress.UNKNOWN_ADDRESS)) {
436436
String addressHigh;
437437
String addressLow;
438438

@@ -627,7 +627,7 @@ public void updateDeviceDataFrom(AbstractXBeeDevice device) {
627627

628628
// Only update the 64-bit address if the original is null or unknown.
629629
XBee64BitAddress addr64 = device.get64BitAddress();
630-
if (addr64 != null && addr64 != XBee64BitAddress.UNKNOWN_ADDRESS
630+
if (addr64 != null && !addr64.equals(XBee64BitAddress.UNKNOWN_ADDRESS)
631631
&& !addr64.equals(xbee64BitAddress)
632632
&& (xbee64BitAddress == null
633633
|| xbee64BitAddress.equals(XBee64BitAddress.UNKNOWN_ADDRESS))) {

library/src/main/java/com/digi/xbee/api/XBeeDevice.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2109,7 +2109,7 @@ protected APIOutputMode getAPIOutputMode() throws TimeoutException, XBeeExceptio
21092109
@Override
21102110
public String toString() {
21112111
String id = getNodeID() == null ? "" : getNodeID();
2112-
String addr64 = get64BitAddress() == null || get64BitAddress() == XBee64BitAddress.UNKNOWN_ADDRESS ?
2112+
String addr64 = get64BitAddress() == null || get64BitAddress().equals(XBee64BitAddress.UNKNOWN_ADDRESS) ?
21132113
"" : get64BitAddress().toString();
21142114

21152115
if (id.length() == 0 && addr64.length() == 0)

library/src/main/java/com/digi/xbee/api/connection/DataReader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,9 +699,9 @@ public RemoteXBeeDevice getRemoteXBeeDeviceFromPacket(XBeeAPIPacket packet) thro
699699
ReceivePacket receivePacket = (ReceivePacket)apiPacket;
700700
addr64 = receivePacket.get64bitSourceAddress();
701701
addr16 = receivePacket.get16bitSourceAddress();
702-
if (addr64 != XBee64BitAddress.UNKNOWN_ADDRESS)
702+
if (!addr64.equals(XBee64BitAddress.UNKNOWN_ADDRESS))
703703
remoteDevice = network.getDevice(addr64);
704-
else if (addr16 != XBee16BitAddress.UNKNOWN_ADDRESS)
704+
else if (!addr16.equals(XBee16BitAddress.UNKNOWN_ADDRESS))
705705
remoteDevice = network.getDevice(addr16);
706706
break;
707707
case RX_64:
@@ -747,7 +747,7 @@ else if (addr16 != XBee16BitAddress.UNKNOWN_ADDRESS)
747747
// If the origin is not in the network, add it.
748748
if (remoteDevice == null) {
749749
remoteDevice = createRemoteXBeeDevice(addr64, addr16, null);
750-
if (addr64 != XBee64BitAddress.UNKNOWN_ADDRESS || addr16 != XBee16BitAddress.UNKNOWN_ADDRESS)
750+
if (!addr64.equals(XBee64BitAddress.UNKNOWN_ADDRESS) || !addr16.equals(XBee16BitAddress.UNKNOWN_ADDRESS))
751751
network.addRemoteDevice(remoteDevice);
752752
}
753753

library/src/test/java/com/digi/xbee/api/connection/DataReaderTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@ public void setUp() throws Exception {
214214
NOT_SPECIFIC_PACKET = parser.parsePacket(new byte[]{0x7E, 0x00, 0x04, 0x08, 0x01, 0x4E, 0x49, 0x5F}, OperatingMode.API);
215215
AT_CMD_RESPONSE = parser.parsePacket(new byte[]{0x7E, 0x00, 0x08, 0x08, 0x01, 0x4E, 0x49, 0x4E, 0x41, 0x4D, 0x45, 0x3E}, OperatingMode.API);
216216
RMT_AT_CMD_RESPONSE = parser.parsePacket(new byte[]{0x7E, 0x00, 0x13, (byte)0x97, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0xFF, (byte)0xFE, 0x4E, 0x49, 0x00, 0x4E, 0x41, 0x4D, 0x45, (byte)0xB2}, OperatingMode.API);
217-
RX_64_PACKET = parser.parsePacket(new byte[]{0x7E, 0x00, 0x0F, (byte)0x80, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, 0x00, 0x01, 0x64, 0x61, 0x74, 0x61, (byte)0xEC}, OperatingMode.API);
217+
RX_64_PACKET = parser.parsePacket(new byte[]{0x7E, 0x00, 0x0F, (byte)0x80, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x00, 0x01, 0x64, 0x61, 0x74, 0x61, 0x08}, OperatingMode.API);
218218
RX_16_PACKET = parser.parsePacket(new byte[]{0x7E, 0x00, 0x09, (byte)0x81, (byte)0xFF, (byte)0xFE, 0x00, 0x01, 0x64, 0x61, 0x74, 0x61, (byte)0xE6}, OperatingMode.API);
219-
RX_PACKET = parser.parsePacket(new byte[]{0x7E, 0x00, 0x10, (byte)0x90, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFE, 0x01, 0x64, 0x61, 0x74, 0x61, (byte)0xDF}, OperatingMode.API);
220-
RX_IO_64_PACKET = parser.parsePacket(new byte[]{0x7E, 0x00, 0x10, (byte)0x82, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, 0x4B, 0x40, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, OperatingMode.API);
219+
RX_PACKET = parser.parsePacket(new byte[]{0x7E, 0x00, 0x10, (byte)0x90, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte)0xFF, (byte)0xFE, 0x01, 0x64, 0x61, 0x74, 0x61, (byte)0xFB}, OperatingMode.API);
220+
RX_IO_64_PACKET = parser.parsePacket(new byte[]{0x7E, 0x00, 0x10, (byte)0x82, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x4B, 0x40, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, 0x1B}, OperatingMode.API);
221221
RX_IO_16_PACKET = parser.parsePacket(new byte[]{0x7E, 0x00, 0x0A, (byte)0x83, (byte)0xFF, (byte)0xFE, 0x4B, 0x40, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xF9}, OperatingMode.API);
222222
RX_IO_PACKET = parser.parsePacket(new byte[]{0x7E, 0x00, 0x12, (byte)0x92, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFE, 0x40, 0x01, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, 0x3C}, OperatingMode.API);
223223
MODEM_STATUS_PACKET = parser.parsePacket(new byte[]{0x7E, 0x00, 0x02, (byte)0x8A, 0x11, 0x64}, OperatingMode.API);

0 commit comments

Comments
 (0)