use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspIncomingMessageHandler 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());
}
Aggregations