use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZdoSimpleDescriptor method create.
public static ZigBeeApsFrame create(ZToolPacket packet) {
ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
apsFrame.setCluster(ZdoCommandType.SIMPLE_DESCRIPTOR_RESPONSE.getClusterId());
apsFrame.setDestinationEndpoint(0);
apsFrame.setSourceAddress(packet.getPacket()[4] + (packet.getPacket()[5] << 8));
apsFrame.setSourceEndpoint(0);
apsFrame.setProfile(0);
apsFrame.setPayload(Arrays.copyOfRange(packet.getPacket(), 5, packet.getPacket().length - 1));
return apsFrame;
}
use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZDO_MGMT_RTG_RSP_Test method testReceive.
@Test
public void testReceive() {
ZToolPacket data = getPacket("FE 0B 45 B2 00 00 00 01 00 01 2A 2F 00 35 38 F4");
ZigBeeApsFrame apsFrame = ZdoManagementRouting.create(data);
assertEquals(0x0000, apsFrame.getSourceAddress());
assertEquals(0, apsFrame.getProfile());
assertEquals(0, apsFrame.getDestinationEndpoint());
assertTrue(Arrays.equals(getPacketData("00 00 01 00 01 2A 2F 00 35 38"), apsFrame.getPayload()));
}
use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZDO_SIMPLE_DESC_RSP_Test method testReceive2.
@Test
public void testReceive2() {
ZToolPacket data = getPacket("FE 18 45 84 21 A4 00 21 A4 12 02 04 01 01 00 00 02 00 00 03 00 03 05 00 06 00 08 00 C4");
ZigBeeApsFrame apsFrame = ZdoSimpleDescriptor.create(data);
assertEquals(42017, apsFrame.getSourceAddress());
assertEquals(0, apsFrame.getProfile());
assertEquals(0, apsFrame.getDestinationEndpoint());
assertTrue(Arrays.equals(getPacketData("A4 00 21 A4 12 02 04 01 01 00 00 02 00 00 03 00 03 05 00 06 00 08 00"), apsFrame.getPayload()));
}
use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeDongleConBee method receiveIncomingFrame.
/**
* @param frame the received {@link ConBeeFrame}
*/
public void receiveIncomingFrame(ConBeeFrame frame) {
if (frame instanceof ConBeeReadReceivedDataResponse) {
ConBeeReadReceivedDataResponse receivedData = (ConBeeReadReceivedDataResponse) frame;
if (receivedData.getStatus() != ConBeeStatus.SUCCESS) {
return;
}
ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
// apsFrame.setApsCounter(emberApsFrame.getSequence());
apsFrame.setCluster(receivedData.getClusterId());
apsFrame.setDestinationEndpoint(receivedData.getDestinationEndpoint());
apsFrame.setProfile(receivedData.getProfileId());
apsFrame.setSourceEndpoint(receivedData.getSourceEndpoint());
// receivedData.getSourceAddressMode()
// apsFrame.sets
apsFrame.setSourceAddress(receivedData.getSourceNetworkAddress());
apsFrame.setPayload(receivedData.getAdsuData());
zigbeeNetworkReceive.receiveCommand(apsFrame);
return;
}
if (frame instanceof ConBeeDeviceStateChanged || frame instanceof ConBeeDeviceStateResponse) {
ConBeeDeviceState deviceState;
if (frame instanceof ConBeeDeviceStateChanged) {
deviceState = ((ConBeeDeviceStateChanged) frame).getDeviceState();
} else {
deviceState = ((ConBeeDeviceStateResponse) frame).getDeviceState();
}
if (!initialisationComplete || deviceState.getNetworkState() == currentNetworkState) {
return;
}
currentNetworkState = deviceState.getNetworkState();
switch(deviceState.getNetworkState()) {
case NET_CONNECTED:
zigbeeNetworkReceive.setNetworkState(ZigBeeTransportState.ONLINE);
break;
case NET_JOINING:
case NET_LEAVING:
case NET_OFFLINE:
zigbeeNetworkReceive.setNetworkState(ZigBeeTransportState.OFFLINE);
break;
default:
break;
}
}
}
use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZDO_END_DEVICE_ANNCE_IND_Test method testReceive.
@Test
public void testReceive() {
ZToolPacket data = getPacket("FE 0D 45 C1 2A 2F 2A 2F F9 41 F6 02 00 4B 12 00 00 9C");
ZigBeeApsFrame apsFrame = ZdoEndDeviceAnnounce.create(data);
assertEquals(0x2f2a, apsFrame.getSourceAddress());
assertEquals(0, apsFrame.getProfile());
assertEquals(0, apsFrame.getDestinationEndpoint());
assertTrue(Arrays.equals(getPacketData("2F 2A 2F F9 41 F6 02 00 4B 12 00 00"), apsFrame.getPayload()));
}
Aggregations