Search in sources :

Example 1 with ConBeeSingleResponseTransaction

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());
}
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 ConBeeSingleResponseTransaction

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;
}
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 ConBeeSingleResponseTransaction

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());
}
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)

Example 4 with ConBeeSingleResponseTransaction

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

Example 5 with ConBeeSingleResponseTransaction

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

Aggregations

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