use of com.zsmartsystems.zigbee.ZigBeeApsFrame 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());
}
use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZDO_MSG_CB_INCOMING_Test method testReceive.
@Test
public void testReceive() {
ZToolPacket data = getPacket("FE 15 45 FF 00 00 00 01 80 00 00 00 1B 00 5B 23 EB 09 00 4B 12 00 00 00 00 F6");
ZigBeeApsFrame apsFrame = ZdoCallbackIncoming.create(data);
assertEquals(0x8001, apsFrame.getCluster());
assertEquals(0x0000, apsFrame.getSourceAddress());
assertEquals(0, apsFrame.getProfile());
assertEquals(0, apsFrame.getDestinationEndpoint());
assertTrue(Arrays.equals(getPacketData("1B 00 5B 23 EB 09 00 4B 12 00 00 00 00"), apsFrame.getPayload()));
}
use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZDO_NODE_DESC_RSP_Test method testReceive.
@Test
public void testReceive() {
ZToolPacket data = getPacket("FE 12 45 82 00 00 00 00 00 00 40 0F 00 00 50 A0 00 01 00 A0 00 00 CB");
ZigBeeApsFrame apsFrame = ZdoNodeDescriptor.create(data);
assertEquals(0x0000, apsFrame.getSourceAddress());
assertEquals(0, apsFrame.getProfile());
assertEquals(0, apsFrame.getDestinationEndpoint());
assertTrue(Arrays.equals(getPacketData("00 00 00 00 00 40 0F 00 00 50 A0 00 01 00 A0 00 00"), apsFrame.getPayload()));
}
use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZDO_POWER_DESC_RSP_Test method testReceive.
@Test
public void testReceive() {
ZToolPacket data = getPacket("FE 07 45 83 00 00 00 00 00 10 C1 10");
ZigBeeApsFrame apsFrame = ZdoPowerDescriptor.create(data);
assertEquals(0x0000, apsFrame.getSourceAddress());
assertEquals(0, apsFrame.getProfile());
assertEquals(0, apsFrame.getDestinationEndpoint());
assertTrue(Arrays.equals(getPacketData("00 00 00 00 10 C1"), apsFrame.getPayload()));
}
use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZDO_SIMPLE_DESC_RSP_Test method testReceive1.
@Test
public void testReceive1() {
ZToolPacket data = getPacket("FE 2E 45 84 00 00 00 00 00 28 01 04 01 00 00 00 00 10 00 00 01 00 02 00 03 00 04 00 05 00 06 00 07 00 08 00 09 00 0F 00 0A 00 0C 00 15 00 00 01 01 01 CF");
ZigBeeApsFrame apsFrame = ZdoSimpleDescriptor.create(data);
assertEquals(0x0000, apsFrame.getSourceAddress());
assertEquals(0, apsFrame.getProfile());
assertEquals(0, apsFrame.getDestinationEndpoint());
assertTrue(Arrays.equals(getPacketData("00 00 00 00 28 01 04 01 00 00 00 00 10 00 00 01 00 02 00 03 00 04 00 05 00 06 00 07 00 08 00 09 00 0F 00 0A 00 0C 00 15 00 00 01 01 01"), apsFrame.getPayload()));
}
Aggregations