Search in sources :

Example 1 with ZB_WRITE_CONFIGURATION_RSP

use of com.zsmartsystems.zigbee.dongle.cc2531.network.packet.simple.ZB_WRITE_CONFIGURATION_RSP in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeNetworkManager method dongleSetPanId.

private boolean dongleSetPanId() {
    currentPanId = -1;
    ZB_WRITE_CONFIGURATION_RSP response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchronous(new ZB_WRITE_CONFIGURATION(ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_PANID, new int[] { Integers.getByteAsInteger(pan, 0), Integers.getByteAsInteger(pan, 1) }));
    return response != null && response.Status == 0;
}
Also used : ZB_WRITE_CONFIGURATION_RSP(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.simple.ZB_WRITE_CONFIGURATION_RSP) ZB_WRITE_CONFIGURATION(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.simple.ZB_WRITE_CONFIGURATION)

Example 2 with ZB_WRITE_CONFIGURATION_RSP

use of com.zsmartsystems.zigbee.dongle.cc2531.network.packet.simple.ZB_WRITE_CONFIGURATION_RSP in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeNetworkManager method dongleSetChannel.

/**
 * Sets the ZigBee RF channel. The allowable channel range is 11 to 26.
 * <p>
 * This method will sanity check the channel and if the mask is invalid
 * the default channel will be used.
 *
 * @param channelMask
 * @return
 */
private boolean dongleSetChannel(int[] channelMask) {
    // Error check the channels.
    // Incorrectly setting the channel can cause the stick to hang!!
    // Mask out any invalid channels
    channelMask[0] &= ZNP_CHANNEL_MASK0;
    channelMask[1] &= ZNP_CHANNEL_MASK1;
    channelMask[2] &= ZNP_CHANNEL_MASK2;
    channelMask[3] &= ZNP_CHANNEL_MASK3;
    // If there's no channels set, then we go for the default
    if (channelMask[0] == 0 && channelMask[1] == 0 && channelMask[2] == 0 && channelMask[3] == 0) {
        channelMask[0] = ZNP_CHANNEL_DEFAULT0;
        channelMask[1] = ZNP_CHANNEL_DEFAULT1;
        channelMask[2] = ZNP_CHANNEL_DEFAULT2;
        channelMask[3] = ZNP_CHANNEL_DEFAULT3;
    }
    logger.trace("Setting the channel to {}{}{}{}", new Object[] { Integer.toHexString(channelMask[0]), Integer.toHexString(channelMask[1]), Integer.toHexString(channelMask[2]), Integer.toHexString(channelMask[3]) });
    ZB_WRITE_CONFIGURATION_RSP response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchronous(new ZB_WRITE_CONFIGURATION(ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_CHANLIST, channelMask));
    return response != null && response.Status == 0;
}
Also used : ZB_WRITE_CONFIGURATION_RSP(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.simple.ZB_WRITE_CONFIGURATION_RSP) ZB_WRITE_CONFIGURATION(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.simple.ZB_WRITE_CONFIGURATION)

Example 3 with ZB_WRITE_CONFIGURATION_RSP

use of com.zsmartsystems.zigbee.dongle.cc2531.network.packet.simple.ZB_WRITE_CONFIGURATION_RSP 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)

Example 4 with ZB_WRITE_CONFIGURATION_RSP

use of com.zsmartsystems.zigbee.dongle.cc2531.network.packet.simple.ZB_WRITE_CONFIGURATION_RSP in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeNetworkManager method dongleSetStartupOption.

private boolean dongleSetStartupOption(int mask) {
    if ((mask & ~(STARTOPT_CLEAR_CONFIG | STARTOPT_CLEAR_STATE)) != 0) {
        logger.warn("Invalid ZCD_NV_STARTUP_OPTION mask {}.", String.format("%08X", mask));
        return false;
    }
    ZB_WRITE_CONFIGURATION_RSP response;
    response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchronous(new ZB_WRITE_CONFIGURATION(ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_STARTUP_OPTION, new int[] { mask }));
    if (response == null || response.Status != 0) {
        logger.warn("Couldn't set ZCD_NV_STARTUP_OPTION mask {}", String.format("%08X", mask));
        return false;
    } else {
        logger.trace("Set ZCD_NV_STARTUP_OPTION mask {}", String.format("%08X", mask));
    }
    return true;
}
Also used : ZB_WRITE_CONFIGURATION_RSP(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.simple.ZB_WRITE_CONFIGURATION_RSP) ZB_WRITE_CONFIGURATION(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.simple.ZB_WRITE_CONFIGURATION)

Aggregations

ZB_WRITE_CONFIGURATION (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.simple.ZB_WRITE_CONFIGURATION)4 ZB_WRITE_CONFIGURATION_RSP (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.simple.ZB_WRITE_CONFIGURATION_RSP)4 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