Search in sources :

Example 1 with EzspChildJoinHandler

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspChildJoinHandler in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeDongleEzsp method handlePacket.

@Override
public void handlePacket(EzspFrame response) {
    logger.debug("RX: " + response.toString());
    if (response instanceof EzspIncomingMessageHandler) {
        EzspIncomingMessageHandler incomingMessage = (EzspIncomingMessageHandler) response;
        EmberApsFrame emberApsFrame = incomingMessage.getApsFrame();
        ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
        apsFrame.setApsCounter(emberApsFrame.getSequence());
        apsFrame.setCluster(emberApsFrame.getClusterId());
        apsFrame.setDestinationEndpoint(emberApsFrame.getDestinationEndpoint());
        apsFrame.setProfile(emberApsFrame.getProfileId());
        apsFrame.setSourceEndpoint(emberApsFrame.getSourceEndpoint());
        apsFrame.setSequence(incomingMessage.getSequenceNumber());
        apsFrame.setSourceAddress(incomingMessage.getSender());
        apsFrame.setPayload(incomingMessage.getMessageContents());
        zigbeeTransportReceive.receiveCommand(apsFrame);
        return;
    }
    // TODO: Check if this should be done only after initialisation is complete?
    if (response instanceof EzspStackStatusHandler) {
        switch(((EzspStackStatusHandler) response).getStatus()) {
            case EMBER_NETWORK_BUSY:
                break;
            case EMBER_NETWORK_DOWN:
                zigbeeTransportReceive.setNetworkState(ZigBeeTransportState.OFFLINE);
                break;
            case EMBER_NETWORK_UP:
                break;
            default:
                break;
        }
        return;
    }
    if (response instanceof EzspTrustCenterJoinHandler) {
        EzspTrustCenterJoinHandler joinHandler = (EzspTrustCenterJoinHandler) response;
        ZigBeeNodeStatus status;
        switch(joinHandler.getStatus()) {
            case EMBER_HIGH_SECURITY_UNSECURED_JOIN:
            case EMBER_STANDARD_SECURITY_UNSECURED_JOIN:
                status = ZigBeeNodeStatus.UNSECURED_JOIN;
                break;
            case EMBER_HIGH_SECURITY_UNSECURED_REJOIN:
            case EMBER_STANDARD_SECURITY_UNSECURED_REJOIN:
                status = ZigBeeNodeStatus.UNSECURED_REJOIN;
                break;
            case EMBER_HIGH_SECURITY_SECURED_REJOIN:
            case EMBER_STANDARD_SECURITY_SECURED_REJOIN:
                status = ZigBeeNodeStatus.SECURED_REJOIN;
                break;
            case EMBER_DEVICE_LEFT:
                status = ZigBeeNodeStatus.DEVICE_LEFT;
                break;
            default:
                logger.debug("Unknown state in trust centre join handler {}", joinHandler.getStatus());
                return;
        }
        zigbeeTransportReceive.nodeStatusUpdate(status, joinHandler.getNewNodeId(), joinHandler.getNewNodeEui64());
        return;
    }
    if (response instanceof EzspChildJoinHandler) {
        EzspChildJoinHandler joinHandler = (EzspChildJoinHandler) response;
        zigbeeTransportReceive.nodeStatusUpdate(ZigBeeNodeStatus.UNSECURED_JOIN, joinHandler.getChildId(), joinHandler.getChildEui64());
        return;
    }
    logger.debug("Unhandled EZSP Frame: {}", response.toString());
}
Also used : ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame) EzspStackStatusHandler(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspStackStatusHandler) EmberApsFrame(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberApsFrame) ZigBeeNodeStatus(com.zsmartsystems.zigbee.ZigBeeNodeStatus) EzspIncomingMessageHandler(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspIncomingMessageHandler) EzspTrustCenterJoinHandler(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspTrustCenterJoinHandler) EzspChildJoinHandler(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspChildJoinHandler)

Aggregations

ZigBeeApsFrame (com.zsmartsystems.zigbee.ZigBeeApsFrame)1 ZigBeeNodeStatus (com.zsmartsystems.zigbee.ZigBeeNodeStatus)1 EzspChildJoinHandler (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspChildJoinHandler)1 EzspIncomingMessageHandler (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspIncomingMessageHandler)1 EzspStackStatusHandler (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspStackStatusHandler)1 EzspTrustCenterJoinHandler (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspTrustCenterJoinHandler)1 EmberApsFrame (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberApsFrame)1