Skip to content

Commit

Permalink
Change default to only add devices during a scan (#869)
Browse files Browse the repository at this point in the history
* Change default to only add devices during a scan

Signed-off-by: Chris Jackson <[email protected]>

* Fix unstable test (hopefully!)

Signed-off-by: Chris Jackson <[email protected]>

---------

Signed-off-by: Chris Jackson <[email protected]>
  • Loading branch information
cdjackson authored Oct 31, 2024
1 parent 507a186 commit a6438e7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Slzb06NetworkPortTest {
public void processReceivedData() {
Slzb06NetworkPort port = new Slzb06NetworkPort(null, 0);

byte[] chunk = new byte[Slzb06NetworkPort.RX_BUFFER_LEN - 1];
byte[] chunk = new byte[Slzb06NetworkPort.RX_BUFFER_LEN - 2];
byte[] extra = new byte[1];

for (int i = 0; i < chunk.length; i++) {
Expand All @@ -37,7 +37,7 @@ public void processReceivedData() {
extra[0] = 1;
port.processReceivedData(extra, 1);

for (int i = 0; i < chunk.length - 1; i++) {
for (int i = 0; i < chunk.length; i++) {
assertEquals(0, port.read(1));
}
assertEquals(1, port.read(1));
Expand All @@ -47,10 +47,10 @@ public void processReceivedData() {
public void processReceivedDataOverflow() {
Slzb06NetworkPort port = new Slzb06NetworkPort(null, 0);

byte[] chunk = new byte[Slzb06NetworkPort.RX_BUFFER_LEN];
byte[] chunk = new byte[Slzb06NetworkPort.RX_BUFFER_LEN - 1];
byte[] extra = new byte[1];

for (int i = 0; i < Slzb06NetworkPort.RX_BUFFER_LEN; i++) {
for (int i = 0; i < chunk.length; i++) {
chunk[i] = 0;
}
port.processReceivedData(chunk, chunk.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class ZigBeeDiscoveryService extends AbstractDiscoveryService {
private final static int SEARCH_TIME = 60;
private final static String CONFIG_PROPERTY_CREATE_RESULTS_ONLY_DURING_ACTIVE_SCANS = "createResultsOnlyDuringActiveScans";

private boolean createResultsOnlyDuringActiveScans = false;
private boolean createResultsOnlyDuringActiveScans = true;
private volatile boolean scanStarted = false;

private final Set<ZigBeeCoordinatorHandler> coordinatorHandlers = new CopyOnWriteArraySet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1161,13 +1161,24 @@ public void childHandlerDisposed(ThingHandler childHandler, Thing childThing) {
childThing.getUID(), children.size());
}

/**
* Check if the child defined with the {@link IeeeAddress} has completed initialisation
*
* @param address the {@link IeeeAddress}
* @return true if the child is initialised
*/
public boolean isChildInitialized(IeeeAddress address) {
logger.debug("{}: ZigBee coordinator {} check if child is initialised", address, getThing().getUID());
for (ZigBeeThingHandler child : children.values()) {
if (child.getIeeeAddress().equals(address)) {
logger.debug("{}: ZigBee coordinator {} check if child is initialised - found {}", address,
getThing().getUID(), child.isDeviceInitialized());
return child.isDeviceInitialized();
}
}

logger.debug("{}: ZigBee coordinator {} check if child is initialised - not found", address,
getThing().getUID());
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ private synchronized void doNodeInitialisation() {
}
}
} catch (Exception e) {
logger.error("{}: Exception creating channels ", nodeIeeeAddress, e);
logger.error("{}: Exception creating channels", nodeIeeeAddress, e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.HANDLER_INITIALIZING_ERROR);
return;
}
Expand Down

0 comments on commit a6438e7

Please sign in to comment.