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