use of com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeSingleResponseTransaction 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.transaction.ConBeeSingleResponseTransaction in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeDongleConBee method initialize.
@Override
public ZigBeeInitializeResponse initialize() {
logger.debug("ConBee transport initialize");
zigbeeNetworkReceive.setNetworkState(ZigBeeTransportState.UNINITIALISED);
if (!serialPort.open()) {
logger.error("Unable to open ConBee serial port");
return ZigBeeInitializeResponse.FAILED;
}
conbeeHandler = new ConBeeFrameHandler(serialPort, this);
ConBeeVersionRequest versionRequest = new ConBeeVersionRequest();
ConBeeVersionResponse versionResponse = (ConBeeVersionResponse) conbeeHandler.sendTransaction(new ConBeeSingleResponseTransaction(versionRequest, ConBeeVersionResponse.class)).getResponse();
firmwareVersion = String.format("%08X", versionResponse.getVersion());
ConBeeReadParameterRequest readParameter;
ConBeeReadParameterResponse readResponse;
readParameter = new ConBeeReadParameterRequest();
readParameter.setParameter(ConBeeNetworkParameter.DEVICE_TYPE);
conbeeHandler.sendTransaction(new ConBeeSingleResponseTransaction(readParameter, ConBeeReadParameterResponse.class));
readParameter = new ConBeeReadParameterRequest();
readParameter.setParameter(ConBeeNetworkParameter.MAC_ADDRESS);
readResponse = (ConBeeReadParameterResponse) conbeeHandler.sendTransaction(new ConBeeSingleResponseTransaction(readParameter, ConBeeReadParameterResponse.class)).getResponse();
ieeeAddress = (IeeeAddress) readResponse.getValue();
readParameter = new ConBeeReadParameterRequest();
readParameter.setParameter(ConBeeNetworkParameter.NWK_PANID);
readResponse = (ConBeeReadParameterResponse) conbeeHandler.sendTransaction(new ConBeeSingleResponseTransaction(readParameter, ConBeeReadParameterResponse.class)).getResponse();
readParameter = new ConBeeReadParameterRequest();
readParameter.setParameter(ConBeeNetworkParameter.APS_EXTENDED_PANID);
conbeeHandler.sendTransaction(new ConBeeSingleResponseTransaction(readParameter, ConBeeReadParameterResponse.class));
readParameter = new ConBeeReadParameterRequest();
readParameter.setParameter(ConBeeNetworkParameter.NWK_ADDRESS);
conbeeHandler.sendTransaction(new ConBeeSingleResponseTransaction(readParameter, ConBeeReadParameterResponse.class));
readParameter = new ConBeeReadParameterRequest();
readParameter.setParameter(ConBeeNetworkParameter.NWK_EXTENDED_PANID);
conbeeHandler.sendTransaction(new ConBeeSingleResponseTransaction(readParameter, ConBeeReadParameterResponse.class));
readParameter = new ConBeeReadParameterRequest();
readParameter.setParameter(ConBeeNetworkParameter.CURRENT_CHANNEL);
conbeeHandler.sendTransaction(new ConBeeSingleResponseTransaction(readParameter, ConBeeReadParameterResponse.class));
ConBeeDeviceStateRequest stateRequest = new ConBeeDeviceStateRequest();
conbeeHandler.sendTransaction(new ConBeeSingleResponseTransaction(stateRequest, ConBeeDeviceStateResponse.class));
initialisationComplete = true;
return ZigBeeInitializeResponse.JOINED;
}
use of com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeSingleResponseTransaction in project com.zsmartsystems.zigbee by zsmartsystems.
the class ConBeeSingleResponseTransactionTest method testResponseMatchFails.
@Test
public void testResponseMatchFails() {
ConBeeDeviceStateRequest request = new ConBeeDeviceStateRequest();
ConBeeTransaction transaction = new ConBeeSingleResponseTransaction(request, ConBeeDeviceStateResponse.class);
ConBeeEnqueueSendDataResponse response = new ConBeeEnqueueSendDataResponse(new int[] { 0x12, 0x0D, 0x00, 0x09, 0x00, 0x02, 0x00, 0x22, 0x00, 0xB4, 0xFF });
assertFalse(transaction.isMatch(response));
assertNull(transaction.getResponse());
}
use of com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeSingleResponseTransaction in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeDongleConBee method getZigBeePanId.
@Override
public int getZigBeePanId() {
ConBeeReadParameterRequest readParameter = new ConBeeReadParameterRequest();
readParameter.setParameter(ConBeeNetworkParameter.NWK_PANID);
ConBeeReadParameterResponse response = (ConBeeReadParameterResponse) conbeeHandler.sendTransaction(new ConBeeSingleResponseTransaction(readParameter, ConBeeReadParameterResponse.class)).getResponse();
return (int) response.getValue();
}
use of com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeSingleResponseTransaction 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;
}
Aggregations