From 60e8255a741d46e1adf56518548aec3b0137bf32 Mon Sep 17 00:00:00 2001 From: Chris Jackson Date: Tue, 9 Jul 2024 08:36:44 +1200 Subject: [PATCH] Fix discovery NPE (#1430) Signed-off-by: Chris Jackson --- .../zigbee/app/discovery/ZigBeeNetworkDiscoverer.java | 4 ++-- .../zigbee/zdo/command/IeeeAddressResponseTest.java | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/com.zsmartsystems.zigbee/src/main/java/com/zsmartsystems/zigbee/app/discovery/ZigBeeNetworkDiscoverer.java b/com.zsmartsystems.zigbee/src/main/java/com/zsmartsystems/zigbee/app/discovery/ZigBeeNetworkDiscoverer.java index 60c9325e9..b92ca9432 100644 --- a/com.zsmartsystems.zigbee/src/main/java/com/zsmartsystems/zigbee/app/discovery/ZigBeeNetworkDiscoverer.java +++ b/com.zsmartsystems.zigbee/src/main/java/com/zsmartsystems/zigbee/app/discovery/ZigBeeNetworkDiscoverer.java @@ -402,8 +402,8 @@ private boolean getAssociatedNodes(final int networkAddress) throws InterruptedE final IeeeAddressResponse ieeeAddressResponse = response.getResponse(); logger.debug("NWK Discovery for {} IeeeAddressRequest returned {}", String.format("%04X", networkAddress), ieeeAddressResponse); - if (ieeeAddressResponse != null && ieeeAddressResponse.getStatus() == ZdoStatus.SUCCESS - && startIndex == ieeeAddressResponse.getStartIndex()) { + if (ieeeAddressResponse != null && ieeeAddressResponse.getStatus() == ZdoStatus.SUCCESS && + ieeeAddressResponse.getStartIndex() != null && startIndex == ieeeAddressResponse.getStartIndex()) { associatedDevices.addAll(ieeeAddressResponse.getNwkAddrAssocDevList()); startIndex += ieeeAddressResponse.getNwkAddrAssocDevList().size(); diff --git a/com.zsmartsystems.zigbee/src/test/java/com/zsmartsystems/zigbee/zdo/command/IeeeAddressResponseTest.java b/com.zsmartsystems.zigbee/src/test/java/com/zsmartsystems/zigbee/zdo/command/IeeeAddressResponseTest.java index 5db933589..6df96816f 100644 --- a/com.zsmartsystems.zigbee/src/test/java/com/zsmartsystems/zigbee/zdo/command/IeeeAddressResponseTest.java +++ b/com.zsmartsystems.zigbee/src/test/java/com/zsmartsystems/zigbee/zdo/command/IeeeAddressResponseTest.java @@ -8,6 +8,7 @@ package com.zsmartsystems.zigbee.zdo.command; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import org.junit.Test; @@ -41,6 +42,7 @@ public void testReceiveShort() { assertEquals(new IeeeAddress("0022A300001732BF"), addressResponse.getIeeeAddrRemoteDev()); assertEquals(0x8001, (int) addressResponse.getClusterId()); assertEquals(ZdoStatus.SUCCESS, addressResponse.getStatus()); + assertNull(addressResponse.getStartIndex()); } @Test