Search in sources :

Example 1 with ZDO_STARTUP_FROM_APP

use of com.zsmartsystems.zigbee.dongle.cc2531.network.packet.zdo.ZDO_STARTUP_FROM_APP in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeNetworkManager method createZigBeeNetwork.

private boolean createZigBeeNetwork() {
    createCustomDevicesOnDongle();
    logger.debug("Creating network as {}", mode.toString());
    final int ALL_CLUSTERS = 0xFFFF;
    logger.trace("Reset seq: Trying MSG_CB_REGISTER");
    ZDO_MSG_CB_REGISTER_SRSP responseCb = (ZDO_MSG_CB_REGISTER_SRSP) sendSynchronous(new ZDO_MSG_CB_REGISTER(new DoubleByte(ALL_CLUSTERS)));
    if (responseCb == null) {
        return false;
    }
    ZB_WRITE_CONFIGURATION_RSP responseCfg;
    responseCfg = (ZB_WRITE_CONFIGURATION_RSP) sendSynchronous(new ZB_WRITE_CONFIGURATION(ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_ZDO_DIRECT_CB, new int[] { 1 }));
    if (responseCfg == null) {
        return false;
    }
    final int instantStartup = 0;
    ZDO_STARTUP_FROM_APP_SRSP response = (ZDO_STARTUP_FROM_APP_SRSP) sendSynchronous(new ZDO_STARTUP_FROM_APP(instantStartup), STARTUP_TIMEOUT);
    if (response == null) {
        return false;
    }
    switch(response.Status) {
        case 0:
            {
                logger.info("Initialized ZigBee network with existing network state.");
                return true;
            }
        case 1:
            {
                logger.info("Initialized ZigBee network with new or reset network state.");
                return true;
            }
        case 2:
            {
                logger.warn("Initializing ZigBee network failed.");
                return false;
            }
        default:
            {
                logger.error("Unexpected response state for ZDO_STARTUP_FROM_APP {}", response.Status);
                return false;
            }
    }
}
Also used : ZDO_MSG_CB_REGISTER(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.zdo.ZDO_MSG_CB_REGISTER) ZB_WRITE_CONFIGURATION_RSP(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.simple.ZB_WRITE_CONFIGURATION_RSP) ZDO_STARTUP_FROM_APP_SRSP(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.zdo.ZDO_STARTUP_FROM_APP_SRSP) ZDO_STARTUP_FROM_APP(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.zdo.ZDO_STARTUP_FROM_APP) ZB_WRITE_CONFIGURATION(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.simple.ZB_WRITE_CONFIGURATION) DoubleByte(com.zsmartsystems.zigbee.dongle.cc2531.zigbee.util.DoubleByte) ZDO_MSG_CB_REGISTER_SRSP(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.zdo.ZDO_MSG_CB_REGISTER_SRSP)

Aggregations

ZB_WRITE_CONFIGURATION (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.simple.ZB_WRITE_CONFIGURATION)1 ZB_WRITE_CONFIGURATION_RSP (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.simple.ZB_WRITE_CONFIGURATION_RSP)1 ZDO_MSG_CB_REGISTER (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.zdo.ZDO_MSG_CB_REGISTER)1 ZDO_MSG_CB_REGISTER_SRSP (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.zdo.ZDO_MSG_CB_REGISTER_SRSP)1 ZDO_STARTUP_FROM_APP (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.zdo.ZDO_STARTUP_FROM_APP)1 ZDO_STARTUP_FROM_APP_SRSP (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.zdo.ZDO_STARTUP_FROM_APP_SRSP)1 DoubleByte (com.zsmartsystems.zigbee.dongle.cc2531.zigbee.util.DoubleByte)1