use of com.zsmartsystems.zigbee.dongle.xbee.internal.protocol.XBeeReceivePacketExplicitEvent in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeDongleXBee method xbeeEventReceived.
@Override
public void xbeeEventReceived(XBeeEvent event) {
if (event instanceof XBeeReceivePacketExplicitEvent) {
XBeeReceivePacketExplicitEvent rxMessage = (XBeeReceivePacketExplicitEvent) event;
ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
apsFrame.setCluster(rxMessage.getClusterId());
apsFrame.setDestinationEndpoint(rxMessage.getDestinationEndpoint());
apsFrame.setProfile(rxMessage.getProfileId());
apsFrame.setSourceEndpoint(rxMessage.getSourceEndpoint());
apsFrame.setSourceAddress(rxMessage.getNetworkAddress());
apsFrame.setPayload(rxMessage.getData());
zigbeeTransportReceive.receiveCommand(apsFrame);
return;
}
// Handle devices joining and leaving
if (event instanceof XBeeModemStatusEvent) {
XBeeModemStatusEvent modemStatus = (XBeeModemStatusEvent) event;
switch(modemStatus.getStatus()) {
case COORDINATOR_STARTED:
coordinatorStarted = true;
if (initialisationComplete) {
zigbeeTransportReceive.setNetworkState(ZigBeeTransportState.ONLINE);
}
break;
case DISASSOCIATED:
zigbeeTransportReceive.setNetworkState(ZigBeeTransportState.OFFLINE);
break;
case HARDWARE_RESET:
break;
case JOINED_NETWORK:
break;
case NETWORK_SECURITY_KEY_UPDATED:
break;
case WATCHDOG_TIMER_RESET:
break;
default:
break;
}
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 XBee Frame: {}", event.toString());
}
use of com.zsmartsystems.zigbee.dongle.xbee.internal.protocol.XBeeReceivePacketExplicitEvent in project com.zsmartsystems.zigbee by zsmartsystems.
the class XBeeEventFactoryTest method testGetEvent.
@Test
public void testGetEvent() {
int[] data = getPacketData("00 1A 91 00 17 88 01 02 13 65 36 F7 7B 02 01 00 01 01 04 41 18 7C 01 21 00 00 20 C8 C4");
XBeeEvent frame = XBeeEventFactory.getXBeeFrame(data);
assertTrue(frame instanceof XBeeReceivePacketExplicitEvent);
System.out.println(frame);
XBeeReceivePacketExplicitEvent event = (XBeeReceivePacketExplicitEvent) frame;
assertEquals(Integer.valueOf(1), event.getClusterId());
assertEquals(Integer.valueOf(1), event.getDestinationEndpoint());
assertEquals(Integer.valueOf(63355), event.getNetworkAddress());
assertEquals(Integer.valueOf(0x104), event.getProfileId());
}
Aggregations