Skip to content

Commit 60e8255

Browse files
authored
Fix discovery NPE (#1430)
Signed-off-by: Chris Jackson <[email protected]>
1 parent 9df7ffb commit 60e8255

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

com.zsmartsystems.zigbee/src/main/java/com/zsmartsystems/zigbee/app/discovery/ZigBeeNetworkDiscoverer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ private boolean getAssociatedNodes(final int networkAddress) throws InterruptedE
402402
final IeeeAddressResponse ieeeAddressResponse = response.getResponse();
403403
logger.debug("NWK Discovery for {} IeeeAddressRequest returned {}", String.format("%04X", networkAddress),
404404
ieeeAddressResponse);
405-
if (ieeeAddressResponse != null && ieeeAddressResponse.getStatus() == ZdoStatus.SUCCESS
406-
&& startIndex == ieeeAddressResponse.getStartIndex()) {
405+
if (ieeeAddressResponse != null && ieeeAddressResponse.getStatus() == ZdoStatus.SUCCESS &&
406+
ieeeAddressResponse.getStartIndex() != null && startIndex == ieeeAddressResponse.getStartIndex()) {
407407
associatedDevices.addAll(ieeeAddressResponse.getNwkAddrAssocDevList());
408408

409409
startIndex += ieeeAddressResponse.getNwkAddrAssocDevList().size();

com.zsmartsystems.zigbee/src/test/java/com/zsmartsystems/zigbee/zdo/command/IeeeAddressResponseTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package com.zsmartsystems.zigbee.zdo.command;
99

1010
import static org.junit.Assert.assertEquals;
11+
import static org.junit.Assert.assertNull;
1112

1213
import org.junit.Test;
1314

@@ -41,6 +42,7 @@ public void testReceiveShort() {
4142
assertEquals(new IeeeAddress("0022A300001732BF"), addressResponse.getIeeeAddrRemoteDev());
4243
assertEquals(0x8001, (int) addressResponse.getClusterId());
4344
assertEquals(ZdoStatus.SUCCESS, addressResponse.getStatus());
45+
assertNull(addressResponse.getStartIndex());
4446
}
4547

4648
@Test

0 commit comments

Comments
 (0)