Search in sources :

Example 1 with ConBeeVersionResponse

use of com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeVersionResponse in project com.zsmartsystems.zigbee by zsmartsystems.

the class ConBeeVersionResponseTest method readMacAddress.

@Test
public void readMacAddress() {
    ConBeeVersionResponse readParameter = new ConBeeVersionResponse(new int[] { 0x0D, 0x02, 0x00, 0x09, 0x00, 0x00, 0x05, 0x1B, 0x26, 0xA2, 0xFF });
    System.out.println(readParameter);
    assertEquals(2, readParameter.getSequence());
    assertEquals(0x261B0500, readParameter.getVersion());
}
Also used : ConBeeVersionResponse(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeVersionResponse) Test(org.junit.Test)

Example 2 with ConBeeVersionResponse

use of com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeVersionResponse 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)

Aggregations

ConBeeVersionResponse (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeVersionResponse)2 ConBeeFrameHandler (com.zsmartsystems.zigbee.dongle.conbee.internal.ConBeeFrameHandler)1 ConBeeDeviceStateRequest (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateRequest)1 ConBeeDeviceStateResponse (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateResponse)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 ConBeeSingleResponseTransaction (com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeSingleResponseTransaction)1 Test (org.junit.Test)1