use of com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateResponse in project com.zsmartsystems.zigbee by zsmartsystems.
the class ConBeeSingleResponseTransactionTest method testResponseMatches.
@Test
public void testResponseMatches() {
ConBeeDeviceStateRequest request = new ConBeeDeviceStateRequest();
ConBeeTransaction transaction = new ConBeeSingleResponseTransaction(request, ConBeeDeviceStateResponse.class);
ConBeeDeviceStateResponse response = new ConBeeDeviceStateResponse(new int[] { 0x07, 0x00, 0x00, 0x08, 0x00, 0xA2, 0x00, 0x00, 0x4F, 0xFF });
assertTrue(transaction.isMatch(response));
transaction.getRequest();
assertEquals(1, transaction.getResponses().size());
assertNotNull(transaction.getResponses());
assertEquals(transaction.getResponses().get(0), transaction.getResponse());
}
use of com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateResponse in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeDongleConBee method startup.
@Override
public boolean startup(boolean reinitialize) {
logger.debug("ConBee transport startup");
ConBeeDeviceStateRequest stateRequest = new ConBeeDeviceStateRequest();
ConBeeDeviceStateResponse stateResponse = (ConBeeDeviceStateResponse) conbeeHandler.sendTransaction(new ConBeeSingleResponseTransaction(stateRequest, ConBeeDeviceStateResponse.class)).getResponse();
stateResponse.getDeviceState();
return true;
}
use of com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateResponse 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.ConBeeDeviceStateResponse in project com.zsmartsystems.zigbee by zsmartsystems.
the class ConBeeDeviceStateResponseTest method doRequest.
@Test
public void doRequest() {
ConBeeDeviceStateResponse response = new ConBeeDeviceStateResponse(new int[] { 0x07, 0x00, 0x00, 0x08, 0x00, 0xA2, 0x00, 0x00, 0x4F, 0xFF });
System.out.print(response);
assertEquals(0, response.getSequence());
assertEquals(ConBeeStatus.SUCCESS, response.getStatus());
assertEquals(ConBeeNetworkState.NET_CONNECTED, response.getDeviceState().getNetworkState());
assertFalse(response.getDeviceState().isDataConfirm());
assertFalse(response.getDeviceState().isDataIndication());
assertTrue(response.getDeviceState().isDataRequest());
assertFalse(response.getDeviceState().isConfigChanged());
}
use of com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateResponse in project com.zsmartsystems.zigbee by zsmartsystems.
the class ConBeeFrameTest method testCreateDeviceStateResponse.
@Test
public void testCreateDeviceStateResponse() {
ConBeeFrame frame = ConBeeFrame.create(new int[] { 0x07, 0x00, 0x00, 0x08, 0x00, 0xA2, 0x00, 0x00, 0x4F, 0xFF });
System.out.println(frame);
assertNotNull(frame);
assertTrue(frame instanceof ConBeeDeviceStateResponse);
assertEquals(0, frame.getSequence());
}
Aggregations