use of com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateChanged 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.dongle.conbee.internal.frame.ConBeeDeviceStateChanged in project com.zsmartsystems.zigbee by zsmartsystems.
the class ConBeeDeviceStateChangedTest method doRequest.
@Test
public void doRequest() {
ConBeeDeviceStateChanged response = new ConBeeDeviceStateChanged(new int[] { 0x0E, 0x11, 0x00, 0x07, 0x00, 0xA6, 0x00, 0x34, 0xFF });
System.out.print(response);
assertEquals(17, response.getSequence());
assertEquals(ConBeeStatus.SUCCESS, response.getStatus());
assertEquals(ConBeeNetworkState.NET_CONNECTED, response.getDeviceState().getNetworkState());
assertTrue(response.getDeviceState().isDataConfirm());
assertFalse(response.getDeviceState().isDataIndication());
assertTrue(response.getDeviceState().isDataRequest());
assertFalse(response.getDeviceState().isConfigChanged());
}
Aggregations