Search in sources :

Example 1 with ConBeeDeviceStateRequest

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());
}
Also used : ConBeeSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeSingleResponseTransaction) ConBeeDeviceStateRequest(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateRequest) ConBeeTransaction(com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeTransaction) ConBeeDeviceStateResponse(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateResponse) Test(org.junit.Test)

Example 2 with ConBeeDeviceStateRequest

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;
}
Also used : ConBeeSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeSingleResponseTransaction) ConBeeDeviceStateRequest(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateRequest) ConBeeReadParameterResponse(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeReadParameterResponse) ConBeeVersionRequest(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeVersionRequest) ConBeeVersionResponse(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeVersionResponse) ConBeeReadParameterRequest(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeReadParameterRequest) ConBeeDeviceStateResponse(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateResponse) ConBeeFrameHandler(com.zsmartsystems.zigbee.dongle.conbee.internal.ConBeeFrameHandler)

Example 3 with ConBeeDeviceStateRequest

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());
}
Also used : ConBeeDeviceStateRequest(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateRequest)

Example 4 with ConBeeDeviceStateRequest

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()));
}
Also used : ConBeeDeviceStateRequest(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateRequest) Test(org.junit.Test)

Example 5 with ConBeeDeviceStateRequest

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());
}
Also used : ConBeeSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeSingleResponseTransaction) ConBeeDeviceStateRequest(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateRequest) ConBeeTransaction(com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeTransaction) ConBeeEnqueueSendDataResponse(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeEnqueueSendDataResponse) Test(org.junit.Test)

Aggregations

ConBeeDeviceStateRequest (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateRequest)6 ConBeeSingleResponseTransaction (com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeSingleResponseTransaction)4 ConBeeDeviceStateResponse (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateResponse)3 Test (org.junit.Test)3 ConBeeTransaction (com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeTransaction)2 ConBeeFrameHandler (com.zsmartsystems.zigbee.dongle.conbee.internal.ConBeeFrameHandler)1 ConBeeEnqueueSendDataResponse (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeEnqueueSendDataResponse)1 ConBeeReadParameterRequest (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeReadParameterRequest)1 ConBeeReadParameterResponse (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeReadParameterResponse)1 ConBeeVersionRequest (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeVersionRequest)1 ConBeeVersionResponse (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeVersionResponse)1