Search in sources :

Example 1 with BlockingCommandReceiver

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;
}
Also used : SYS_RESET(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.system.SYS_RESET) BlockingCommandReceiver(com.zsmartsystems.zigbee.dongle.cc2531.network.impl.BlockingCommandReceiver) SYS_RESET_RESPONSE(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.system.SYS_RESET_RESPONSE) IOException(java.io.IOException)

Example 2 with BlockingCommandReceiver

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;
}
Also used : AF_DATA_SRSP(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.af.AF_DATA_SRSP) AF_DATA_CONFIRM(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.af.AF_DATA_CONFIRM) BlockingCommandReceiver(com.zsmartsystems.zigbee.dongle.cc2531.network.impl.BlockingCommandReceiver)

Example 3 with BlockingCommandReceiver

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;
}
Also used : BlockingCommandReceiver(com.zsmartsystems.zigbee.dongle.cc2531.network.impl.BlockingCommandReceiver) SYS_RESET_RESPONSE(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.system.SYS_RESET_RESPONSE) IOException(java.io.IOException)

Example 4 with BlockingCommandReceiver

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;
    }
}
Also used : ZToolPacket(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket) BlockingCommandReceiver(com.zsmartsystems.zigbee.dongle.cc2531.network.impl.BlockingCommandReceiver) SYS_VERSION_RESPONSE(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.system.SYS_VERSION_RESPONSE) SYS_RESET_RESPONSE(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.system.SYS_RESET_RESPONSE)

Aggregations

BlockingCommandReceiver (com.zsmartsystems.zigbee.dongle.cc2531.network.impl.BlockingCommandReceiver)4 SYS_RESET_RESPONSE (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.system.SYS_RESET_RESPONSE)3 IOException (java.io.IOException)2 ZToolPacket (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket)1 AF_DATA_CONFIRM (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.af.AF_DATA_CONFIRM)1 AF_DATA_SRSP (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.af.AF_DATA_SRSP)1 SYS_RESET (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.system.SYS_RESET)1 SYS_VERSION_RESPONSE (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.system.SYS_VERSION_RESPONSE)1