use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeDongleTelegesis method telegesisEventReceived.
@Override
public void telegesisEventReceived(TelegesisEvent event) {
if (event instanceof TelegesisReceiveMessageEvent) {
TelegesisReceiveMessageEvent rxMessage = (TelegesisReceiveMessageEvent) event;
ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
// apsFrame.setApsCounter(emberApsFrame.getSequence());
apsFrame.setCluster(rxMessage.getClusterId());
apsFrame.setDestinationEndpoint(rxMessage.getDestinationEp());
apsFrame.setProfile(rxMessage.getProfileId());
apsFrame.setSourceEndpoint(rxMessage.getSourceEp());
apsFrame.setSourceAddress(rxMessage.getNetworkAddress());
apsFrame.setPayload(rxMessage.getMessageData());
zigbeeTransportReceive.receiveCommand(apsFrame);
return;
}
// Handle devices joining and leaving
if (event instanceof TelegesisDeviceJoinedNetworkEvent) {
TelegesisDeviceJoinedNetworkEvent deviceJoinedEvent = (TelegesisDeviceJoinedNetworkEvent) event;
zigbeeTransportReceive.nodeStatusUpdate(ZigBeeNodeStatus.UNSECURED_JOIN, deviceJoinedEvent.getNetworkAddress(), deviceJoinedEvent.getIeeeAddress());
return;
}
if (event instanceof TelegesisDeviceLeftNetworkEvent) {
TelegesisDeviceLeftNetworkEvent deviceLeftEvent = (TelegesisDeviceLeftNetworkEvent) event;
zigbeeTransportReceive.nodeStatusUpdate(ZigBeeNodeStatus.DEVICE_LEFT, deviceLeftEvent.getNetworkAddress(), deviceLeftEvent.getIeeeAddress());
return;
}
// Handle link changes and notify framework or just reset link with dongle?
if (event instanceof TelegesisNetworkLeftEvent | event instanceof TelegesisNetworkLostEvent) {
zigbeeTransportReceive.setNetworkState(ZigBeeTransportState.OFFLINE);
return;
}
if (event instanceof TelegesisNetworkJoinedEvent) {
zigbeeTransportReceive.setNetworkState(ZigBeeTransportState.ONLINE);
return;
}
logger.debug("Unhandled Telegesis Frame: {}", event.toString());
}
use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZdoActiveEndpoint method create.
public static ZigBeeApsFrame create(ZToolPacket packet) {
ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
apsFrame.setCluster(ZdoCommandType.ACTIVE_ENDPOINTS_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 ZdoCallbackIncoming method create.
public static ZigBeeApsFrame create(ZToolPacket packet) {
ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
apsFrame.setCluster(packet.getPacket()[7] + (packet.getPacket()[8] << 8));
apsFrame.setDestinationAddress(packet.getPacket()[11] + (packet.getPacket()[12] << 8));
apsFrame.setDestinationEndpoint(0);
apsFrame.setSourceAddress(packet.getPacket()[4] + (packet.getPacket()[5] << 8));
apsFrame.setSourceEndpoint(0);
apsFrame.setProfile(0);
apsFrame.setApsCounter(packet.getPacket()[10]);
apsFrame.setPayload(Arrays.copyOfRange(packet.getPacket(), 12, packet.getPacket().length - 1));
return apsFrame;
}
use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZDO_ACTIVE_EP_RSP_Test method testReceive.
@Test
public void testReceive() {
String packetString = "FE 08 45 85 00 00 00 00 00 02 02 01 C9";
ZToolPacket data = getPacket(packetString);
assertEquals(packetString, data.getPacketString());
ZigBeeApsFrame apsFrame = ZdoActiveEndpoint.create(data);
assertEquals(0x0000, apsFrame.getSourceAddress());
assertEquals(0, apsFrame.getProfile());
assertEquals(0, apsFrame.getDestinationEndpoint());
assertTrue(Arrays.equals(getPacketData("00 00 00 00 02 02 01"), apsFrame.getPayload()));
}
use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZdoEndDeviceAnnounce method create.
public static ZigBeeApsFrame create(ZToolPacket packet) {
ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
apsFrame.setCluster(ZdoCommandType.DEVICE_ANNOUNCE.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;
}
Aggregations