Skip to content

Commit

Permalink
New autocoder employing XML definition file format
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Jackson <chris@cd-jackson.com>
  • Loading branch information
cdjackson committed Feb 9, 2019
1 parent da475fa commit d5848e9
Show file tree
Hide file tree
Showing 601 changed files with 108,283 additions and 19,153 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -4,6 +4,8 @@ bin/
*.log
*.log.*
*.json
*.sh
*.zip
.metadata
local.properties

Expand Down
52 changes: 52 additions & 0 deletions README.md
Expand Up @@ -15,6 +15,58 @@ Features include -:
* ZigBee Cluster Library
* Over-The-Air firmware upgrade

### ZigBee Cluster Library

The framework includes a ZigBee Cluster Library that is auto-generated from an XML definition file.

The following clusters are currently supported -:

| ID | Cluster | Description |
|----|---------|-------------|
| 0000 | BASIC | This cluster supports an interface to the node or physical device. It provides attributes and commands for determining basic information, setting user information such as location, and resetting to factory defaults. |
| 0001 | POWER_CONFIGURATION | Attributes for determining detailed information about a device’s power source(s), and for configuring under/over voltage alarms. |
| 0003 | IDENTIFY | Attributes and commands to put a device into an Identification mode (e.g. flashing a light), that indicates to an observer – e.g. an installer - which of several devices it is, also to request any device that is identifying itself to respond to the initiator. |
| 0004 | GROUPS | The ZigBee specification provides the capability for group addressing. That is, any endpoint on any device may be assigned to one or more groups, each labeled with a 16-bit identifier (0x0001 – 0xfff7), which acts for all intents and purposes like a network address. Once a group is established, frames, sent using the APSDE-DATA.request primitive and having a DstAddrMode of 0x01, denoting group addressing, will be delivered to every endpoint assigned to the group address named in the DstAddr parameter of the outgoing APSDE-DATA.request primitive on every device in the network for which there are such endpoints. |
| 0005 | SCENES | The scenes cluster provides attributes and commands for setting up and recalling scenes. Each scene corresponds to a set of stored values of specified attributes for one or more clusters on the same end point as the scenes cluster. |
| 0006 | ON_OFF | Attributes and commands for switching devices between ‘On’ and ‘Off’ states. |
| 0007 | ON_OFF_SWITCH_CONFIGURATION | Attributes and commands for configuring On/Off switching devices |
| 0008 | LEVEL_CONTROL | This cluster provides an interface for controlling a characteristic of a device that can be set to a level, for example the brightness of a light, the degree of closure of a door, or the power output of a heater. |
| 0009 | ALARMS | Attributes and commands for sending alarm notifications and configuring alarm functionality. |
| 000A | TIME | This cluster provides a basic interface to a real-time clock. The clock time MAY be read and also written, in order to synchronize the clock (as close as practical) to a time standard. This time standard is the number of seconds since 0 hrs 0 mins 0 sec on 1st January 2000 UTC (Universal Coordinated Time). |
| 000B | RSSI_LOCATION | This cluster provides a means for exchanging Received Signal Strength Indication (RSSI) information among one hop devices as well as messages to report RSSI data to a centralized device that collects all the RSSI data in the network. |
| 000F | BINARY_INPUT_BASIC | The Binary Input (Basic) cluster provides an interface for reading the value of a binary measurement and accessing various characteristics of that measurement. The cluster is typically used to implement a sensor that measures a two-state physical quantity. |
| 0012 | MULTISTATE_INPUT_BASIC | The Multistate Input (Basic) cluster provides an interface for reading the value of a multistate measurement and accessing various characteristics of that measurement. The cluster is typically used to implement a sensor that measures a physical quantity that can take on one of a number of discrete states. |
| 0013 | MULTISTATE_OUTPUT_BASIC | The Multistate Output (Basic) cluster provides an interface for setting the value of an output that can take one of a number of discrete values, and accessing characteristics of that value. |
| 0014 | MULTISTATE_VALUE_BASIC | The Multistate Value (Basic) cluster provides an interface for setting a multistate value, typically used as a control system parameter, and accessing characteristics of that value. |
| 0019 | OTA_UPGRADE | The cluster provides a standard way to upgrade devices in the network via OTA messages. Thus the upgrade process MAY be performed between two devices from different manufacturers. Devices are required to have application bootloader and additional memory space in order to successfully implement the cluster. |
| 0020 | POLL_CONTROL | This cluster provides a mechanism for the management of an end device’s MAC Data Request rate. For the purposes of this cluster, the term “poll” always refers to the sending of a MAC Data Request from the end device to the end device’s parent. This cluster can be used for instance by a configuration device to make an end device responsive for a certain period of time so that the device can be managed by the controller. This cluster is composed of a client and server. The end device implements the server side of this cluster. The server side contains several attributes related to the MAC Data Request rate for the device. The client side implements commands used to manage the poll rate for the device. The end device which implements the server side of this cluster sends a query to the client on a predetermined interval to see if the client would like to manage the poll period of the end device in question. When the client side of the cluster hears from the server it has the opportunity to respond with configuration data to either put the end device in a short poll mode or let the end device continue to function normally. |
| 0101 | DOOR_LOCK | The door lock cluster provides an interface to a generic way to secure a door. The physical object that provides the locking functionality is abstracted from the cluster. The cluster has a small list of mandatory attributes and functions and a list of optional features. |
| 0102 | WINDOW_COVERING | Provides an interface for controlling and adjusting automatic window coverings. |
| 0201 | THERMOSTAT | This cluster provides an interface to the functionality of a thermostat. |
| 0202 | FAN_CONTROL | This cluster specifies an interface to control the speed of a fan as part of a heating / cooling system. |
| 0203 | DEHUMIDIFICATION_CONTROL | This cluster provides an interface to dehumidification functionality. |
| 0204 | THERMOSTAT_USER_INTERFACE_CONFIGURATION | This cluster provides an interface to allow configuration of the user interface for a thermostat, or a thermostat controller device, that supports a keypad and LCD screen. |
| 0300 | COLOR_CONTROL | This cluster provides an interface for changing the color of a light. Color is specified according to the Commission Internationale de l'Éclairage (CIE) specification CIE 1931 Color Space, [B4]. Color control is carried out in terms of x,y values, as defined by this specification. |
| 0400 | ILLUMINANCE_MEASUREMENT | The cluster provides an interface to illuminance measurement functionality, including configuration and provision of notifications of illuminance measurements. |
| 0401 | ILLUMINANCE_LEVEL_SENSING | The cluster provides an interface to illuminance level sensing functionality, including configuration and provision of notifications of whether the illuminance is within, above or below a target band. |
| 0402 | TEMPERATURE_MEASUREMENT | The server cluster provides an interface to temperature measurement functionality, including configuration and provision of notifications of temperature measurements. |
| 0403 | PRESSURE_MEASUREMENT | The cluster provides an interface to pressure measurement functionality, including configuration and provision of notifications of pressure measurements. |
| 0404 | FLOW_MEASUREMENT | The server cluster provides an interface to flow measurement functionality, including configuration and provision of notifications of flow measurements. |
| 0405 | RELATIVE_HUMIDITY_MEASUREMENT | The server cluster provides an interface to relative humidity measurement functionality, including configuration and provision of notifications of relative humidity measurements. |
| 0406 | OCCUPANCY_SENSING | The cluster provides an interface to occupancy sensing functionality, including configuration and provision of notifications of occupancy status. |
| 0500 | IAS_ZONE | The IAS Zone cluster defines an interface to the functionality of an IAS security zone device. IAS Zone supports up to two alarm types per zone, low battery reports and supervision of the IAS network. |
| 0501 | IAS_ACE | The IAS ACE cluster defines an interface to the functionality of any Ancillary Control Equipment of the IAS system. Using this cluster, a ZigBee enabled ACE device can access a IAS CIE device and manipulate the IAS system, on behalf of a level-2 user. |
| 0502 | IAS_WD | The IAS WD cluster provides an interface to the functionality of any Warning Device equipment of the IAS system. Using this cluster, a ZigBee enabled CIE device can access a ZigBee enabled IAS WD device and issue alarm warning indications (siren, strobe lighting, etc.) when a system alarm condition is detected. |
| 0700 | PRICE | The Price Cluster provides the mechanism for communicating Gas, Energy, or Water pricing information within the premises. This pricing information is distributed to the ESI from either the utilities or from regional energy providers. The ESI conveys the information (via the Price Cluster mechanisms) to other Smart Energy devices. |
| 0701 | DEMAND_RESPONSE_AND_LOAD_CONTROL | This cluster provides an interface to the functionality of Smart Energy Demand Response and Load Control. Devices targeted by this cluster include thermostats and devices that support load control. |
| 0702 | METERING | The Metering Cluster provides a mechanism to retrieve usage information from Electric, Gas, Water, and potentially Thermal metering devices. These devices can operate on either battery or mains power, and can have a wide variety of sophistication. The Metering Cluster is designed to provide flexibility while limiting capabilities to a set number of metered information types. More advanced forms or data sets from metering devices will be supported in the Smart Energy Tunneling Cluster |
| 0703 | MESSAGING | This cluster provides an interface for passing text messages between ZigBee devices. Messages are expected to be delivered via the ESI and then unicast to all individually registered devices implementing the Messaging Cluster on the ZigBee network, or just made available to all devices for later pickup. Nested and overlapping messages are not allowed. The current active message will be replaced if a new message is received by the ESI. |
| 0704 | SMART_ENERGY_TUNNELING | The tunneling cluster provides an interface for tunneling protocols. It is comprised of commands and attributes required to transport any existing metering communication protocol within the payload of standard ZigBee frames (including the handling of issues such as addressing, fragmentation and flow control). Examples for such protocols are DLMS/COSEM, IEC61107, ANSI C12, M-Bus, ClimateTalk etc. |
| 0705 | PREPAYMENT | The Prepayment Cluster provides the facility to pass messages relating to the accounting functionality of a meter between devices on the HAN. It allows for the implementation of a system conforming to the set of standards relating to Payment Electricity Meters (IEC 62055) and also for the case where the accounting function is remote from the meter. Prepayment is used in situations where the supply of a service may be interrupted or enabled under the control of the meter or system in relation to a payment tariff. The accounting process may be within the meter or elsewhere in the system. The amount of available credit is decremented as the service is consumed and is incremented through payments made by the consumer. Such a system allows the consumer to better manage their energy consumption and reduces the risk of bad debt owing to the supplier. |
| 0800 | KEY_ESTABLISHMENT | This cluster provides attributes and commands to perform mutual authentication and establish keys between two ZigBee devices. |
| 0B04 | ELECTRICAL_MEASUREMENT | This cluster provides a mechanism for querying data about the electrical properties as measured by the device. This cluster may be implemented on any device type and be implemented on a per-endpoint basis. For example, a power strip device could represent each outlet on a different endpoint and report electrical information for each individual outlet. The only caveat is that if you implement an attribute that has an associated multiplier and divisor, then you must implement the associated multiplier and divisor attributes. For example if you implement DCVoltage, you must also implement DCVoltageMultiplier and DCVoltageDivisor. |
| 0B05 | DIAGNOSTICS | The diagnostics cluster provides access to information regarding the operation of the ZigBee stack over time. This information is useful to installers and other network administrators who wish to know how a particular device is functioning on the network. |

# Packages

The framework implements a package structure that allows efficient use of re-usable components in a number of different applications.
Expand Down

This file was deleted.

@@ -0,0 +1,108 @@
/**
* 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.autocode;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;

/**
* Utility class to compare to files and copy if they are different
*
* @author Chris Jackson
*
*/
public class FileCopy {
private boolean fileCompare(String file1, String file2) throws IOException {
File f = new File(file1);
if (!f.exists()) {
return false;
}
f = new File(file2);
if (!f.exists()) {
return false;
}

BufferedReader reader1 = new BufferedReader(new FileReader(file1));
BufferedReader reader2 = new BufferedReader(new FileReader(file2));

String line1 = reader1.readLine();
String line2 = reader2.readLine();

boolean areEqual = true;

int lineNum = 1;

while (line1 != null || line2 != null) {
if (line1 == null || line2 == null) {
areEqual = false;

break;
} else if (!line1.startsWith("@Generated") && !line1.equalsIgnoreCase(line2)) {
areEqual = false;

break;
}

line1 = reader1.readLine();
line2 = reader2.readLine();

lineNum++;
}

if (areEqual) {
System.out.println("Two files have same content.");
} else {
System.out.println("Two files have different content. They differ at line " + lineNum);
System.out.println("File1 has " + line1 + " and File2 has " + line2 + " at line " + lineNum);
}

reader1.close();
reader2.close();

return areEqual;
}

private void copyFile(String source, String dest) throws IOException {
File target = new File(dest);

File parent = target.getParentFile();
if (!parent.exists() && !parent.mkdirs()) {
throw new IllegalStateException("Couldn't create dir: " + parent);
}

if (target.exists()) {
Files.delete(new File(dest).toPath());
}

Files.copy(new File(source).toPath(), new File(dest).toPath());
}

public void compareFiles(String inFolder, String outFolder, String folder) {
File[] files = new File(inFolder + folder).listFiles();
for (File file : files) {
if (file.isDirectory()) {
compareFiles(inFolder, outFolder, folder + "/" + file.getName());
} else {
System.out.println("File: " + folder + "/" + file.getName());
try {
if (!fileCompare(inFolder + folder + "/" + file.getName(),
outFolder + folder + "/" + file.getName())) {
copyFile(inFolder + folder + "/" + file.getName(), outFolder + folder + "/" + file.getName());
System.out.println("File: " + folder + "/" + file.getName() + " updated");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

}

0 comments on commit d5848e9

Please sign in to comment.