Search in sources :

Example 1 with EzspVersionResponse

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeDongleEzsp method initialiseEzspProtocol.

private boolean initialiseEzspProtocol() {
    if (!serialPort.open()) {
        logger.error("Unable to open Ember serial port");
        return false;
    }
    ashHandler = new AshFrameHandler(this);
    EmberNcp ncp = new EmberNcp(ashHandler);
    // Connect to the ASH handler and NCP
    ashHandler.start(serialPort);
    ashHandler.connect();
    // We MUST send the version command first.
    EzspVersionResponse version = ncp.getVersion(4);
    logger.debug(version.toString());
    if (version.getProtocolVersion() != EzspFrame.getEzspVersion()) {
        // The device supports a different version that we current have set
        if (!EzspFrame.setEzspVersion(version.getProtocolVersion())) {
            logger.error("NCP requires unsupported version of EZSP (required = V{}, supported = V{})", version.getProtocolVersion(), EzspFrame.getEzspVersion());
            return false;
        }
        version = ncp.getVersion(EzspFrame.getEzspVersion());
        logger.debug(version.toString());
    }
    StringBuilder builder = new StringBuilder(60);
    builder.append("EZSP Version=");
    builder.append(version.getProtocolVersion());
    builder.append(", Stack Type=");
    builder.append(version.getStackType());
    builder.append(", Stack Version=");
    for (int cnt = 3; cnt >= 0; cnt--) {
        builder.append((version.getStackVersion() >> (cnt * 4)) & 0x0F);
        if (cnt != 0) {
            builder.append('.');
        }
    }
    versionString = builder.toString();
    return true;
}
Also used : EzspVersionResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse) AshFrameHandler(com.zsmartsystems.zigbee.dongle.ember.internal.ash.AshFrameHandler)

Example 2 with EzspVersionResponse

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse in project com.zsmartsystems.zigbee by zsmartsystems.

the class EzspFrameResponseTest method testResponseV5.

@Test
public void testResponseV5() {
    EzspVersionResponse response = new EzspVersionResponse(new int[] { 0x01, 0x80, 0xFF, 0x00, 0x00, 0x05, 0x02, 0x10, 0x5A });
    System.out.println(response);
    assertEquals(5, response.getProtocolVersion());
    assertEquals(0x5A10, response.getStackVersion());
}
Also used : EzspVersionResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse) Test(org.junit.Test)

Example 3 with EzspVersionResponse

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse in project com.zsmartsystems.zigbee by zsmartsystems.

the class EzspFrameResponseTest method testResponseV4.

@Test
public void testResponseV4() {
    EzspVersionResponse response = new EzspVersionResponse(new int[] { 0x01, 0x80, 0x00, 0x04, 0x02, 0x00, 0x59 });
    System.out.println(response);
    assertEquals(4, response.getProtocolVersion());
    assertEquals(0x5900, response.getStackVersion());
}
Also used : EzspVersionResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse) Test(org.junit.Test)

Example 4 with EzspVersionResponse

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberConsoleNcpVersionCommand method process.

@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException {
    EmberNcp ncp = getEmberNcp(networkManager);
    EzspVersionResponse version = ncp.getVersion(0);
    out.println("Ember NCP version " + getVersionString(version.getStackVersion()) + ", EZSP version " + EzspFrame.getEzspVersion());
}
Also used : EmberNcp(com.zsmartsystems.zigbee.dongle.ember.EmberNcp) EzspVersionResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse)

Example 5 with EzspVersionResponse

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse in project com.zsmartsystems.zigbee by zsmartsystems.

the class EzspSingleResponseTransactionTest method testResponseMatches.

@Test
public void testResponseMatches() {
    EzspVersionRequest version = new EzspVersionRequest();
    version.setSequenceNumber(3);
    version.setDesiredProtocolVersion(4);
    EzspTransaction versionTransaction = new EzspSingleResponseTransaction(version, EzspVersionResponse.class);
    EzspVersionResponse versionResponse = new EzspVersionResponse(getPacketData("03 80 00 04 02 00 58"));
    assertTrue(versionTransaction.isMatch(versionResponse));
    versionTransaction.getRequest();
    assertEquals(1, versionTransaction.getResponses().size());
    assertNotNull(versionTransaction.getResponses());
    assertEquals(versionTransaction.getResponses().get(0), versionTransaction.getResponse());
}
Also used : EzspVersionRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionRequest) EzspTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction) EzspVersionResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction) EzspFrameTest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest) Test(org.junit.Test)

Aggregations

EzspVersionResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse)7 Test (org.junit.Test)4 EzspVersionRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionRequest)3 EzspSingleResponseTransaction (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)3 EzspTransaction (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction)3 EzspFrameTest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest)2 EmberNcp (com.zsmartsystems.zigbee.dongle.ember.EmberNcp)1 AshFrameHandler (com.zsmartsystems.zigbee.dongle.ember.internal.ash.AshFrameHandler)1