use of com.zsmartsystems.zigbee.zdo.command.ManagementBindRequest in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNode method updateBindingTable.
/**
* Request an update of the binding table for this node.
* <p>
* This method returns a future to a boolean. Upon success the caller should call {@link #getBindingTable()}
*
* @return {@link Future} returning a {@link Boolean}
*/
public Future<Boolean> updateBindingTable() {
RunnableFuture<Boolean> future = new FutureTask<Boolean>(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
int index = 0;
int tableSize = 0;
List<BindingTable> bindingTable = new ArrayList<BindingTable>();
do {
ManagementBindRequest bindingRequest = new ManagementBindRequest();
bindingRequest.setDestinationAddress(new ZigBeeEndpointAddress(networkAddress));
bindingRequest.setStartIndex(index);
CommandResult result = networkManager.unicast(bindingRequest, new ManagementBindRequest()).get();
if (result.isError()) {
return false;
}
ManagementBindResponse response = (ManagementBindResponse) result.getResponse();
if (response.getStartIndex() == index) {
tableSize = response.getBindingTableEntries();
index += response.getBindingTableList().size();
bindingTable.addAll(response.getBindingTableList());
}
} while (index < tableSize);
setBindingTable(bindingTable);
return true;
}
});
// start the thread to execute it
new Thread(future).start();
return future;
}
Aggregations