Search in sources :

Example 1 with AshFrameHandler

use of com.zsmartsystems.zigbee.dongle.ember.internal.ash.AshFrameHandler 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)

Aggregations

AshFrameHandler (com.zsmartsystems.zigbee.dongle.ember.internal.ash.AshFrameHandler)1 EzspVersionResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse)1