use of com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateRequest 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.ConBeeDeviceStateRequest 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.frame.ConBeeDeviceStateRequest in project com.zsmartsystems.zigbee by zsmartsystems.
the class ConBeeFrameHandler method queueFrame.
/**
* Add a frame to the send queue. The sendQueue is a FIFO queue.
* This method queues a {@link ConBeeFrame} frame without waiting for a response and
* no transaction management is performed.
*
* @param request {@link ConBeeFrameRequest}
*/
public synchronized void queueFrame(ConBeeFrameRequest request) {
sendQueue.add(request);
logger.debug("TX CONBEE queue: {}", sendQueue.size());
synchronized (transmitSync) {
logger.debug("TX CONBEE queue: {} sync", sendQueue.size());
if (sentFrame == null) {
logger.debug("TX CONBEE queue: {} send", sendQueue.size());
outputFrame(new ConBeeDeviceStateRequest());
}
}
logger.debug("TX CONBEE queue: {} exit", sendQueue.size());
}
use of com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateRequest in project com.zsmartsystems.zigbee by zsmartsystems.
the class ConBeeDeviceStateRequestTest method doRequest.
@Test
public void doRequest() {
ConBeeDeviceStateRequest request = new ConBeeDeviceStateRequest();
request.setSequence(0);
System.out.println(request);
assertTrue(Arrays.equals(new int[] { 0x07, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0xF1, 0xFF }, request.getOutputBuffer()));
}
use of com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateRequest 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());
}
Aggregations