");
+ out.print(indent + " * Note:");
+ len = 15;
+ continue;
+ }
+ if (len + word.length() > lineLen) {
+ out.println();
+ out.print(indent + " *");
+ len = 2;
+ }
+ out.print(" ");
+ out.print(word);
+ len += word.length();
+ }
+
+ if (len != 0) {
+ out.println();
+ }
+ }
+
+ protected String formatParameterString(Parameter parameter) {
+ if (parameter.displayType != null) {
+ switch (parameter.displayType.toLowerCase()) {
+ case "hex":
+ String size = "";
+ if (parameter.displayLength != 0) {
+ size = "0" + parameter.displayLength;
+ }
+ return "String.format(\"%" + size + "X\", " + camelCaseToLowerCamelCase(parameter.name) + ")";
+ default:
+ break;
+ }
+ }
+ return camelCaseToLowerCamelCase(parameter.name);
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack.autocode/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/autocode/CommandGenerator.java b/com.zsmartsystems.zigbee.dongle.zstack.autocode/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/autocode/CommandGenerator.java
new file mode 100644
index 0000000000..0c30c1ee9d
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack.autocode/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/autocode/CommandGenerator.java
@@ -0,0 +1,1095 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.autocode;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import com.zsmartsystems.zigbee.dongle.zstack.autocode.xml.Command;
+import com.zsmartsystems.zigbee.dongle.zstack.autocode.xml.Command.ZstackRequestType;
+import com.zsmartsystems.zigbee.dongle.zstack.autocode.xml.Enumeration;
+import com.zsmartsystems.zigbee.dongle.zstack.autocode.xml.Parameter;
+import com.zsmartsystems.zigbee.dongle.zstack.autocode.xml.Protocol;
+import com.zsmartsystems.zigbee.dongle.zstack.autocode.xml.Structure;
+import com.zsmartsystems.zigbee.dongle.zstack.autocode.xml.Value;
+
+/**
+ *
+ * @author Chris Jackson
+ *
+ */
+public class CommandGenerator extends ClassGenerator {
+ protected final String zssPackage = "com.zsmartsystems.zigbee";
+ protected final String zstackInternalPackage = "com.zsmartsystems.zigbee.dongle.zstack.internal";
+ protected final String zstackCommandPackage = "com.zsmartsystems.zigbee.dongle.zstack.api";
+
+ private List ");
+ if (command.description != null && !command.description.isEmpty()) {
+ outputWithLinebreak(out, "", command.description);
+ out.println(" * ");
+ }
+ out.println(" * Note that this code is autogenerated. Manual changes may be overwritten.");
+ out.println(" *");
+ out.println(" * @author Chris Jackson");
+ out.println(" */");
+
+ if (className.endsWith("Srsp") || className.endsWith("Areq")) {
+ addImport(zstackCommandPackage + ".ZstackFrameResponse");
+ out.println("public class " + className + " extends ZstackFrameResponse {");
+ } else {
+ addImport(zstackCommandPackage + ".ZstackFrameRequest");
+ out.println("public class " + className + " extends ZstackFrameRequest {");
+ }
+
+ for (Parameter parameter : parameters) {
+ if (parameter.auto_size != null) {
+ continue;
+ }
+
+ out.println();
+ out.println(" /**");
+ if (parameter.description != null && !parameter.description.isEmpty()) {
+ outputWithLinebreak(out, " ", parameter.description);
+ }
+ if (parameter.multiple) {
+ out.println(" * ");
+ out.println(" * Parameter allows multiple options so implemented as a {@link Set}.");
+ }
+ out.println(" */");
+ if (parameter.multiple) {
+ addImport("java.util.Set");
+ addImport("java.util.HashSet");
+ out.println(" private Set<" + getTypeClass(command.subsystem, parameter.data_type) + "> "
+ + camelCaseToLowerCamelCase(parameter.name) + " = new HashSet<>();");
+ } else {
+ out.println(" private " + getTypeClass(command.subsystem, parameter.data_type) + " "
+ + camelCaseToLowerCamelCase(parameter.name) + ";");
+ }
+
+ // out.println(" private " + getTypeClass(command.subsystem, parameter.data_type) + " "
+ // + camelCaseToLowerCamelCase(parameter.name) + ";");
+ }
+
+ if (className.endsWith("Srsp") || className.endsWith("Areq")) {
+ out.println();
+ out.println(" /**");
+ out.println(" * Response and Handler constructor");
+ out.println(" */");
+ out.println(" public " + className + "(int[] inputBuffer) {");
+ out.println(" // Super creates deserializer and reads header fields");
+ out.println(" super(inputBuffer);");
+ if (className.endsWith("Srsp")) {
+ out.println();
+ out.println(" synchronousCommand = true;");
+ }
+ out.println();
+ out.println(" // Deserialize the fields");
+ Map ");
+ if (structure.description != null && !structure.description.isEmpty()) {
+ outputWithLinebreak(out, "", structure.description);
+ out.println(" * ");
+ }
+ out.println(" * Note that this code is autogenerated. Manual changes may be overwritten.");
+ out.println(" *");
+ out.println(" * @author Chris Jackson");
+ out.println(" */");
+
+ addImport(zstackInternalPackage + ".serializer.ZstackSerializer");
+ addImport(zstackInternalPackage + ".serializer.ZstackDeserializer");
+ out.println("public class " + className + " {");
+
+ for (Parameter parameter : structure.parameters) {
+ if (parameter.auto_size != null) {
+ continue;
+ }
+
+ out.println();
+ out.println(" /**");
+ if (parameter.description != null && !parameter.description.isEmpty()) {
+ outputWithLinebreak(out, " ", parameter.description);
+ }
+ if (parameter.multiple) {
+ out.println(" * ");
+ out.println(" * Parameter allows multiple options so implemented as a {@link Set}.");
+ }
+ out.println(" */");
+ if (parameter.multiple) {
+ addImport("java.util.Set");
+ addImport("java.util.HashSet");
+ out.println(" private Set<" + getTypeClass(structure.subsystem, parameter.data_type) + "> "
+ + camelCaseToLowerCamelCase(parameter.name) + " = new HashSet<>();");
+ } else {
+ out.println(" private " + getTypeClass(structure.subsystem, parameter.data_type) + " "
+ + camelCaseToLowerCamelCase(parameter.name) + ";");
+ }
+
+ // out.println(" private " + getTypeClass(command.subsystem, parameter.data_type) + " "
+ // + camelCaseToLowerCamelCase(parameter.name) + ";");
+ }
+
+ for (Parameter parameter : structure.parameters) {
+ if (parameter.auto_size != null) {
+ continue;
+ }
+
+ out.println();
+ out.println(" /**");
+ outputWithLinebreak(out, " ", parameter.description);
+ out.println(" *");
+ if (parameter.multiple) {
+ out.println(" * @return the current " + camelCaseToLowerCamelCase(parameter.name)
+ + " as {@link Set} of {@link " + getTypeClass(structure.subsystem, parameter.data_type) + "}");
+ } else {
+ out.println(" * @return the current " + camelCaseToLowerCamelCase(parameter.name) + " as {@link "
+ + getTypeClass(structure.subsystem, parameter.data_type) + "}");
+ }
+ out.println(" */");
+ if (parameter.multiple) {
+ out.println(" public Set<" + getTypeClass(structure.subsystem, parameter.data_type) + "> get"
+ + upperCaseFirstCharacter(parameter.name) + "() {");
+ } else {
+ out.println(" public " + getTypeClass(structure.subsystem, parameter.data_type) + " get"
+ + upperCaseFirstCharacter(parameter.name) + "() {");
+ }
+
+ out.println(" return " + camelCaseToLowerCamelCase(parameter.name) + ";");
+ out.println(" }");
+ out.println();
+
+ if (parameter.multiple) {
+ out.println(" /**");
+ outputWithLinebreak(out, " ", parameter.description);
+ out.println(" *");
+ out.println(" * @param " + camelCaseToLowerCamelCase(parameter.name) + " the " + parameter.name
+ + " to add to the {@link Set} as {@link "
+ + getTypeClass(structure.subsystem, parameter.data_type) + "}");
+ out.println(" */");
+ out.println(" public void add" + upperCaseFirstCharacter(parameter.name) + "("
+ + getTypeClass(structure.subsystem, parameter.data_type) + " "
+ + camelCaseToLowerCamelCase(parameter.name) + ") {");
+ out.println(" this." + camelCaseToLowerCamelCase(parameter.name) + ".add("
+ + camelCaseToLowerCamelCase(parameter.name) + ");");
+ out.println(" }");
+ out.println();
+ out.println(" /**");
+ outputWithLinebreak(out, " ", parameter.description);
+ out.println(" *");
+ out.println(" * @param " + camelCaseToLowerCamelCase(parameter.name) + " the " + parameter.name
+ + " to remove to the {@link Set} as {@link "
+ + getTypeClass(structure.subsystem, parameter.data_type) + "}");
+ out.println(" */");
+ out.println(" public void remove" + upperCaseFirstCharacter(parameter.name) + "("
+ + getTypeClass(structure.subsystem, parameter.data_type) + " "
+ + camelCaseToLowerCamelCase(parameter.name) + ") {");
+ out.println(" this." + camelCaseToLowerCamelCase(parameter.name) + ".remove("
+ + camelCaseToLowerCamelCase(parameter.name) + ");");
+ out.println(" }");
+ } else {
+ out.println(" /**");
+ outputWithLinebreak(out, " ", parameter.description);
+ out.println(" *");
+ out.println(" * @param " + camelCaseToLowerCamelCase(parameter.name) + " the " + parameter.name
+ + " to set as {@link " + getTypeClass(structure.subsystem, parameter.data_type) + "}");
+ out.println(" */");
+ out.println(" public void set" + upperCaseFirstCharacter(parameter.name) + "("
+ + getTypeClass(structure.subsystem, parameter.data_type) + " "
+ + camelCaseToLowerCamelCase(parameter.name) + ") {");
+ out.println(" this." + camelCaseToLowerCamelCase(parameter.name) + " = "
+ + camelCaseToLowerCamelCase(parameter.name) + ";");
+ out.println(" }");
+ }
+ }
+
+ out.println();
+ out.println(" /**");
+ out.println(" * Serialize the data from this structure class to an integer array");
+ out.println(" *");
+ out.println(" * @param serializer the {@link ZstackSerializer} to use");
+ out.println(" */");
+ out.println(" public int[] serialize(ZstackSerializer serializer) {");
+ out.println(" // Serialize the fields");
+ for (Parameter parameter : structure.parameters) {
+ String enumModifier = "";
+ if (getDataType(parameter.data_type) != parameter.data_type) {
+ enumModifier = ".getKey()";
+ }
+ if (parameter.auto_size != null) {
+ out.println(" serializer.serialize" + getTypeSerializer(structure.subsystem, parameter.data_type)
+ + "(" + camelCaseToLowerCamelCase(parameter.auto_size) + ".length);");
+ continue;
+ }
+ if (parameter.multiple) {
+ out.println(" " + getTypeClass(structure.subsystem, getDataType(parameter.data_type)) + " tmp"
+ + upperCaseFirstCharacter(parameter.name) + " = 0;");
+ out.println(" for (" + getTypeClass(parameter.data_type) + " value : "
+ + camelCaseToLowerCamelCase(parameter.name) + ") {");
+ out.println(" tmp" + upperCaseFirstCharacter(parameter.name) + " += value.getKey();");
+ out.println(" }");
+ out.println(" serializer.serialize" + getTypeSerializer(structure.subsystem, parameter.data_type)
+ + "(" + "tmp" + upperCaseFirstCharacter(parameter.name) + ");");
+ } else {
+ out.println(" serializer.serialize" + getTypeSerializer(structure.subsystem, parameter.data_type)
+ + "(" + camelCaseToLowerCamelCase(parameter.name) + enumModifier + ");");
+ }
+ }
+ out.println(" return serializer.getBuffer();");
+ out.println(" }");
+
+ out.println();
+ out.println(" /**");
+ out.println(" * Deserialize the data into this structure class");
+ out.println(" *");
+ out.println(" * @param deserializer the {@link ZstackDeserializer} to use");
+ out.println(" */");
+ out.println(" public void deserialize (ZstackDeserializer deserializer) {");
+ out.println(" // Deserialize the fields");
+ Map ");
+ outputWithLinebreak(out, "", enumeration.description);
+ }
+ out.println(" * ");
+ out.println(" * Note that this code is autogenerated. Manual changes may be overwritten.");
+ out.println(" *");
+ out.println(" * @author Chris Jackson");
+ out.println(" */");
+
+ out.println("public enum " + className + " {");
+
+ if (!enumeration.fullyDefined) {
+ out.println(" /**");
+ out.println(" * Default unknown value");
+ out.println(" */");
+ out.println(" UNKNOWN(-1),");
+ }
+
+ boolean first = true;
+ for (Value value : enumeration.values) {
+ if (!first) {
+ out.println(",");
+ }
+ first = false;
+ out.println();
+ out.println(" /**");
+ outputWithLinebreak(out, " ", value.description);
+ out.println(" */");
+ out.print(" " + super.stringToConstant(value.name) + "(0x" + String.format("%04X", value.enum_value)
+ + ")");
+ }
+
+ out.println(";");
+
+ out.println();
+ out.println(" /**");
+ out.println(" * A mapping between the integer code and its corresponding type to");
+ out.println(" * facilitate lookup by code.");
+ out.println(" */");
+ out.println(" private static Map ");
+ out.println(" * Note that this code is autogenerated. Manual changes may be overwritten.");
+ out.println(" *");
+ out.println(" * @author Chris Jackson");
+ out.println(" */");
+ out.println("public class ZstackFrameFactory {");
+ out.println(" /**");
+ out.println(" * Logger");
+ out.println(" */");
+ out.println(" private static Logger logger = LoggerFactory.getLogger(ZstackFrameFactory.class);");
+
+ out.println();
+
+ out.println(" /*");
+ out.println(" * Subsystem definitions");
+ out.println(" */");
+ out.println(" public static int ZSTACK_RPC = 0x0000;");
+ out.println(" public static int ZSTACK_SYS = 0x0100;");
+ out.println(" public static int ZSTACK_MAC = 0x0200;");
+ out.println(" public static int ZSTACK_AF = 0x0400;");
+ out.println(" public static int ZSTACK_ZDO = 0x0500;");
+ out.println(" public static int ZSTACK_SAPI = 0x0600;");
+ out.println(" public static int ZSTACK_UTIL = 0x0700;");
+ out.println(" public static int ZSTACK_APP_CNF = 0x0F00;");
+ out.println(" public static int ZSTACK_SBL = 0x0D00;");
+ out.println();
+ out.println(" /**");
+ out.println(" * Subsystem definition mask");
+ out.println(" */");
+ out.println(" private static int ZSTACK_SUBSYSTEM_MASK = 0x1F;");
+ out.println();
+
+ for (Command command : commandMap.values()) {
+ if (command.requestType == ZstackRequestType.ASYNCMD) {
+ continue;
+ }
+
+ String reference = camelCaseToConstant(
+ command.name.substring(0, 1).toUpperCase() + command.name.substring(1));
+ out.println(
+ " private static final int " + reference + " = 0x" + String.format("%02X", command.id) + ";");
+ }
+
+ out.println();
+ out.println(" private static Map
+ * Usage notes...
+ *
+ * Note that this must be called prior to {@link #initialize()} for the configuration to be effective.
+ *
+ * @param configId the {@link ZstackConfigId} to be updated.
+ * @param value the value to set (as int[]). Setting this to null will remove the configuration Id from
+ * the list of configuration to be sent during NCP initialisation.
+ * @return the previously configured value, or null if no value was set for the {@link ZstackConfigId}
+ */
+ public int[] updateDefaultConfiguration(ZstackConfigId configId, int[] value) {
+ if (value == null) {
+ return stackConfiguration.remove(configId);
+ }
+ return stackConfiguration.put(configId, value);
+ }
+
+ /**
+ * Different hardware may use a different "Magic Number" to skip waiting in the bootloader. Otherwise
+ * the dongle may wait in the bootloader for 60 seconds after it's powered on or reset.
+ *
+ * This method allows the user to change the magic number which may be required when using different
+ * sticks.
+ *
+ * @param magicNumber the byte to send to the dongle to exit the bootloader
+ */
+ public void setMagicNumber(int magicNumber) {
+ this.magicNumber = magicNumber;
+ }
+
+ @Override
+ public ZigBeeStatus initialize() {
+ logger.debug("ZStack dongle initialize: Starting");
+
+ if (!serialPort.open()) {
+ logger.error("Unable to open ZStack serial port");
+ return ZigBeeStatus.COMMUNICATION_ERROR;
+ }
+
+ frameHandler = new ZstackProtocolHandler(this);
+ frameHandler.start(serialPort);
+
+ ZstackNetworkInitialisation netInitialiser = new ZstackNetworkInitialisation(frameHandler);
+ netInitialiser.setMagicNumber(magicNumber);
+
+ netInitialiser.initializeNcp(false, serialPort);
+
+ ZstackNcp ncp = getZstackNcp();
+
+ Set
+ * Note that for ZB3, this should be set to true, however for backward compatability with HA1.2, this needs to be
+ * set to false or devices will not be able to join the network.
+ *
+ * @param required true if the TCLK exchange procedure is required.
+ * @return {@link ZigBeeStatus}
+ */
+ public ZigBeeStatus requireKeyExchange(boolean required) {
+ ZstackNcp ncp = getZstackNcp();
+
+ return ncp.requireKeyExchange(required) == ZstackResponseCode.SUCCESS ? ZigBeeStatus.SUCCESS
+ : ZigBeeStatus.FAILURE;
+ }
+
+ @Override
+ public void updateTransportConfig(TransportConfig configuration) {
+ for (TransportConfigOption option : configuration.getOptions()) {
+ try {
+ switch (option) {
+ case CONCENTRATOR_CONFIG:
+ break;
+
+ case INSTALL_KEY:
+ ZstackNcp ncp = getZstackNcp();
+ ZigBeeKey nodeKey = (ZigBeeKey) configuration.getValue(option);
+ if (!nodeKey.hasAddress()) {
+ logger.debug("Attempt to set INSTALL_KEY without setting address");
+ configuration.setResult(option, ZigBeeStatus.FAILURE);
+ break;
+ }
+ ZstackResponseCode result = ncp.addInstallCode(nodeKey.getAddress(), nodeKey);
+
+ configuration.setResult(option,
+ result == ZstackResponseCode.SUCCESS ? ZigBeeStatus.SUCCESS : ZigBeeStatus.FAILURE);
+ break;
+
+ case RADIO_TX_POWER:
+ txPower = (int) configuration.getValue(option);
+ configuration.setResult(option, setTxPower(txPower));
+ break;
+
+ case DEVICE_TYPE:
+ deviceType = (DeviceType) configuration.getValue(option);
+ configuration.setResult(option, ZigBeeStatus.SUCCESS);
+ break;
+
+ case TRUST_CENTRE_LINK_KEY:
+ setTcLinkKey((ZigBeeKey) configuration.getValue(option));
+ configuration.setResult(option, ZigBeeStatus.SUCCESS);
+ break;
+
+ case TRUST_CENTRE_JOIN_MODE:
+ // configuration.setResult(option,
+ // setTcJoinMode((TrustCentreJoinMode) configuration.getValue(option)));
+ break;
+
+ default:
+ configuration.setResult(option, ZigBeeStatus.UNSUPPORTED);
+ logger.debug("Unsupported configuration option \"{}\" in ZStack dongle", option);
+ break;
+ }
+ } catch (ClassCastException e) {
+ configuration.setResult(option, ZigBeeStatus.INVALID_ARGUMENTS);
+ }
+ }
+ }
+
+ private ZigBeeStatus setTxPower(int txPower) {
+ ZstackNcp ncp = getZstackNcp();
+ Integer powerResponse = ncp.setTxPower(txPower);
+ if (powerResponse == null) {
+ logger.debug("ZStack error setting transmit power");
+ return ZigBeeStatus.COMMUNICATION_ERROR;
+ }
+
+ if (txPower != powerResponse) {
+ logger.debug("ZStack error setting transmit power. Requested {}dBm, but set to {}dBm", txPower,
+ powerResponse);
+ }
+
+ return ZigBeeStatus.SUCCESS;
+ }
+
+ @Override
+ public String getVersionString() {
+ return versionString;
+ }
+
+ /**
+ * Gets the endpoint given the profile - for sending
+ *
+ * @param profileId the profile ID
+ * @return the endpoint used for this profile
+ */
+ private int getSendingEndpoint(int profileId) {
+ synchronized (sender2Endpoint) {
+ if (sender2Endpoint.containsKey(profileId)) {
+ return sender2Endpoint.get(profileId);
+ } else {
+ logger.info("No endpoint registered for profileId={}", profileId);
+ return -1;
+ }
+ }
+ }
+
+ /**
+ * Gets the profile used in an endpoint.
+ *
+ * @param endpointId the endpoint
+ * @return the profile used in the endpoint
+ */
+ private int getEndpointProfile(int endpointId) {
+ synchronized (endpoint2Profile) {
+ if (endpoint2Profile.containsKey(endpointId)) {
+ return endpoint2Profile.get(endpointId);
+ } else {
+ logger.info("No endpoint {} registered", endpointId);
+ // final byte ep = createEndPoint( profileId);
+ return -1;
+ }
+ }
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/ZstackNcp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/ZstackNcp.java
new file mode 100644
index 0000000000..710f9bb833
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/ZstackNcp.java
@@ -0,0 +1,677 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.zsmartsystems.zigbee.ExtendedPanId;
+import com.zsmartsystems.zigbee.IeeeAddress;
+import com.zsmartsystems.zigbee.ZigBeeChannelMask;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+import com.zsmartsystems.zigbee.dongle.zstack.api.af.ZstackAfRegisterSreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.af.ZstackAfRegisterSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackAppCnfBdbAddInstallcodeSreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackAppCnfBdbAddInstallcodeSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackAppCnfBdbSetActiveDefaultCentralizedKeySreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackAppCnfBdbSetActiveDefaultCentralizedKeySrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackAppCnfBdbSetTcRequireKeyExchangeSreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackAppCnfBdbSetTcRequireKeyExchangeSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackAppCnfSetAllowrejoinTcPolicySreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackAppCnfSetAllowrejoinTcPolicySrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackCentralizedLinkKeyMode;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackInstallCodeFormat;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sapi.ZstackZbReadConfigurationSreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sapi.ZstackZbReadConfigurationSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sapi.ZstackZbWriteConfigurationSreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sapi.ZstackZbWriteConfigurationSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackConfigId;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackDiagnosticAttribute;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackResetType;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysOsalNvReadSreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysOsalNvReadSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysOsalNvWriteSreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysOsalNvWriteSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysPingSreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysPingSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysResetIndAreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysResetReqAcmd;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysSetTxPowerSreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysSetTxPowerSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysVersionSreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysVersionSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysZdiagsGetStatsSreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysZdiagsGetStatsSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSystemCapabilities;
+import com.zsmartsystems.zigbee.dongle.zstack.api.util.ZstackUtilGetDeviceInfoSreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.util.ZstackUtilGetDeviceInfoSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.util.ZstackUtilGetNvInfoSreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.util.ZstackUtilGetNvInfoSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.util.ZstackUtilSetChannelsSreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.util.ZstackUtilSetChannelsSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.zdo.ZstackZdoMsgCbRegisterSreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.zdo.ZstackZdoMsgCbRegisterSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.zdo.ZstackZdoStartupFromAppSreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.zdo.ZstackZdoStartupFromAppSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.internal.ZstackFrameHandler;
+import com.zsmartsystems.zigbee.dongle.zstack.internal.ZstackProtocolHandler;
+import com.zsmartsystems.zigbee.dongle.zstack.internal.transaction.ZstackSingleResponseTransaction;
+import com.zsmartsystems.zigbee.dongle.zstack.internal.transaction.ZstackTransaction;
+import com.zsmartsystems.zigbee.security.ZigBeeKey;
+import com.zsmartsystems.zigbee.transport.DeviceType;
+
+/**
+ * This class provides utility methods for accessing the ZStack NCP and returning specific data for use in the
+ * application. It ensures the correct correlation of the requests and responses, and checks for errors.
+ *
+ * @author Chris Jackson - Initial contribution
+ *
+ */
+public class ZstackNcp {
+ /**
+ * The {@link Logger}.
+ */
+ private final Logger logger = LoggerFactory.getLogger(ZstackNcp.class);
+
+ /**
+ * Flag to use the old (deprecated) config functions
+ */
+ private boolean useOldCfgCalls = true;
+
+ /*
+ * Startup options bitmap
+ */
+ private final int STARTOPT_CLEAR_CONFIG = 0x0001;
+ private final int STARTOPT_CLEAR_STATE = 0x0002;
+
+ /**
+ * The protocol handler used to send and receive ZStack packets
+ */
+ private ZstackProtocolHandler protocolHandler;
+
+ /**
+ * Create the NCP instance
+ *
+ * @param protocolHandler the {@link ZstackFrameHandler} used for communicating with the NCP
+ */
+ public ZstackNcp(ZstackProtocolHandler protocolHandler) {
+ this.protocolHandler = protocolHandler;
+ }
+
+ /**
+ * Resets the NCP
+ *
+ * @param resetType the {@link ZstackResetType} to request
+ * @return the {@link ZstackSysResetIndAreq} from the NCP or null if there was an error
+ */
+ public ZstackSysResetIndAreq resetNcp(ZstackResetType resetType) {
+ ZstackSysResetReqAcmd request = new ZstackSysResetReqAcmd();
+ request.setType(resetType);
+ ZstackTransaction transaction = protocolHandler
+ .sendTransaction(new ZstackSingleResponseTransaction(request, ZstackSysResetIndAreq.class));
+ ZstackSysResetIndAreq response = (ZstackSysResetIndAreq) transaction.getResponse();
+ if (response == null) {
+ logger.debug("No response from Reset command");
+ return null;
+ }
+ logger.debug(response.toString());
+
+ return response;
+ }
+
+ /**
+ * Ping the NCP and return the set of subsystem capabilities compiled into the NCP firmware
+ *
+ * @return the list of subsystem {@link ZstackSystemCapabilities} from the NCP, or an empty set if there was an
+ * error
+ */
+ public Set
+ * The CC2530-ZNP device has two kinds of information stored in non-volatile memory. The configuration parameters
+ * and network state information.
+ *
+ * The configuration parameters are configured by the user before start of ZigBee operation. The
+ * STARTOPT_CLEAR_CONFIG bit is read by the CC2530-ZNP device immediately when it powers up after a reset.
+ * When the configuration parameters are restored to defaults, the ZCD_NV_STARTUP_OPTION itself is not restored
+ * except for clearing the STARTOPT_CLEAR_CONFIG bit.
+ *
+ * The network state information is collected by the device after it joins a network and creates bindings etc. (at
+ * runtime). This is not set by the application processor. This information is stored so that if the device were to
+ * reset accidentally, it can restore itself without going through all the network joining and binding process
+ * again.
+ *
+ * If the application processor does not wish to continue operating in the previous ZigBee network, it needs to
+ * instruct the CC2530-ZNP device to clear the network state information and start again based on the configuration
+ * parameters. This is done by setting the STARTOPT_CLEAR_STATE bit in the startup option.
+ *
+ * @param clearConfig STARTOPT_CLEAR_CONFIG – If this option is set, the device will overwrite all the configuration
+ * parameters (except this one) with the “default” values that it is programmed with. This is used to
+ * erase the existing configuration and bring the device into a known state.
+ * @param clearState STARTOPT_CLEAR_STATE – If this option is set, the device will clear its previous network state
+ * (which would exist if the device had been operating on a network prior to the reset). This is
+ * typically used during application development. During regular device operation, this flag is typically
+ * not set, so that an accidental device reset will not cause loss of network state.
+ * @return {@link ZstackResponseCode} returned from the NCP
+ */
+ public ZstackResponseCode setStartupOptions(boolean clearConfig, boolean clearState) {
+ int optionVal = (clearConfig ? STARTOPT_CLEAR_CONFIG : 0) + (clearState ? STARTOPT_CLEAR_STATE : 0);
+ return writeConfiguration(ZstackConfigId.ZCD_NV_STARTUP_OPTION, valueFromUInt8(optionVal));
+ }
+
+ /**
+ * Reads a configuration parameter from the NCP
+ *
+ * @param configId the {@link ZstackConfigId} to read
+ * @return a int[] with the value of the configuration data or null on error
+ */
+ public int[] readConfiguration(ZstackConfigId configId) {
+ if (useOldCfgCalls) {
+ ZstackZbReadConfigurationSreq request = new ZstackZbReadConfigurationSreq();
+ request.setConfigId(configId);
+ ZstackTransaction transaction = protocolHandler
+ .sendTransaction(new ZstackSingleResponseTransaction(request, ZstackZbReadConfigurationSrsp.class));
+ ZstackZbReadConfigurationSrsp response = (ZstackZbReadConfigurationSrsp) transaction.getResponse();
+ if (response == null) {
+ logger.debug("No response from ReadConfiguration command");
+ return null;
+ }
+ logger.debug(response.toString());
+ if (response.getStatus() != ZstackResponseCode.SUCCESS) {
+ logger.debug("No response from ReadConfiguration command: {}", response.getStatus());
+ return null;
+ }
+ return response.getValue();
+ } else {
+ ZstackSysOsalNvReadSreq request = new ZstackSysOsalNvReadSreq();
+ request.setId(configId);
+ ZstackTransaction transaction = protocolHandler
+ .sendTransaction(new ZstackSingleResponseTransaction(request, ZstackSysOsalNvReadSrsp.class));
+ ZstackSysOsalNvReadSrsp response = (ZstackSysOsalNvReadSrsp) transaction.getResponse();
+ if (response == null) {
+ logger.debug("No response from ReadConfiguration command");
+ return null;
+ }
+ if (response.getStatus() != ZstackResponseCode.SUCCESS) {
+ logger.debug("No response from ReadConfiguration command: {}", response.getStatus());
+ return null;
+ }
+ logger.debug(response.toString());
+ return response.getValue();
+ }
+ }
+
+ /**
+ * Writes a configuration parameter to the NCP
+ *
+ * @param configId the {@link ZstackConfigId} to read
+ * @param value an int array containing the value to be written
+ * @return {@link ZstackResponseCode} returned from the NCP
+ */
+ public ZstackResponseCode writeConfiguration(ZstackConfigId configId, int[] value) {
+ if (useOldCfgCalls) {
+ ZstackZbWriteConfigurationSreq request = new ZstackZbWriteConfigurationSreq();
+ request.setConfigId(configId);
+ request.setValue(value);
+ ZstackTransaction transaction = protocolHandler.sendTransaction(
+ new ZstackSingleResponseTransaction(request, ZstackZbWriteConfigurationSrsp.class));
+ ZstackZbWriteConfigurationSrsp response = (ZstackZbWriteConfigurationSrsp) transaction.getResponse();
+ if (response == null) {
+ logger.debug("No response from WriteConfiguration command");
+ return ZstackResponseCode.FAILURE;
+ }
+ logger.debug(response.toString());
+ return response.getStatus();
+ } else {
+ ZstackSysOsalNvWriteSreq request = new ZstackSysOsalNvWriteSreq();
+ request.setId(configId);
+ request.setValue(value);
+ ZstackTransaction transaction = protocolHandler
+ .sendTransaction(new ZstackSingleResponseTransaction(request, ZstackSysOsalNvWriteSrsp.class));
+ ZstackSysOsalNvWriteSrsp response = (ZstackSysOsalNvWriteSrsp) transaction.getResponse();
+ if (response == null) {
+ logger.debug("No response from WriteConfiguration command");
+ return ZstackResponseCode.FAILURE;
+ }
+ logger.debug(response.toString());
+ return response.getStatus();
+ }
+ }
+
+ /**
+ * Sets the ZStack device type
+ *
+ * @param deviceType the {@link DeviceType} to use
+ * @return {@link ZstackResponseCode} returned from the NCP
+ */
+ public ZstackResponseCode setDeviceType(DeviceType deviceType) {
+ int value;
+ switch (deviceType) {
+ case COORDINATOR:
+ value = 0;
+ break;
+ case ROUTER:
+ value = 1;
+ break;
+ default:
+ logger.debug("Unknown device type {}", deviceType);
+ return ZstackResponseCode.FAILURE;
+ }
+ return writeConfiguration(ZstackConfigId.ZCD_NV_LOGICAL_TYPE, valueFromUInt8(value));
+ }
+
+ /**
+ * Sets the PAN ID
+ *
+ * @param panId the 16 bit PAN ID
+ * @return {@link ZstackResponseCode} returned from the NCP
+ */
+ public ZstackResponseCode setPanId(int panId) {
+ return writeConfiguration(ZstackConfigId.ZCD_NV_PANID, valueFromUInt16(panId));
+ }
+
+ /**
+ * Sets the extended PAN ID
+ *
+ * @param panId the {@link ExtendedPanId} extended PAN ID
+ * @return {@link ZstackResponseCode} returned from the NCP
+ */
+ public ZstackResponseCode setExtendedPanId(ExtendedPanId epanId) {
+ return writeConfiguration(ZstackConfigId.ZCD_NV_EXTPANID, epanId.getValue());
+ }
+
+ /**
+ * Sets the network key, and enables its use.
+ *
+ * @param key the {@link ZigBeeKey} to use for the network key
+ * @return {@link ZstackResponseCode} returned from the NCP
+ */
+ public ZstackResponseCode setNetworkKey(ZigBeeKey key) {
+ ZstackResponseCode responseCode = writeConfiguration(ZstackConfigId.ZCD_NV_PRECFGKEY, key.getValue());
+ if (responseCode != ZstackResponseCode.SUCCESS) {
+ return responseCode;
+ }
+ // Enable the network key
+ return writeConfiguration(ZstackConfigId.ZCD_NV_PRECFGKEYS_ENABLE, valueFromUInt8(1));
+ }
+
+ /**
+ * Gets the network key.
+ *
+ * @return the {@link ZigBeeKey} returned from the NCP or null on error
+ */
+ public ZigBeeKey getNetworkKey() {
+ int[] response = readConfiguration(ZstackConfigId.ZCD_NV_PRECFGKEY);
+ if (response == null) {
+ return null;
+ }
+
+ return new ZigBeeKey(response);
+ }
+
+ /**
+ * Enables network security
+ *
+ * @param enableSecurity true to enable network security
+ * @return {@link ZstackResponseCode} returned from the NCP
+ */
+ public ZstackResponseCode setNetworkSecurity(boolean enableSecurity) {
+ return writeConfiguration(ZstackConfigId.ZCD_NV_SECURITY_MODE, valueFromBoolean(enableSecurity));
+ }
+
+ /**
+ * Sets the transmit power to be used in the NCP
+ *
+ * @param txPower the TX power in dBm
+ * @return the power returned from the NCP on success or null on error
+ */
+ public Integer setTxPower(int txPower) {
+ ZstackSysSetTxPowerSreq request = new ZstackSysSetTxPowerSreq();
+ request.setTxPower(txPower);
+ ZstackTransaction transaction = protocolHandler
+ .sendTransaction(new ZstackSingleResponseTransaction(request, ZstackSysSetTxPowerSrsp.class));
+ ZstackSysSetTxPowerSrsp response = (ZstackSysSetTxPowerSrsp) transaction.getResponse();
+ if (response == null) {
+ logger.debug("No response from SetTxPower command");
+ return null;
+ }
+ logger.debug(response.toString());
+ return response.getTxPower();
+ }
+
+ /**
+ * Sets the channels that can be used in the NCP
+ *
+ * @param channelMask the {@link ZigBeeChannelMask} to set
+ * @return {@link ZstackResponseCode} returned from the NCP
+ */
+ public ZstackResponseCode setChannelMask(ZigBeeChannelMask channelMask) {
+ // TODO: ZCD_NV_CHANLIST
+ ZstackUtilSetChannelsSreq request = new ZstackUtilSetChannelsSreq();
+ request.setChannels(channelMask.getChannelMask());
+ ZstackTransaction transaction = protocolHandler
+ .sendTransaction(new ZstackSingleResponseTransaction(request, ZstackUtilSetChannelsSrsp.class));
+ ZstackUtilSetChannelsSrsp response = (ZstackUtilSetChannelsSrsp) transaction.getResponse();
+ if (response == null) {
+ logger.debug("No response from SetChannels command");
+ return ZstackResponseCode.FAILURE;
+ }
+ logger.debug(response.toString());
+ return response.getStatus();
+ }
+
+ /**
+ * Starts the application on the NCP. This will put the NCP onto the network.
+ *
+ * @return {@link ZstackResponseCode} returned from the NCP
+ */
+ public ZstackResponseCode startupApplication() {
+ ZstackZdoStartupFromAppSreq request = new ZstackZdoStartupFromAppSreq();
+ request.setStartDelay(100);
+ ZstackTransaction transaction = protocolHandler
+ .sendTransaction(new ZstackSingleResponseTransaction(request, ZstackZdoStartupFromAppSrsp.class));
+ ZstackZdoStartupFromAppSrsp response = (ZstackZdoStartupFromAppSrsp) transaction.getResponse();
+ if (response == null) {
+ logger.debug("No response from startupApplication command");
+ return ZstackResponseCode.FAILURE;
+ }
+ logger.debug(response.toString());
+ return response.getStatus();
+ }
+
+ /**
+ * Sets the policy flag on Trust Center device to mandate or not the TCLK exchange procedure.
+ *
+ * APP_CNF_BDB_SET_TC_REQUIRE_KEY_EXCHANGE
+ *
+ * @param required true if the TCLK exchange procedure is required.
+ * @return {@link ZstackResponseCode} returned from the NCP
+ */
+ public ZstackResponseCode requireKeyExchange(boolean required) {
+ ZstackAppCnfBdbSetTcRequireKeyExchangeSreq request = new ZstackAppCnfBdbSetTcRequireKeyExchangeSreq();
+ request.setTrustCenterRequireKeyExchange(required);
+ ZstackTransaction transaction = protocolHandler.sendTransaction(
+ new ZstackSingleResponseTransaction(request, ZstackAppCnfBdbSetTcRequireKeyExchangeSrsp.class));
+ ZstackAppCnfBdbSetTcRequireKeyExchangeSrsp response = (ZstackAppCnfBdbSetTcRequireKeyExchangeSrsp) transaction
+ .getResponse();
+ if (response == null) {
+ logger.debug("No response from requireKeyExchange command");
+ return ZstackResponseCode.FAILURE;
+ }
+ logger.debug(response.toString());
+ return response.getStatus();
+ }
+
+ /**
+ * Sets the policy to mandate or not the usage of an Install Code upon joining.
+ *
+ * APP_CNF_BDB_SET_ACTIVE_DEFAULT_CENTRALIZED_KEY
+ *
+ * @param mode the {@link ZstackCentralizedLinkKeyMode}
+ * @param installCode array with the code in the required format
+ * @return {@link ZstackResponseCode} returned from the NCP
+ */
+ public ZstackResponseCode setCentralisedKey(ZstackCentralizedLinkKeyMode mode, int[] installCode) {
+ ZstackAppCnfBdbSetActiveDefaultCentralizedKeySreq request = new ZstackAppCnfBdbSetActiveDefaultCentralizedKeySreq();
+ request.setCentralizedLinkKeyMode(mode);
+ request.setInstallCode(installCode);
+ ZstackTransaction transaction = protocolHandler.sendTransaction(
+ new ZstackSingleResponseTransaction(request, ZstackAppCnfBdbSetActiveDefaultCentralizedKeySrsp.class));
+ ZstackAppCnfBdbSetActiveDefaultCentralizedKeySrsp response = (ZstackAppCnfBdbSetActiveDefaultCentralizedKeySrsp) transaction
+ .getResponse();
+ if (response == null) {
+ logger.debug("No response from setCentralisedKey command");
+ return ZstackResponseCode.FAILURE;
+ }
+ logger.debug(response.toString());
+ return response.getStatus();
+ }
+
+ /**
+ * Sets the AllowRejoin TC policy.
+ *
+ * APP_CNF_SET_ALLOWREJOIN_TC_POLICY
+ *
+ * @param allow true to allow rejoins
+ * @return {@link ZstackResponseCode} returned from the NCP
+ */
+ public ZstackResponseCode allowRejoin(boolean allow) {
+ ZstackAppCnfSetAllowrejoinTcPolicySreq request = new ZstackAppCnfSetAllowrejoinTcPolicySreq();
+ request.setAllowRejoin(allow);
+ ZstackTransaction transaction = protocolHandler.sendTransaction(
+ new ZstackSingleResponseTransaction(request, ZstackAppCnfSetAllowrejoinTcPolicySrsp.class));
+ ZstackAppCnfSetAllowrejoinTcPolicySrsp response = (ZstackAppCnfSetAllowrejoinTcPolicySrsp) transaction
+ .getResponse();
+ if (response == null) {
+ logger.debug("No response from allowRejoin command");
+ return ZstackResponseCode.FAILURE;
+ }
+ logger.debug(response.toString());
+ return response.getStatus();
+ }
+
+ /**
+ * Registers for a ZDO callback
+ *
+ * @return {@link ZstackResponseCode} returned from the NCP
+ */
+ public ZstackResponseCode zdoRegisterCallback(int clusterId) {
+ ZstackZdoMsgCbRegisterSreq request = new ZstackZdoMsgCbRegisterSreq();
+ request.setClusterId(clusterId);
+ ZstackTransaction transaction = protocolHandler
+ .sendTransaction(new ZstackSingleResponseTransaction(request, ZstackZdoMsgCbRegisterSrsp.class));
+ ZstackZdoMsgCbRegisterSrsp response = (ZstackZdoMsgCbRegisterSrsp) transaction.getResponse();
+ if (response == null) {
+ logger.debug("No response from RegisterZdoCallback command");
+ return ZstackResponseCode.FAILURE;
+ }
+ logger.debug(response.toString());
+ return response.getStatus();
+ }
+
+ /**
+ * Registers an AF Endpoint in the NCP
+ *
+ * @param endpointId the endpoint number to add
+ * @param deviceId the device id for the endpoint
+ * @param profileId the profile id
+ * @param inputClusters an array of input clusters supported by the endpoint
+ * @param outputClusters an array of output clusters supported by the endpoint
+ * @return {@link ZstackResponseCode} returned from the NCP
+ */
+ public ZstackResponseCode addEndpoint(int endpointId, int deviceId, int profileId, int[] inputClusters,
+ int[] outputClusters) {
+ ZstackAfRegisterSreq request = new ZstackAfRegisterSreq();
+ request.setEndPoint(endpointId);
+ request.setAppDeviceId(deviceId);
+ request.setAppProfId(profileId);
+ request.setAppInClusterList(inputClusters);
+ request.setAppOutClusterList(outputClusters);
+ request.setLatencyReq(0);
+ request.setAppDevVer(0);
+
+ ZstackTransaction transaction = protocolHandler
+ .sendTransaction(new ZstackSingleResponseTransaction(request, ZstackAfRegisterSrsp.class));
+ ZstackAfRegisterSrsp response = (ZstackAfRegisterSrsp) transaction.getResponse();
+ if (response == null) {
+ logger.debug("No response from RegisterEndpoint command");
+ return ZstackResponseCode.FAILURE;
+ }
+ logger.debug(response.toString());
+ return response.getStatus();
+ }
+
+ /**
+ * Adds an install code to the NCP. The code must be a ZigBee key - ie not the install code itself.
+ *
+ * @param ieeeAddress the {@link IeeeAddress} associated with the key
+ * @param key the {@link ZigBeeKey} to set
+ * @return {@link ZstackResponseCode} returned from the NCP
+ */
+ public ZstackResponseCode addInstallCode(IeeeAddress ieeeAddress, ZigBeeKey key) {
+ ZstackAppCnfBdbAddInstallcodeSreq request = new ZstackAppCnfBdbAddInstallcodeSreq();
+ request.setInstallCodeFormat(ZstackInstallCodeFormat.DERIVED_KEY);
+ request.setIeeeAddress(ieeeAddress);
+ request.setInstallCode(key);
+
+ ZstackTransaction transaction = protocolHandler
+ .sendTransaction(new ZstackSingleResponseTransaction(request, ZstackAppCnfBdbAddInstallcodeSrsp.class));
+ ZstackAppCnfBdbAddInstallcodeSrsp response = (ZstackAppCnfBdbAddInstallcodeSrsp) transaction.getResponse();
+ if (response == null) {
+ logger.debug("No response from AddInstallCode command");
+ return ZstackResponseCode.FAILURE;
+ }
+ logger.debug(response.toString());
+ return response.getStatus();
+ }
+
+ private int[] valueFromBoolean(boolean value) {
+ return new int[] { value ? 1 : 0 };
+ }
+
+ private int[] valueFromUInt8(int value) {
+ return new int[] { value };
+ }
+
+ private int[] valueFromUInt16(int value) {
+ return new int[] { value & 0xFF, (value >> 8) & 0xFF };
+ }
+
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/ZstackCommand.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/ZstackCommand.java
new file mode 100644
index 0000000000..fa0dfe6a0d
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/ZstackCommand.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api;
+
+/**
+ * Base class for all ZStack commands
+ *
+ * @author Chris Jackson
+ *
+ */
+public abstract class ZstackCommand {
+ /**
+ * Definitions of API subsystems
+ */
+ protected static int ZSTACK_RPC = 0x00;
+ protected static int ZSTACK_SYS = 0x01;
+ protected static int ZSTACK_MAC = 0x02;
+ protected static int ZSTACK_AF = 0x04;
+ protected static int ZSTACK_ZDO = 0x05;
+ protected static int ZSTACK_SAPI = 0x06;
+ protected static int ZSTACK_UTIL = 0x07;
+ protected static int ZSTACK_APP = 0x09;
+ protected static int ZSTACK_SBL = 0x0D;
+ protected static int ZSTACK_APP_CNF = 0x0F;
+
+ /**
+ * Flag denoting if this command/request is done synchronously
+ */
+ protected boolean synchronousCommand = false;
+
+ /**
+ * Returns true if this request/response is performed synchronously
+ *
+ * @return true if the request requires asynchronous response
+ */
+ public boolean isSynchronous() {
+ return synchronousCommand;
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/ZstackFrameFactory.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/ZstackFrameFactory.java
new file mode 100644
index 0000000000..8a45c3e40e
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/ZstackFrameFactory.java
@@ -0,0 +1,233 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.af.ZstackAfDataConfirmAreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.af.ZstackAfDataRequestSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.af.ZstackAfIncomingMsgAreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.af.ZstackAfRegisterSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackAppCnfBdbAddInstallcodeSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackAppCnfBdbCommissioningNotificationAreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackAppCnfBdbSetActiveDefaultCentralizedKeySrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackAppCnfBdbSetJoinusesinstallcodekeySrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackAppCnfBdbSetTcRequireKeyExchangeSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackAppCnfSetAllowrejoinTcPolicySrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.mac.ZstackMacScanReqSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sapi.ZstackZbGetDeviceInfoSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sapi.ZstackZbReadConfigurationSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sapi.ZstackZbWriteConfigurationSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sbl.ZstackSbHandshakeCmdSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sbl.ZstackSbWriteCmdSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysGetExtAddrSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysOsalNvReadSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysOsalNvWriteSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysPingSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysResetIndAreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysSetExtAddrSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysSetTxPowerSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysVersionSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysZdiagsClearStatsSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysZdiagsGetStatsSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysZdiagsInitStatsSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysZdiagsRestoreStatsNvSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysZdiagsSaveStatsToNvSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.util.ZstackUtilApsmeLinkKeyDataGetSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.util.ZstackUtilApsmeLinkKeyNvIdGetSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.util.ZstackUtilGetDeviceInfoSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.util.ZstackUtilGetNvInfoSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.util.ZstackUtilLedControlSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.util.ZstackUtilSetChannelsSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.util.ZstackUtilSetPanidSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.util.ZstackUtilSetPrecfgkeySrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.util.ZstackUtilSetSeclevelSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.zdo.ZstackZdoGetLinkKeySrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.zdo.ZstackZdoLeaveIndAreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.zdo.ZstackZdoMsgCbIncomingAreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.zdo.ZstackZdoMsgCbRegisterSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.zdo.ZstackZdoNwkDiscoveryReqSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.zdo.ZstackZdoRemoveLinkKeySrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.zdo.ZstackZdoSetLinkKeySrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.zdo.ZstackZdoStartupFromAppSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.zdo.ZstackZdoStateChangeIndAreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.zdo.ZstackZdoTcDevIndAreq;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Factory class to create Z-Stack commands from incoming data. This will only create {@link ZstackFrameResponse}s.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackFrameFactory {
+ /**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(ZstackFrameFactory.class);
+
+ /*
+ * Subsystem definitions
+ */
+ public static int ZSTACK_RPC = 0x0000;
+ public static int ZSTACK_SYS = 0x0100;
+ public static int ZSTACK_MAC = 0x0200;
+ public static int ZSTACK_AF = 0x0400;
+ public static int ZSTACK_ZDO = 0x0500;
+ public static int ZSTACK_SAPI = 0x0600;
+ public static int ZSTACK_UTIL = 0x0700;
+ public static int ZSTACK_APP_CNF = 0x0F00;
+ public static int ZSTACK_SBL = 0x0D00;
+
+ /**
+ * Subsystem definition mask
+ */
+ private static int ZSTACK_SUBSYSTEM_MASK = 0x1F;
+
+ private static final int AF_DATA_CONFIRM = 0x80;
+ private static final int AF_DATA_REQUEST = 0x01;
+ private static final int AF_INCOMING_MSG = 0x81;
+ private static final int AF_REGISTER = 0x00;
+ private static final int APP_CNF_BDB_ADD_INSTALLCODE = 0x04;
+ private static final int APP_CNF_BDB_COMMISSIONING_NOTIFICATION = 0x80;
+ private static final int APP_CNF_BDB_SET_ACTIVE_DEFAULT_CENTRALIZED_KEY = 0x07;
+ private static final int APP_CNF_BDB_SET_JOINUSESINSTALLCODEKEY = 0x06;
+ private static final int APP_CNF_BDB_SET_TC_REQUIRE_KEY_EXCHANGE = 0x09;
+ private static final int APP_CNF_SET_ALLOWREJOIN_TC_POLICY = 0x03;
+ private static final int MAC_SCAN_REQ = 0x0C;
+ private static final int RPC_SREQ_ERROR = 0x00;
+ private static final int SB_HANDSHAKE_CMD = 0x04;
+ private static final int SB_WRITE_CMD = 0x00;
+ private static final int SYS_GET_EXT_ADDR = 0x04;
+ private static final int SYS_OSAL_NV_READ = 0x08;
+ private static final int SYS_OSAL_NV_WRITE = 0x09;
+ private static final int SYS_PING = 0x01;
+ private static final int SYS_RESET_IND = 0x80;
+ private static final int SYS_SET_EXT_ADDR = 0x03;
+ private static final int SYS_SET_TX_POWER = 0x14;
+ private static final int SYS_VERSION = 0x02;
+ private static final int SYS_ZDIAGS_CLEAR_STATS = 0x18;
+ private static final int SYS_ZDIAGS_GET_STATS = 0x19;
+ private static final int SYS_ZDIAGS_INIT_STATS = 0x17;
+ private static final int SYS_ZDIAGS_RESTORE_STATS_NV = 0x1A;
+ private static final int SYS_ZDIAGS_SAVE_STATS_TO_NV = 0x1B;
+ private static final int UTIL_APSME_LINK_KEY_DATA_GET = 0x44;
+ private static final int UTIL_APSME_LINK_KEY_NV_ID_GET = 0x45;
+ private static final int UTIL_GET_DEVICE_INFO = 0x00;
+ private static final int UTIL_GET_NV_INFO = 0x01;
+ private static final int UTIL_LED_CONTROL = 0x09;
+ private static final int UTIL_SET_CHANNELS = 0x03;
+ private static final int UTIL_SET_PANID = 0x02;
+ private static final int UTIL_SET_PRECFGKEY = 0x05;
+ private static final int UTIL_SET_SECLEVEL = 0x04;
+ private static final int ZB_GET_DEVICE_INFO = 0x06;
+ private static final int ZB_READ_CONFIGURATION = 0x04;
+ private static final int ZB_WRITE_CONFIGURATION = 0x05;
+ private static final int ZDO_GET_LINK_KEY = 0x25;
+ private static final int ZDO_LEAVE_IND = 0xC9;
+ private static final int ZDO_MSG_CB_INCOMING = 0xFF;
+ private static final int ZDO_MSG_CB_REGISTER = 0x3E;
+ private static final int ZDO_NWK_DISCOVERY_REQ = 0x26;
+ private static final int ZDO_REMOVE_LINK_KEY = 0x24;
+ private static final int ZDO_SET_LINK_KEY = 0x23;
+ private static final int ZDO_STARTUP_FROM_APP = 0x40;
+ private static final int ZDO_STATE_CHANGE_IND = 0xC0;
+ private static final int ZDO_TC_DEV_IND = 0xCA;
+
+ private static Map
+ * Global response codes
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public enum ZstackResponseCode {
+ /**
+ * Default unknown value
+ */
+ UNKNOWN(-1),
+
+ /**
+ *
+ */
+ SUCCESS(0x0000),
+
+ /**
+ *
+ */
+ FAILURE(0x0001),
+
+ /**
+ *
+ */
+ AF_INVALID_PARAMETER(0x0002),
+
+ /**
+ * Security manager key table full
+ */
+ AF_MEM_FAIL(0x0010),
+
+ /**
+ * Security manager key table full
+ */
+ KEY_TABLE_FULL(0x0011),
+
+ /**
+ * The operation could not be completed because no memory resources were available
+ */
+ MAC_NO_RESOURCES(0x001A),
+
+ /**
+ * Invalid Request
+ */
+ INVALID_REQUEST(0x00C2),
+
+ /**
+ * Not Permitted
+ */
+ NOT_PERMITTED(0x00C3),
+
+ /**
+ * Unknown Device
+ */
+ UNKNOWN_DEVICE(0x00C8),
+
+ /**
+ *
+ */
+ AF_NO_ROUTE(0x00CD),
+
+ /**
+ * The scan request failed because a scan is already in progress
+ */
+ MAC_SCAN_IN_PROGRESS(0x00FC);
+
+ /**
+ * A mapping between the integer code and its corresponding type to
+ * facilitate lookup by code.
+ */
+ private static Map
+ * Options applied when sending frames
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public enum AfDataOptions {
+
+ /**
+ * Set this bit to request APS acknowledgement for this packet
+ */
+ AF_ACK_REQUEST(0x0010),
+
+ /**
+ * Set this bit to force route discovery if a routing table entry doesn’t exist
+ */
+ AF_DISCV_ROUTE(0x0020),
+
+ /**
+ * Set this bit to enable APS security for this packet.
+ */
+ AF_EN_SECURITY(0x0040),
+
+ /**
+ * Skip routing.
+ */
+ AF_NO_ROUTING(0x0080);
+
+ /**
+ * A mapping between the integer code and its corresponding type to
+ * facilitate lookup by code.
+ */
+ private static Map
+ * This command is sent by the device to the user after it receives an AF_DATA_REQUEST. For each AF_DATA_REQUEST, a
+ * AF_DATA_CONFIRM is always returned. If APS acknowledgement was used for the AF_DATA_REQUEST, the confirm carries the status
+ * of whether the APS acknowledgement was received or not (ZApsNoAck – 0xb7). If APS acknowledgement was not used, then the confirm
+ * carries the status of whether the MAC acknowledgement (“next hop” acknowledgment) was received or not (ZMacNoACK – 0xe9). This
+ * also applies to packets that are sent using AF_DATA_REQUEST_EXT and AF_DATA_STORE. For APS fragmented packets, the value of
+ * the configuration item ZCD_NV_APSF_WINDOW_SIZE determines when an AF_DATA_CONFIRM that carries the status of the APS
+ * acknowledgement is received.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAfDataConfirmAreq extends ZstackFrameResponse {
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Endpoint of the device.
+ */
+ private int endpoint;
+
+ /**
+ * Specifies the transaction sequence number of the message.
+ */
+ private int transId;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackAfDataConfirmAreq(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ endpoint = deserializer.deserializeUInt8();
+ transId = deserializer.deserializeUInt8();
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ /**
+ * Endpoint of the device.
+ *
+ * @return the current endpoint as {@link int}
+ */
+ public int getEndpoint() {
+ return endpoint;
+ }
+
+ /**
+ * Endpoint of the device.
+ *
+ * @param endpoint the Endpoint to set as {@link int}
+ */
+ public void setEndpoint(int endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ /**
+ * Specifies the transaction sequence number of the message.
+ *
+ * @return the current transId as {@link int}
+ */
+ public int getTransId() {
+ return transId;
+ }
+
+ /**
+ * Specifies the transaction sequence number of the message.
+ *
+ * @param transId the TransId to set as {@link int}
+ */
+ public void setTransId(int transId) {
+ this.transId = transId;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(101);
+ builder.append("ZstackAfDataConfirmAreq [status=");
+ builder.append(status);
+ builder.append(", endpoint=");
+ builder.append(String.format("%02X", endpoint));
+ builder.append(", transId=");
+ builder.append(String.format("%02X", transId));
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/af/ZstackAfDataRequestSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/af/ZstackAfDataRequestSreq.java
new file mode 100644
index 0000000000..10d94543c6
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/af/ZstackAfDataRequestSreq.java
@@ -0,0 +1,290 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.af;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.af.AfDataOptions;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Class to implement the Z-Stack command AF_DATA_REQUEST.
+ *
+ * This command is used by the App processor to build and send a message through AF layer.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAfDataRequestSreq extends ZstackFrameRequest {
+
+ /**
+ * Short address of the destination device.
+ */
+ private int dstAddr;
+
+ /**
+ * Endpoint of the destination device.
+ */
+ private int destEndpoint;
+
+ /**
+ * Endpoint of the source device.
+ */
+ private int srcEndpoint;
+
+ /**
+ * Specifies the cluster ID.
+ */
+ private int clusterId;
+
+ /**
+ * Specifies the transaction sequence number of the message. The corresponding AF_DATA_CONFIRM will have the same TransID. This
+ * can be useful if the application wishes to match up AF_DATA_REQUESTs with AF_DATA_CONFIRMs.
+ */
+ private int transId;
+
+ /**
+ * The transmit options field is organized as a bitmask. The following enumerates the values for the various supported bitmasks.
+ * For example, a value of 0x10 means that bit 4 is set.
+ *
+ * Parameter allows multiple options so implemented as a {@link Set}.
+ */
+ private Set
+ * This command is used by the App processor to build and send a message through AF layer.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAfDataRequestSrsp extends ZstackFrameResponse {
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackAfDataRequestSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(51);
+ builder.append("ZstackAfDataRequestSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/af/ZstackAfIncomingMsgAreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/af/ZstackAfIncomingMsgAreq.java
new file mode 100644
index 0000000000..107102f28e
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/af/ZstackAfIncomingMsgAreq.java
@@ -0,0 +1,334 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.af;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+
+/**
+ * Class to implement the Z-Stack command AF_INCOMING_MSG.
+ *
+ * This callback message is in response to incoming data to any of the registered endpoints on this device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAfIncomingMsgAreq extends ZstackFrameResponse {
+
+ /**
+ * Specifies the group ID of the device.
+ */
+ private int groupId;
+
+ /**
+ * Specifies the cluster ID.
+ */
+ private int clusterId;
+
+ /**
+ * Specifies the ZigBee network address of the source device sending the message.
+ */
+ private int srcAddr;
+
+ /**
+ * Specifies the source endpoint of the message.
+ */
+ private int srcEndpoint;
+
+ /**
+ * Specifies the destination endpoint of the message.
+ */
+ private int destEndpoint;
+
+ /**
+ * Specifies if the message was a broadcast or not.
+ */
+ private boolean wasBroadcast;
+
+ /**
+ * Indicates the link quality measured during reception.
+ */
+ private int linkQuality;
+
+ /**
+ * Specifies if the security is used or not.
+ */
+ private boolean securityUse;
+
+ /**
+ * Specifies the timestamp of the message.
+ */
+ private int timeStamp;
+
+ /**
+ * Specifies transaction sequence number of the message.
+ */
+ private int seqNumber;
+
+ /**
+ * Contains 0 to 99 bytes of data. Without any security (99 bytes), with NWK security (81 bytes), with NWK and APS security (64
+ * bytes).
+ */
+ private int[] data;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackAfIncomingMsgAreq(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ // Deserialize the fields
+ groupId = deserializer.deserializeUInt16();
+ clusterId = deserializer.deserializeUInt16();
+ srcAddr = deserializer.deserializeUInt16();
+ srcEndpoint = deserializer.deserializeUInt8();
+ destEndpoint = deserializer.deserializeUInt8();
+ wasBroadcast = deserializer.deserializeBoolean();
+ linkQuality = deserializer.deserializeUInt8();
+ securityUse = deserializer.deserializeBoolean();
+ timeStamp = deserializer.deserializeUInt32();
+ seqNumber = deserializer.deserializeUInt8();
+ int len = deserializer.deserializeUInt8();
+ data = deserializer.deserializeUInt8Array(len);
+ }
+
+ /**
+ * Specifies the group ID of the device.
+ *
+ * @return the current groupId as {@link int}
+ */
+ public int getGroupId() {
+ return groupId;
+ }
+
+ /**
+ * Specifies the group ID of the device.
+ *
+ * @param groupId the GroupId to set as {@link int}
+ */
+ public void setGroupId(int groupId) {
+ this.groupId = groupId;
+ }
+
+ /**
+ * Specifies the cluster ID.
+ *
+ * @return the current clusterId as {@link int}
+ */
+ public int getClusterId() {
+ return clusterId;
+ }
+
+ /**
+ * Specifies the cluster ID.
+ *
+ * @param clusterId the ClusterId to set as {@link int}
+ */
+ public void setClusterId(int clusterId) {
+ this.clusterId = clusterId;
+ }
+
+ /**
+ * Specifies the ZigBee network address of the source device sending the message.
+ *
+ * @return the current srcAddr as {@link int}
+ */
+ public int getSrcAddr() {
+ return srcAddr;
+ }
+
+ /**
+ * Specifies the ZigBee network address of the source device sending the message.
+ *
+ * @param srcAddr the SrcAddr to set as {@link int}
+ */
+ public void setSrcAddr(int srcAddr) {
+ this.srcAddr = srcAddr;
+ }
+
+ /**
+ * Specifies the source endpoint of the message.
+ *
+ * @return the current srcEndpoint as {@link int}
+ */
+ public int getSrcEndpoint() {
+ return srcEndpoint;
+ }
+
+ /**
+ * Specifies the source endpoint of the message.
+ *
+ * @param srcEndpoint the SrcEndpoint to set as {@link int}
+ */
+ public void setSrcEndpoint(int srcEndpoint) {
+ this.srcEndpoint = srcEndpoint;
+ }
+
+ /**
+ * Specifies the destination endpoint of the message.
+ *
+ * @return the current destEndpoint as {@link int}
+ */
+ public int getDestEndpoint() {
+ return destEndpoint;
+ }
+
+ /**
+ * Specifies the destination endpoint of the message.
+ *
+ * @param destEndpoint the DestEndpoint to set as {@link int}
+ */
+ public void setDestEndpoint(int destEndpoint) {
+ this.destEndpoint = destEndpoint;
+ }
+
+ /**
+ * Specifies if the message was a broadcast or not.
+ *
+ * @return the current wasBroadcast as {@link boolean}
+ */
+ public boolean getWasBroadcast() {
+ return wasBroadcast;
+ }
+
+ /**
+ * Specifies if the message was a broadcast or not.
+ *
+ * @param wasBroadcast the WasBroadcast to set as {@link boolean}
+ */
+ public void setWasBroadcast(boolean wasBroadcast) {
+ this.wasBroadcast = wasBroadcast;
+ }
+
+ /**
+ * Indicates the link quality measured during reception.
+ *
+ * @return the current linkQuality as {@link int}
+ */
+ public int getLinkQuality() {
+ return linkQuality;
+ }
+
+ /**
+ * Indicates the link quality measured during reception.
+ *
+ * @param linkQuality the LinkQuality to set as {@link int}
+ */
+ public void setLinkQuality(int linkQuality) {
+ this.linkQuality = linkQuality;
+ }
+
+ /**
+ * Specifies if the security is used or not.
+ *
+ * @return the current securityUse as {@link boolean}
+ */
+ public boolean getSecurityUse() {
+ return securityUse;
+ }
+
+ /**
+ * Specifies if the security is used or not.
+ *
+ * @param securityUse the SecurityUse to set as {@link boolean}
+ */
+ public void setSecurityUse(boolean securityUse) {
+ this.securityUse = securityUse;
+ }
+
+ /**
+ * Specifies the timestamp of the message.
+ *
+ * @return the current timeStamp as {@link int}
+ */
+ public int getTimeStamp() {
+ return timeStamp;
+ }
+
+ /**
+ * Specifies the timestamp of the message.
+ *
+ * @param timeStamp the TimeStamp to set as {@link int}
+ */
+ public void setTimeStamp(int timeStamp) {
+ this.timeStamp = timeStamp;
+ }
+
+ /**
+ * Specifies transaction sequence number of the message.
+ *
+ * @return the current seqNumber as {@link int}
+ */
+ public int getSeqNumber() {
+ return seqNumber;
+ }
+
+ /**
+ * Specifies transaction sequence number of the message.
+ *
+ * @param seqNumber the SeqNumber to set as {@link int}
+ */
+ public void setSeqNumber(int seqNumber) {
+ this.seqNumber = seqNumber;
+ }
+
+ /**
+ * Contains 0 to 99 bytes of data. Without any security (99 bytes), with NWK security (81 bytes), with NWK and APS security (64
+ * bytes).
+ *
+ * @return the current data as {@link int[]}
+ */
+ public int[] getData() {
+ return data;
+ }
+
+ /**
+ * Contains 0 to 99 bytes of data. Without any security (99 bytes), with NWK security (81 bytes), with NWK and APS security (64
+ * bytes).
+ *
+ * @param data the Data to set as {@link int[]}
+ */
+ public void setData(int[] data) {
+ this.data = data;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(326);
+ builder.append("ZstackAfIncomingMsgAreq [groupId=");
+ builder.append(String.format("%04X", groupId));
+ builder.append(", clusterId=");
+ builder.append(String.format("%04X", clusterId));
+ builder.append(", srcAddr=");
+ builder.append(String.format("%04X", srcAddr));
+ builder.append(", srcEndpoint=");
+ builder.append(String.format("%02X", srcEndpoint));
+ builder.append(", destEndpoint=");
+ builder.append(String.format("%02X", destEndpoint));
+ builder.append(", wasBroadcast=");
+ builder.append(wasBroadcast);
+ builder.append(", linkQuality=");
+ builder.append(linkQuality);
+ builder.append(", securityUse=");
+ builder.append(securityUse);
+ builder.append(", timeStamp=");
+ builder.append(String.format("%08X", timeStamp));
+ builder.append(", seqNumber=");
+ builder.append(String.format("%02X", seqNumber));
+ builder.append(", data=");
+ for (int c = 0; c < data.length; c++) {
+ if (c > 0) {
+ builder.append(' ');
+ }
+ builder.append(String.format("%02X", data[c]));
+ }
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/af/ZstackAfRegisterSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/af/ZstackAfRegisterSreq.java
new file mode 100644
index 0000000000..ec1f160a31
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/af/ZstackAfRegisterSreq.java
@@ -0,0 +1,248 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.af;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command AF_REGISTER.
+ *
+ * This command enables the host processor to register an application’s endpoint description (and its simple descriptor).
+ * Multiple endpoints may be registered with the AF by making multiple calls to AF_REGISTER. This could be useful in the case where
+ * the device needs to support multiple application profiles, where each AF_REGISTER call would register a unique endpoint
+ * description per application profile.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAfRegisterSreq extends ZstackFrameRequest {
+
+ /**
+ * Specifies the endpoint of this simple descriptor.
+ */
+ private int endPoint;
+
+ /**
+ * Specifies the profile id of the application.
+ */
+ private int appProfId;
+
+ /**
+ * Specifies the device description id for this endpoint.
+ */
+ private int appDeviceId;
+
+ /**
+ * Specifies the device version number.
+ */
+ private int appDevVer;
+
+ /**
+ * Specifies latency. For ZigBee the only applicable value is 0x00. 0x00-No latency 0x01-fast beacons 0x02-slow beacons
+ */
+ private int latencyReq;
+
+ /**
+ * Specifies the list of Input Cluster Ids (2 bytes each).
+ */
+ private int[] appInClusterList;
+
+ /**
+ * Specifies the list of Output Cluster Ids (2 bytes each)
+ */
+ private int[] appOutClusterList;
+
+ /**
+ * Request constructor
+ */
+ public ZstackAfRegisterSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * Specifies the endpoint of this simple descriptor.
+ *
+ * @return the current endPoint as {@link int}
+ */
+ public int getEndPoint() {
+ return endPoint;
+ }
+
+ /**
+ * Specifies the endpoint of this simple descriptor.
+ *
+ * @param endPoint the EndPoint to set as {@link int}
+ */
+ public void setEndPoint(int endPoint) {
+ this.endPoint = endPoint;
+ }
+
+ /**
+ * Specifies the profile id of the application.
+ *
+ * @return the current appProfId as {@link int}
+ */
+ public int getAppProfId() {
+ return appProfId;
+ }
+
+ /**
+ * Specifies the profile id of the application.
+ *
+ * @param appProfId the AppProfId to set as {@link int}
+ */
+ public void setAppProfId(int appProfId) {
+ this.appProfId = appProfId;
+ }
+
+ /**
+ * Specifies the device description id for this endpoint.
+ *
+ * @return the current appDeviceId as {@link int}
+ */
+ public int getAppDeviceId() {
+ return appDeviceId;
+ }
+
+ /**
+ * Specifies the device description id for this endpoint.
+ *
+ * @param appDeviceId the AppDeviceId to set as {@link int}
+ */
+ public void setAppDeviceId(int appDeviceId) {
+ this.appDeviceId = appDeviceId;
+ }
+
+ /**
+ * Specifies the device version number.
+ *
+ * @return the current appDevVer as {@link int}
+ */
+ public int getAppDevVer() {
+ return appDevVer;
+ }
+
+ /**
+ * Specifies the device version number.
+ *
+ * @param appDevVer the AppDevVer to set as {@link int}
+ */
+ public void setAppDevVer(int appDevVer) {
+ this.appDevVer = appDevVer;
+ }
+
+ /**
+ * Specifies latency. For ZigBee the only applicable value is 0x00. 0x00-No latency 0x01-fast beacons 0x02-slow beacons
+ *
+ * @return the current latencyReq as {@link int}
+ */
+ public int getLatencyReq() {
+ return latencyReq;
+ }
+
+ /**
+ * Specifies latency. For ZigBee the only applicable value is 0x00. 0x00-No latency 0x01-fast beacons 0x02-slow beacons
+ *
+ * @param latencyReq the LatencyReq to set as {@link int}
+ */
+ public void setLatencyReq(int latencyReq) {
+ this.latencyReq = latencyReq;
+ }
+
+ /**
+ * Specifies the list of Input Cluster Ids (2 bytes each).
+ *
+ * @return the current appInClusterList as {@link int[]}
+ */
+ public int[] getAppInClusterList() {
+ return appInClusterList;
+ }
+
+ /**
+ * Specifies the list of Input Cluster Ids (2 bytes each).
+ *
+ * @param appInClusterList the AppInClusterList to set as {@link int[]}
+ */
+ public void setAppInClusterList(int[] appInClusterList) {
+ this.appInClusterList = appInClusterList;
+ }
+
+ /**
+ * Specifies the list of Output Cluster Ids (2 bytes each)
+ *
+ * @return the current appOutClusterList as {@link int[]}
+ */
+ public int[] getAppOutClusterList() {
+ return appOutClusterList;
+ }
+
+ /**
+ * Specifies the list of Output Cluster Ids (2 bytes each)
+ *
+ * @param appOutClusterList the AppOutClusterList to set as {@link int[]}
+ */
+ public void setAppOutClusterList(int[] appOutClusterList) {
+ this.appOutClusterList = appOutClusterList;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_AF) && (response.getReqCmd1() == 0x00));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_AF, 0x00);
+
+ // Serialize the fields
+ serializer.serializeUInt8(endPoint);
+ serializer.serializeUInt16(appProfId);
+ serializer.serializeUInt16(appDeviceId);
+ serializer.serializeUInt8(appDevVer);
+ serializer.serializeUInt8(latencyReq);
+ serializer.serializeUInt8(appInClusterList.length);
+ serializer.serializeUInt16Array(appInClusterList);
+ serializer.serializeUInt8(appOutClusterList.length);
+ serializer.serializeUInt16Array(appOutClusterList);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(248);
+ builder.append("ZstackAfRegisterSreq [endPoint=");
+ builder.append(String.format("%02X", endPoint));
+ builder.append(", appProfId=");
+ builder.append(String.format("%04X", appProfId));
+ builder.append(", appDeviceId=");
+ builder.append(appDeviceId);
+ builder.append(", appDevVer=");
+ builder.append(appDevVer);
+ builder.append(", latencyReq=");
+ builder.append(latencyReq);
+ builder.append(", appInClusterList=");
+ for (int c = 0; c < appInClusterList.length; c++) {
+ if (c > 0) {
+ builder.append(' ');
+ }
+ builder.append(String.format("%04X", appInClusterList[c]));
+ }
+ builder.append(", appOutClusterList=");
+ for (int c = 0; c < appOutClusterList.length; c++) {
+ if (c > 0) {
+ builder.append(' ');
+ }
+ builder.append(String.format("%04X", appOutClusterList[c]));
+ }
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/af/ZstackAfRegisterSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/af/ZstackAfRegisterSrsp.java
new file mode 100644
index 0000000000..2073db3578
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/af/ZstackAfRegisterSrsp.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.af;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command AF_REGISTER.
+ *
+ * This command enables the host processor to register an application’s endpoint description (and its simple descriptor).
+ * Multiple endpoints may be registered with the AF by making multiple calls to AF_REGISTER. This could be useful in the case where
+ * the device needs to support multiple application profiles, where each AF_REGISTER call would register a unique endpoint
+ * description per application profile.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAfRegisterSrsp extends ZstackFrameResponse {
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackAfRegisterSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(48);
+ builder.append("ZstackAfRegisterSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbAddInstallcodeSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbAddInstallcodeSreq.java
new file mode 100644
index 0000000000..1e70d27aad
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbAddInstallcodeSreq.java
@@ -0,0 +1,134 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.appcnf;
+
+import com.zsmartsystems.zigbee.IeeeAddress;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+import com.zsmartsystems.zigbee.security.ZigBeeKey;
+
+/**
+ * Class to implement the Z-Stack command APP_CNF_BDB_ADD_INSTALLCODE.
+ *
+ * Add a preconfigured key (plain key or IC) to Trust Center device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAppCnfBdbAddInstallcodeSreq extends ZstackFrameRequest {
+
+ /**
+ * This value specifies the format in which the install code is being added. The following list contains the values corresponding
+ * to the supported formats: 0x01 Install Code + CRC 0x02 Key derived from Install Code
+ */
+ private ZstackInstallCodeFormat installCodeFormat;
+
+ /**
+ * Full IEEE address for the device joining the network
+ */
+ private IeeeAddress ieeeAddress;
+
+ /**
+ * 16 Bytes for the Key derived from the IC. 18 Bytes for the Install Code +CRC
+ */
+ private ZigBeeKey installCode;
+
+ /**
+ * Request constructor
+ */
+ public ZstackAppCnfBdbAddInstallcodeSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * This value specifies the format in which the install code is being added. The following list contains the values corresponding
+ * to the supported formats: 0x01 Install Code + CRC 0x02 Key derived from Install Code
+ *
+ * @return the current installCodeFormat as {@link ZstackInstallCodeFormat}
+ */
+ public ZstackInstallCodeFormat getInstallCodeFormat() {
+ return installCodeFormat;
+ }
+
+ /**
+ * This value specifies the format in which the install code is being added. The following list contains the values corresponding
+ * to the supported formats: 0x01 Install Code + CRC 0x02 Key derived from Install Code
+ *
+ * @param installCodeFormat the InstallCodeFormat to set as {@link ZstackInstallCodeFormat}
+ */
+ public void setInstallCodeFormat(ZstackInstallCodeFormat installCodeFormat) {
+ this.installCodeFormat = installCodeFormat;
+ }
+
+ /**
+ * Full IEEE address for the device joining the network
+ *
+ * @return the current ieeeAddress as {@link IeeeAddress}
+ */
+ public IeeeAddress getIeeeAddress() {
+ return ieeeAddress;
+ }
+
+ /**
+ * Full IEEE address for the device joining the network
+ *
+ * @param ieeeAddress the IeeeAddress to set as {@link IeeeAddress}
+ */
+ public void setIeeeAddress(IeeeAddress ieeeAddress) {
+ this.ieeeAddress = ieeeAddress;
+ }
+
+ /**
+ * 16 Bytes for the Key derived from the IC. 18 Bytes for the Install Code +CRC
+ *
+ * @return the current installCode as {@link ZigBeeKey}
+ */
+ public ZigBeeKey getInstallCode() {
+ return installCode;
+ }
+
+ /**
+ * 16 Bytes for the Key derived from the IC. 18 Bytes for the Install Code +CRC
+ *
+ * @param installCode the InstallCode to set as {@link ZigBeeKey}
+ */
+ public void setInstallCode(ZigBeeKey installCode) {
+ this.installCode = installCode;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_APP_CNF) && (response.getReqCmd1() == 0x04));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_APP_CNF, 0x04);
+
+ // Serialize the fields
+ serializer.serializeUInt8(installCodeFormat.getKey());
+ serializer.serializeIeeeAddress(ieeeAddress);
+ serializer.serializeZigBeeKey(installCode);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(111);
+ builder.append("ZstackAppCnfBdbAddInstallcodeSreq [installCodeFormat=");
+ builder.append(installCodeFormat);
+ builder.append(", ieeeAddress=");
+ builder.append(ieeeAddress);
+ builder.append(", installCode=");
+ builder.append(installCode);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbAddInstallcodeSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbAddInstallcodeSrsp.java
new file mode 100644
index 0000000000..4ba8025790
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbAddInstallcodeSrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.appcnf;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command APP_CNF_BDB_ADD_INSTALLCODE.
+ *
+ * Add a preconfigured key (plain key or IC) to Trust Center device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAppCnfBdbAddInstallcodeSrsp extends ZstackFrameResponse {
+
+ /**
+ * Status values: 0x00 Success. 0x01 Failure (IC not supported) 0x02 Invalid parameter (bad CRC).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackAppCnfBdbAddInstallcodeSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Status values: 0x00 Success. 0x01 Failure (IC not supported) 0x02 Invalid parameter (bad CRC).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status values: 0x00 Success. 0x01 Failure (IC not supported) 0x02 Invalid parameter (bad CRC).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(61);
+ builder.append("ZstackAppCnfBdbAddInstallcodeSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbCommissioningNotificationAreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbCommissioningNotificationAreq.java
new file mode 100644
index 0000000000..c0a4c337c0
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbCommissioningNotificationAreq.java
@@ -0,0 +1,136 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.appcnf;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.appcnf.ZstackBdbRemainingCommissioningModes;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Class to implement the Z-Stack command APP_CNF_BDB_COMMISSIONING_NOTIFICATION.
+ *
+ * Callback to receive notifications from BDB process.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAppCnfBdbCommissioningNotificationAreq extends ZstackFrameResponse {
+
+ /**
+ * Status of the commissioning mode being notified
+ */
+ private ZstackBdbStatus status;
+
+ /**
+ * Commissioning mode for which the notification is done and to which the status is related
+ */
+ private ZstackBdbCommissioningMode commissioningMode;
+
+ /**
+ * Bitmask of the remaining commissioning modes after this notification.
+ *
+ * Parameter allows multiple options so implemented as a {@link Set}.
+ */
+ private Set
+ * Sets the policy to mandate or not the usage of an Install Code upon joining.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAppCnfBdbSetActiveDefaultCentralizedKeySreq extends ZstackFrameRequest {
+
+ /**
+ * This parameter controls which key will be used when performing association to a centralized network.
+ */
+ private ZstackCentralizedLinkKeyMode centralizedLinkKeyMode;
+
+ /**
+ * Buffer with the key in any of its formats.
+ */
+ private int[] installCode;
+
+ /**
+ * Request constructor
+ */
+ public ZstackAppCnfBdbSetActiveDefaultCentralizedKeySreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * This parameter controls which key will be used when performing association to a centralized network.
+ *
+ * @return the current centralizedLinkKeyMode as {@link ZstackCentralizedLinkKeyMode}
+ */
+ public ZstackCentralizedLinkKeyMode getCentralizedLinkKeyMode() {
+ return centralizedLinkKeyMode;
+ }
+
+ /**
+ * This parameter controls which key will be used when performing association to a centralized network.
+ *
+ * @param centralizedLinkKeyMode the CentralizedLinkKeyMode to set as {@link ZstackCentralizedLinkKeyMode}
+ */
+ public void setCentralizedLinkKeyMode(ZstackCentralizedLinkKeyMode centralizedLinkKeyMode) {
+ this.centralizedLinkKeyMode = centralizedLinkKeyMode;
+ }
+
+ /**
+ * Buffer with the key in any of its formats.
+ *
+ * @return the current installCode as {@link int[]}
+ */
+ public int[] getInstallCode() {
+ return installCode;
+ }
+
+ /**
+ * Buffer with the key in any of its formats.
+ *
+ * @param installCode the InstallCode to set as {@link int[]}
+ */
+ public void setInstallCode(int[] installCode) {
+ this.installCode = installCode;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_APP_CNF) && (response.getReqCmd1() == 0x07));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_APP_CNF, 0x07);
+
+ // Serialize the fields
+ serializer.serializeUInt8(centralizedLinkKeyMode.getKey());
+ serializer.serializeUInt8Array(installCode);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(102);
+ builder.append("ZstackAppCnfBdbSetActiveDefaultCentralizedKeySreq [centralizedLinkKeyMode=");
+ builder.append(centralizedLinkKeyMode);
+ builder.append(", installCode=");
+ for (int c = 0; c < installCode.length; c++) {
+ if (c > 0) {
+ builder.append(' ');
+ }
+ builder.append(String.format("%02X", installCode[c]));
+ }
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbSetActiveDefaultCentralizedKeySrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbSetActiveDefaultCentralizedKeySrsp.java
new file mode 100644
index 0000000000..9200b66c75
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbSetActiveDefaultCentralizedKeySrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.appcnf;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command APP_CNF_BDB_SET_ACTIVE_DEFAULT_CENTRALIZED_KEY.
+ *
+ * Sets the policy to mandate or not the usage of an Install Code upon joining.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAppCnfBdbSetActiveDefaultCentralizedKeySrsp extends ZstackFrameResponse {
+
+ /**
+ * 0x00 Success 0x01 Failure (IC not supported) 0x02 Invalid Parameters (bad CRC).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackAppCnfBdbSetActiveDefaultCentralizedKeySrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * 0x00 Success 0x01 Failure (IC not supported) 0x02 Invalid Parameters (bad CRC).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * 0x00 Success 0x01 Failure (IC not supported) 0x02 Invalid Parameters (bad CRC).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(77);
+ builder.append("ZstackAppCnfBdbSetActiveDefaultCentralizedKeySrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbSetJoinusesinstallcodekeySreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbSetJoinusesinstallcodekeySreq.java
new file mode 100644
index 0000000000..4e871c2ebc
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbSetJoinusesinstallcodekeySreq.java
@@ -0,0 +1,101 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.appcnf;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command APP_CNF_BDB_SET_JOINUSESINSTALLCODEKEY.
+ *
+ * Sets the policy to mandate or not the usage of an Install Code upon joining.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAppCnfBdbSetJoinusesinstallcodekeySreq extends ZstackFrameRequest {
+
+ /**
+ * If it is equal to TRUE and the installation code derived link key is not stored, the Trust Center SHALL terminate the procedure for
+ * adding a new node into the network. If bdbJoinUsesInstall- CodeKey is equal to TRUE and the installation code derived link key is
+ * stored, the Trust Center SHALL first find the entry in apsDeviceKeyPairSet that corresponds to the joining node and then
+ * overwrite the LinkKey entry with the installation code derived link key and set the KeyAttributes field to PROVISIONAL_KEY.
+ * The Trust Center MAY then set OutgoingFrame- Counter to 0 and SHALL set IncomingFrameCounter to 0. If
+ * bdbJoinUsesInstallCodeKey is equal to FALSE, the Trust Center SHALL first find the entry in apsDeviceKeyPairSet that
+ * corresponds to the joining node and then overwrite the LinkKey entry with the default global Trust Center link key and set the
+ * KeyAttributes field to PROVISIONAL_KEY. The Trust Center MAY then set OutgoingFrameCounter to 0 and SHALL set
+ * IncomingFrameCounter to 0.
+ */
+ private boolean joinUsesInstallCodeKey;
+
+ /**
+ * Request constructor
+ */
+ public ZstackAppCnfBdbSetJoinusesinstallcodekeySreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * If it is equal to TRUE and the installation code derived link key is not stored, the Trust Center SHALL terminate the procedure for
+ * adding a new node into the network. If bdbJoinUsesInstall- CodeKey is equal to TRUE and the installation code derived link key is
+ * stored, the Trust Center SHALL first find the entry in apsDeviceKeyPairSet that corresponds to the joining node and then
+ * overwrite the LinkKey entry with the installation code derived link key and set the KeyAttributes field to PROVISIONAL_KEY.
+ * The Trust Center MAY then set OutgoingFrame- Counter to 0 and SHALL set IncomingFrameCounter to 0. If
+ * bdbJoinUsesInstallCodeKey is equal to FALSE, the Trust Center SHALL first find the entry in apsDeviceKeyPairSet that
+ * corresponds to the joining node and then overwrite the LinkKey entry with the default global Trust Center link key and set the
+ * KeyAttributes field to PROVISIONAL_KEY. The Trust Center MAY then set OutgoingFrameCounter to 0 and SHALL set
+ * IncomingFrameCounter to 0.
+ *
+ * @return the current joinUsesInstallCodeKey as {@link boolean}
+ */
+ public boolean getJoinUsesInstallCodeKey() {
+ return joinUsesInstallCodeKey;
+ }
+
+ /**
+ * If it is equal to TRUE and the installation code derived link key is not stored, the Trust Center SHALL terminate the procedure for
+ * adding a new node into the network. If bdbJoinUsesInstall- CodeKey is equal to TRUE and the installation code derived link key is
+ * stored, the Trust Center SHALL first find the entry in apsDeviceKeyPairSet that corresponds to the joining node and then
+ * overwrite the LinkKey entry with the installation code derived link key and set the KeyAttributes field to PROVISIONAL_KEY.
+ * The Trust Center MAY then set OutgoingFrame- Counter to 0 and SHALL set IncomingFrameCounter to 0. If
+ * bdbJoinUsesInstallCodeKey is equal to FALSE, the Trust Center SHALL first find the entry in apsDeviceKeyPairSet that
+ * corresponds to the joining node and then overwrite the LinkKey entry with the default global Trust Center link key and set the
+ * KeyAttributes field to PROVISIONAL_KEY. The Trust Center MAY then set OutgoingFrameCounter to 0 and SHALL set
+ * IncomingFrameCounter to 0.
+ *
+ * @param joinUsesInstallCodeKey the JoinUsesInstallCodeKey to set as {@link boolean}
+ */
+ public void setJoinUsesInstallCodeKey(boolean joinUsesInstallCodeKey) {
+ this.joinUsesInstallCodeKey = joinUsesInstallCodeKey;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_APP_CNF) && (response.getReqCmd1() == 0x06));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_APP_CNF, 0x06);
+
+ // Serialize the fields
+ serializer.serializeBoolean(joinUsesInstallCodeKey);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(72);
+ builder.append("ZstackAppCnfBdbSetJoinusesinstallcodekeySreq [joinUsesInstallCodeKey=");
+ builder.append(joinUsesInstallCodeKey);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbSetJoinusesinstallcodekeySrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbSetJoinusesinstallcodekeySrsp.java
new file mode 100644
index 0000000000..8547b421b6
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbSetJoinusesinstallcodekeySrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.appcnf;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command APP_CNF_BDB_SET_JOINUSESINSTALLCODEKEY.
+ *
+ * Sets the policy to mandate or not the usage of an Install Code upon joining.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAppCnfBdbSetJoinusesinstallcodekeySrsp extends ZstackFrameResponse {
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackAppCnfBdbSetJoinusesinstallcodekeySrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(72);
+ builder.append("ZstackAppCnfBdbSetJoinusesinstallcodekeySrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbSetTcRequireKeyExchangeSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbSetTcRequireKeyExchangeSreq.java
new file mode 100644
index 0000000000..0afe323c69
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbSetTcRequireKeyExchangeSreq.java
@@ -0,0 +1,89 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.appcnf;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command APP_CNF_BDB_SET_TC_REQUIRE_KEY_EXCHANGE.
+ *
+ * Sets the policy flag on Trust Center device to mandate or not the TCLK exchange procedure.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAppCnfBdbSetTcRequireKeyExchangeSreq extends ZstackFrameRequest {
+
+ /**
+ * The bdbTrustCenterRequireKeyExchange attribute specifies whether the Trust Center requires a joining device to exchange
+ * its initial link key with a new link key generated by the Trust Center. If bdbTrustCenterRequireKeyExchange is equal to TRUE,
+ * the joining node must undergo the link key exchange procedure; failure to exchange the link key will result in the node being
+ * removed from the network. If bdbTrustCenterRequireKeyExchange is equal to FALSE, the Trust Center will permit the joining
+ * node to remain on the network without exchanging its initial link key. This attribute is used by ZigBee coordinator nodes.
+ */
+ private boolean trustCenterRequireKeyExchange;
+
+ /**
+ * Request constructor
+ */
+ public ZstackAppCnfBdbSetTcRequireKeyExchangeSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * The bdbTrustCenterRequireKeyExchange attribute specifies whether the Trust Center requires a joining device to exchange
+ * its initial link key with a new link key generated by the Trust Center. If bdbTrustCenterRequireKeyExchange is equal to TRUE,
+ * the joining node must undergo the link key exchange procedure; failure to exchange the link key will result in the node being
+ * removed from the network. If bdbTrustCenterRequireKeyExchange is equal to FALSE, the Trust Center will permit the joining
+ * node to remain on the network without exchanging its initial link key. This attribute is used by ZigBee coordinator nodes.
+ *
+ * @return the current trustCenterRequireKeyExchange as {@link boolean}
+ */
+ public boolean getTrustCenterRequireKeyExchange() {
+ return trustCenterRequireKeyExchange;
+ }
+
+ /**
+ * The bdbTrustCenterRequireKeyExchange attribute specifies whether the Trust Center requires a joining device to exchange
+ * its initial link key with a new link key generated by the Trust Center. If bdbTrustCenterRequireKeyExchange is equal to TRUE,
+ * the joining node must undergo the link key exchange procedure; failure to exchange the link key will result in the node being
+ * removed from the network. If bdbTrustCenterRequireKeyExchange is equal to FALSE, the Trust Center will permit the joining
+ * node to remain on the network without exchanging its initial link key. This attribute is used by ZigBee coordinator nodes.
+ *
+ * @param trustCenterRequireKeyExchange the TrustCenterRequireKeyExchange to set as {@link boolean}
+ */
+ public void setTrustCenterRequireKeyExchange(boolean trustCenterRequireKeyExchange) {
+ this.trustCenterRequireKeyExchange = trustCenterRequireKeyExchange;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_APP_CNF) && (response.getReqCmd1() == 0x09));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_APP_CNF, 0x09);
+
+ // Serialize the fields
+ serializer.serializeBoolean(trustCenterRequireKeyExchange);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(70);
+ builder.append("ZstackAppCnfBdbSetTcRequireKeyExchangeSreq [trustCenterRequireKeyExchange=");
+ builder.append(trustCenterRequireKeyExchange);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbSetTcRequireKeyExchangeSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbSetTcRequireKeyExchangeSrsp.java
new file mode 100644
index 0000000000..56c1eea507
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfBdbSetTcRequireKeyExchangeSrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.appcnf;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command APP_CNF_BDB_SET_TC_REQUIRE_KEY_EXCHANGE.
+ *
+ * Sets the policy flag on Trust Center device to mandate or not the TCLK exchange procedure.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAppCnfBdbSetTcRequireKeyExchangeSrsp extends ZstackFrameResponse {
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackAppCnfBdbSetTcRequireKeyExchangeSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(70);
+ builder.append("ZstackAppCnfBdbSetTcRequireKeyExchangeSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfSetAllowrejoinTcPolicySreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfSetAllowrejoinTcPolicySreq.java
new file mode 100644
index 0000000000..6206c9c111
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfSetAllowrejoinTcPolicySreq.java
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.appcnf;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command APP_CNF_SET_ALLOWREJOIN_TC_POLICY.
+ *
+ * Sets the AllowRejoin TC policy.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAppCnfSetAllowrejoinTcPolicySreq extends ZstackFrameRequest {
+
+ /**
+ * This value specifies whether or not the Trust Center allows devices to rejoin.
+ */
+ private boolean allowRejoin;
+
+ /**
+ * Request constructor
+ */
+ public ZstackAppCnfSetAllowrejoinTcPolicySreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * This value specifies whether or not the Trust Center allows devices to rejoin.
+ *
+ * @return the current allowRejoin as {@link boolean}
+ */
+ public boolean getAllowRejoin() {
+ return allowRejoin;
+ }
+
+ /**
+ * This value specifies whether or not the Trust Center allows devices to rejoin.
+ *
+ * @param allowRejoin the AllowRejoin to set as {@link boolean}
+ */
+ public void setAllowRejoin(boolean allowRejoin) {
+ this.allowRejoin = allowRejoin;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_APP_CNF) && (response.getReqCmd1() == 0x03));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_APP_CNF, 0x03);
+
+ // Serialize the fields
+ serializer.serializeBoolean(allowRejoin);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(66);
+ builder.append("ZstackAppCnfSetAllowrejoinTcPolicySreq [allowRejoin=");
+ builder.append(allowRejoin);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfSetAllowrejoinTcPolicySrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfSetAllowrejoinTcPolicySrsp.java
new file mode 100644
index 0000000000..95d9a19585
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAppCnfSetAllowrejoinTcPolicySrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.appcnf;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command APP_CNF_SET_ALLOWREJOIN_TC_POLICY.
+ *
+ * Sets the AllowRejoin TC policy.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackAppCnfSetAllowrejoinTcPolicySrsp extends ZstackFrameResponse {
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackAppCnfSetAllowrejoinTcPolicySrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(66);
+ builder.append("ZstackAppCnfSetAllowrejoinTcPolicySrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAuthenticationOption.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAuthenticationOption.java
new file mode 100644
index 0000000000..423ed85050
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/appcnf/ZstackAuthenticationOption.java
@@ -0,0 +1,75 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.appcnf;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Class to implement the Z-Stack Enumeration ZstackAuthenticationOption.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public enum ZstackAuthenticationOption {
+
+ /**
+ * The device has not been authenticated
+ */
+ NOT_AUTHENTICATED(0x0000),
+
+ /**
+ * The device has been authenticated using CBKE
+ */
+ AUTHENTICATED_CBCK(0x0001),
+
+ /**
+ * The device has been authenticated using EA
+ */
+ AUTHENTICATED_EA(0x0002);
+
+ /**
+ * A mapping between the integer code and its corresponding type to
+ * facilitate lookup by code.
+ */
+ private static Map
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public enum ZstackBdbCommissioningMode {
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_INITIALIZATION(0x0000),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_NWK_STEERING(0x0001),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_FORMATION(0x0002),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_FINDING_BINDING(0x0003),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_TOUCHLINK(0x0004),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_PARENT_LOST(0x0005);
+
+ /**
+ * A mapping between the integer code and its corresponding type to
+ * facilitate lookup by code.
+ */
+ private static Map
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public enum ZstackBdbRemainingCommissioningModes {
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_MODE_INITIATOR_TL(0x0001),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_MODE_NWK_STEERING(0x0002),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_MODE_NWK_FORMATION(0x0004),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_MODE_FINDING_BINDING(0x0008),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_MODE_INITIALIZATION(0x0010),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_MODE_PARENT_LOST(0x0020);
+
+ /**
+ * A mapping between the integer code and its corresponding type to
+ * facilitate lookup by code.
+ */
+ private static Map
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public enum ZstackBdbStatus {
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_SUCCESS(0x0000),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_IN_PROGRESS(0x0001),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_NO_NETWORK(0x0002),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_TL_TARGET_FAILURE(0x0003),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_TL_NOT_AA_CAPABLE(0x0004),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_TL_NO_SCAN_RESPONSE(0x0005),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_TL_NOT_PERMITTED(0x0006),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_TCLK_EX_FAILURE(0x0007),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_FORMATION_FAILURE(0x0008),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_FB_TARGET_IN_PROGRESS(0x0009),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_FB_INITIATOR_IN_PROGRESS(0x000A),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_FB_NO_IDENTIFY_QUERY_RESPONSE(0x000B),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_FB_BINDING_TABLE_FULL(0x000C),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_NETWORK_RESTORED(0x000D),
+
+ /**
+ *
+ */
+ BDB_COMMISSIONING_FAILURE(0x000E);
+
+ /**
+ * A mapping between the integer code and its corresponding type to
+ * facilitate lookup by code.
+ */
+ private static Map
+ * Central link key policies
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public enum ZstackCentralizedLinkKeyMode {
+ /**
+ * Default unknown value
+ */
+ UNKNOWN(-1),
+
+ /**
+ * Instruct joining node to use Default Global Trust Center link key. No key buffer required
+ */
+ DEFAULT_GLOBAL_KEY(0x0000),
+
+ /**
+ * Instruct the joining node to use the provided install code (16 bytes + 2 CRC bytes) to derive APS Link key to be used during joining
+ */
+ PROVIDED_INSTALL_CODE(0x0001),
+
+ /**
+ * Instruct the joining node to use the provided install code (16 bytes + 2 CRC bytes) to derive APS Link key to be used during joining.
+ * If it fails to decrypt Transport Key, it will automatically try Default Global Trust Center Link Key
+ */
+ PROVIDED_INSTALL_CODE_THEN_DEFAULT_GLOBAL_KEY(0x0002),
+
+ /**
+ * Instruct the joining node to use the provided APS Link key to be used during joining (key size is 16 bytes)
+ */
+ PROVIDED_APS_KEY(0x0003),
+
+ /**
+ * Instruct the joining node to use the provided APS Link key to be used during joining (key size is 16 bytes). If it fails to decrypt
+ * Transport Key, it will automatically try Default Global Trust Center Link Key
+ */
+ PROVIDED_APS_CODE_THEN_DEFAULT_GLOBAL_KEY(0x0004);
+
+ /**
+ * A mapping between the integer code and its corresponding type to
+ * facilitate lookup by code.
+ */
+ private static Map
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public enum ZstackInstallCodeFormat {
+
+ /**
+ *
+ */
+ INSTALL_CODE(0x0001),
+
+ /**
+ *
+ */
+ DERIVED_KEY(0x0002);
+
+ /**
+ * A mapping between the integer code and its corresponding type to
+ * facilitate lookup by code.
+ */
+ private static Map
+ * This command is used to send a request to the device to perform a network scan.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackMacScanReqSreq extends ZstackFrameRequest {
+
+ /**
+ * This represents a bit-mask of channels to be scanned when starting the device: NONE = 0x00000000, ALL_CHANNELS = 0x07FFF800,
+ * CHANNEL 11 = 0x00000800, CHANNEL 12 = 0x00001000, CHANNEL 13 = 0x00002000, CHANNEL 14 = 0x00004000, CHANNEL 15 = 0x00008000,
+ * CHANNEL 16 = 0x00010000, CHANNEL 17 = 0x00020000, CHANNEL 18 = 0x00040000, CHANNEL_19 = 0x00080000, CHANNEL 20 = 0x00100000,
+ * CHANNEL 21 = 0x00200000, CHANNEL 22 = 0x00400000, CHANNEL 23 = 0x00800000, CHANNEL 24 = 0x01000000 CHANNEL 25 = 0x02000000,
+ * CHANNEL 26 = 0x04000000
+ */
+ private int scanChannels;
+
+ /**
+ * Specifies the scan type:
+ */
+ private int scanType;
+
+ /**
+ * Duration of the scan - The exponent used in the scan duration calculation.
+ */
+ private int scanDuration;
+
+ /**
+ * The channel page on which to perform the scan.
+ */
+ private int channelPage;
+
+ /**
+ * Key Source of this data frame.
+ */
+ private int keySource;
+
+ /**
+ * Security Level of this data frame:
+ */
+ private int securityLevel;
+
+ /**
+ * Key Id Mode of this data frame:
+ */
+ private int keyIdMode;
+
+ /**
+ * Key Index of this data frame.
+ */
+ private int keyIndex;
+
+ /**
+ * Request constructor
+ */
+ public ZstackMacScanReqSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * This represents a bit-mask of channels to be scanned when starting the device: NONE = 0x00000000, ALL_CHANNELS = 0x07FFF800,
+ * CHANNEL 11 = 0x00000800, CHANNEL 12 = 0x00001000, CHANNEL 13 = 0x00002000, CHANNEL 14 = 0x00004000, CHANNEL 15 = 0x00008000,
+ * CHANNEL 16 = 0x00010000, CHANNEL 17 = 0x00020000, CHANNEL 18 = 0x00040000, CHANNEL_19 = 0x00080000, CHANNEL 20 = 0x00100000,
+ * CHANNEL 21 = 0x00200000, CHANNEL 22 = 0x00400000, CHANNEL 23 = 0x00800000, CHANNEL 24 = 0x01000000 CHANNEL 25 = 0x02000000,
+ * CHANNEL 26 = 0x04000000
+ *
+ * @return the current scanChannels as {@link int}
+ */
+ public int getScanChannels() {
+ return scanChannels;
+ }
+
+ /**
+ * This represents a bit-mask of channels to be scanned when starting the device: NONE = 0x00000000, ALL_CHANNELS = 0x07FFF800,
+ * CHANNEL 11 = 0x00000800, CHANNEL 12 = 0x00001000, CHANNEL 13 = 0x00002000, CHANNEL 14 = 0x00004000, CHANNEL 15 = 0x00008000,
+ * CHANNEL 16 = 0x00010000, CHANNEL 17 = 0x00020000, CHANNEL 18 = 0x00040000, CHANNEL_19 = 0x00080000, CHANNEL 20 = 0x00100000,
+ * CHANNEL 21 = 0x00200000, CHANNEL 22 = 0x00400000, CHANNEL 23 = 0x00800000, CHANNEL 24 = 0x01000000 CHANNEL 25 = 0x02000000,
+ * CHANNEL 26 = 0x04000000
+ *
+ * @param scanChannels the ScanChannels to set as {@link int}
+ */
+ public void setScanChannels(int scanChannels) {
+ this.scanChannels = scanChannels;
+ }
+
+ /**
+ * Specifies the scan type:
+ *
+ * @return the current scanType as {@link int}
+ */
+ public int getScanType() {
+ return scanType;
+ }
+
+ /**
+ * Specifies the scan type:
+ *
+ * @param scanType the ScanType to set as {@link int}
+ */
+ public void setScanType(int scanType) {
+ this.scanType = scanType;
+ }
+
+ /**
+ * Duration of the scan - The exponent used in the scan duration calculation.
+ *
+ * @return the current scanDuration as {@link int}
+ */
+ public int getScanDuration() {
+ return scanDuration;
+ }
+
+ /**
+ * Duration of the scan - The exponent used in the scan duration calculation.
+ *
+ * @param scanDuration the ScanDuration to set as {@link int}
+ */
+ public void setScanDuration(int scanDuration) {
+ this.scanDuration = scanDuration;
+ }
+
+ /**
+ * The channel page on which to perform the scan.
+ *
+ * @return the current channelPage as {@link int}
+ */
+ public int getChannelPage() {
+ return channelPage;
+ }
+
+ /**
+ * The channel page on which to perform the scan.
+ *
+ * @param channelPage the ChannelPage to set as {@link int}
+ */
+ public void setChannelPage(int channelPage) {
+ this.channelPage = channelPage;
+ }
+
+ /**
+ * Key Source of this data frame.
+ *
+ * @return the current keySource as {@link int}
+ */
+ public int getKeySource() {
+ return keySource;
+ }
+
+ /**
+ * Key Source of this data frame.
+ *
+ * @param keySource the KeySource to set as {@link int}
+ */
+ public void setKeySource(int keySource) {
+ this.keySource = keySource;
+ }
+
+ /**
+ * Security Level of this data frame:
+ *
+ * @return the current securityLevel as {@link int}
+ */
+ public int getSecurityLevel() {
+ return securityLevel;
+ }
+
+ /**
+ * Security Level of this data frame:
+ *
+ * @param securityLevel the SecurityLevel to set as {@link int}
+ */
+ public void setSecurityLevel(int securityLevel) {
+ this.securityLevel = securityLevel;
+ }
+
+ /**
+ * Key Id Mode of this data frame:
+ *
+ * @return the current keyIdMode as {@link int}
+ */
+ public int getKeyIdMode() {
+ return keyIdMode;
+ }
+
+ /**
+ * Key Id Mode of this data frame:
+ *
+ * @param keyIdMode the KeyIdMode to set as {@link int}
+ */
+ public void setKeyIdMode(int keyIdMode) {
+ this.keyIdMode = keyIdMode;
+ }
+
+ /**
+ * Key Index of this data frame.
+ *
+ * @return the current keyIndex as {@link int}
+ */
+ public int getKeyIndex() {
+ return keyIndex;
+ }
+
+ /**
+ * Key Index of this data frame.
+ *
+ * @param keyIndex the KeyIndex to set as {@link int}
+ */
+ public void setKeyIndex(int keyIndex) {
+ this.keyIndex = keyIndex;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_MAC) && (response.getReqCmd1() == 0x0C));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_MAC, 0x0C);
+
+ // Serialize the fields
+ serializer.serializeUInt32(scanChannels);
+ serializer.serializeUInt8(scanType);
+ serializer.serializeUInt8(scanDuration);
+ serializer.serializeUInt8(channelPage);
+ serializer.serializeUInt8(keySource);
+ serializer.serializeUInt8(securityLevel);
+ serializer.serializeUInt8(keyIdMode);
+ serializer.serializeUInt8(keyIndex);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(223);
+ builder.append("ZstackMacScanReqSreq [scanChannels=");
+ builder.append(scanChannels);
+ builder.append(", scanType=");
+ builder.append(scanType);
+ builder.append(", scanDuration=");
+ builder.append(scanDuration);
+ builder.append(", channelPage=");
+ builder.append(channelPage);
+ builder.append(", keySource=");
+ builder.append(keySource);
+ builder.append(", securityLevel=");
+ builder.append(securityLevel);
+ builder.append(", keyIdMode=");
+ builder.append(keyIdMode);
+ builder.append(", keyIndex=");
+ builder.append(keyIndex);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/mac/ZstackMacScanReqSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/mac/ZstackMacScanReqSrsp.java
new file mode 100644
index 0000000000..ed1b6a51b9
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/mac/ZstackMacScanReqSrsp.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.mac;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+
+/**
+ * Class to implement the Z-Stack command MAC_SCAN_REQ.
+ *
+ * This command is used to send a request to the device to perform a network scan.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackMacScanReqSrsp extends ZstackFrameResponse {
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackMacScanReqSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ }
+
+ @Override
+ public String toString() {
+ return "ZstackMacScanReqSrsp []";
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/rpc/ZstackRpcSreqErrorSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/rpc/ZstackRpcSreqErrorSrsp.java
new file mode 100644
index 0000000000..2965de8dd1
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/rpc/ZstackRpcSreqErrorSrsp.java
@@ -0,0 +1,119 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.rpc;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+
+/**
+ * Class to implement the Z-Stack command RPC_SREQ_ERROR.
+ *
+ * When the ZNP cannot recognize an SREQ command from the host processor, the following SRSP is returned.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackRpcSreqErrorSrsp extends ZstackFrameResponse {
+
+ /**
+ * The error code maps to one of the enumerated values.
+ */
+ private ZstackSreqErrorCode errorCode;
+
+ /**
+ * The Cmd0 value of the processed SREQ
+ */
+ private int reqCmd0;
+
+ /**
+ * The Cmd1 value of the processed SREQ
+ */
+ private int reqCmd1;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackRpcSreqErrorSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ errorCode = ZstackSreqErrorCode.valueOf(deserializer.deserializeUInt8());
+ reqCmd0 = deserializer.deserializeUInt8();
+ reqCmd1 = deserializer.deserializeUInt8();
+ }
+
+ /**
+ * The error code maps to one of the enumerated values.
+ *
+ * @return the current errorCode as {@link ZstackSreqErrorCode}
+ */
+ public ZstackSreqErrorCode getErrorCode() {
+ return errorCode;
+ }
+
+ /**
+ * The error code maps to one of the enumerated values.
+ *
+ * @param errorCode the ErrorCode to set as {@link ZstackSreqErrorCode}
+ */
+ public void setErrorCode(ZstackSreqErrorCode errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ /**
+ * The Cmd0 value of the processed SREQ
+ *
+ * @return the current reqCmd0 as {@link int}
+ */
+ public int getReqCmd0() {
+ return reqCmd0;
+ }
+
+ /**
+ * The Cmd0 value of the processed SREQ
+ *
+ * @param reqCmd0 the ReqCmd0 to set as {@link int}
+ */
+ public void setReqCmd0(int reqCmd0) {
+ this.reqCmd0 = reqCmd0;
+ }
+
+ /**
+ * The Cmd1 value of the processed SREQ
+ *
+ * @return the current reqCmd1 as {@link int}
+ */
+ public int getReqCmd1() {
+ return reqCmd1;
+ }
+
+ /**
+ * The Cmd1 value of the processed SREQ
+ *
+ * @param reqCmd1 the ReqCmd1 to set as {@link int}
+ */
+ public void setReqCmd1(int reqCmd1) {
+ this.reqCmd1 = reqCmd1;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(100);
+ builder.append("ZstackRpcSreqErrorSrsp [errorCode=");
+ builder.append(errorCode);
+ builder.append(", reqCmd0=");
+ builder.append(String.format("%02X", reqCmd0));
+ builder.append(", reqCmd1=");
+ builder.append(String.format("%02X", reqCmd1));
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/rpc/ZstackSreqErrorCode.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/rpc/ZstackSreqErrorCode.java
new file mode 100644
index 0000000000..1913654f82
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/rpc/ZstackSreqErrorCode.java
@@ -0,0 +1,89 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.rpc;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Class to implement the Z-Stack Enumeration ZstackSreqErrorCode.
+ *
+ * SREQ RPC Error code
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public enum ZstackSreqErrorCode {
+ /**
+ * Default unknown value
+ */
+ UNKNOWN(-1),
+
+ /**
+ *
+ */
+ INVALID_SUBSYSTEM(0x0001),
+
+ /**
+ *
+ */
+ INVALID_COMMAND_ID(0x0002),
+
+ /**
+ *
+ */
+ INVALID_PARAMETER(0x0003),
+
+ /**
+ *
+ */
+ INVALID_LENGTH(0x0003);
+
+ /**
+ * A mapping between the integer code and its corresponding type to
+ * facilitate lookup by code.
+ */
+ private static Map
+ * Device Info Constants
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public enum ZstackDeviceInformation {
+ /**
+ * Default unknown value
+ */
+ UNKNOWN(-1),
+
+ /**
+ *
+ */
+ ZB_INFO_DEV_STATE(0x0000),
+
+ /**
+ *
+ */
+ ZB_INFO_IEEE_ADDR(0x0001),
+
+ /**
+ *
+ */
+ ZB_INFO_SHORT_ADDR(0x0002),
+
+ /**
+ *
+ */
+ ZB_INFO_PARENT_SHORT_ADDR(0x0003),
+
+ /**
+ *
+ */
+ ZB_INFO_PARENT_IEEE_ADDR(0x0004),
+
+ /**
+ *
+ */
+ ZB_INFO_CHANNEL(0x0005),
+
+ /**
+ *
+ */
+ ZB_INFO_PAN_ID(0x0006),
+
+ /**
+ *
+ */
+ ZB_INFO_EXT_PAN_ID(0x0007);
+
+ /**
+ * A mapping between the integer code and its corresponding type to
+ * facilitate lookup by code.
+ */
+ private static Map
+ * This command retrieves a Device Information Property.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZbGetDeviceInfoSreq extends ZstackFrameRequest {
+
+ /**
+ * The Identifier for the device information.
+ */
+ private int param;
+
+ /**
+ * Request constructor
+ */
+ public ZstackZbGetDeviceInfoSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * The Identifier for the device information.
+ *
+ * @return the current param as {@link int}
+ */
+ public int getParam() {
+ return param;
+ }
+
+ /**
+ * The Identifier for the device information.
+ *
+ * @param param the Param to set as {@link int}
+ */
+ public void setParam(int param) {
+ this.param = param;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SAPI) && (response.getReqCmd1() == 0x06));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SAPI, 0x06);
+
+ // Serialize the fields
+ serializer.serializeUInt8(param);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(53);
+ builder.append("ZstackZbGetDeviceInfoSreq [param=");
+ builder.append(param);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sapi/ZstackZbGetDeviceInfoSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sapi/ZstackZbGetDeviceInfoSrsp.java
new file mode 100644
index 0000000000..754f0781c4
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sapi/ZstackZbGetDeviceInfoSrsp.java
@@ -0,0 +1,93 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sapi;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+
+/**
+ * Class to implement the Z-Stack command ZB_GET_DEVICE_INFO.
+ *
+ * This command retrieves a Device Information Property.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZbGetDeviceInfoSrsp extends ZstackFrameResponse {
+
+ /**
+ * The Identifier for the device information.
+ */
+ private int param;
+
+ /**
+ * A buffer to hold the device information
+ */
+ private int value;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackZbGetDeviceInfoSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ param = deserializer.deserializeUInt8();
+ value = deserializer.deserializeUInt16();
+ }
+
+ /**
+ * The Identifier for the device information.
+ *
+ * @return the current param as {@link int}
+ */
+ public int getParam() {
+ return param;
+ }
+
+ /**
+ * The Identifier for the device information.
+ *
+ * @param param the Param to set as {@link int}
+ */
+ public void setParam(int param) {
+ this.param = param;
+ }
+
+ /**
+ * A buffer to hold the device information
+ *
+ * @return the current value as {@link int}
+ */
+ public int getValue() {
+ return value;
+ }
+
+ /**
+ * A buffer to hold the device information
+ *
+ * @param value the Value to set as {@link int}
+ */
+ public void setValue(int value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(78);
+ builder.append("ZstackZbGetDeviceInfoSrsp [param=");
+ builder.append(param);
+ builder.append(", value=");
+ builder.append(value);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sapi/ZstackZbReadConfigurationSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sapi/ZstackZbReadConfigurationSreq.java
new file mode 100644
index 0000000000..5f634a02f6
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sapi/ZstackZbReadConfigurationSreq.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sapi;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackConfigId;
+
+/**
+ * Class to implement the Z-Stack command ZB_READ_CONFIGURATION.
+ *
+ * This command is used to get a configuration property from non-volatile memory.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZbReadConfigurationSreq extends ZstackFrameRequest {
+
+ /**
+ * Specifies the Identifier for the configuration property.
+ */
+ private ZstackConfigId configId;
+
+ /**
+ * Request constructor
+ */
+ public ZstackZbReadConfigurationSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * Specifies the Identifier for the configuration property.
+ *
+ * @return the current configId as {@link ZstackConfigId}
+ */
+ public ZstackConfigId getConfigId() {
+ return configId;
+ }
+
+ /**
+ * Specifies the Identifier for the configuration property.
+ *
+ * @param configId the ConfigId to set as {@link ZstackConfigId}
+ */
+ public void setConfigId(ZstackConfigId configId) {
+ this.configId = configId;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SAPI) && (response.getReqCmd1() == 0x04));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SAPI, 0x04);
+
+ // Serialize the fields
+ serializer.serializeUInt8(configId.getKey());
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(57);
+ builder.append("ZstackZbReadConfigurationSreq [configId=");
+ builder.append(configId);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sapi/ZstackZbReadConfigurationSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sapi/ZstackZbReadConfigurationSrsp.java
new file mode 100644
index 0000000000..e17fa2c3c4
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sapi/ZstackZbReadConfigurationSrsp.java
@@ -0,0 +1,127 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sapi;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackConfigId;
+
+/**
+ * Class to implement the Z-Stack command ZB_READ_CONFIGURATION.
+ *
+ * This command is used to get a configuration property from non-volatile memory.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZbReadConfigurationSrsp extends ZstackFrameResponse {
+
+ /**
+ * This field indicates either SUCCESS (0) or FAILURE (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Specifies the Identifier for the configuration property.
+ */
+ private ZstackConfigId configId;
+
+ /**
+ * Buffer to hold the configuration property.
+ */
+ private int[] value;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackZbReadConfigurationSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ configId = ZstackConfigId.valueOf(deserializer.deserializeUInt8());
+ int len = deserializer.deserializeUInt8();
+ value = deserializer.deserializeUInt8Array(len);
+ }
+
+ /**
+ * This field indicates either SUCCESS (0) or FAILURE (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * This field indicates either SUCCESS (0) or FAILURE (1).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ /**
+ * Specifies the Identifier for the configuration property.
+ *
+ * @return the current configId as {@link ZstackConfigId}
+ */
+ public ZstackConfigId getConfigId() {
+ return configId;
+ }
+
+ /**
+ * Specifies the Identifier for the configuration property.
+ *
+ * @param configId the ConfigId to set as {@link ZstackConfigId}
+ */
+ public void setConfigId(ZstackConfigId configId) {
+ this.configId = configId;
+ }
+
+ /**
+ * Buffer to hold the configuration property.
+ *
+ * @return the current value as {@link int[]}
+ */
+ public int[] getValue() {
+ return value;
+ }
+
+ /**
+ * Buffer to hold the configuration property.
+ *
+ * @param value the Value to set as {@link int[]}
+ */
+ public void setValue(int[] value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(132);
+ builder.append("ZstackZbReadConfigurationSrsp [status=");
+ builder.append(status);
+ builder.append(", configId=");
+ builder.append(configId);
+ builder.append(", value=");
+ for (int c = 0; c < value.length; c++) {
+ if (c > 0) {
+ builder.append(' ');
+ }
+ builder.append(String.format("%02X", value[c]));
+ }
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sapi/ZstackZbWriteConfigurationSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sapi/ZstackZbWriteConfigurationSreq.java
new file mode 100644
index 0000000000..c46a281e6d
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sapi/ZstackZbWriteConfigurationSreq.java
@@ -0,0 +1,110 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sapi;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackConfigId;
+
+/**
+ * Class to implement the Z-Stack command ZB_WRITE_CONFIGURATION.
+ *
+ * This command is used to write a configuration property to nonvolatile memory.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZbWriteConfigurationSreq extends ZstackFrameRequest {
+
+ /**
+ * Specifies the Identifier for the configuration property.
+ */
+ private ZstackConfigId configId;
+
+ /**
+ * Buffer to hold the configuration property.
+ */
+ private int[] value;
+
+ /**
+ * Request constructor
+ */
+ public ZstackZbWriteConfigurationSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * Specifies the Identifier for the configuration property.
+ *
+ * @return the current configId as {@link ZstackConfigId}
+ */
+ public ZstackConfigId getConfigId() {
+ return configId;
+ }
+
+ /**
+ * Specifies the Identifier for the configuration property.
+ *
+ * @param configId the ConfigId to set as {@link ZstackConfigId}
+ */
+ public void setConfigId(ZstackConfigId configId) {
+ this.configId = configId;
+ }
+
+ /**
+ * Buffer to hold the configuration property.
+ *
+ * @return the current value as {@link int[]}
+ */
+ public int[] getValue() {
+ return value;
+ }
+
+ /**
+ * Buffer to hold the configuration property.
+ *
+ * @param value the Value to set as {@link int[]}
+ */
+ public void setValue(int[] value) {
+ this.value = value;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SAPI) && (response.getReqCmd1() == 0x05));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SAPI, 0x05);
+
+ // Serialize the fields
+ serializer.serializeUInt8(configId.getKey());
+ serializer.serializeUInt8(value.length);
+ serializer.serializeUInt8Array(value);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(108);
+ builder.append("ZstackZbWriteConfigurationSreq [configId=");
+ builder.append(configId);
+ builder.append(", value=");
+ for (int c = 0; c < value.length; c++) {
+ if (c > 0) {
+ builder.append(' ');
+ }
+ builder.append(String.format("%02X", value[c]));
+ }
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sapi/ZstackZbWriteConfigurationSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sapi/ZstackZbWriteConfigurationSrsp.java
new file mode 100644
index 0000000000..65055010ad
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sapi/ZstackZbWriteConfigurationSrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sapi;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command ZB_WRITE_CONFIGURATION.
+ *
+ * This command is used to write a configuration property to nonvolatile memory.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZbWriteConfigurationSrsp extends ZstackFrameResponse {
+
+ /**
+ * This field indicates either SUCCESS (0) or FAILURE (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackZbWriteConfigurationSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * This field indicates either SUCCESS (0) or FAILURE (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * This field indicates either SUCCESS (0) or FAILURE (1).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(58);
+ builder.append("ZstackZbWriteConfigurationSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sbl/ZstackSbHandshakeCmdSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sbl/ZstackSbHandshakeCmdSreq.java
new file mode 100644
index 0000000000..a4dff033a6
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sbl/ZstackSbHandshakeCmdSreq.java
@@ -0,0 +1,47 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sbl;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command SB_HANDSHAKE_CMD.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSbHandshakeCmdSreq extends ZstackFrameRequest {
+
+ /**
+ * Request constructor
+ */
+ public ZstackSbHandshakeCmdSreq() {
+ synchronousCommand = true;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SBL) && (response.getReqCmd1() == 0x04));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SBL, 0x04);
+
+ // Serialize the fields
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ return "ZstackSbHandshakeCmdSreq []";
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sbl/ZstackSbHandshakeCmdSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sbl/ZstackSbHandshakeCmdSrsp.java
new file mode 100644
index 0000000000..f10c485932
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sbl/ZstackSbHandshakeCmdSrsp.java
@@ -0,0 +1,168 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sbl;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command SB_HANDSHAKE_CMD.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSbHandshakeCmdSrsp extends ZstackFrameResponse {
+
+ /**
+ * 0x00 - SUCCESS 0x01 - FAILURE
+ */
+ private ZstackResponseCode status;
+
+ /**
+ */
+ private int bootloaderRevision;
+
+ /**
+ */
+ private int deviceType;
+
+ /**
+ * The maximum data size to use with Read / Write command
+ */
+ private int bufferLength;
+
+ /**
+ * 0x800 – CC2538 flash page size
+ */
+ private int pageSize;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackSbHandshakeCmdSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ bootloaderRevision = deserializer.deserializeUInt32();
+ deviceType = deserializer.deserializeUInt8();
+ bufferLength = deserializer.deserializeUInt32();
+ pageSize = deserializer.deserializeUInt32();
+ }
+
+ /**
+ * 0x00 - SUCCESS 0x01 - FAILURE
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * 0x00 - SUCCESS 0x01 - FAILURE
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ /**
+ *
+ *
+ * @return the current bootloaderRevision as {@link int}
+ */
+ public int getBootloaderRevision() {
+ return bootloaderRevision;
+ }
+
+ /**
+ *
+ *
+ * @param bootloaderRevision the BootloaderRevision to set as {@link int}
+ */
+ public void setBootloaderRevision(int bootloaderRevision) {
+ this.bootloaderRevision = bootloaderRevision;
+ }
+
+ /**
+ *
+ *
+ * @return the current deviceType as {@link int}
+ */
+ public int getDeviceType() {
+ return deviceType;
+ }
+
+ /**
+ *
+ *
+ * @param deviceType the DeviceType to set as {@link int}
+ */
+ public void setDeviceType(int deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ /**
+ * The maximum data size to use with Read / Write command
+ *
+ * @return the current bufferLength as {@link int}
+ */
+ public int getBufferLength() {
+ return bufferLength;
+ }
+
+ /**
+ * The maximum data size to use with Read / Write command
+ *
+ * @param bufferLength the BufferLength to set as {@link int}
+ */
+ public void setBufferLength(int bufferLength) {
+ this.bufferLength = bufferLength;
+ }
+
+ /**
+ * 0x800 – CC2538 flash page size
+ *
+ * @return the current pageSize as {@link int}
+ */
+ public int getPageSize() {
+ return pageSize;
+ }
+
+ /**
+ * 0x800 – CC2538 flash page size
+ *
+ * @param pageSize the PageSize to set as {@link int}
+ */
+ public void setPageSize(int pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(152);
+ builder.append("ZstackSbHandshakeCmdSrsp [status=");
+ builder.append(status);
+ builder.append(", bootloaderRevision=");
+ builder.append(bootloaderRevision);
+ builder.append(", deviceType=");
+ builder.append(deviceType);
+ builder.append(", bufferLength=");
+ builder.append(bufferLength);
+ builder.append(", pageSize=");
+ builder.append(pageSize);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sbl/ZstackSbWriteCmdSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sbl/ZstackSbWriteCmdSreq.java
new file mode 100644
index 0000000000..4ac9970054
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sbl/ZstackSbWriteCmdSreq.java
@@ -0,0 +1,81 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sbl;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command SB_WRITE_CMD.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSbWriteCmdSreq extends ZstackFrameRequest {
+
+ /**
+ * Payload data.
+ */
+ private int[] payload;
+
+ /**
+ * Request constructor
+ */
+ public ZstackSbWriteCmdSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * Payload data.
+ *
+ * @return the current payload as {@link int[]}
+ */
+ public int[] getPayload() {
+ return payload;
+ }
+
+ /**
+ * Payload data.
+ *
+ * @param payload the Payload to set as {@link int[]}
+ */
+ public void setPayload(int[] payload) {
+ this.payload = payload;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SBL) && (response.getReqCmd1() == 0x00));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SBL, 0x00);
+
+ // Serialize the fields
+ serializer.serializeUInt32(payload.length);
+ serializer.serializeUInt8Array(payload);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(73);
+ builder.append("ZstackSbWriteCmdSreq [payload=");
+ for (int c = 0; c < payload.length; c++) {
+ if (c > 0) {
+ builder.append(' ');
+ }
+ builder.append(String.format("%02X", payload[c]));
+ }
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sbl/ZstackSbWriteCmdSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sbl/ZstackSbWriteCmdSrsp.java
new file mode 100644
index 0000000000..13e9e6bca6
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sbl/ZstackSbWriteCmdSrsp.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sbl;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command SB_WRITE_CMD.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSbWriteCmdSrsp extends ZstackFrameResponse {
+
+ /**
+ * 0x00 - SUCCESS 0x01 - FAILURE
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackSbWriteCmdSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * 0x00 - SUCCESS 0x01 - FAILURE
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * 0x00 - SUCCESS 0x01 - FAILURE
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(48);
+ builder.append("ZstackSbWriteCmdSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackConfigId.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackConfigId.java
new file mode 100644
index 0000000000..fe5bdf8393
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackConfigId.java
@@ -0,0 +1,658 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Class to implement the Z-Stack Enumeration ZstackConfigId.
+ *
+ * Device specific configuration parameters.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public enum ZstackConfigId {
+ /**
+ * Default unknown value
+ */
+ UNKNOWN(-1),
+
+ /**
+ *
+ */
+ ZCD_NV_EXTADDR(0x0000),
+
+ /**
+ *
+ */
+ ZCD_NV_BOOTCOUNTER(0x0001),
+
+ /**
+ * This parameter controls the device startup options. Size: 1 byte; Default value: 0
+ */
+ ZCD_NV_STARTUP_OPTION(0x0003),
+
+ /**
+ *
+ */
+ ZCD_NV_START_DELAY(0x0004),
+
+ /**
+ * If this parameter is set to a non-zero value, a CC2530-ZNP device that is configured as an end- device will wake up periodically
+ * with this duration to check for data with its parent device. This value is specified in milliseconds and can range from 1 to 65000.
+ * If this parameter is set to zero, the device will not automatically wake up to poll for data. Instead, an external trigger or an
+ * internal event (for example, via a software timer event) can be used to wake up the device. Size: 4 bytes; Default value: 2000
+ */
+ ZCD_NV_POLL_RATE_OLD16(0x0035),
+
+ /**
+ * When an end-device polls for data with its parent and finds that it does have data, it can poll again with a shorter duration in case
+ * there is more data queued for it at its parent device. This value is specified in milliseconds. This feature can be turned off by
+ * setting this value to zero. Size: 2 bytes; Default value: 100
+ */
+ ZCD_NV_QUEUED_POLL_RATE(0x0025),
+
+ /**
+ * When an end-device sends a data packet, it can poll again with a shorter duration, specified by this parameter, if the
+ * application is expecting to receive an application level packet in response. This value is specified in milliseconds. This
+ * feature can be turned off by setting the value to zero.
+ *
+ * Note: The setting of the queued and response poll rates has to be done with caution if the device is sending and receiving
+ * at the same time or if the device is sending data too fast. If the device is sending data too fast, setting a queued poll rate with a
+ * higher duration than the sending rate will cause the poll event to be continuously rescheduled to the future. Then the device
+ * will never poll for data with its parent and consequently it may miss any packets destined for it. Size: 2 bytes; Default value:
+ * 100
+ */
+ ZCD_NV_RESPONSE_POLL_RATE(0x0026),
+
+ /**
+ *
+ */
+ ZCD_NV_REJOIN_POLL_RATE(0x0027),
+
+ /**
+ *
+ */
+ ZCD_NV_DATA_RETRIES(0x0028),
+
+ /**
+ * The number of times an end-device will fail when communicating with its parent before invoking the rejoin mechanism to find and
+ * join a new parent. Size: 1 byte; Default value: 2.
+ */
+ ZCD_NV_POLL_FAILURE_RETRIES(0x0029),
+
+ /**
+ *
+ */
+ ZCD_NV_STACK_PROFILE(0x002A),
+
+ /**
+ * The amount of time (in seconds) that a router or coordinator device will buffer messages destined to their end-device child
+ * nodes. It is recommended that this is at least greater than the poll rate (ZCD_NV_POLL_RATE) to ensure that end-device will have
+ * a chance to wakeup and poll for the data. Size: 1 byte; Default value: 7
+ */
+ ZCD_NV_INDIRECT_MSG_TIMEOUT(0x002B),
+
+ /**
+ * The amount of time (in seconds) for which a route must be idle (i.e. no packets are transmitted on that route) before that routing
+ * entry is marked as expired. An expired entry may be deleted if the table is full and the space is needed for another new routing
+ * entry. This can be set to a special value of 0 to turn off route expiry. In this case, route entries are not expired. Size: 1 byte;
+ * Default value: 60.
+ */
+ ZCD_NV_ROUTE_EXPIRY_TIME(0x002C),
+
+ /**
+ * This parameter configures the EXTENDED PAN ID in Z-Stack. The extended pan id is used to further segregate the sub network(s)
+ * among a bigger PAN network.
+ */
+ ZCD_NV_EXTPANID(0x002D),
+
+ /**
+ * The maximum number of retransmissions that a device will attempt when trying to transmit a broadcast packet. The typical range
+ * is from 1 through 3. Size: 1 byte; Default value: 2.
+ */
+ ZCD_NV_BCAST_RETRIES(0x002E),
+
+ /**
+ * The amount of time (in units of 100milliseconds) a device will wait before retransmitting a broadcast packet. The
+ * retransmission will not happen if the node hears that each of its neighbor nodes have all transmitted that packet. Size: 1 byte;
+ * Default value: 5
+ */
+ ZCD_NV_PASSIVE_ACK_TIMEOUT(0x002F),
+
+ /**
+ * The maximum amount of time (in units of 100ms) that it can take for a broadcast packet to propagate through the entire network.
+ * This includes time for all retransmissions.
+ *
+ * Note: This parameter must be set with caution. It must be set to a value of at least (ZCD_NV_BCAST_RETRIES + 1) *
+ * ZCD_NV_PASSIVE_ACK_TIMEOUT To be safe, the actual value should be higher than the above minimum by about 500ms or more. Size: 1
+ * byte; Default value: 30.
+ */
+ ZCD_NV_BCAST_DELIVERY_TIME(0x0030),
+
+ /**
+ * Holds the value of the network operational mode. The default value is NWK_MODE_MESH and must not be modified.
+ */
+ ZCD_NV_NWK_MODE(0x0031),
+
+ /**
+ *
+ */
+ ZCD_NV_CONCENTRATOR_ENABLE(0x0032),
+
+ /**
+ *
+ */
+ ZCD_NV_CONCENTRATOR_DISCOVERY(0x0033),
+
+ /**
+ *
+ */
+ ZCD_NV_CONCENTRATOR_RADIUS(0x0034),
+
+ /**
+ * If this parameter is set to a non-zero value, a CC2530-ZNP device that is configured as an end- device will wake up periodically
+ * with this duration to check for data with its parent device. This value is specified in milliseconds and can range from 1 to 65000.
+ * If this parameter is set to zero, the device will not automatically wake up to poll for data. Instead, an external trigger or an
+ * internal event (for example, via a software timer event) can be used to wake up the device. Size: 4 bytes; Default value: 2000
+ */
+ ZCD_NV_POLL_RATE(0x0035),
+
+ /**
+ * Holds the value of route cache flag. This enables or disables the route cache for coordinator and is FALSE by default.
+ */
+ ZCD_NV_CONCENTRATOR_RC(0x0036),
+
+ /**
+ *
+ */
+ ZCD_NV_NWK_MGR_MODE(0x0037),
+
+ /**
+ *
+ */
+ ZCD_NV_SRC_RTG_EXPIRY_TIME(0x0038),
+
+ /**
+ *
+ */
+ ZCD_NV_ROUTE_DISCOVERY_TIME(0x0039),
+
+ /**
+ *
+ */
+ ZCD_NV_NWK_ACTIVE_KEY_INFO(0x003A),
+
+ /**
+ *
+ */
+ ZCD_NV_NWK_ALTERN_KEY_INFO(0x003B),
+
+ /**
+ *
+ */
+ ZCD_NV_ROUTER_OFF_ASSOC_CLEANUP(0x003C),
+
+ /**
+ *
+ */
+ ZCD_NV_NWK_LEAVE_REQ_ALLOWED(0x003D),
+
+ /**
+ * Holds the value of Child Aging capability flag. This enables or disables child aging and must be set to TRUE for Zigbee 3.0
+ * compliance.
+ */
+ ZCD_NV_NWK_CHILD_AGE_ENABLE(0x003E),
+
+ /**
+ *
+ */
+ ZCD_NV_DEVICE_LIST_KA_TIMEOUT(0x003F),
+
+ /**
+ *
+ */
+ ZCD_NV_BINDING_TABLE(0x0041),
+
+ /**
+ *
+ */
+ ZCD_NV_GROUP_TABLE(0x0042),
+
+ /**
+ * The number of retransmissions performed on a data packet at the application layer if the packet was transmitted with the
+ * end-to-end acknowledgement option enabled. Size: 1 byte; Default value: 3
+ */
+ ZCD_NV_APS_FRAME_RETRIES(0x0043),
+
+ /**
+ * The amount of time (in milliseconds) a device will wait before re-transmitting a packet that used the APS acknowledgement
+ * option. If the APS acknowledgement is not received by this time, the sending device will assume a failure and attempt a
+ * re-transmission.
+ *
+ * Note: This is recommended to be set to approximately the expected round trip time for the packet. Note that if the
+ * destination (or source) device is an end-device, the round trip time for the packet will include an additional delay up to the
+ * poll duration. This is in addition to the delay normally caused by the network. Size: 2 bytes; Default value: 3000
+ */
+ ZCD_NV_APS_ACK_WAIT_DURATION(0x0044),
+
+ /**
+ *
+ */
+ ZCD_NV_APS_ACK_WAIT_MULTIPLIER(0x0045),
+
+ /**
+ * The amount of time (in milliseconds) a device will wait for a response to a binding request. Size: 2 bytes; Default value: 8000
+ */
+ ZCD_NV_BINDING_TIME(0x0046),
+
+ /**
+ *
+ */
+ ZCD_NV_APS_USE_EXT_PANID(0x0047),
+
+ /**
+ *
+ */
+ ZCD_NV_COMMISSIONED_NWK_ADDR(0x0049),
+
+ /**
+ *
+ */
+ ZCD_NV_APS_NONMEMBER_RADIUS(0x004B),
+
+ /**
+ * Holds the security manager entries of type ZDSecMgrEntry_t to store the TCKL used to talk with devices in the network that
+ * require APS security. The number of entries is controled by ZDSECMGR_DEVICE_MAX=3 by default.
+ */
+ ZCD_NV_APS_LINK_KEY_TABLE(0x004C),
+
+ /**
+ *
+ */
+ ZCD_NV_APS_DUPREJ_TIMEOUT_INC(0x004D),
+
+ /**
+ *
+ */
+ ZCD_NV_APS_DUPREJ_TIMEOUT_COUNT(0x004E),
+
+ /**
+ *
+ */
+ ZCD_NV_APS_DUPREJ_TABLE_SIZE(0x004F),
+
+ /**
+ *
+ */
+ ZCD_NV_DIAGNOSTIC_STATS(0x0050),
+
+ /**
+ *
+ */
+ ZCD_NV_NWK_PARENT_INFO(0x0051),
+
+ /**
+ *
+ */
+ ZCD_NV_NWK_ENDDEV_TIMEOUT_DEF(0x0052),
+
+ /**
+ * Holds the value of Child Aging Timeout. This is the time in seconds used by END DEVICE when sending End Device Timeout Request that
+ * tells a COORDINATOR the timeout to remove this END DEVICE after no data poll is received.
+ */
+ ZCD_NV_END_DEV_TIMEOUT_VALUE(0x0053),
+
+ /**
+ * Holds the value of End Device Configuration field when END DEVICE when sending End Device Timeout Request. Is set to 0x00 by
+ * default which is the only valid value accourding to Zigbee Core spec R21.
+ */
+ ZCD_NV_END_DEV_CONFIGURATION(0x0054),
+
+ /**
+ *
+ */
+ ZCD_NV_BDBNODEISONANETWORK(0x0055),
+
+ /**
+ *
+ */
+ ZCD_NV_BDBREPORTINGCONFIG(0x0056),
+
+ /**
+ * holds the value of network key that is generated by default. The key can be set to a fixed value by setting DEFAULT_KEY macro. This
+ * is used for securing and un-securing packets in the network, if security is enabled for the network.
+ *
+ * Note: Use of this configuration item requires the ZNP code to be built with the SECURE=1 compile option. Size: 16 bytes;
+ * Default value: [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F]
+ */
+ ZCD_NV_PRECFGKEY(0x0062),
+
+ /**
+ * If security functionality is enabled, there are two options to distribute the security key to all devices in the network. If this
+ * parameter is true, the same security key is assumed to be pre-configured in all devices in the network.If it is set to false, then
+ * the key only needs to be configured on the coordinator device. In this case, the key is distributed to each device upon joining by
+ * the coordinator. This key distribution will happen in the “clear” on the last hop of the packet transmission and this
+ * constitutes a brief “period of vulnerability” during which a malicious device can capture the key. Hence it is not recommended
+ * unless it can be ensured that there are no malicious devices in the vicinity at the time of network formation.
+ *
+ * Note: Use of this configuration item requires the ZNP code to be built with the SECURE=1 compile option. Size: 1 byte;
+ * Default value: TRUE
+ */
+ ZCD_NV_PRECFGKEYS_ENABLE(0x0063),
+
+ /**
+ * This parameter determines if security is used or not in this network. It can be set to 0 (to turn off NWK security) or 1 (to turn on NWK
+ * security). Size: 1 byte; Default value: 0.
+ */
+ ZCD_NV_SECURITY_MODE(0x0064),
+
+ /**
+ * This value tells if only secure joins are allowed. Set to TRUE by default which is the only valid value according to Zigbee Core
+ * spec R21.
+ */
+ ZCD_NV_SECURE_PERMIT_JOIN(0x0065),
+
+ /**
+ * Is equal to ZG_GLOBAL_LINK_KEY=1 and must not be modified according to Zigbee Core spec R21.
+ */
+ ZCD_NV_APS_LINK_KEY_TYPE(0x0066),
+
+ /**
+ *
+ */
+ ZCD_NV_APS_ALLOW_R19_SECURITY(0x0067),
+
+ /**
+ * Default distributed nwk key Id. Nv ID not in use
+ */
+ ZCD_NV_DISTRIBUTED_KEY(0x0068),
+
+ /**
+ *
+ */
+ ZCD_NV_IMPLICIT_CERTIFICATE(0x0069),
+
+ /**
+ *
+ */
+ ZCD_NV_DEVICE_PRIVATE_KEY(0x006A),
+
+ /**
+ *
+ */
+ ZCD_NV_CA_PUBLIC_KEY(0x006B),
+
+ /**
+ *
+ */
+ ZCD_NV_KE_MAX_DEVICES(0x006C),
+
+ /**
+ * Controls whether a single pre-configured trust center link key is used or whether multiple pre- configured trust center link
+ * keys are used, hereby referred to as Single Key Mode and Multiple Key Mode, respectively. In multiple key mode, unique
+ * pre-configured trust center link keys are used between the trust center and each individual device joining the network.
+ * Multiple key mode is required by the recommended secure procedure in ZigBeeSE profile Specification. In single key mode, all
+ * devices are using the same pre-configured trust center link key to join the network. The single key mode provides a simplified
+ * alternative procedure to set up the network. It can be used for testing and debugging purpose. Size: 1 byte; Default value: TRUE
+ */
+ ZCD_NV_USE_DEFAULT_TCLK(0x006D),
+
+ /**
+ *
+ */
+ ZCD_NV_RNG_COUNTER(0x006F),
+
+ /**
+ *
+ */
+ ZCD_NV_RANDOM_SEED(0x0070),
+
+ /**
+ *
+ */
+ ZCD_NV_TRUSTCENTER_ADDR(0x0071),
+
+ /**
+ *
+ */
+ ZCD_NV_CERT_283(0x0072),
+
+ /**
+ *
+ */
+ ZCD_NV_PRIVATE_KEY_283(0x0073),
+
+ /**
+ *
+ */
+ ZCD_NV_PUBLIC_KEY_283(0x0074),
+
+ /**
+ *
+ */
+ ZCD_NV_NWK_SEC_MATERIAL_TABLE_START(0x0075),
+
+ /**
+ *
+ */
+ ZCD_NV_NWK_SEC_MATERIAL_TABLE_END(0x0080),
+
+ /**
+ * An optional user-defined data (up to 16bytes) that can be configured in a CC2530-ZNP device so that it can easily identified or
+ * described later. The first byte is the length of the user descriptor data and must not be greater than 16. Size: 17 bytes; Default
+ * value: “CC2530-ZNP x......” (dots represent the device IEEE address)
+ */
+ ZCD_NV_USERDESC(0x0081),
+
+ /**
+ * This holds the value of nwkActiveKeyItems structure and restores the NWK key counter after power cycles.
+ */
+ ZCD_NV_NWKKEY(0x0082),
+
+ /**
+ * This parameter identifies the ZigBee network. This should be set to a value between 0 and 0x3FFF. Networks that exist in the same
+ * vicinity must have different values for this parameter. It can be set to a special value of 0xFFFF to indicate “don’t care”. Size:
+ * 2 bytes; Default value: 0xFFFF
+ */
+ ZCD_NV_PANID(0x0083),
+
+ /**
+ * This parameter is a bit mask of the channels on which this network can operate (note that multiple channels can be selected). See
+ * section 4.5.16 for a table of the bitmap representation that maps to each channel. Multiple networks that exist in the same
+ * vicinity are encouraged to have different values. If multiple channels are selected, the coordinator will pick one of the
+ * channels for network operation. First, an energy scan is performed on each channel and those channels with a high energy level
+ * are discarded. Then, the coordinator determines the number of existing ZigBee networks on each of the remaining channels and
+ * picks the one with the fewest networks. For routers and end-devices, the device will simply scan all the selected channels until
+ * it finds the ZigBee network. Size: 4 bytes; Default value: 0x00000800
+ */
+ ZCD_NV_CHANLIST(0x0084),
+
+ /**
+ *
+ */
+ ZCD_NV_SCAN_DURATION(0x0086),
+
+ /**
+ * This is the logical type of the device in the ZigBee network. This can be set to a COORDINATOR (0x00), ROUTER (0x01) or ENDDEVICE
+ * (0x02).
+ *
+ * Note: This parameter is read by the CC2530-ZNP device immediately when it powers up after a reset. Size: 1 byte; Default
+ * value: 0x00
+ */
+ ZCD_NV_LOGICAL_TYPE(0x0087),
+
+ /**
+ *
+ */
+ ZCD_NV_NWKMGR_MIN_TX(0x0088),
+
+ /**
+ *
+ */
+ ZCD_NV_NWKMGR_ADDR(0x0089),
+
+ /**
+ * This configures the manner in which ZDO responses (hereby referred to as callbacks) are issued to the host processor. By
+ * default, this item is set to FALSE, which means that the host processor must use the ZDO_MSG_CB_REGISTER command to subscribe to
+ * a specific ZDO callback in order to receive it. The ZDO callback is then conveyed as part of the ZDO_MSG_CB_INCOMING command. If
+ * ZCD_NV_ZDO_DIRECT_CB is set TRUE, then the host processor will receive the “verbose” response. For example, the host
+ * processor would receive the ZDO_IEEE_ADDR_RSP command in response to ZDO_IEEE_ADDR_REQ. Size: 1 byte; Default value: FALSE
+ */
+ ZCD_NV_ZDO_DIRECT_CB(0x008F),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_SHORT_ADDR(0x00B1),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_EXT_PANID(0x00B2),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_PANID(0x00B3),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_CHANNEL_MASK(0x00B4),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_PROTOCOL_VER(0x00B5),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_STACK_PROFILE(0x00B6),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_STARTUP_CTRL(0x00B7),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_TC_ADDR(0x00C1),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_TC_MASTER_KEY(0x00C2),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_NWK_KEY(0x00C3),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_USE_INSEC_JOIN(0x00C4),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_PRECFG_LINK_KEY(0x00C5),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_NWK_KEY_SEQ_NUM(0x00C6),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_NWK_KEY_TYPE(0x00C7),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_NWK_MGR_ADDR(0x00C8),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_CURR_TC_MASTER_KEY(0x00D1),
+
+ /**
+ *
+ */
+ ZCD_NV_SAS_CURR_NWK_KEY(0x00D2),
+
+ /**
+ *
+ */
+ ZCD_NV_TCLK_TABLE_START(0x0101),
+
+ /**
+ *
+ */
+ ZCD_NV_TCLK_TABLE_END(0x01FF),
+
+ /**
+ *
+ */
+ ZCD_NV_APS_LINK_KEY_DATA_START(0x0201),
+
+ /**
+ *
+ */
+ ZCD_NV_APS_LINK_KEY_DATA_END(0x02FF);
+
+ /**
+ * A mapping between the integer code and its corresponding type to
+ * facilitate lookup by code.
+ */
+ private static Map
+ * Diagnostics attribute IDs.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public enum ZstackDiagnosticAttribute {
+ /**
+ * Default unknown value
+ */
+ UNKNOWN(-1),
+
+ /**
+ * System Clock when stats were saved/cleared
+ */
+ ZDIAGS_SYSTEM_CLOCK(0x0000),
+
+ /**
+ * Increments every time the system resets
+ */
+ ZDIAGS_NUMBER_OF_RESETS(0x0001),
+
+ /**
+ * MAC diagnostic CRC success counter
+ */
+ ZDIAGS_MAC_RX_CRC_PASS(0x0064),
+
+ /**
+ * MAC diagnostic CRC failure counter
+ */
+ ZDIAGS_MAC_RX_CRC_FAIL(0x0065),
+
+ /**
+ * MAC layer retries a unicast
+ */
+ ZDIAGS_MAC_TX_UCAST_RETRY(0x006A),
+
+ /**
+ * Mac layer fails to send a unicast
+ */
+ ZDIAGS_MAC_TX_UCAST_FAIL(0x006B),
+
+ /**
+ * NWK packet decryption failed
+ */
+ ZDIAGS_NWK_DECRYPT_FAILURES(0x00CF),
+
+ /**
+ * NWK packet drop because of validation error
+ */
+ ZDIAGS_PACKET_VALIDATE_DROP_COUNT(0x00D3),
+
+ /**
+ * APS layer transmits broadcast
+ */
+ ZDIAGS_APS_TX_BCAST(0x012D),
+
+ /**
+ * APS layer successfully transmits a unicast
+ */
+ ZDIAGS_APS_TX_UCAST_SUCCESS(0x012F),
+
+ /**
+ * APS layer retries the sending of a unicast
+ */
+ ZDIAGS_APS_TX_UCAST_RETRY(0x0130),
+
+ /**
+ * APS layer fails to send a unicast
+ */
+ ZDIAGS_APS_TX_UCAST_FAIL(0x0131),
+
+ /**
+ * APS packet decryption failed
+ */
+ ZDIAGS_APS_DECRYPT_FAILURES(0x0134),
+
+ /**
+ * APS invalid packet dropped
+ */
+ ZDIAGS_APS_INVALID_PACKETS(0x0135),
+
+ /**
+ * Number of MAC retries per APS message
+ */
+ ZDIAGS_MAC_RETRIES_PER_APS_TX_SUCCESS(0x0136);
+
+ /**
+ * A mapping between the integer code and its corresponding type to
+ * facilitate lookup by code.
+ */
+ private static Map
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackNwkKeyDesc {
+
+ /**
+ */
+ private int keySeqNum;
+
+ /**
+ */
+ private ZigBeeKey key;
+
+ /**
+ *
+ *
+ * @return the current keySeqNum as {@link int}
+ */
+ public int getKeySeqNum() {
+ return keySeqNum;
+ }
+
+ /**
+ *
+ *
+ * @param keySeqNum the keySeqNum to set as {@link int}
+ */
+ public void setKeySeqNum(int keySeqNum) {
+ this.keySeqNum = keySeqNum;
+ }
+
+ /**
+ *
+ *
+ * @return the current key as {@link ZigBeeKey}
+ */
+ public ZigBeeKey getKey() {
+ return key;
+ }
+
+ /**
+ *
+ *
+ * @param key the key to set as {@link ZigBeeKey}
+ */
+ public void setKey(ZigBeeKey key) {
+ this.key = key;
+ }
+
+ /**
+ * Serialize the data from this structure class to an integer array
+ *
+ * @param serializer the {@link ZstackSerializer} to use
+ */
+ public int[] serialize(ZstackSerializer serializer) {
+ // Serialize the fields
+ serializer.serializeUInt8(keySeqNum);
+ serializer.serializeZigBeeKey(key);
+ return serializer.getBuffer();
+ }
+
+ /**
+ * Deserialize the data into this structure class
+ *
+ * @param deserializer the {@link ZstackDeserializer} to use
+ */
+ public void deserialize (ZstackDeserializer deserializer) {
+ // Deserialize the fields
+ keySeqNum = deserializer.deserializeUInt8();
+ key = deserializer.deserializeZigBeeKey();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(69);
+ builder.append("ZstackNwkKeyDesc [keySeqNum=");
+ builder.append(keySeqNum);
+ builder.append(", key=");
+ builder.append(key);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackResetReason.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackResetReason.java
new file mode 100644
index 0000000000..6487a20ced
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackResetReason.java
@@ -0,0 +1,84 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Class to implement the Z-Stack Enumeration ZstackResetReason.
+ *
+ * Reasons for reset
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public enum ZstackResetReason {
+ /**
+ * Default unknown value
+ */
+ UNKNOWN(-1),
+
+ /**
+ *
+ */
+ POWER_UP(0x0000),
+
+ /**
+ *
+ */
+ EXTERNAL(0x0001),
+
+ /**
+ *
+ */
+ WATCH_DOG(0x0002);
+
+ /**
+ * A mapping between the integer code and its corresponding type to
+ * facilitate lookup by code.
+ */
+ private static Map
+ * Reset Command Type
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public enum ZstackResetType {
+ /**
+ * Default unknown value
+ */
+ UNKNOWN(-1),
+
+ /**
+ *
+ */
+ TARGET_DEVICE(0x0000),
+
+ /**
+ *
+ */
+ SERIAL_BOOTLOADER(0x0001);
+
+ /**
+ * A mapping between the integer code and its corresponding type to
+ * facilitate lookup by code.
+ */
+ private static Map
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSecMgrEntry {
+
+ /**
+ * Address manager index that holds the IEEE address of destination device. INVALID_NODE_ADDR = 0xFFFE
+ */
+ private int ami;
+
+ /**
+ * Index to the Link Key table in NV
+ */
+ private int keyNvId;
+
+ /**
+ */
+ private ZstackAuthenticationOption authenticateOption;
+
+ /**
+ * Address manager index that holds the IEEE address of destination device. INVALID_NODE_ADDR = 0xFFFE
+ *
+ * @return the current ami as {@link int}
+ */
+ public int getAmi() {
+ return ami;
+ }
+
+ /**
+ * Address manager index that holds the IEEE address of destination device. INVALID_NODE_ADDR = 0xFFFE
+ *
+ * @param ami the ami to set as {@link int}
+ */
+ public void setAmi(int ami) {
+ this.ami = ami;
+ }
+
+ /**
+ * Index to the Link Key table in NV
+ *
+ * @return the current keyNvId as {@link int}
+ */
+ public int getKeyNvId() {
+ return keyNvId;
+ }
+
+ /**
+ * Index to the Link Key table in NV
+ *
+ * @param keyNvId the keyNvId to set as {@link int}
+ */
+ public void setKeyNvId(int keyNvId) {
+ this.keyNvId = keyNvId;
+ }
+
+ /**
+ *
+ *
+ * @return the current authenticateOption as {@link ZstackAuthenticationOption}
+ */
+ public ZstackAuthenticationOption getAuthenticateOption() {
+ return authenticateOption;
+ }
+
+ /**
+ *
+ *
+ * @param authenticateOption the authenticateOption to set as {@link ZstackAuthenticationOption}
+ */
+ public void setAuthenticateOption(ZstackAuthenticationOption authenticateOption) {
+ this.authenticateOption = authenticateOption;
+ }
+
+ /**
+ * Serialize the data from this structure class to an integer array
+ *
+ * @param serializer the {@link ZstackSerializer} to use
+ */
+ public int[] serialize(ZstackSerializer serializer) {
+ // Serialize the fields
+ serializer.serializeUInt16(ami);
+ serializer.serializeUInt16(keyNvId);
+ serializer.serializeUInt8(authenticateOption.getKey());
+ return serializer.getBuffer();
+ }
+
+ /**
+ * Deserialize the data into this structure class
+ *
+ * @param deserializer the {@link ZstackDeserializer} to use
+ */
+ public void deserialize (ZstackDeserializer deserializer) {
+ // Deserialize the fields
+ ami = deserializer.deserializeUInt16();
+ keyNvId = deserializer.deserializeUInt16();
+ authenticateOption = ZstackAuthenticationOption.valueOf(deserializer.deserializeUInt8());
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(95);
+ builder.append("ZstackSecMgrEntry [ami=");
+ builder.append(ami);
+ builder.append(", keyNvId=");
+ builder.append(keyNvId);
+ builder.append(", authenticateOption=");
+ builder.append(authenticateOption);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysGetExtAddrSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysGetExtAddrSreq.java
new file mode 100644
index 0000000000..27c76cd145
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysGetExtAddrSreq.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command SYS_GET_EXT_ADDR.
+ *
+ * This command is used to set the extended address of the device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysGetExtAddrSreq extends ZstackFrameRequest {
+
+ /**
+ * Request constructor
+ */
+ public ZstackSysGetExtAddrSreq() {
+ synchronousCommand = true;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SYS) && (response.getReqCmd1() == 0x04));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SYS, 0x04);
+
+ // Serialize the fields
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ return "ZstackSysGetExtAddrSreq []";
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysGetExtAddrSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysGetExtAddrSrsp.java
new file mode 100644
index 0000000000..2c8e335ccd
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysGetExtAddrSrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.IeeeAddress;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+
+/**
+ * Class to implement the Z-Stack command SYS_GET_EXT_ADDR.
+ *
+ * This command is used to set the extended address of the device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysGetExtAddrSrsp extends ZstackFrameResponse {
+
+ /**
+ * The device’s extended address.
+ */
+ private IeeeAddress extAddress;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackSysGetExtAddrSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ extAddress = deserializer.deserializeIeeeAddress();
+ }
+
+ /**
+ * The device’s extended address.
+ *
+ * @return the current extAddress as {@link IeeeAddress}
+ */
+ public IeeeAddress getExtAddress() {
+ return extAddress;
+ }
+
+ /**
+ * The device’s extended address.
+ *
+ * @param extAddress the ExtAddress to set as {@link IeeeAddress}
+ */
+ public void setExtAddress(IeeeAddress extAddress) {
+ this.extAddress = extAddress;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(51);
+ builder.append("ZstackSysGetExtAddrSrsp [extAddress=");
+ builder.append(extAddress);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysOsalNvReadSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysOsalNvReadSreq.java
new file mode 100644
index 0000000000..bbb4b17728
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysOsalNvReadSreq.java
@@ -0,0 +1,104 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command SYS_OSAL_NV_READ.
+ *
+ * This command is used to read a single memory item from the target non-volatile memory. The command accepts an attribute Id value
+ * and data offset and returns the memory value present in the target for the specified attribute Id.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysOsalNvReadSreq extends ZstackFrameRequest {
+
+ /**
+ * The Id of the NV item.
+ */
+ private ZstackConfigId id;
+
+ /**
+ * Number of bytes offset from the beginning or the NV value.
+ */
+ private int offset;
+
+ /**
+ * Request constructor
+ */
+ public ZstackSysOsalNvReadSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * The Id of the NV item.
+ *
+ * @return the current id as {@link ZstackConfigId}
+ */
+ public ZstackConfigId getId() {
+ return id;
+ }
+
+ /**
+ * The Id of the NV item.
+ *
+ * @param id the id to set as {@link ZstackConfigId}
+ */
+ public void setId(ZstackConfigId id) {
+ this.id = id;
+ }
+
+ /**
+ * Number of bytes offset from the beginning or the NV value.
+ *
+ * @return the current offset as {@link int}
+ */
+ public int getOffset() {
+ return offset;
+ }
+
+ /**
+ * Number of bytes offset from the beginning or the NV value.
+ *
+ * @param offset the Offset to set as {@link int}
+ */
+ public void setOffset(int offset) {
+ this.offset = offset;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SYS) && (response.getReqCmd1() == 0x08));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SYS, 0x08);
+
+ // Serialize the fields
+ serializer.serializeUInt8(id.getKey());
+ serializer.serializeUInt8(offset);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(76);
+ builder.append("ZstackSysOsalNvReadSreq [id=");
+ builder.append(id);
+ builder.append(", offset=");
+ builder.append(offset);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysOsalNvReadSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysOsalNvReadSrsp.java
new file mode 100644
index 0000000000..77b667f89a
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysOsalNvReadSrsp.java
@@ -0,0 +1,101 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command SYS_OSAL_NV_READ.
+ *
+ * This command is used to read a single memory item from the target non-volatile memory. The command accepts an attribute Id value
+ * and data offset and returns the memory value present in the target for the specified attribute Id.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysOsalNvReadSrsp extends ZstackFrameResponse {
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Value of the NV item.
+ */
+ private int[] value;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackSysOsalNvReadSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ int len = deserializer.deserializeUInt8();
+ value = deserializer.deserializeUInt8Array(len);
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @param status the status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ /**
+ * Value of the NV item.
+ *
+ * @return the current value as {@link int[]}
+ */
+ public int[] getValue() {
+ return value;
+ }
+
+ /**
+ * Value of the NV item.
+ *
+ * @param value the Value to set as {@link int[]}
+ */
+ public void setValue(int[] value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(101);
+ builder.append("ZstackSysOsalNvReadSrsp [status=");
+ builder.append(status);
+ builder.append(", value=");
+ for (int c = 0; c < value.length; c++) {
+ if (c > 0) {
+ builder.append(' ');
+ }
+ builder.append(String.format("%02X", value[c]));
+ }
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysOsalNvWriteSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysOsalNvWriteSreq.java
new file mode 100644
index 0000000000..090a4421f6
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysOsalNvWriteSreq.java
@@ -0,0 +1,136 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command SYS_OSAL_NV_WRITE.
+ *
+ * This command is used to write to a particular item in non-volatile memory. The command accepts an attribute Id, data offset, data
+ * length, and attribute value. The attribute value is written to the location specified for the attribute Id in the target.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysOsalNvWriteSreq extends ZstackFrameRequest {
+
+ /**
+ * The Id of the NV item.
+ */
+ private ZstackConfigId id;
+
+ /**
+ * Number of bytes offset from the beginning or the NV value.
+ */
+ private int offset;
+
+ /**
+ * Value of the NV item.
+ */
+ private int[] value;
+
+ /**
+ * Request constructor
+ */
+ public ZstackSysOsalNvWriteSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * The Id of the NV item.
+ *
+ * @return the current id as {@link ZstackConfigId}
+ */
+ public ZstackConfigId getId() {
+ return id;
+ }
+
+ /**
+ * The Id of the NV item.
+ *
+ * @param id the Id to set as {@link ZstackConfigId}
+ */
+ public void setId(ZstackConfigId id) {
+ this.id = id;
+ }
+
+ /**
+ * Number of bytes offset from the beginning or the NV value.
+ *
+ * @return the current offset as {@link int}
+ */
+ public int getOffset() {
+ return offset;
+ }
+
+ /**
+ * Number of bytes offset from the beginning or the NV value.
+ *
+ * @param offset the Offset to set as {@link int}
+ */
+ public void setOffset(int offset) {
+ this.offset = offset;
+ }
+
+ /**
+ * Value of the NV item.
+ *
+ * @return the current value as {@link int[]}
+ */
+ public int[] getValue() {
+ return value;
+ }
+
+ /**
+ * Value of the NV item.
+ *
+ * @param value the Value to set as {@link int[]}
+ */
+ public void setValue(int[] value) {
+ this.value = value;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SYS) && (response.getReqCmd1() == 0x09));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SYS, 0x09);
+
+ // Serialize the fields
+ serializer.serializeUInt8(id.getKey());
+ serializer.serializeUInt8(offset);
+ serializer.serializeUInt8(value.length);
+ serializer.serializeUInt8Array(value);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(127);
+ builder.append("ZstackSysOsalNvWriteSreq [id=");
+ builder.append(id);
+ builder.append(", offset=");
+ builder.append(offset);
+ builder.append(", value=");
+ for (int c = 0; c < value.length; c++) {
+ if (c > 0) {
+ builder.append(' ');
+ }
+ builder.append(String.format("%02X", value[c]));
+ }
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysOsalNvWriteSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysOsalNvWriteSrsp.java
new file mode 100644
index 0000000000..b06ba01548
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysOsalNvWriteSrsp.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command SYS_OSAL_NV_WRITE.
+ *
+ * This command is used to write to a particular item in non-volatile memory. The command accepts an attribute Id, data offset, data
+ * length, and attribute value. The attribute value is written to the location specified for the attribute Id in the target.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysOsalNvWriteSrsp extends ZstackFrameResponse {
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackSysOsalNvWriteSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @param status the status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(52);
+ builder.append("ZstackSysOsalNvWriteSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysPingSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysPingSreq.java
new file mode 100644
index 0000000000..8f953acd39
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysPingSreq.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command SYS_PING.
+ *
+ * This command issues PING requests to verify if a device is active and check the capability of the device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysPingSreq extends ZstackFrameRequest {
+
+ /**
+ * Request constructor
+ */
+ public ZstackSysPingSreq() {
+ synchronousCommand = true;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SYS) && (response.getReqCmd1() == 0x01));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SYS, 0x01);
+
+ // Serialize the fields
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ return "ZstackSysPingSreq []";
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysPingSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysPingSrsp.java
new file mode 100644
index 0000000000..23041e9586
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysPingSrsp.java
@@ -0,0 +1,67 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+
+/**
+ * Class to implement the Z-Stack command SYS_PING.
+ *
+ * This command issues PING requests to verify if a device is active and check the capability of the device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysPingSrsp extends ZstackFrameResponse {
+
+ /**
+ * This field represents the interfaces that this device can handle (compiled into the device).
+ */
+ private int capabilities;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackSysPingSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ capabilities = deserializer.deserializeUInt16();
+ }
+
+ /**
+ * This field represents the interfaces that this device can handle (compiled into the device).
+ *
+ * @return the current capabilities as {@link int}
+ */
+ public int getCapabilities() {
+ return capabilities;
+ }
+
+ /**
+ * This field represents the interfaces that this device can handle (compiled into the device).
+ *
+ * @param capabilities the Capabilities to set as {@link int}
+ */
+ public void setCapabilities(int capabilities) {
+ this.capabilities = capabilities;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(45);
+ builder.append("ZstackSysPingSrsp [capabilities=");
+ builder.append(String.format("%04X", capabilities));
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysResetIndAreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysResetIndAreq.java
new file mode 100644
index 0000000000..8d9840c5e7
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysResetIndAreq.java
@@ -0,0 +1,195 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+
+/**
+ * Class to implement the Z-Stack command SYS_RESET_IND.
+ *
+ * This command is generated by the CC2530 device automatically immediately after a reset.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysResetIndAreq extends ZstackFrameResponse {
+
+ /**
+ * One of the following values indicating the reason for the reset. Power=0x00, External=0x01, Watchdog=0x02
+ */
+ private ZstackResetReason reason;
+
+ /**
+ * Transport protocol revision
+ */
+ private int transportRev;
+
+ /**
+ * Product Id
+ */
+ private int product;
+
+ /**
+ * Software major release number
+ */
+ private int majorRel;
+
+ /**
+ * Software minor release number
+ */
+ private int minorRel;
+
+ /**
+ * Hardware revision number.
+ */
+ private int hwRev;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackSysResetIndAreq(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ // Deserialize the fields
+ reason = ZstackResetReason.valueOf(deserializer.deserializeUInt8());
+ transportRev = deserializer.deserializeUInt8();
+ product = deserializer.deserializeUInt8();
+ majorRel = deserializer.deserializeUInt8();
+ minorRel = deserializer.deserializeUInt8();
+ hwRev = deserializer.deserializeUInt8();
+ }
+
+ /**
+ * One of the following values indicating the reason for the reset. Power=0x00, External=0x01, Watchdog=0x02
+ *
+ * @return the current reason as {@link ZstackResetReason}
+ */
+ public ZstackResetReason getReason() {
+ return reason;
+ }
+
+ /**
+ * One of the following values indicating the reason for the reset. Power=0x00, External=0x01, Watchdog=0x02
+ *
+ * @param reason the Reason to set as {@link ZstackResetReason}
+ */
+ public void setReason(ZstackResetReason reason) {
+ this.reason = reason;
+ }
+
+ /**
+ * Transport protocol revision
+ *
+ * @return the current transportRev as {@link int}
+ */
+ public int getTransportRev() {
+ return transportRev;
+ }
+
+ /**
+ * Transport protocol revision
+ *
+ * @param transportRev the TransportRev to set as {@link int}
+ */
+ public void setTransportRev(int transportRev) {
+ this.transportRev = transportRev;
+ }
+
+ /**
+ * Product Id
+ *
+ * @return the current product as {@link int}
+ */
+ public int getProduct() {
+ return product;
+ }
+
+ /**
+ * Product Id
+ *
+ * @param product the Product to set as {@link int}
+ */
+ public void setProduct(int product) {
+ this.product = product;
+ }
+
+ /**
+ * Software major release number
+ *
+ * @return the current majorRel as {@link int}
+ */
+ public int getMajorRel() {
+ return majorRel;
+ }
+
+ /**
+ * Software major release number
+ *
+ * @param majorRel the MajorRel to set as {@link int}
+ */
+ public void setMajorRel(int majorRel) {
+ this.majorRel = majorRel;
+ }
+
+ /**
+ * Software minor release number
+ *
+ * @return the current minorRel as {@link int}
+ */
+ public int getMinorRel() {
+ return minorRel;
+ }
+
+ /**
+ * Software minor release number
+ *
+ * @param minorRel the MinorRel to set as {@link int}
+ */
+ public void setMinorRel(int minorRel) {
+ this.minorRel = minorRel;
+ }
+
+ /**
+ * Hardware revision number.
+ *
+ * @return the current hwRev as {@link int}
+ */
+ public int getHwRev() {
+ return hwRev;
+ }
+
+ /**
+ * Hardware revision number.
+ *
+ * @param hwRev the HwRev to set as {@link int}
+ */
+ public void setHwRev(int hwRev) {
+ this.hwRev = hwRev;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(174);
+ builder.append("ZstackSysResetIndAreq [reason=");
+ builder.append(reason);
+ builder.append(", transportRev=");
+ builder.append(transportRev);
+ builder.append(", product=");
+ builder.append(product);
+ builder.append(", majorRel=");
+ builder.append(majorRel);
+ builder.append(", minorRel=");
+ builder.append(minorRel);
+ builder.append(", hwRev=");
+ builder.append(hwRev);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysResetReqAcmd.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysResetReqAcmd.java
new file mode 100644
index 0000000000..5b3e747a42
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysResetReqAcmd.java
@@ -0,0 +1,74 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+
+/**
+ * Class to implement the Z-Stack command SYS_RESET_REQ.
+ *
+ * This command is issued by the application processor to reset the CC2530 device. The reset is achieved through an internal
+ * watchdog reset on the CC2530. Note that the hardware reset interface is recommended over using this interface.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysResetReqAcmd extends ZstackFrameRequest {
+
+ /**
+ * This requests a target device reset (0) or serial bootloader reset (1). If the target device does not support serial
+ * bootloading, bootloader reset commands are ignored and no response is sent from the target.
+ */
+ private ZstackResetType type;
+
+ /**
+ * Request constructor
+ */
+ public ZstackSysResetReqAcmd() {
+ }
+
+ /**
+ * This requests a target device reset (0) or serial bootloader reset (1). If the target device does not support serial
+ * bootloading, bootloader reset commands are ignored and no response is sent from the target.
+ *
+ * @return the current type as {@link ZstackResetType}
+ */
+ public ZstackResetType getType() {
+ return type;
+ }
+
+ /**
+ * This requests a target device reset (0) or serial bootloader reset (1). If the target device does not support serial
+ * bootloading, bootloader reset commands are ignored and no response is sent from the target.
+ *
+ * @param type the Type to set as {@link ZstackResetType}
+ */
+ public void setType(ZstackResetType type) {
+ this.type = type;
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_ACMD, ZSTACK_SYS, 0x00);
+
+ // Serialize the fields
+ serializer.serializeUInt8(type.getKey());
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(49);
+ builder.append("ZstackSysResetReqAcmd [type=");
+ builder.append(type);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysSetExtAddrSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysSetExtAddrSreq.java
new file mode 100644
index 0000000000..39cfed944f
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysSetExtAddrSreq.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.IeeeAddress;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command SYS_SET_EXT_ADDR.
+ *
+ * This command is used to set the extended address of the device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysSetExtAddrSreq extends ZstackFrameRequest {
+
+ /**
+ * The device’s extended address.
+ */
+ private IeeeAddress extAddress;
+
+ /**
+ * Request constructor
+ */
+ public ZstackSysSetExtAddrSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * The device’s extended address.
+ *
+ * @return the current extAddress as {@link IeeeAddress}
+ */
+ public IeeeAddress getExtAddress() {
+ return extAddress;
+ }
+
+ /**
+ * The device’s extended address.
+ *
+ * @param extAddress the ExtAddress to set as {@link IeeeAddress}
+ */
+ public void setExtAddress(IeeeAddress extAddress) {
+ this.extAddress = extAddress;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SYS) && (response.getReqCmd1() == 0x03));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SYS, 0x03);
+
+ // Serialize the fields
+ serializer.serializeIeeeAddress(extAddress);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(51);
+ builder.append("ZstackSysSetExtAddrSreq [extAddress=");
+ builder.append(extAddress);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysSetExtAddrSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysSetExtAddrSrsp.java
new file mode 100644
index 0000000000..fadf08c210
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysSetExtAddrSrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command SYS_SET_EXT_ADDR.
+ *
+ * This command is used to set the extended address of the device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysSetExtAddrSrsp extends ZstackFrameResponse {
+
+ /**
+ * Status is either Success (1) or Failure (0)
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackSysSetExtAddrSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Status is either Success (1) or Failure (0)
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is either Success (1) or Failure (0)
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(51);
+ builder.append("ZstackSysSetExtAddrSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysSetTxPowerSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysSetTxPowerSreq.java
new file mode 100644
index 0000000000..4f821e9732
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysSetTxPowerSreq.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command SYS_SET_TX_POWER.
+ *
+ * This command is used by the tester to set the target system radio transmit power. The returned TX power is the actual setting
+ * applied to the radio – nearest characterized value for the specific radio.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysSetTxPowerSreq extends ZstackFrameRequest {
+
+ /**
+ * Requested TX power setting, in dBm.
+ */
+ private int txPower;
+
+ /**
+ * Request constructor
+ */
+ public ZstackSysSetTxPowerSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * Requested TX power setting, in dBm.
+ *
+ * @return the current txPower as {@link int}
+ */
+ public int getTxPower() {
+ return txPower;
+ }
+
+ /**
+ * Requested TX power setting, in dBm.
+ *
+ * @param txPower the TxPower to set as {@link int}
+ */
+ public void setTxPower(int txPower) {
+ this.txPower = txPower;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SYS) && (response.getReqCmd1() == 0x14));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SYS, 0x14);
+
+ // Serialize the fields
+ serializer.serializeUInt8(txPower);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(51);
+ builder.append("ZstackSysSetTxPowerSreq [txPower=");
+ builder.append(txPower);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysSetTxPowerSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysSetTxPowerSrsp.java
new file mode 100644
index 0000000000..bc5e473525
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysSetTxPowerSrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+
+/**
+ * Class to implement the Z-Stack command SYS_SET_TX_POWER.
+ *
+ * This command is used by the tester to set the target system radio transmit power. The returned TX power is the actual setting
+ * applied to the radio – nearest characterized value for the specific radio.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysSetTxPowerSrsp extends ZstackFrameResponse {
+
+ /**
+ * Requested TX power setting, in dBm.
+ */
+ private int txPower;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackSysSetTxPowerSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ txPower = deserializer.deserializeUInt8();
+ }
+
+ /**
+ * Requested TX power setting, in dBm.
+ *
+ * @return the current txPower as {@link int}
+ */
+ public int getTxPower() {
+ return txPower;
+ }
+
+ /**
+ * Requested TX power setting, in dBm.
+ *
+ * @param txPower the TxPower to set as {@link int}
+ */
+ public void setTxPower(int txPower) {
+ this.txPower = txPower;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(51);
+ builder.append("ZstackSysSetTxPowerSrsp [txPower=");
+ builder.append(txPower);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysVersionSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysVersionSreq.java
new file mode 100644
index 0000000000..3b0810af13
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysVersionSreq.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command SYS_VERSION.
+ *
+ * This command issues PING requests to verify if a device is active and check the capability of the device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysVersionSreq extends ZstackFrameRequest {
+
+ /**
+ * Request constructor
+ */
+ public ZstackSysVersionSreq() {
+ synchronousCommand = true;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SYS) && (response.getReqCmd1() == 0x02));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SYS, 0x02);
+
+ // Serialize the fields
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ return "ZstackSysVersionSreq []";
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysVersionSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysVersionSrsp.java
new file mode 100644
index 0000000000..69728fbd41
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysVersionSrsp.java
@@ -0,0 +1,171 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+
+/**
+ * Class to implement the Z-Stack command SYS_VERSION.
+ *
+ * This command issues PING requests to verify if a device is active and check the capability of the device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysVersionSrsp extends ZstackFrameResponse {
+
+ /**
+ * Transport protocol revision
+ */
+ private int transportRev;
+
+ /**
+ * Product Id
+ */
+ private int product;
+
+ /**
+ * Software major release number
+ */
+ private int majorRel;
+
+ /**
+ * Software minor release number
+ */
+ private int minorRel;
+
+ /**
+ * Software maintenance release number
+ */
+ private int maintRel;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackSysVersionSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ transportRev = deserializer.deserializeUInt8();
+ product = deserializer.deserializeUInt8();
+ majorRel = deserializer.deserializeUInt8();
+ minorRel = deserializer.deserializeUInt8();
+ maintRel = deserializer.deserializeUInt8();
+ }
+
+ /**
+ * Transport protocol revision
+ *
+ * @return the current transportRev as {@link int}
+ */
+ public int getTransportRev() {
+ return transportRev;
+ }
+
+ /**
+ * Transport protocol revision
+ *
+ * @param transportRev the TransportRev to set as {@link int}
+ */
+ public void setTransportRev(int transportRev) {
+ this.transportRev = transportRev;
+ }
+
+ /**
+ * Product Id
+ *
+ * @return the current product as {@link int}
+ */
+ public int getProduct() {
+ return product;
+ }
+
+ /**
+ * Product Id
+ *
+ * @param product the Product to set as {@link int}
+ */
+ public void setProduct(int product) {
+ this.product = product;
+ }
+
+ /**
+ * Software major release number
+ *
+ * @return the current majorRel as {@link int}
+ */
+ public int getMajorRel() {
+ return majorRel;
+ }
+
+ /**
+ * Software major release number
+ *
+ * @param majorRel the MajorRel to set as {@link int}
+ */
+ public void setMajorRel(int majorRel) {
+ this.majorRel = majorRel;
+ }
+
+ /**
+ * Software minor release number
+ *
+ * @return the current minorRel as {@link int}
+ */
+ public int getMinorRel() {
+ return minorRel;
+ }
+
+ /**
+ * Software minor release number
+ *
+ * @param minorRel the MinorRel to set as {@link int}
+ */
+ public void setMinorRel(int minorRel) {
+ this.minorRel = minorRel;
+ }
+
+ /**
+ * Software maintenance release number
+ *
+ * @return the current maintRel as {@link int}
+ */
+ public int getMaintRel() {
+ return maintRel;
+ }
+
+ /**
+ * Software maintenance release number
+ *
+ * @param maintRel the MaintRel to set as {@link int}
+ */
+ public void setMaintRel(int maintRel) {
+ this.maintRel = maintRel;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(148);
+ builder.append("ZstackSysVersionSrsp [transportRev=");
+ builder.append(transportRev);
+ builder.append(", product=");
+ builder.append(product);
+ builder.append(", majorRel=");
+ builder.append(majorRel);
+ builder.append(", minorRel=");
+ builder.append(minorRel);
+ builder.append(", maintRel=");
+ builder.append(maintRel);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsClearStatsSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsClearStatsSreq.java
new file mode 100644
index 0000000000..3f51f6d98e
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsClearStatsSreq.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command SYS_ZDIAGS_CLEAR_STATS.
+ *
+ * This command is used to clear the statistics table. To clear data in NV (including the Boot Counter) the clearNV flag shall be set
+ * to TRUE.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysZdiagsClearStatsSreq extends ZstackFrameRequest {
+
+ /**
+ * TRUE – Clears statistics in NV memory including Boot Counter. FALSE – Clears statistics in RAM only. Boot Counter is preserved.
+ */
+ private boolean clearNv;
+
+ /**
+ * Request constructor
+ */
+ public ZstackSysZdiagsClearStatsSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * TRUE – Clears statistics in NV memory including Boot Counter. FALSE – Clears statistics in RAM only. Boot Counter is preserved.
+ *
+ * @return the current clearNv as {@link boolean}
+ */
+ public boolean getClearNV() {
+ return clearNv;
+ }
+
+ /**
+ * TRUE – Clears statistics in NV memory including Boot Counter. FALSE – Clears statistics in RAM only. Boot Counter is preserved.
+ *
+ * @param clearNv the clearNV to set as {@link boolean}
+ */
+ public void setClearNV(boolean clearNv) {
+ this.clearNv = clearNv;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SYS) && (response.getReqCmd1() == 0x18));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SYS, 0x18);
+
+ // Serialize the fields
+ serializer.serializeBoolean(clearNv);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(57);
+ builder.append("ZstackSysZdiagsClearStatsSreq [clearNv=");
+ builder.append(clearNv);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsClearStatsSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsClearStatsSrsp.java
new file mode 100644
index 0000000000..eeea7e39c7
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsClearStatsSrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+
+/**
+ * Class to implement the Z-Stack command SYS_ZDIAGS_CLEAR_STATS.
+ *
+ * This command is used to clear the statistics table. To clear data in NV (including the Boot Counter) the clearNV flag shall be set
+ * to TRUE.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysZdiagsClearStatsSrsp extends ZstackFrameResponse {
+
+ /**
+ * Milliseconds since last reset.
+ */
+ private int sysClock;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackSysZdiagsClearStatsSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ sysClock = deserializer.deserializeUInt32();
+ }
+
+ /**
+ * Milliseconds since last reset.
+ *
+ * @return the current sysClock as {@link int}
+ */
+ public int getSysClock() {
+ return sysClock;
+ }
+
+ /**
+ * Milliseconds since last reset.
+ *
+ * @param sysClock the SysClock to set as {@link int}
+ */
+ public void setSysClock(int sysClock) {
+ this.sysClock = sysClock;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(57);
+ builder.append("ZstackSysZdiagsClearStatsSrsp [sysClock=");
+ builder.append(sysClock);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsGetStatsSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsGetStatsSreq.java
new file mode 100644
index 0000000000..91e27c8598
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsGetStatsSreq.java
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command SYS_ZDIAGS_GET_STATS.
+ *
+ * This command is used to read a specific system (attribute) ID statistics and/or metrics value.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysZdiagsGetStatsSreq extends ZstackFrameRequest {
+
+ /**
+ * System Diagnostics (ZDiags) attribute ID, as defined in ZDiags.h module.
+ */
+ private ZstackDiagnosticAttribute attributeId;
+
+ /**
+ * Request constructor
+ */
+ public ZstackSysZdiagsGetStatsSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * System Diagnostics (ZDiags) attribute ID, as defined in ZDiags.h module.
+ *
+ * @return the current attributeId as {@link ZstackDiagnosticAttribute}
+ */
+ public ZstackDiagnosticAttribute getAttributeID() {
+ return attributeId;
+ }
+
+ /**
+ * System Diagnostics (ZDiags) attribute ID, as defined in ZDiags.h module.
+ *
+ * @param attributeId the AttributeID to set as {@link ZstackDiagnosticAttribute}
+ */
+ public void setAttributeID(ZstackDiagnosticAttribute attributeId) {
+ this.attributeId = attributeId;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SYS) && (response.getReqCmd1() == 0x19));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SYS, 0x19);
+
+ // Serialize the fields
+ serializer.serializeUInt16(attributeId.getKey());
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(55);
+ builder.append("ZstackSysZdiagsGetStatsSreq [attributeId=");
+ builder.append(attributeId);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsGetStatsSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsGetStatsSrsp.java
new file mode 100644
index 0000000000..8354040f0b
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsGetStatsSrsp.java
@@ -0,0 +1,67 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+
+/**
+ * Class to implement the Z-Stack command SYS_ZDIAGS_GET_STATS.
+ *
+ * This command is used to read a specific system (attribute) ID statistics and/or metrics value.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysZdiagsGetStatsSrsp extends ZstackFrameResponse {
+
+ /**
+ * Value of the requested attribute.
+ */
+ private int attributeValue;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackSysZdiagsGetStatsSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ attributeValue = deserializer.deserializeUInt32();
+ }
+
+ /**
+ * Value of the requested attribute.
+ *
+ * @return the current attributeValue as {@link int}
+ */
+ public int getAttributeValue() {
+ return attributeValue;
+ }
+
+ /**
+ * Value of the requested attribute.
+ *
+ * @param attributeValue the AttributeValue to set as {@link int}
+ */
+ public void setAttributeValue(int attributeValue) {
+ this.attributeValue = attributeValue;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(55);
+ builder.append("ZstackSysZdiagsGetStatsSrsp [attributeValue=");
+ builder.append(attributeValue);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsInitStatsSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsInitStatsSreq.java
new file mode 100644
index 0000000000..e75ddd3bce
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsInitStatsSreq.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command SYS_ZDIAGS_INIT_STATS.
+ *
+ * This command is used to initialize the statistics table in NV memory.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysZdiagsInitStatsSreq extends ZstackFrameRequest {
+
+ /**
+ * Request constructor
+ */
+ public ZstackSysZdiagsInitStatsSreq() {
+ synchronousCommand = true;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SYS) && (response.getReqCmd1() == 0x17));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SYS, 0x17);
+
+ // Serialize the fields
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ return "ZstackSysZdiagsInitStatsSreq []";
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsInitStatsSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsInitStatsSrsp.java
new file mode 100644
index 0000000000..5b0e84bd56
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsInitStatsSrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command SYS_ZDIAGS_INIT_STATS.
+ *
+ * This command is used to initialize the statistics table in NV memory.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysZdiagsInitStatsSrsp extends ZstackFrameResponse {
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackSysZdiagsInitStatsSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(56);
+ builder.append("ZstackSysZdiagsInitStatsSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsRestoreStatsNvSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsRestoreStatsNvSreq.java
new file mode 100644
index 0000000000..c60a2f76b3
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsRestoreStatsNvSreq.java
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command SYS_ZDIAGS_RESTORE_STATS_NV.
+ *
+ * This command is used to restore the statistics table from NV into the RAM table.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysZdiagsRestoreStatsNvSreq extends ZstackFrameRequest {
+
+ /**
+ * System Diagnostics (ZDiags) attribute ID, as defined in ZDiags.h module.
+ */
+ private ZstackDiagnosticAttribute attributeId;
+
+ /**
+ * Request constructor
+ */
+ public ZstackSysZdiagsRestoreStatsNvSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * System Diagnostics (ZDiags) attribute ID, as defined in ZDiags.h module.
+ *
+ * @return the current attributeId as {@link ZstackDiagnosticAttribute}
+ */
+ public ZstackDiagnosticAttribute getAttributeID() {
+ return attributeId;
+ }
+
+ /**
+ * System Diagnostics (ZDiags) attribute ID, as defined in ZDiags.h module.
+ *
+ * @param attributeId the AttributeID to set as {@link ZstackDiagnosticAttribute}
+ */
+ public void setAttributeID(ZstackDiagnosticAttribute attributeId) {
+ this.attributeId = attributeId;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SYS) && (response.getReqCmd1() == 0x1A));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SYS, 0x1A);
+
+ // Serialize the fields
+ serializer.serializeUInt16(attributeId.getKey());
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(61);
+ builder.append("ZstackSysZdiagsRestoreStatsNvSreq [attributeId=");
+ builder.append(attributeId);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsRestoreStatsNvSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsRestoreStatsNvSrsp.java
new file mode 100644
index 0000000000..ca1ebdf4ae
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsRestoreStatsNvSrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command SYS_ZDIAGS_RESTORE_STATS_NV.
+ *
+ * This command is used to restore the statistics table from NV into the RAM table.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysZdiagsRestoreStatsNvSrsp extends ZstackFrameResponse {
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackSysZdiagsRestoreStatsNvSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(61);
+ builder.append("ZstackSysZdiagsRestoreStatsNvSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsSaveStatsToNvSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsSaveStatsToNvSreq.java
new file mode 100644
index 0000000000..ca8a96c788
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsSaveStatsToNvSreq.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command SYS_ZDIAGS_SAVE_STATS_TO_NV.
+ *
+ * This command is used to save the statistics table from RAM to NV.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysZdiagsSaveStatsToNvSreq extends ZstackFrameRequest {
+
+ /**
+ * Request constructor
+ */
+ public ZstackSysZdiagsSaveStatsToNvSreq() {
+ synchronousCommand = true;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_SYS) && (response.getReqCmd1() == 0x1B));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_SYS, 0x1B);
+
+ // Serialize the fields
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ return "ZstackSysZdiagsSaveStatsToNvSreq []";
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsSaveStatsToNvSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsSaveStatsToNvSrsp.java
new file mode 100644
index 0000000000..4a9bd13404
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSysZdiagsSaveStatsToNvSrsp.java
@@ -0,0 +1,67 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+
+/**
+ * Class to implement the Z-Stack command SYS_ZDIAGS_SAVE_STATS_TO_NV.
+ *
+ * This command is used to save the statistics table from RAM to NV.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackSysZdiagsSaveStatsToNvSrsp extends ZstackFrameResponse {
+
+ /**
+ * Milliseconds since last reset.
+ */
+ private int sysClock;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackSysZdiagsSaveStatsToNvSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ sysClock = deserializer.deserializeUInt32();
+ }
+
+ /**
+ * Milliseconds since last reset.
+ *
+ * @return the current sysClock as {@link int}
+ */
+ public int getSysClock() {
+ return sysClock;
+ }
+
+ /**
+ * Milliseconds since last reset.
+ *
+ * @param sysClock the SysClock to set as {@link int}
+ */
+ public void setSysClock(int sysClock) {
+ this.sysClock = sysClock;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(60);
+ builder.append("ZstackSysZdiagsSaveStatsToNvSrsp [sysClock=");
+ builder.append(sysClock);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSystemCapabilities.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSystemCapabilities.java
new file mode 100644
index 0000000000..fdb0c686b1
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/sys/ZstackSystemCapabilities.java
@@ -0,0 +1,119 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.sys;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Class to implement the Z-Stack Enumeration ZstackSystemCapabilities.
+ *
+ * Subsystem capabilities bitmap
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public enum ZstackSystemCapabilities {
+ /**
+ * Default unknown value
+ */
+ UNKNOWN(-1),
+
+ /**
+ *
+ */
+ MT_CAP_SYS(0x0001),
+
+ /**
+ *
+ */
+ MT_CAP_MAC(0x0002),
+
+ /**
+ *
+ */
+ MT_CAP_NWK(0x0004),
+
+ /**
+ *
+ */
+ MT_CAP_AF(0x0008),
+
+ /**
+ *
+ */
+ MT_CAP_ZDO(0x0010),
+
+ /**
+ *
+ */
+ MT_CAP_SAPI(0x0020),
+
+ /**
+ *
+ */
+ MT_CAP_UTIL(0x0040),
+
+ /**
+ *
+ */
+ MT_CAP_DEBUG(0x0080),
+
+ /**
+ *
+ */
+ MT_CAP_APP(0x0100),
+
+ /**
+ *
+ */
+ MT_CAP_ZOAD(0x1000);
+
+ /**
+ * A mapping between the integer code and its corresponding type to
+ * facilitate lookup by code.
+ */
+ private static Map
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public enum ZstackZdoState {
+ /**
+ * Default unknown value
+ */
+ UNKNOWN(-1),
+
+ /**
+ * Initialized - not started automatically
+ */
+ DEV_HOLD(0x0000),
+
+ /**
+ * Initialized - not connected to anything
+ */
+ DEV_INIT(0x0001),
+
+ /**
+ * Discovering PAN's to join
+ */
+ DEV_NWK_DISC(0x0002),
+
+ /**
+ * Joining a PAN
+ */
+ DEV_NWK_JOINING(0x0003),
+
+ /**
+ * ReJoining a PAN, only for end devices
+ */
+ DEV_NWK_REJOIN(0x0004),
+
+ /**
+ * Joined but not yet authenticated by trust center
+ */
+ DEV_END_DEVICE_UNAUTH(0x0005),
+
+ /**
+ * Started as device after authentication
+ */
+ DEV_END_DEVICE(0x0006),
+
+ /**
+ * Device joined, authenticated and is a router
+ */
+ DEV_ROUTER(0x0007),
+
+ /**
+ * Starting as Zigbee Coordinator
+ */
+ DEV_COORD_STARTING(0x0008),
+
+ /**
+ * Started as Zigbee Coordinator
+ */
+ DEV_ZB_COORD(0x0009),
+
+ /**
+ * Device has lost information about its parent
+ */
+ DEV_NWK_ORPHAN(0x000A);
+
+ /**
+ * A mapping between the integer code and its corresponding type to
+ * facilitate lookup by code.
+ */
+ private static Map
+ * This command retrieves APS link key data, Tx and Rx frame counters.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilApsmeLinkKeyDataGetSreq extends ZstackFrameRequest {
+
+ /**
+ * The extended address for which to get the link key data.
+ */
+ private IeeeAddress extAddr;
+
+ /**
+ * Request constructor
+ */
+ public ZstackUtilApsmeLinkKeyDataGetSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * The extended address for which to get the link key data.
+ *
+ * @return the current extAddr as {@link IeeeAddress}
+ */
+ public IeeeAddress getExtAddr() {
+ return extAddr;
+ }
+
+ /**
+ * The extended address for which to get the link key data.
+ *
+ * @param extAddr the ExtAddr to set as {@link IeeeAddress}
+ */
+ public void setExtAddr(IeeeAddress extAddr) {
+ this.extAddr = extAddr;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_UTIL) && (response.getReqCmd1() == 0x44));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_UTIL, 0x44);
+
+ // Serialize the fields
+ serializer.serializeIeeeAddress(extAddr);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(61);
+ builder.append("ZstackUtilApsmeLinkKeyDataGetSreq [extAddr=");
+ builder.append(extAddr);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilApsmeLinkKeyDataGetSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilApsmeLinkKeyDataGetSrsp.java
new file mode 100644
index 0000000000..8bd2c98126
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilApsmeLinkKeyDataGetSrsp.java
@@ -0,0 +1,147 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+import com.zsmartsystems.zigbee.security.ZigBeeKey;
+
+/**
+ * Class to implement the Z-Stack command UTIL_APSME_LINK_KEY_DATA_GET.
+ *
+ * This command retrieves APS link key data, Tx and Rx frame counters.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilApsmeLinkKeyDataGetSrsp extends ZstackFrameResponse {
+
+ /**
+ * The ZStatus_t returned by the proxy call to APSME_LinkKeyNVIdGet().
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * On success, the security key looked up; otherwise N/A.
+ */
+ private ZigBeeKey secKey;
+
+ /**
+ * On success, the TX frame counter; otherwise N/A.
+ */
+ private int txFrmCntr;
+
+ /**
+ * On success, the RX frame counter; otherwise N/A.
+ */
+ private int rxFrmCntr;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackUtilApsmeLinkKeyDataGetSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ secKey = deserializer.deserializeZigBeeKey();
+ txFrmCntr = deserializer.deserializeUInt32();
+ rxFrmCntr = deserializer.deserializeUInt32();
+ }
+
+ /**
+ * The ZStatus_t returned by the proxy call to APSME_LinkKeyNVIdGet().
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * The ZStatus_t returned by the proxy call to APSME_LinkKeyNVIdGet().
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ /**
+ * On success, the security key looked up; otherwise N/A.
+ *
+ * @return the current secKey as {@link ZigBeeKey}
+ */
+ public ZigBeeKey getSecKey() {
+ return secKey;
+ }
+
+ /**
+ * On success, the security key looked up; otherwise N/A.
+ *
+ * @param secKey the SecKey to set as {@link ZigBeeKey}
+ */
+ public void setSecKey(ZigBeeKey secKey) {
+ this.secKey = secKey;
+ }
+
+ /**
+ * On success, the TX frame counter; otherwise N/A.
+ *
+ * @return the current txFrmCntr as {@link int}
+ */
+ public int getTxFrmCntr() {
+ return txFrmCntr;
+ }
+
+ /**
+ * On success, the TX frame counter; otherwise N/A.
+ *
+ * @param txFrmCntr the TxFrmCntr to set as {@link int}
+ */
+ public void setTxFrmCntr(int txFrmCntr) {
+ this.txFrmCntr = txFrmCntr;
+ }
+
+ /**
+ * On success, the RX frame counter; otherwise N/A.
+ *
+ * @return the current rxFrmCntr as {@link int}
+ */
+ public int getRxFrmCntr() {
+ return rxFrmCntr;
+ }
+
+ /**
+ * On success, the RX frame counter; otherwise N/A.
+ *
+ * @param rxFrmCntr the RxFrmCntr to set as {@link int}
+ */
+ public void setRxFrmCntr(int rxFrmCntr) {
+ this.rxFrmCntr = rxFrmCntr;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(136);
+ builder.append("ZstackUtilApsmeLinkKeyDataGetSrsp [status=");
+ builder.append(status);
+ builder.append(", secKey=");
+ builder.append(secKey);
+ builder.append(", txFrmCntr=");
+ builder.append(String.format("%08X", txFrmCntr));
+ builder.append(", rxFrmCntr=");
+ builder.append(String.format("%08X", rxFrmCntr));
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilApsmeLinkKeyNvIdGetSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilApsmeLinkKeyNvIdGetSreq.java
new file mode 100644
index 0000000000..27c9b68e24
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilApsmeLinkKeyNvIdGetSreq.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.IeeeAddress;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command UTIL_APSME_LINK_KEY_NV_ID_GET.
+ *
+ * This command is a proxy call to the APSME_LinkKeyNvIdGet() function.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilApsmeLinkKeyNvIdGetSreq extends ZstackFrameRequest {
+
+ /**
+ * The extended address for which to get the link key NV Id.
+ */
+ private IeeeAddress extAddr;
+
+ /**
+ * Request constructor
+ */
+ public ZstackUtilApsmeLinkKeyNvIdGetSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * The extended address for which to get the link key NV Id.
+ *
+ * @return the current extAddr as {@link IeeeAddress}
+ */
+ public IeeeAddress getExtAddr() {
+ return extAddr;
+ }
+
+ /**
+ * The extended address for which to get the link key NV Id.
+ *
+ * @param extAddr the ExtAddr to set as {@link IeeeAddress}
+ */
+ public void setExtAddr(IeeeAddress extAddr) {
+ this.extAddr = extAddr;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_UTIL) && (response.getReqCmd1() == 0x45));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_UTIL, 0x45);
+
+ // Serialize the fields
+ serializer.serializeIeeeAddress(extAddr);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(61);
+ builder.append("ZstackUtilApsmeLinkKeyNvIdGetSreq [extAddr=");
+ builder.append(extAddr);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilApsmeLinkKeyNvIdGetSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilApsmeLinkKeyNvIdGetSrsp.java
new file mode 100644
index 0000000000..e0f51b8f78
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilApsmeLinkKeyNvIdGetSrsp.java
@@ -0,0 +1,94 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command UTIL_APSME_LINK_KEY_NV_ID_GET.
+ *
+ * This command is a proxy call to the APSME_LinkKeyNvIdGet() function.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilApsmeLinkKeyNvIdGetSrsp extends ZstackFrameResponse {
+
+ /**
+ * The ZStatus_t returned by the proxy call to APSME_LinkKeyNVIdGet().
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * On success, link key NV ID. Otherwise 0xFFFF
+ */
+ private int linkKeyNvId;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackUtilApsmeLinkKeyNvIdGetSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ linkKeyNvId = deserializer.deserializeUInt16();
+ }
+
+ /**
+ * The ZStatus_t returned by the proxy call to APSME_LinkKeyNVIdGet().
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * The ZStatus_t returned by the proxy call to APSME_LinkKeyNVIdGet().
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ /**
+ * On success, link key NV ID. Otherwise 0xFFFF
+ *
+ * @return the current linkKeyNvId as {@link int}
+ */
+ public int getLinkKeyNvId() {
+ return linkKeyNvId;
+ }
+
+ /**
+ * On success, link key NV ID. Otherwise 0xFFFF
+ *
+ * @param linkKeyNvId the LinkKeyNvId to set as {@link int}
+ */
+ public void setLinkKeyNvId(int linkKeyNvId) {
+ this.linkKeyNvId = linkKeyNvId;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(86);
+ builder.append("ZstackUtilApsmeLinkKeyNvIdGetSrsp [status=");
+ builder.append(status);
+ builder.append(", linkKeyNvId=");
+ builder.append(linkKeyNvId);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilGetDeviceInfoSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilGetDeviceInfoSreq.java
new file mode 100644
index 0000000000..90e2eac0b9
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilGetDeviceInfoSreq.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command UTIL_GET_DEVICE_INFO.
+ *
+ * This command is used to retrieve the device info.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilGetDeviceInfoSreq extends ZstackFrameRequest {
+
+ /**
+ * Request constructor
+ */
+ public ZstackUtilGetDeviceInfoSreq() {
+ synchronousCommand = true;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_UTIL) && (response.getReqCmd1() == 0x00));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_UTIL, 0x00);
+
+ // Serialize the fields
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ return "ZstackUtilGetDeviceInfoSreq []";
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilGetDeviceInfoSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilGetDeviceInfoSrsp.java
new file mode 100644
index 0000000000..8353cf4609
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilGetDeviceInfoSrsp.java
@@ -0,0 +1,212 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.IeeeAddress;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackZdoState;
+
+/**
+ * Class to implement the Z-Stack command UTIL_GET_DEVICE_INFO.
+ *
+ * This command is used to retrieve the device info.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilGetDeviceInfoSrsp extends ZstackFrameResponse {
+
+ /**
+ * Status is a one byte field and is either success(0) or fail(1). The fail status is returned if the address value in the command
+ * message was not within the valid range.
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * IEEE address of the device.
+ */
+ private IeeeAddress ieeeAddress;
+
+ /**
+ * Short address of the device.
+ */
+ private int shortAddr;
+
+ /**
+ * Indicates device type, where bits 0 to 2 indicate the capability for the device to operate as a coordinator, router, or end
+ * device, respectively.
+ */
+ private int deviceType;
+
+ /**
+ * Indicates the state of the device.
+ */
+ private ZstackZdoState deviceState;
+
+ /**
+ * Array of 16-bits specifies the network address associated with the device.
+ */
+ private int[] assocDevicesList;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackUtilGetDeviceInfoSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ ieeeAddress = deserializer.deserializeIeeeAddress();
+ shortAddr = deserializer.deserializeUInt16();
+ deviceType = deserializer.deserializeUInt8();
+ deviceState = ZstackZdoState.valueOf(deserializer.deserializeUInt8());
+ int numAssocDevices = deserializer.deserializeUInt8();
+ assocDevicesList = deserializer.deserializeUInt16Array(numAssocDevices);
+ }
+
+ /**
+ * Status is a one byte field and is either success(0) or fail(1). The fail status is returned if the address value in the command
+ * message was not within the valid range.
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is a one byte field and is either success(0) or fail(1). The fail status is returned if the address value in the command
+ * message was not within the valid range.
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ /**
+ * IEEE address of the device.
+ *
+ * @return the current ieeeAddress as {@link IeeeAddress}
+ */
+ public IeeeAddress getIeeeAddress() {
+ return ieeeAddress;
+ }
+
+ /**
+ * IEEE address of the device.
+ *
+ * @param ieeeAddress the IeeeAddress to set as {@link IeeeAddress}
+ */
+ public void setIeeeAddress(IeeeAddress ieeeAddress) {
+ this.ieeeAddress = ieeeAddress;
+ }
+
+ /**
+ * Short address of the device.
+ *
+ * @return the current shortAddr as {@link int}
+ */
+ public int getShortAddr() {
+ return shortAddr;
+ }
+
+ /**
+ * Short address of the device.
+ *
+ * @param shortAddr the ShortAddr to set as {@link int}
+ */
+ public void setShortAddr(int shortAddr) {
+ this.shortAddr = shortAddr;
+ }
+
+ /**
+ * Indicates device type, where bits 0 to 2 indicate the capability for the device to operate as a coordinator, router, or end
+ * device, respectively.
+ *
+ * @return the current deviceType as {@link int}
+ */
+ public int getDeviceType() {
+ return deviceType;
+ }
+
+ /**
+ * Indicates device type, where bits 0 to 2 indicate the capability for the device to operate as a coordinator, router, or end
+ * device, respectively.
+ *
+ * @param deviceType the DeviceType to set as {@link int}
+ */
+ public void setDeviceType(int deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ /**
+ * Indicates the state of the device.
+ *
+ * @return the current deviceState as {@link ZstackZdoState}
+ */
+ public ZstackZdoState getDeviceState() {
+ return deviceState;
+ }
+
+ /**
+ * Indicates the state of the device.
+ *
+ * @param deviceState the DeviceState to set as {@link ZstackZdoState}
+ */
+ public void setDeviceState(ZstackZdoState deviceState) {
+ this.deviceState = deviceState;
+ }
+
+ /**
+ * Array of 16-bits specifies the network address associated with the device.
+ *
+ * @return the current assocDevicesList as {@link int[]}
+ */
+ public int[] getAssocDevicesList() {
+ return assocDevicesList;
+ }
+
+ /**
+ * Array of 16-bits specifies the network address associated with the device.
+ *
+ * @param assocDevicesList the AssocDevicesList to set as {@link int[]}
+ */
+ public void setAssocDevicesList(int[] assocDevicesList) {
+ this.assocDevicesList = assocDevicesList;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(205);
+ builder.append("ZstackUtilGetDeviceInfoSrsp [status=");
+ builder.append(status);
+ builder.append(", ieeeAddress=");
+ builder.append(ieeeAddress);
+ builder.append(", shortAddr=");
+ builder.append(String.format("%04X", shortAddr));
+ builder.append(", deviceType=");
+ builder.append(deviceType);
+ builder.append(", deviceState=");
+ builder.append(deviceState);
+ builder.append(", assocDevicesList=");
+ for (int c = 0; c < assocDevicesList.length; c++) {
+ if (c > 0) {
+ builder.append(' ');
+ }
+ builder.append(String.format("%02X", assocDevicesList[c]));
+ }
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilGetNvInfoSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilGetNvInfoSreq.java
new file mode 100644
index 0000000000..492250e6f9
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilGetNvInfoSreq.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command UTIL_GET_NV_INFO.
+ *
+ * This command is used to read a block of parameters from non-volatile storage of the target device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilGetNvInfoSreq extends ZstackFrameRequest {
+
+ /**
+ * Request constructor
+ */
+ public ZstackUtilGetNvInfoSreq() {
+ synchronousCommand = true;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_UTIL) && (response.getReqCmd1() == 0x01));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_UTIL, 0x01);
+
+ // Serialize the fields
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ return "ZstackUtilGetNvInfoSreq []";
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilGetNvInfoSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilGetNvInfoSrsp.java
new file mode 100644
index 0000000000..d20e973c5b
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilGetNvInfoSrsp.java
@@ -0,0 +1,205 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.IeeeAddress;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.security.ZigBeeKey;
+
+/**
+ * Class to implement the Z-Stack command UTIL_GET_NV_INFO.
+ *
+ * This command is used to read a block of parameters from non-volatile storage of the target device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilGetNvInfoSrsp extends ZstackFrameResponse {
+
+ /**
+ * A value of zero indicates success. Failure is indicated by a non-zero value, representing a bit mask of each item that failed to be
+ * retrieved from NV memory. Bit0 is used for the first item (IEEEAddress), bit1 for the second item (ScanChannels), and so forth.
+ * Data values for failed items are returned as one or more bytes of 0xFF, the typical value read from erased NV memory.
+ */
+ private int status;
+
+ /**
+ * IEEE address of the device.
+ */
+ private IeeeAddress ieeeAddress;
+
+ /**
+ * This represents a bit-mask of channels to be scanned when starting the device.
+ */
+ private int scanChannels;
+
+ /**
+ * Specifies the Pan Id to start or join. Set to 0xFFFF to select a PAN after scanning.
+ */
+ private int panId;
+
+ /**
+ * This specifies the network messaging security level, zero disables security.
+ */
+ private int securityLevel;
+
+ /**
+ * This specifies the pre-configured security key.
+ */
+ private ZigBeeKey preConfigKey;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackUtilGetNvInfoSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = deserializer.deserializeUInt8();
+ ieeeAddress = deserializer.deserializeIeeeAddress();
+ scanChannels = deserializer.deserializeUInt32();
+ panId = deserializer.deserializeUInt16();
+ securityLevel = deserializer.deserializeUInt8();
+ preConfigKey = deserializer.deserializeZigBeeKey();
+ }
+
+ /**
+ * A value of zero indicates success. Failure is indicated by a non-zero value, representing a bit mask of each item that failed to be
+ * retrieved from NV memory. Bit0 is used for the first item (IEEEAddress), bit1 for the second item (ScanChannels), and so forth.
+ * Data values for failed items are returned as one or more bytes of 0xFF, the typical value read from erased NV memory.
+ *
+ * @return the current status as {@link int}
+ */
+ public int getStatus() {
+ return status;
+ }
+
+ /**
+ * A value of zero indicates success. Failure is indicated by a non-zero value, representing a bit mask of each item that failed to be
+ * retrieved from NV memory. Bit0 is used for the first item (IEEEAddress), bit1 for the second item (ScanChannels), and so forth.
+ * Data values for failed items are returned as one or more bytes of 0xFF, the typical value read from erased NV memory.
+ *
+ * @param status the Status to set as {@link int}
+ */
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ /**
+ * IEEE address of the device.
+ *
+ * @return the current ieeeAddress as {@link IeeeAddress}
+ */
+ public IeeeAddress getIeeeAddress() {
+ return ieeeAddress;
+ }
+
+ /**
+ * IEEE address of the device.
+ *
+ * @param ieeeAddress the IeeeAddress to set as {@link IeeeAddress}
+ */
+ public void setIeeeAddress(IeeeAddress ieeeAddress) {
+ this.ieeeAddress = ieeeAddress;
+ }
+
+ /**
+ * This represents a bit-mask of channels to be scanned when starting the device.
+ *
+ * @return the current scanChannels as {@link int}
+ */
+ public int getScanChannels() {
+ return scanChannels;
+ }
+
+ /**
+ * This represents a bit-mask of channels to be scanned when starting the device.
+ *
+ * @param scanChannels the ScanChannels to set as {@link int}
+ */
+ public void setScanChannels(int scanChannels) {
+ this.scanChannels = scanChannels;
+ }
+
+ /**
+ * Specifies the Pan Id to start or join. Set to 0xFFFF to select a PAN after scanning.
+ *
+ * @return the current panId as {@link int}
+ */
+ public int getPanId() {
+ return panId;
+ }
+
+ /**
+ * Specifies the Pan Id to start or join. Set to 0xFFFF to select a PAN after scanning.
+ *
+ * @param panId the PanId to set as {@link int}
+ */
+ public void setPanId(int panId) {
+ this.panId = panId;
+ }
+
+ /**
+ * This specifies the network messaging security level, zero disables security.
+ *
+ * @return the current securityLevel as {@link int}
+ */
+ public int getSecurityLevel() {
+ return securityLevel;
+ }
+
+ /**
+ * This specifies the network messaging security level, zero disables security.
+ *
+ * @param securityLevel the SecurityLevel to set as {@link int}
+ */
+ public void setSecurityLevel(int securityLevel) {
+ this.securityLevel = securityLevel;
+ }
+
+ /**
+ * This specifies the pre-configured security key.
+ *
+ * @return the current preConfigKey as {@link ZigBeeKey}
+ */
+ public ZigBeeKey getPreConfigKey() {
+ return preConfigKey;
+ }
+
+ /**
+ * This specifies the pre-configured security key.
+ *
+ * @param preConfigKey the PreConfigKey to set as {@link ZigBeeKey}
+ */
+ public void setPreConfigKey(ZigBeeKey preConfigKey) {
+ this.preConfigKey = preConfigKey;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(176);
+ builder.append("ZstackUtilGetNvInfoSrsp [status=");
+ builder.append(status);
+ builder.append(", ieeeAddress=");
+ builder.append(ieeeAddress);
+ builder.append(", scanChannels=");
+ builder.append(scanChannels);
+ builder.append(", panId=");
+ builder.append(String.format("%04X", panId));
+ builder.append(", securityLevel=");
+ builder.append(securityLevel);
+ builder.append(", preConfigKey=");
+ builder.append(preConfigKey);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilLedControlSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilLedControlSreq.java
new file mode 100644
index 0000000000..214582fc99
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilLedControlSreq.java
@@ -0,0 +1,103 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command UTIL_LED_CONTROL.
+ *
+ * This command is used by the tester to control the LEDs on the board.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilLedControlSreq extends ZstackFrameRequest {
+
+ /**
+ * The LED number.
+ */
+ private int ledId;
+
+ /**
+ * 0: OFF, 1: ON.
+ */
+ private boolean mode;
+
+ /**
+ * Request constructor
+ */
+ public ZstackUtilLedControlSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * The LED number.
+ *
+ * @return the current ledId as {@link int}
+ */
+ public int getLedId() {
+ return ledId;
+ }
+
+ /**
+ * The LED number.
+ *
+ * @param ledId the LedId to set as {@link int}
+ */
+ public void setLedId(int ledId) {
+ this.ledId = ledId;
+ }
+
+ /**
+ * 0: OFF, 1: ON.
+ *
+ * @return the current mode as {@link boolean}
+ */
+ public boolean getMode() {
+ return mode;
+ }
+
+ /**
+ * 0: OFF, 1: ON.
+ *
+ * @param mode the Mode to set as {@link boolean}
+ */
+ public void setMode(boolean mode) {
+ this.mode = mode;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_UTIL) && (response.getReqCmd1() == 0x09));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_UTIL, 0x09);
+
+ // Serialize the fields
+ serializer.serializeUInt8(ledId);
+ serializer.serializeBoolean(mode);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(77);
+ builder.append("ZstackUtilLedControlSreq [ledId=");
+ builder.append(ledId);
+ builder.append(", mode=");
+ builder.append(mode);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilLedControlSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilLedControlSrsp.java
new file mode 100644
index 0000000000..17c511ab1c
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilLedControlSrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command UTIL_LED_CONTROL.
+ *
+ * This command is used by the tester to control the LEDs on the board.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilLedControlSrsp extends ZstackFrameResponse {
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackUtilLedControlSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(52);
+ builder.append("ZstackUtilLedControlSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetChannelsSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetChannelsSreq.java
new file mode 100644
index 0000000000..eb25e1dfb7
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetChannelsSreq.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command UTIL_SET_CHANNELS.
+ *
+ * This command is used to store a channel select bit-mask into Non-Volatile memory to be used the next time the target device
+ * resets.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilSetChannelsSreq extends ZstackFrameRequest {
+
+ /**
+ * A bit-mask representing the channel(s) to scan the next time the target device resets.
+ */
+ private int channels;
+
+ /**
+ * Request constructor
+ */
+ public ZstackUtilSetChannelsSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * A bit-mask representing the channel(s) to scan the next time the target device resets.
+ *
+ * @return the current channels as {@link int}
+ */
+ public int getChannels() {
+ return channels;
+ }
+
+ /**
+ * A bit-mask representing the channel(s) to scan the next time the target device resets.
+ *
+ * @param channels the Channels to set as {@link int}
+ */
+ public void setChannels(int channels) {
+ this.channels = channels;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_UTIL) && (response.getReqCmd1() == 0x03));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_UTIL, 0x03);
+
+ // Serialize the fields
+ serializer.serializeUInt32(channels);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(53);
+ builder.append("ZstackUtilSetChannelsSreq [channels=");
+ builder.append(channels);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetChannelsSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetChannelsSrsp.java
new file mode 100644
index 0000000000..0655c5176e
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetChannelsSrsp.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command UTIL_SET_CHANNELS.
+ *
+ * This command is used to store a channel select bit-mask into Non-Volatile memory to be used the next time the target device
+ * resets.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilSetChannelsSrsp extends ZstackFrameResponse {
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackUtilSetChannelsSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(53);
+ builder.append("ZstackUtilSetChannelsSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetPanidSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetPanidSreq.java
new file mode 100644
index 0000000000..608fde1050
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetPanidSreq.java
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command UTIL_SET_PANID.
+ *
+ * Store a PanId value into Non-Volatile memory to be used the next time the target device resets.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilSetPanidSreq extends ZstackFrameRequest {
+
+ /**
+ * PanId that will be set.
+ */
+ private int panId;
+
+ /**
+ * Request constructor
+ */
+ public ZstackUtilSetPanidSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * PanId that will be set.
+ *
+ * @return the current panId as {@link int}
+ */
+ public int getPanId() {
+ return panId;
+ }
+
+ /**
+ * PanId that will be set.
+ *
+ * @param panId the PanId to set as {@link int}
+ */
+ public void setPanId(int panId) {
+ this.panId = panId;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_UTIL) && (response.getReqCmd1() == 0x02));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_UTIL, 0x02);
+
+ // Serialize the fields
+ serializer.serializeUInt16(panId);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(50);
+ builder.append("ZstackUtilSetPanidSreq [panId=");
+ builder.append(String.format("%04X", panId));
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetPanidSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetPanidSrsp.java
new file mode 100644
index 0000000000..d8da673aa6
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetPanidSrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command UTIL_SET_PANID.
+ *
+ * Store a PanId value into Non-Volatile memory to be used the next time the target device resets.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilSetPanidSrsp extends ZstackFrameResponse {
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackUtilSetPanidSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(50);
+ builder.append("ZstackUtilSetPanidSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetPrecfgkeySreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetPrecfgkeySreq.java
new file mode 100644
index 0000000000..2623dcc139
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetPrecfgkeySreq.java
@@ -0,0 +1,79 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+import com.zsmartsystems.zigbee.security.ZigBeeKey;
+
+/**
+ * Class to implement the Z-Stack command UTIL_SET_PRECFGKEY.
+ *
+ * This command is used to store a pre-configured key array into Non-Volatile memory to be used the next time the target device
+ * resets.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilSetPrecfgkeySreq extends ZstackFrameRequest {
+
+ /**
+ * An array representing the pre-configured key to use the next time the target device resets.
+ */
+ private ZigBeeKey preCfgKey;
+
+ /**
+ * Request constructor
+ */
+ public ZstackUtilSetPrecfgkeySreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * An array representing the pre-configured key to use the next time the target device resets.
+ *
+ * @return the current preCfgKey as {@link ZigBeeKey}
+ */
+ public ZigBeeKey getPreCfgKey() {
+ return preCfgKey;
+ }
+
+ /**
+ * An array representing the pre-configured key to use the next time the target device resets.
+ *
+ * @param preCfgKey the PreCfgKey to set as {@link ZigBeeKey}
+ */
+ public void setPreCfgKey(ZigBeeKey preCfgKey) {
+ this.preCfgKey = preCfgKey;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_UTIL) && (response.getReqCmd1() == 0x05));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_UTIL, 0x05);
+
+ // Serialize the fields
+ serializer.serializeZigBeeKey(preCfgKey);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(54);
+ builder.append("ZstackUtilSetPrecfgkeySreq [preCfgKey=");
+ builder.append(preCfgKey);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetPrecfgkeySrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetPrecfgkeySrsp.java
new file mode 100644
index 0000000000..50b489517b
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetPrecfgkeySrsp.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command UTIL_SET_PRECFGKEY.
+ *
+ * This command is used to store a pre-configured key array into Non-Volatile memory to be used the next time the target device
+ * resets.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilSetPrecfgkeySrsp extends ZstackFrameResponse {
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackUtilSetPrecfgkeySrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(54);
+ builder.append("ZstackUtilSetPrecfgkeySrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetSeclevelSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetSeclevelSreq.java
new file mode 100644
index 0000000000..417f4d0cd5
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetSeclevelSreq.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command UTIL_SET_SECLEVEL.
+ *
+ * This command is used to store a channel select bit-mask into Non-Volatile memory to be used the next time the target device
+ * resets.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilSetSeclevelSreq extends ZstackFrameRequest {
+
+ /**
+ * Security level to use the next time the target device resets. Zero is used to disable security.
+ */
+ private int secLevel;
+
+ /**
+ * Request constructor
+ */
+ public ZstackUtilSetSeclevelSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * Security level to use the next time the target device resets. Zero is used to disable security.
+ *
+ * @return the current secLevel as {@link int}
+ */
+ public int getSecLevel() {
+ return secLevel;
+ }
+
+ /**
+ * Security level to use the next time the target device resets. Zero is used to disable security.
+ *
+ * @param secLevel the SecLevel to set as {@link int}
+ */
+ public void setSecLevel(int secLevel) {
+ this.secLevel = secLevel;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_UTIL) && (response.getReqCmd1() == 0x04));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_UTIL, 0x04);
+
+ // Serialize the fields
+ serializer.serializeUInt8(secLevel);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(53);
+ builder.append("ZstackUtilSetSeclevelSreq [secLevel=");
+ builder.append(secLevel);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetSeclevelSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetSeclevelSrsp.java
new file mode 100644
index 0000000000..39e8f10e60
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/util/ZstackUtilSetSeclevelSrsp.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.util;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command UTIL_SET_SECLEVEL.
+ *
+ * This command is used to store a channel select bit-mask into Non-Volatile memory to be used the next time the target device
+ * resets.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackUtilSetSeclevelSrsp extends ZstackFrameResponse {
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackUtilSetSeclevelSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Status is either Success (0) or Failure (1).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(53);
+ builder.append("ZstackUtilSetSeclevelSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoGetLinkKeySreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoGetLinkKeySreq.java
new file mode 100644
index 0000000000..830a75229e
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoGetLinkKeySreq.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.zdo;
+
+import com.zsmartsystems.zigbee.IeeeAddress;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command ZDO_GET_LINK_KEY.
+ *
+ * This command retrieves the application link key of a given device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZdoGetLinkKeySreq extends ZstackFrameRequest {
+
+ /**
+ * Specifies the IEEE address of the pair device of the link key
+ */
+ private IeeeAddress ieeeAddr;
+
+ /**
+ * Request constructor
+ */
+ public ZstackZdoGetLinkKeySreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * Specifies the IEEE address of the pair device of the link key
+ *
+ * @return the current ieeeAddr as {@link IeeeAddress}
+ */
+ public IeeeAddress getIeeeAddr() {
+ return ieeeAddr;
+ }
+
+ /**
+ * Specifies the IEEE address of the pair device of the link key
+ *
+ * @param ieeeAddr the IeeeAddr to set as {@link IeeeAddress}
+ */
+ public void setIeeeAddr(IeeeAddress ieeeAddr) {
+ this.ieeeAddr = ieeeAddr;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_ZDO) && (response.getReqCmd1() == 0x25));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_ZDO, 0x25);
+
+ // Serialize the fields
+ serializer.serializeIeeeAddress(ieeeAddr);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(51);
+ builder.append("ZstackZdoGetLinkKeySreq [ieeeAddr=");
+ builder.append(ieeeAddr);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoGetLinkKeySrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoGetLinkKeySrsp.java
new file mode 100644
index 0000000000..3ed21a4b50
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoGetLinkKeySrsp.java
@@ -0,0 +1,122 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.zdo;
+
+import com.zsmartsystems.zigbee.IeeeAddress;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+import com.zsmartsystems.zigbee.security.ZigBeeKey;
+
+/**
+ * Class to implement the Z-Stack command ZDO_GET_LINK_KEY.
+ *
+ * This command retrieves the application link key of a given device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZdoGetLinkKeySrsp extends ZstackFrameResponse {
+
+ /**
+ * 0x00 – Success. 0xC8 – Unknown device.
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Specifies the IEEE address of the pair device of the link key
+ */
+ private IeeeAddress ieeeAddr;
+
+ /**
+ * Link key data of the device
+ */
+ private ZigBeeKey linkKeyData;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackZdoGetLinkKeySrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ ieeeAddr = deserializer.deserializeIeeeAddress();
+ linkKeyData = deserializer.deserializeZigBeeKey();
+ }
+
+ /**
+ * 0x00 – Success. 0xC8 – Unknown device.
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * 0x00 – Success. 0xC8 – Unknown device.
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ /**
+ * Specifies the IEEE address of the pair device of the link key
+ *
+ * @return the current ieeeAddr as {@link IeeeAddress}
+ */
+ public IeeeAddress getIeeeAddr() {
+ return ieeeAddr;
+ }
+
+ /**
+ * Specifies the IEEE address of the pair device of the link key
+ *
+ * @param ieeeAddr the IeeeAddr to set as {@link IeeeAddress}
+ */
+ public void setIeeeAddr(IeeeAddress ieeeAddr) {
+ this.ieeeAddr = ieeeAddr;
+ }
+
+ /**
+ * Link key data of the device
+ *
+ * @return the current linkKeyData as {@link ZigBeeKey}
+ */
+ public ZigBeeKey getLinkKeyData() {
+ return linkKeyData;
+ }
+
+ /**
+ * Link key data of the device
+ *
+ * @param linkKeyData the LinkKeyData to set as {@link ZigBeeKey}
+ */
+ public void setLinkKeyData(ZigBeeKey linkKeyData) {
+ this.linkKeyData = linkKeyData;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(101);
+ builder.append("ZstackZdoGetLinkKeySrsp [status=");
+ builder.append(status);
+ builder.append(", ieeeAddr=");
+ builder.append(ieeeAddr);
+ builder.append(", linkKeyData=");
+ builder.append(linkKeyData);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoLeaveIndAreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoLeaveIndAreq.java
new file mode 100644
index 0000000000..d2335174dd
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoLeaveIndAreq.java
@@ -0,0 +1,170 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.zdo;
+
+import com.zsmartsystems.zigbee.IeeeAddress;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+
+/**
+ * Class to implement the Z-Stack command ZDO_LEAVE_IND.
+ *
+ * This message is an indication to inform the host of a device leaving the network.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZdoLeaveIndAreq extends ZstackFrameResponse {
+
+ /**
+ * Short address (LSB-MSB) of the source of the leave indication.
+ */
+ private int srcAddr;
+
+ /**
+ * Extended address (LSB-MSB) of the source of the leave indication.
+ */
+ private IeeeAddress extAddr;
+
+ /**
+ * Boolean, TRUE = request, FALSE = indication.
+ */
+ private boolean request;
+
+ /**
+ * Boolean, TRUE = remove children.
+ */
+ private boolean remove;
+
+ /**
+ * Boolean, TRUE = rejoin.
+ */
+ private boolean rejoin;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackZdoLeaveIndAreq(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ // Deserialize the fields
+ srcAddr = deserializer.deserializeUInt16();
+ extAddr = deserializer.deserializeIeeeAddress();
+ request = deserializer.deserializeBoolean();
+ remove = deserializer.deserializeBoolean();
+ rejoin = deserializer.deserializeBoolean();
+ }
+
+ /**
+ * Short address (LSB-MSB) of the source of the leave indication.
+ *
+ * @return the current srcAddr as {@link int}
+ */
+ public int getSrcAddr() {
+ return srcAddr;
+ }
+
+ /**
+ * Short address (LSB-MSB) of the source of the leave indication.
+ *
+ * @param srcAddr the SrcAddr to set as {@link int}
+ */
+ public void setSrcAddr(int srcAddr) {
+ this.srcAddr = srcAddr;
+ }
+
+ /**
+ * Extended address (LSB-MSB) of the source of the leave indication.
+ *
+ * @return the current extAddr as {@link IeeeAddress}
+ */
+ public IeeeAddress getExtAddr() {
+ return extAddr;
+ }
+
+ /**
+ * Extended address (LSB-MSB) of the source of the leave indication.
+ *
+ * @param extAddr the ExtAddr to set as {@link IeeeAddress}
+ */
+ public void setExtAddr(IeeeAddress extAddr) {
+ this.extAddr = extAddr;
+ }
+
+ /**
+ * Boolean, TRUE = request, FALSE = indication.
+ *
+ * @return the current request as {@link boolean}
+ */
+ public boolean getRequest() {
+ return request;
+ }
+
+ /**
+ * Boolean, TRUE = request, FALSE = indication.
+ *
+ * @param request the Request to set as {@link boolean}
+ */
+ public void setRequest(boolean request) {
+ this.request = request;
+ }
+
+ /**
+ * Boolean, TRUE = remove children.
+ *
+ * @return the current remove as {@link boolean}
+ */
+ public boolean getRemove() {
+ return remove;
+ }
+
+ /**
+ * Boolean, TRUE = remove children.
+ *
+ * @param remove the Remove to set as {@link boolean}
+ */
+ public void setRemove(boolean remove) {
+ this.remove = remove;
+ }
+
+ /**
+ * Boolean, TRUE = rejoin.
+ *
+ * @return the current rejoin as {@link boolean}
+ */
+ public boolean getRejoin() {
+ return rejoin;
+ }
+
+ /**
+ * Boolean, TRUE = rejoin.
+ *
+ * @param rejoin the Rejoin to set as {@link boolean}
+ */
+ public void setRejoin(boolean rejoin) {
+ this.rejoin = rejoin;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(149);
+ builder.append("ZstackZdoLeaveIndAreq [srcAddr=");
+ builder.append(String.format("%04X", srcAddr));
+ builder.append(", extAddr=");
+ builder.append(extAddr);
+ builder.append(", request=");
+ builder.append(request);
+ builder.append(", remove=");
+ builder.append(remove);
+ builder.append(", rejoin=");
+ builder.append(rejoin);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoMsgCbIncomingAreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoMsgCbIncomingAreq.java
new file mode 100644
index 0000000000..bcf9fc7bd1
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoMsgCbIncomingAreq.java
@@ -0,0 +1,226 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.zdo;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+
+/**
+ * Class to implement the Z-Stack command ZDO_MSG_CB_INCOMING.
+ *
+ * This message is a ZDO callback for a Cluster Id that the host requested to receive with a ZDO_ MSG_CB_REGISTER request.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZdoMsgCbIncomingAreq extends ZstackFrameResponse {
+
+ /**
+ * Short address (LSB-MSB) of the source of the ZDO message.
+ */
+ private int srcAddr;
+
+ /**
+ * This field indicates whether or not this ZDO message was broadcast.
+ */
+ private boolean wasBroadcast;
+
+ /**
+ * The ZDO Cluster Id of this message.
+ */
+ private int clusterId;
+
+ /**
+ * N/A – not used.
+ */
+ private boolean securityUse;
+
+ /**
+ * The sequence number of this ZDO message.
+ */
+ private int seqNumber;
+
+ /**
+ * The MAC destination short address (LSB-MSB) of the ZDO message.
+ */
+ private int dstAddr;
+
+ /**
+ * The data that corresponds to the Cluster Id of the message
+ */
+ private int[] data;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackZdoMsgCbIncomingAreq(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ // Deserialize the fields
+ srcAddr = deserializer.deserializeUInt16();
+ wasBroadcast = deserializer.deserializeBoolean();
+ clusterId = deserializer.deserializeUInt16();
+ securityUse = deserializer.deserializeBoolean();
+ seqNumber = deserializer.deserializeUInt8();
+ dstAddr = deserializer.deserializeUInt16();
+ data = deserializer.deserializeUInt8Array();
+ }
+
+ /**
+ * Short address (LSB-MSB) of the source of the ZDO message.
+ *
+ * @return the current srcAddr as {@link int}
+ */
+ public int getSrcAddr() {
+ return srcAddr;
+ }
+
+ /**
+ * Short address (LSB-MSB) of the source of the ZDO message.
+ *
+ * @param srcAddr the SrcAddr to set as {@link int}
+ */
+ public void setSrcAddr(int srcAddr) {
+ this.srcAddr = srcAddr;
+ }
+
+ /**
+ * This field indicates whether or not this ZDO message was broadcast.
+ *
+ * @return the current wasBroadcast as {@link boolean}
+ */
+ public boolean getWasBroadcast() {
+ return wasBroadcast;
+ }
+
+ /**
+ * This field indicates whether or not this ZDO message was broadcast.
+ *
+ * @param wasBroadcast the WasBroadcast to set as {@link boolean}
+ */
+ public void setWasBroadcast(boolean wasBroadcast) {
+ this.wasBroadcast = wasBroadcast;
+ }
+
+ /**
+ * The ZDO Cluster Id of this message.
+ *
+ * @return the current clusterId as {@link int}
+ */
+ public int getClusterId() {
+ return clusterId;
+ }
+
+ /**
+ * The ZDO Cluster Id of this message.
+ *
+ * @param clusterId the ClusterId to set as {@link int}
+ */
+ public void setClusterId(int clusterId) {
+ this.clusterId = clusterId;
+ }
+
+ /**
+ * N/A – not used.
+ *
+ * @return the current securityUse as {@link boolean}
+ */
+ public boolean getSecurityUse() {
+ return securityUse;
+ }
+
+ /**
+ * N/A – not used.
+ *
+ * @param securityUse the SecurityUse to set as {@link boolean}
+ */
+ public void setSecurityUse(boolean securityUse) {
+ this.securityUse = securityUse;
+ }
+
+ /**
+ * The sequence number of this ZDO message.
+ *
+ * @return the current seqNumber as {@link int}
+ */
+ public int getSeqNumber() {
+ return seqNumber;
+ }
+
+ /**
+ * The sequence number of this ZDO message.
+ *
+ * @param seqNumber the SeqNumber to set as {@link int}
+ */
+ public void setSeqNumber(int seqNumber) {
+ this.seqNumber = seqNumber;
+ }
+
+ /**
+ * The MAC destination short address (LSB-MSB) of the ZDO message.
+ *
+ * @return the current dstAddr as {@link int}
+ */
+ public int getDstAddr() {
+ return dstAddr;
+ }
+
+ /**
+ * The MAC destination short address (LSB-MSB) of the ZDO message.
+ *
+ * @param dstAddr the DstAddr to set as {@link int}
+ */
+ public void setDstAddr(int dstAddr) {
+ this.dstAddr = dstAddr;
+ }
+
+ /**
+ * The data that corresponds to the Cluster Id of the message
+ *
+ * @return the current data as {@link int[]}
+ */
+ public int[] getData() {
+ return data;
+ }
+
+ /**
+ * The data that corresponds to the Cluster Id of the message
+ *
+ * @param data the Data to set as {@link int[]}
+ */
+ public void setData(int[] data) {
+ this.data = data;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(204);
+ builder.append("ZstackZdoMsgCbIncomingAreq [srcAddr=");
+ builder.append(String.format("%04X", srcAddr));
+ builder.append(", wasBroadcast=");
+ builder.append(wasBroadcast);
+ builder.append(", clusterId=");
+ builder.append(String.format("%04X", clusterId));
+ builder.append(", securityUse=");
+ builder.append(securityUse);
+ builder.append(", seqNumber=");
+ builder.append(String.format("%02X", seqNumber));
+ builder.append(", dstAddr=");
+ builder.append(String.format("%04X", dstAddr));
+ builder.append(", data=");
+ for (int c = 0; c < data.length; c++) {
+ if (c > 0) {
+ builder.append(' ');
+ }
+ builder.append(String.format("%02X", data[c]));
+ }
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoMsgCbRegisterSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoMsgCbRegisterSreq.java
new file mode 100644
index 0000000000..0807e2662c
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoMsgCbRegisterSreq.java
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.zdo;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command ZDO_MSG_CB_REGISTER.
+ *
+ * This command registers for a ZDO callback.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZdoMsgCbRegisterSreq extends ZstackFrameRequest {
+
+ /**
+ * Specifies the ZDO Cluster Id for which to receive a ZDO callback.
+ */
+ private int clusterId;
+
+ /**
+ * Request constructor
+ */
+ public ZstackZdoMsgCbRegisterSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * Specifies the ZDO Cluster Id for which to receive a ZDO callback.
+ *
+ * @return the current clusterId as {@link int}
+ */
+ public int getClusterId() {
+ return clusterId;
+ }
+
+ /**
+ * Specifies the ZDO Cluster Id for which to receive a ZDO callback.
+ *
+ * @param clusterId the ClusterId to set as {@link int}
+ */
+ public void setClusterId(int clusterId) {
+ this.clusterId = clusterId;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_ZDO) && (response.getReqCmd1() == 0x3E));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_ZDO, 0x3E);
+
+ // Serialize the fields
+ serializer.serializeUInt16(clusterId);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(54);
+ builder.append("ZstackZdoMsgCbRegisterSreq [clusterId=");
+ builder.append(String.format("%04X", clusterId));
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoMsgCbRegisterSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoMsgCbRegisterSrsp.java
new file mode 100644
index 0000000000..a092446b13
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoMsgCbRegisterSrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.zdo;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command ZDO_MSG_CB_REGISTER.
+ *
+ * This command registers for a ZDO callback.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZdoMsgCbRegisterSrsp extends ZstackFrameResponse {
+
+ /**
+ * 0x00 – Success.
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackZdoMsgCbRegisterSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * 0x00 – Success.
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * 0x00 – Success.
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(54);
+ builder.append("ZstackZdoMsgCbRegisterSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoNwkDiscoveryReqSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoNwkDiscoveryReqSreq.java
new file mode 100644
index 0000000000..5a2106eb18
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoNwkDiscoveryReqSreq.java
@@ -0,0 +1,103 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.zdo;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command ZDO_NWK_DISCOVERY_REQ.
+ *
+ * This command is used to initiate a network discovery (active scan).
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZdoNwkDiscoveryReqSreq extends ZstackFrameRequest {
+
+ /**
+ * Bit mask for channels to scan.
+ */
+ private int scanChannels;
+
+ /**
+ * A value used to calculate the length of time to spend scanning each channel
+ */
+ private int scanDuration;
+
+ /**
+ * Request constructor
+ */
+ public ZstackZdoNwkDiscoveryReqSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * Bit mask for channels to scan.
+ *
+ * @return the current scanChannels as {@link int}
+ */
+ public int getScanChannels() {
+ return scanChannels;
+ }
+
+ /**
+ * Bit mask for channels to scan.
+ *
+ * @param scanChannels the ScanChannels to set as {@link int}
+ */
+ public void setScanChannels(int scanChannels) {
+ this.scanChannels = scanChannels;
+ }
+
+ /**
+ * A value used to calculate the length of time to spend scanning each channel
+ *
+ * @return the current scanDuration as {@link int}
+ */
+ public int getScanDuration() {
+ return scanDuration;
+ }
+
+ /**
+ * A value used to calculate the length of time to spend scanning each channel
+ *
+ * @param scanDuration the ScanDuration to set as {@link int}
+ */
+ public void setScanDuration(int scanDuration) {
+ this.scanDuration = scanDuration;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_ZDO) && (response.getReqCmd1() == 0x26));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_ZDO, 0x26);
+
+ // Serialize the fields
+ serializer.serializeUInt32(scanChannels);
+ serializer.serializeUInt8(scanDuration);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(81);
+ builder.append("ZstackZdoNwkDiscoveryReqSreq [scanChannels=");
+ builder.append(scanChannels);
+ builder.append(", scanDuration=");
+ builder.append(scanDuration);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoNwkDiscoveryReqSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoNwkDiscoveryReqSrsp.java
new file mode 100644
index 0000000000..0375e74602
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoNwkDiscoveryReqSrsp.java
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.zdo;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command ZDO_NWK_DISCOVERY_REQ.
+ *
+ * This command is used to initiate a network discovery (active scan).
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZdoNwkDiscoveryReqSrsp extends ZstackFrameResponse {
+
+ /**
+ * Success (0) Invalid_Parameter (0x02). ZNwkInvalidRequest (0xC2) if the device is already on a network. User
+ * ZDO_MGMT_NWK_DISC_REQ instead. Or leave the network first, then initiate the request. MAC_SCAN_IN_PROGRESS (0xFC) if a
+ * channel change is in progress. MAC_NO_RESOURCE (0x1A) if the operation could not complete because no memory resource were
+ * available.
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackZdoNwkDiscoveryReqSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Success (0) Invalid_Parameter (0x02). ZNwkInvalidRequest (0xC2) if the device is already on a network. User
+ * ZDO_MGMT_NWK_DISC_REQ instead. Or leave the network first, then initiate the request. MAC_SCAN_IN_PROGRESS (0xFC) if a
+ * channel change is in progress. MAC_NO_RESOURCE (0x1A) if the operation could not complete because no memory resource were
+ * available.
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * Success (0) Invalid_Parameter (0x02). ZNwkInvalidRequest (0xC2) if the device is already on a network. User
+ * ZDO_MGMT_NWK_DISC_REQ instead. Or leave the network first, then initiate the request. MAC_SCAN_IN_PROGRESS (0xFC) if a
+ * channel change is in progress. MAC_NO_RESOURCE (0x1A) if the operation could not complete because no memory resource were
+ * available.
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(56);
+ builder.append("ZstackZdoNwkDiscoveryReqSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoRemoveLinkKeySreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoRemoveLinkKeySreq.java
new file mode 100644
index 0000000000..34e5da8b74
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoRemoveLinkKeySreq.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.zdo;
+
+import com.zsmartsystems.zigbee.IeeeAddress;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command ZDO_REMOVE_LINK_KEY.
+ *
+ * This command removes the application link key of a given device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZdoRemoveLinkKeySreq extends ZstackFrameRequest {
+
+ /**
+ * Specifies the IEEE address of the pair device of the link key
+ */
+ private IeeeAddress ieeeAddr;
+
+ /**
+ * Request constructor
+ */
+ public ZstackZdoRemoveLinkKeySreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * Specifies the IEEE address of the pair device of the link key
+ *
+ * @return the current ieeeAddr as {@link IeeeAddress}
+ */
+ public IeeeAddress getIeeeAddr() {
+ return ieeeAddr;
+ }
+
+ /**
+ * Specifies the IEEE address of the pair device of the link key
+ *
+ * @param ieeeAddr the IeeeAddr to set as {@link IeeeAddress}
+ */
+ public void setIeeeAddr(IeeeAddress ieeeAddr) {
+ this.ieeeAddr = ieeeAddr;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_ZDO) && (response.getReqCmd1() == 0x24));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_ZDO, 0x24);
+
+ // Serialize the fields
+ serializer.serializeIeeeAddress(ieeeAddr);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(54);
+ builder.append("ZstackZdoRemoveLinkKeySreq [ieeeAddr=");
+ builder.append(ieeeAddr);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoRemoveLinkKeySrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoRemoveLinkKeySrsp.java
new file mode 100644
index 0000000000..e99f6c0d6b
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoRemoveLinkKeySrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.zdo;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command ZDO_REMOVE_LINK_KEY.
+ *
+ * This command removes the application link key of a given device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZdoRemoveLinkKeySrsp extends ZstackFrameResponse {
+
+ /**
+ * 0x00 – Success. 0xC8 – Unknown device.
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackZdoRemoveLinkKeySrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * 0x00 – Success. 0xC8 – Unknown device.
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * 0x00 – Success. 0xC8 – Unknown device.
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(54);
+ builder.append("ZstackZdoRemoveLinkKeySrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoSetLinkKeySreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoSetLinkKeySreq.java
new file mode 100644
index 0000000000..0bbc3018fc
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoSetLinkKeySreq.java
@@ -0,0 +1,131 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.zdo;
+
+import com.zsmartsystems.zigbee.IeeeAddress;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+import com.zsmartsystems.zigbee.security.ZigBeeKey;
+
+/**
+ * Class to implement the Z-Stack command ZDO_SET_LINK_KEY.
+ *
+ * This command sets the application link key for a given device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZdoSetLinkKeySreq extends ZstackFrameRequest {
+
+ /**
+ * Specifies the short address of the pair device of the link key.
+ */
+ private int shortAddr;
+
+ /**
+ * Specifies the IEEE address of the pair device of the link key
+ */
+ private IeeeAddress ieeeAddr;
+
+ /**
+ * 128 bit link key data of the device.
+ */
+ private ZigBeeKey linkKeyData;
+
+ /**
+ * Request constructor
+ */
+ public ZstackZdoSetLinkKeySreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * Specifies the short address of the pair device of the link key.
+ *
+ * @return the current shortAddr as {@link int}
+ */
+ public int getShortAddr() {
+ return shortAddr;
+ }
+
+ /**
+ * Specifies the short address of the pair device of the link key.
+ *
+ * @param shortAddr the ShortAddr to set as {@link int}
+ */
+ public void setShortAddr(int shortAddr) {
+ this.shortAddr = shortAddr;
+ }
+
+ /**
+ * Specifies the IEEE address of the pair device of the link key
+ *
+ * @return the current ieeeAddr as {@link IeeeAddress}
+ */
+ public IeeeAddress getIeeeAddr() {
+ return ieeeAddr;
+ }
+
+ /**
+ * Specifies the IEEE address of the pair device of the link key
+ *
+ * @param ieeeAddr the IeeeAddr to set as {@link IeeeAddress}
+ */
+ public void setIeeeAddr(IeeeAddress ieeeAddr) {
+ this.ieeeAddr = ieeeAddr;
+ }
+
+ /**
+ * 128 bit link key data of the device.
+ *
+ * @return the current linkKeyData as {@link ZigBeeKey}
+ */
+ public ZigBeeKey getLinkKeyData() {
+ return linkKeyData;
+ }
+
+ /**
+ * 128 bit link key data of the device.
+ *
+ * @param linkKeyData the LinkKeyData to set as {@link ZigBeeKey}
+ */
+ public void setLinkKeyData(ZigBeeKey linkKeyData) {
+ this.linkKeyData = linkKeyData;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_ZDO) && (response.getReqCmd1() == 0x23));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_ZDO, 0x23);
+
+ // Serialize the fields
+ serializer.serializeUInt16(shortAddr);
+ serializer.serializeIeeeAddress(ieeeAddr);
+ serializer.serializeZigBeeKey(linkKeyData);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(101);
+ builder.append("ZstackZdoSetLinkKeySreq [shortAddr=");
+ builder.append(String.format("%04X", shortAddr));
+ builder.append(", ieeeAddr=");
+ builder.append(ieeeAddr);
+ builder.append(", linkKeyData=");
+ builder.append(linkKeyData);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoSetLinkKeySrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoSetLinkKeySrsp.java
new file mode 100644
index 0000000000..919773d731
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoSetLinkKeySrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.zdo;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command ZDO_SET_LINK_KEY.
+ *
+ * This command sets the application link key for a given device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZdoSetLinkKeySrsp extends ZstackFrameResponse {
+
+ /**
+ * 0x00 – Success. 0x01 – Fail to add to address manager. 0x11 – Security manager key table full
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackZdoSetLinkKeySrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * 0x00 – Success. 0x01 – Fail to add to address manager. 0x11 – Security manager key table full
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * 0x00 – Success. 0x01 – Fail to add to address manager. 0x11 – Security manager key table full
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(51);
+ builder.append("ZstackZdoSetLinkKeySrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoStartupFromAppSreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoStartupFromAppSreq.java
new file mode 100644
index 0000000000..9cb6d76a37
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoStartupFromAppSreq.java
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.zdo;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameRequest;
+import com.zsmartsystems.zigbee.dongle.zstack.api.rpc.ZstackRpcSreqErrorSrsp;
+
+/**
+ * Class to implement the Z-Stack command ZDO_STARTUP_FROM_APP.
+ *
+ * This command starts the device in the network.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZdoStartupFromAppSreq extends ZstackFrameRequest {
+
+ /**
+ * Specifies the time delay before the device starts in milliseconds.
+ */
+ private int startDelay;
+
+ /**
+ * Request constructor
+ */
+ public ZstackZdoStartupFromAppSreq() {
+ synchronousCommand = true;
+ }
+
+ /**
+ * Specifies the time delay before the device starts in milliseconds.
+ *
+ * @return the current startDelay as {@link int}
+ */
+ public int getStartDelay() {
+ return startDelay;
+ }
+
+ /**
+ * Specifies the time delay before the device starts in milliseconds.
+ *
+ * @param startDelay the StartDelay to set as {@link int}
+ */
+ public void setStartDelay(int startDelay) {
+ this.startDelay = startDelay;
+ }
+
+ @Override
+ public boolean matchSreqError(ZstackRpcSreqErrorSrsp response) {
+ return (((response.getReqCmd0() & 0x1F) == ZSTACK_ZDO) && (response.getReqCmd1() == 0x40));
+ }
+
+ @Override
+ public int[] serialize() {
+ // Serialize the header
+ serializeHeader(ZSTACK_SREQ, ZSTACK_ZDO, 0x40);
+
+ // Serialize the fields
+ serializer.serializeUInt16(startDelay);
+ return getPayload();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(55);
+ builder.append("ZstackZdoStartupFromAppSreq [startDelay=");
+ builder.append(startDelay);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoStartupFromAppSrsp.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoStartupFromAppSrsp.java
new file mode 100644
index 0000000000..7dc08b9a08
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoStartupFromAppSrsp.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.zdo;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+
+/**
+ * Class to implement the Z-Stack command ZDO_STARTUP_FROM_APP.
+ *
+ * This command starts the device in the network.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZdoStartupFromAppSrsp extends ZstackFrameResponse {
+
+ /**
+ * This field indicates either SUCCESS (0) or FAILURE (1).
+ */
+ private ZstackResponseCode status;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackZdoStartupFromAppSrsp(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ synchronousCommand = true;
+
+ // Deserialize the fields
+ status = ZstackResponseCode.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * This field indicates either SUCCESS (0) or FAILURE (1).
+ *
+ * @return the current status as {@link ZstackResponseCode}
+ */
+ public ZstackResponseCode getStatus() {
+ return status;
+ }
+
+ /**
+ * This field indicates either SUCCESS (0) or FAILURE (1).
+ *
+ * @param status the Status to set as {@link ZstackResponseCode}
+ */
+ public void setStatus(ZstackResponseCode status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(55);
+ builder.append("ZstackZdoStartupFromAppSrsp [status=");
+ builder.append(status);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoStateChangeIndAreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoStateChangeIndAreq.java
new file mode 100644
index 0000000000..789c9af0c2
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoStateChangeIndAreq.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.zdo;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackZdoState;
+
+/**
+ * Class to implement the Z-Stack command ZDO_STATE_CHANGE_IND.
+ *
+ * This callback message indicates the ZDO state change.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZdoStateChangeIndAreq extends ZstackFrameResponse {
+
+ /**
+ * Specifies the changed ZDO state. An enumerated list starting from 0.
+ */
+ private ZstackZdoState state;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackZdoStateChangeIndAreq(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ // Deserialize the fields
+ state = ZstackZdoState.valueOf(deserializer.deserializeUInt8());
+ }
+
+ /**
+ * Specifies the changed ZDO state. An enumerated list starting from 0.
+ *
+ * @return the current state as {@link ZstackZdoState}
+ */
+ public ZstackZdoState getState() {
+ return state;
+ }
+
+ /**
+ * Specifies the changed ZDO state. An enumerated list starting from 0.
+ *
+ * @param state the State to set as {@link ZstackZdoState}
+ */
+ public void setState(ZstackZdoState state) {
+ this.state = state;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(55);
+ builder.append("ZstackZdoStateChangeIndAreq [state=");
+ builder.append(state);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoTcDevIndAreq.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoTcDevIndAreq.java
new file mode 100644
index 0000000000..9dd6cd5cf0
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/api/zdo/ZstackZdoTcDevIndAreq.java
@@ -0,0 +1,119 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.api.zdo;
+
+import com.zsmartsystems.zigbee.IeeeAddress;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+
+/**
+ * Class to implement the Z-Stack command ZDO_TC_DEV_IND.
+ *
+ * This message is a ZDO callback for TC Device Indication. This is an indication that the TC has delivered the key to a recently
+ * joined device.
+ *
+ * Note that this code is autogenerated. Manual changes may be overwritten.
+ *
+ * @author Chris Jackson
+ */
+public class ZstackZdoTcDevIndAreq extends ZstackFrameResponse {
+
+ /**
+ * Source network Address
+ */
+ private int srcAddr;
+
+ /**
+ * IEEE Address of the source
+ */
+ private IeeeAddress extAddr;
+
+ /**
+ * Network address of the parent
+ */
+ private int parentAddr;
+
+ /**
+ * Response and Handler constructor
+ */
+ public ZstackZdoTcDevIndAreq(int[] inputBuffer) {
+ // Super creates deserializer and reads header fields
+ super(inputBuffer);
+
+ // Deserialize the fields
+ srcAddr = deserializer.deserializeUInt16();
+ extAddr = deserializer.deserializeIeeeAddress();
+ parentAddr = deserializer.deserializeUInt16();
+ }
+
+ /**
+ * Source network Address
+ *
+ * @return the current srcAddr as {@link int}
+ */
+ public int getSrcAddr() {
+ return srcAddr;
+ }
+
+ /**
+ * Source network Address
+ *
+ * @param srcAddr the SrcAddr to set as {@link int}
+ */
+ public void setSrcAddr(int srcAddr) {
+ this.srcAddr = srcAddr;
+ }
+
+ /**
+ * IEEE Address of the source
+ *
+ * @return the current extAddr as {@link IeeeAddress}
+ */
+ public IeeeAddress getExtAddr() {
+ return extAddr;
+ }
+
+ /**
+ * IEEE Address of the source
+ *
+ * @param extAddr the ExtAddr to set as {@link IeeeAddress}
+ */
+ public void setExtAddr(IeeeAddress extAddr) {
+ this.extAddr = extAddr;
+ }
+
+ /**
+ * Network address of the parent
+ *
+ * @return the current parentAddr as {@link int}
+ */
+ public int getParentAddr() {
+ return parentAddr;
+ }
+
+ /**
+ * Network address of the parent
+ *
+ * @param parentAddr the ParentAddr to set as {@link int}
+ */
+ public void setParentAddr(int parentAddr) {
+ this.parentAddr = parentAddr;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder(99);
+ builder.append("ZstackZdoTcDevIndAreq [srcAddr=");
+ builder.append(String.format("%04X", srcAddr));
+ builder.append(", extAddr=");
+ builder.append(extAddr);
+ builder.append(", parentAddr=");
+ builder.append(String.format("%04X", parentAddr));
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/internal/ZstackFrameHandler.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/internal/ZstackFrameHandler.java
new file mode 100644
index 0000000000..413953b129
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/internal/ZstackFrameHandler.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.internal;
+
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackCommand;
+
+/**
+ * Interface to exchange asynchronous packets and link state changes from the low level protocol handlers
+ * to the dongle layer.
+ *
+ * @author Chris Jackson
+ *
+ */
+public interface ZstackFrameHandler {
+ /**
+ * Passes received asynchronous frames from the ZStack protocol handler to the dongle layer
+ *
+ * @param response incoming {@link ZstackCommand} response frame
+ */
+ public void handlePacket(ZstackCommand response);
+
+ /**
+ * Called when the ZStack handler link state changes
+ *
+ * @param state true if the link is UP, false if the link is DOWN
+ */
+ public void handleLinkStateChange(boolean state);
+}
diff --git a/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/internal/ZstackNetworkInitialisation.java b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/internal/ZstackNetworkInitialisation.java
new file mode 100644
index 0000000000..a8792bad13
--- /dev/null
+++ b/com.zsmartsystems.zigbee.dongle.zstack/src/main/java/com/zsmartsystems/zigbee/dongle/zstack/internal/ZstackNetworkInitialisation.java
@@ -0,0 +1,286 @@
+/**
+ * Copyright (c) 2016-2019 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.zsmartsystems.zigbee.dongle.zstack.internal;
+
+import com.zsmartsystems.zigbee.ZigBeeStatus;
+import com.zsmartsystems.zigbee.dongle.zstack.ZstackNcp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackFrameResponse;
+import com.zsmartsystems.zigbee.dongle.zstack.api.ZstackResponseCode;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackSysResetIndAreq;
+import com.zsmartsystems.zigbee.dongle.zstack.api.sys.ZstackZdoState;
+import com.zsmartsystems.zigbee.dongle.zstack.api.util.ZstackUtilGetDeviceInfoSrsp;
+import com.zsmartsystems.zigbee.dongle.zstack.api.zdo.ZstackZdoStateChangeIndAreq;
+import com.zsmartsystems.zigbee.transport.DeviceType;
+import com.zsmartsystems.zigbee.transport.ZigBeePort;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * This class provides utility functions to establish a ZStack ZigBee network
+ *
+ * @author Chris Jackson
+ *
+ */
+public class ZstackNetworkInitialisation {
+ /**
+ * The {@link Logger}.
+ */
+ private final Logger logger = LoggerFactory.getLogger(ZstackNetworkInitialisation.class);
+
+ /**
+ * Number of milliseconds to wait for the bootloader to exit
+ */
+ public static final int BOOTLOAD_TIMEOUT = 3000;
+
+ /**
+ * Number of milliseconds to wait for the NCP to come online
+ */
+ public static final int ONLINE_TIMEOUT = 5000;
+
+ /**
+ * The default magic number used to make the dongle exit the bootloader
+ */
+ public static final int MAGIC_NUMBER_DEFAULT = 0xEF;
+
+ /**
+ * The frame handler used to send the ZStack frames to the NCP
+ */
+ private ZstackProtocolHandler protocolHandler;
+
+ /**
+ * The magic number used to make the dongle exit the bootloader
+ */
+ private int magicNumber = MAGIC_NUMBER_DEFAULT;
+
+ /**
+ * @param protocolHandler the {@link ZstackProtocolHandler} used to communicate with the NCP
+ */
+ public ZstackNetworkInitialisation(ZstackProtocolHandler protocolHandler) {
+ this.protocolHandler = protocolHandler;
+ }
+
+ /**
+ * Different hardware may use a different "Magic Number" to skip waiting in the bootloader. Otherwise
+ * the dongle may wait in the bootloader for 60 seconds after it's powered on or reset.
+ *
+ * This method allows the user to change the magic number which may be required when using different
+ * sticks.
+ *
+ * @param magicNumber
+ */
+ public void setMagicNumber(int magicNumber) {
+ this.magicNumber = magicNumber;
+ }
+
+ /**
+ * This method performs the initial initialisation of the dongle application firmware. This simply starts the
+ * dongle, ensuring that it enters the application (ie exiting the bootloader) and sets the configuration to use the
+ * defaults. From here we have a known configuration on which to start our session.
+ *
+ * The dongle is not reset completely, thus allowing it to be placed back into the previous network.
+ *
+ * @param initialize set to true to reset the dongle and erase all current network settings
+ * @param serialPort
+ */
+ public ZigBeeStatus initializeNcp(boolean initialize, ZigBeePort serialPort) {
+ logger.debug("ZStack Initialisation: Initialise");
+ ZstackNcp ncp = new ZstackNcp(protocolHandler);
+
+ // The reset failed - assume we're in the bootloader and try and exit
+ if (exitBootloader(serialPort) == false) {
+ logger.debug("ZStack Initialisation: Failed to exit bootloader");
+ return ZigBeeStatus.COMMUNICATION_ERROR;
+ }
+
+ if (initialize) {
+ return resetNcp(ncp, true);
+ }
+ return ZigBeeStatus.SUCCESS;
+ }
+
+ /**
+ * Form a new network as the coordinator.
+ *
+ * This assumes that the network configuration parameters have been set prior to calling
+ *
+ * @return {@link ZigBeeStatus} defining the result
+ */
+ public ZigBeeStatus formNetwork() {
+ logger.debug("ZStack forming new network");
+ ZstackNcp ncp = new ZstackNcp(protocolHandler);
+
+ if (ncp.setDeviceType(DeviceType.COORDINATOR) != ZstackResponseCode.SUCCESS) {
+ logger.debug("ZStack forming network: Error setting NCP to coordinator");
+ return ZigBeeStatus.COMMUNICATION_ERROR;
+ }
+
+ return ZigBeeStatus.SUCCESS;
+ }
+
+ /**
+ * Join an existing network as a Router
+ *
+ * This assumes that the network configuration parameters have been set prior to calling
+ *
+ * @return {@link ZigBeeStatus} defining the result
+ */
+ public ZigBeeStatus joinNetwork() {
+ logger.debug("ZStack joining new network");
+ ZstackNcp ncp = new ZstackNcp(protocolHandler);
+
+ if (ncp.setDeviceType(DeviceType.ROUTER) != ZstackResponseCode.SUCCESS) {
+ logger.debug("ZStack forming network: Error setting NCP to router");
+ return ZigBeeStatus.COMMUNICATION_ERROR;
+ }
+
+ return ZigBeeStatus.SUCCESS;
+ }
+
+ /**
+ * Starts the NCP application, placing it on the network as previously configured.
+ *
+ * @return {@link ZigBeeStatus} defining the result
+ */
+ public ZigBeeStatus startNetwork() {
+ logger.debug("ZStack starting network");
+ ZstackNcp ncp = new ZstackNcp(protocolHandler);
+
+ ncp.setNetworkSecurity(true);
+
+ ncp.zdoRegisterCallback(0x0006);// MatchDescriptorRequest
+ ncp.zdoRegisterCallback(0x0013);// DeviceAnnounce
+ ncp.zdoRegisterCallback(0x0036);// ManagementPermitJoiningRequest
+ ncp.zdoRegisterCallback(0x8000);// NetworkAddressResponse() {
+ ncp.zdoRegisterCallback(0x8001);// IeeeAddressResponse() {
+ ncp.zdoRegisterCallback(0x8002);// NodeDescriptorResponse.);
+ ncp.zdoRegisterCallback(0x8003);// PowerDescriptorResponse
+ ncp.zdoRegisterCallback(0x8004);// SimpleDescriptorResponse
+ ncp.zdoRegisterCallback(0x8005);// ActiveEndpointsResponse
+ ncp.zdoRegisterCallback(0x8006);// MatchDescriptorResponse
+ ncp.zdoRegisterCallback(0x8011);// UserDescriptorResponse
+ ncp.zdoRegisterCallback(0x8020);// EndDeviceBindResponse
+ ncp.zdoRegisterCallback(0x8021);// BindResponse
+ ncp.zdoRegisterCallback(0x8022);// UnbindResponse
+ ncp.zdoRegisterCallback(0x8031);// ManagementLqiResponse
+ ncp.zdoRegisterCallback(0x8032);// ManagementRoutingResponse
+ ncp.zdoRegisterCallback(0x8033);// ManagementBindResponse
+ ncp.zdoRegisterCallback(0x8034);// ManagementLeaveResponse
+ ncp.zdoRegisterCallback(0x8036);// ManagementPermitJoiningResponse
+
+ // Now start the NCP
+ if (ncp.startupApplication() != ZstackResponseCode.SUCCESS) {
+ return ZigBeeStatus.COMMUNICATION_ERROR;
+ }
+
+ return ZigBeeStatus.SUCCESS;
+ }
+
+ /**
+ * Attempts to exit the bootloader by sending the "magic number" and waiting for the {@link ZstackSysResetIndAreq}
+ * to be received to confirm that the NCP application firmware has started.
+ *
+ * https://www.ti.com/lit/an/swra466d/swra466d.pdf
+ * https://www.ti.com/lit/ug/swcu185d/swcu185d.pdf
+ *
+ * @return true if the {@link ZstackSysResetIndAreq} was received, otherwise false
+ * @param serialPort Serial port
+ */
+ private boolean exitBootloader(ZigBeePort serialPort) {
+ // FIXME this does not work in the OpenHAB binding, as it seems their write() implementation blocks
+ /*
+ protocolHandler.sendRaw(magicNumber);
+ if (waitForBoot("Magicnumber")) {
+ return true;
+ }
+ */
+
+ serialPort.setDtr(false);
+
+ serialPort.setRts(false);
+ serialPort.setRts(true);
+ serialPort.setRts(false);
+
+ return waitForBoot("Hardware reset");
+ }
+
+ private boolean waitForBoot(String resetMode) {
+ Future
+ * The transaction looks for a received {@link ZstackFrameResponse} that matches the sent {@link ZstackFrameRequest}.
+ * Generally, this is matching the Srsp matching the Sreq.
+ * The {@link ZstackFrameRequest} and {@link ZstackFrameResponse} classes are provided when the transaction is created.
+ *
+ * @author Chris Jackson
+ *
+ */
+public interface ZstackTransaction {
+ /**
+ * Matches request and response.
+ *
+ * @param response the response {@link ZstackFrameResponse}
+ * @return true if response matches the request
+ */
+ boolean isMatch(ZstackFrameResponse response);
+
+ /**
+ * Gets the {@link ZstackFrameRequest} associated with this transaction
+ *
+ * @return the {@link ZstackFrameRequest}
+ */
+ ZstackFrameRequest getRequest();
+
+ /**
+ * Gets the {@link ZstackFrameResponse} for the transaction. If multiple responses are returned, this will return
+ * the
+ * last response, indicating the final response used to complete the transaction.
+ *
+ * @return {@link ZstackFrameResponse} to complete the transaction or null if no response received
+ */
+ ZstackFrameResponse getResponse();
+
+ /**
+ * Gets a {@link List} of the {@link ZstackFrameResponse}s received for the transaction. This is used for
+ * transactions
+ * returning multiple responses - for single response transactions, use {@link #getResponse}.
+ *
+ * @return {@link ZstackFrameResponse} to complete the transaction or null if no response received
+ */
+ List
+ *
+ *
+ * @author Chris Jackson
+ *
+ */
+public class ZigBeeDongleZstack implements ZigBeeTransportTransmit, ZstackFrameHandler {
+ /**
+ * The {@link Logger}.
+ */
+ private final Logger logger = LoggerFactory.getLogger(ZigBeeDongleZstack.class);
+
+ /**
+ * The serial port used to connect to the dongle
+ */
+ private ZigBeePort serialPort;
+
+ /**
+ * The magic number used to make the dongle exit the bootloader
+ */
+ private int magicNumber = ZstackNetworkInitialisation.MAGIC_NUMBER_DEFAULT;
+
+ /**
+ * The protocol handler used to send and receive ZStack packets
+ */
+ private ZstackProtocolHandler frameHandler;
+
+ /**
+ * The stack configuration we need for the NCP
+ */
+ private Map