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;
}
}
}
Aggregations