timing issue

14 views
Skip to first unread message

han.a...@gmail.com

unread,
Oct 18, 2016, 8:16:36 AM10/18/16
to zigbee4java
Hello,
Starting to understand ZigBee4Java, I ran into the following.
Executing the following code (after starting zigbee4java)results in warning (Failed to send org.bubblecloud.zigbee.network.packet.af.AF_DATA_REQUEST during the 1-th (and 2nd and 3rd) tentative):


try {
while (close.get() == 0) {
if (deviceThreePresent.get() == 1) {
// Thread.sleep(3000);
ZigBeeDevice device = findDevice(api, 3);
System.out.println("+++ ACTION FOR DEVICE " + device);
// api.on(device);
waitingForEvents.add(api.read(device, ZigBeeApiConstants.CLUSTER_ID_BASIC, Attributes.MANUFACTURER_NAME.getId()));
deviceThreePresent.decrementAndGet();
}
Thread.sleep(1000);
Set<Future<CommandResult>> toRemove = new HashSet<Future<CommandResult>>();
System.out.println("Waiting for " + waitingForEvents.size() + " responses to be received");
for (Future<CommandResult> f : waitingForEvents) {
if (f.isDone()) {
CommandResult cr = f.get();
System.out.println("Command status: " + cr);
if (cr.isSuccess())
System.out.println("response : " + cr.getResponse());
toRemove.add(f);
}
}
waitingForEvents.removeAll(toRemove);
}
}

Actually, if a command is issued imediately after the device is found/detected, the AF-DATA_REQUEST is timed out.
If a sleeptime is added (Thread.sleep(3000);), the command behaves as expected.

Reply all
Reply to author
Forward
0 new messages