use of com.zsmartsystems.zigbee.dongle.cc2531.network.impl.BlockingCommandReceiver in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNetworkManager method dongleReset.
private boolean dongleReset() {
final BlockingCommandReceiver waiter = new BlockingCommandReceiver(ZToolCMD.SYS_RESET_RESPONSE, commandInterface);
try {
commandInterface.sendAsynchronousCommand(new SYS_RESET(SYS_RESET.RESET_TYPE.SERIAL_BOOTLOADER));
} catch (IOException e) {
logger.error("Failed to send SYS_RESET", e);
return false;
}
SYS_RESET_RESPONSE response = (SYS_RESET_RESPONSE) waiter.getCommand(RESET_TIMEOUT);
return response != null;
}
use of com.zsmartsystems.zigbee.dongle.cc2531.network.impl.BlockingCommandReceiver in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNetworkManager method sendAFDataRequest.
public AF_DATA_CONFIRM sendAFDataRequest(AF_DATA_REQUEST request) {
if (!waitForNetwork()) {
return null;
}
AF_DATA_CONFIRM result = null;
waitAndLock3WayConversation(request);
final BlockingCommandReceiver waiter = new BlockingCommandReceiver(ZToolCMD.AF_DATA_CONFIRM, commandInterface);
AF_DATA_SRSP response = (AF_DATA_SRSP) sendSynchronous(request);
if (response == null || response.Status != 0) {
waiter.cleanup();
} else {
result = (AF_DATA_CONFIRM) waiter.getCommand(TIMEOUT);
}
unLock3WayConversation(request);
return result;
}
use of com.zsmartsystems.zigbee.dongle.cc2531.network.impl.BlockingCommandReceiver in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNetworkManager method bootloaderGetOut.
private boolean bootloaderGetOut(int magicByte) {
final BlockingCommandReceiver waiter = new BlockingCommandReceiver(ZToolCMD.SYS_RESET_RESPONSE, commandInterface);
try {
commandInterface.sendRaw(new int[] { magicByte });
} catch (IOException e) {
logger.error("Failed to send bootloader magic byte", e);
}
SYS_RESET_RESPONSE response = (SYS_RESET_RESPONSE) waiter.getCommand(RESET_TIMEOUT);
return response != null;
}
use of com.zsmartsystems.zigbee.dongle.cc2531.network.impl.BlockingCommandReceiver in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNetworkManager method sendRemoteRequest.
public <REQUEST extends ZToolPacket, RESPONSE extends ZToolPacket> RESPONSE sendRemoteRequest(REQUEST request) {
if (!waitForNetwork()) {
return null;
}
RESPONSE result;
waitAndLock3WayConversation(request);
final BlockingCommandReceiver waiter = new BlockingCommandReceiver(ZToolCMD.ZDO_MGMT_PERMIT_JOIN_RSP, commandInterface);
logger.trace("Sending {}", request);
ZToolPacket response = sendSynchronous(request);
if (response == null) {
logger.error("{} timed out waiting for synchronous local response.", request.getClass().getSimpleName());
waiter.cleanup();
return null;
} else {
logger.error("{} timed out waiting for asynchronous remote response.", request.getClass().getSimpleName());
result = (RESPONSE) waiter.getCommand(TIMEOUT);
unLock3WayConversation(request);
return result;
}
}
Aggregations