[zb4osgi-changeset] [scm] ZigBee 4 OSGi repository change: r1159 - in /projects/zb4osgi/sandbox/giancarlo.riolo: ./ externals/ externals/bundles/ externals/bundles/rxtx/ firmware/ integration.test/ it/ pom/ testing/ trunk/ trunk/externals/ trunk/firmware/ trunk/integration.test/ trunk/it/ trunk/karaf.features/ trunk/pom/ trunk/testing/ trunk/zigbee.CC2530.driver/ trunk/zigbee.basedriver.api/ trunk/zigbee.basedriver.stub/ trunk/zigbee.basedriver/ trunk/zigbee.cc2480.datalink/ trunk/zigbee.common/ trunk/zigbee.dongle.api/ trunk/zigbee.eh.driver/ trunk/zigbee.eh.zcl.library/ trunk/zigbee.ez430-rf2480.driver/ trunk/zigbee.ha.driver.stub/ trunk/zigbee.ha.driver/ trunk/zigbee.hc.driver/ trunk/zigbee.network.browser/ trunk/zigbee.se.zcl.library/ trunk/zigbee.tester/ trunk/zigbee.zcl.library/ trunk/zigbee.zhccl.library/ zigbee.CC2530.driver/ zigbee.CC2530.driver/src/main/java/it/cnr/isti/zigbee/dongle/CC2530/impl/ zigbee.basedriver.api/ zigbee.basedriver.stub/ zigbee.basedriver/ zigbee.cc2480.datalink/ zigbee.cc2480.datalink/src/main/java/com/itaca/ztool/api/ zigbee.common/ zigbee.common/src/test/java/it/cnr/isti/primitivetypes/util/ zigbee.dongle.api/ zigbee.eh.driver/ zigbee.eh.zcl.library/ zigbee.ez430-rf2480.driver/ zigbee.ha.driver.stub/ zigbee.ha.driver/ zigbee.hc.driver/ zigbee.karaf.features/ zigbee.karaf.features/src/main/resources/ zigbee.network.browser/ zigbee.noGUI.tester/ zigbee.se.zcl.library/ zigbee.tester/ zigbee.zcl.library/ zigbee.zhccl.library/
scm-notify at zb4osgi.aaloa.org
scm-notify at zb4osgi.aaloa.org
Fri Feb 13 11:24:04 CET 2015
Author: giancarlo.riolo
Date: Fri Feb 13 11:24:03 2015
New Revision: 1159
Log:
sandbox giancarlo.riolo
Added:
projects/zb4osgi/sandbox/giancarlo.riolo/externals/
- copied from r1158, projects/zb4osgi/trunk/externals/
projects/zb4osgi/sandbox/giancarlo.riolo/firmware/
- copied from r1158, projects/zb4osgi/trunk/firmware/
projects/zb4osgi/sandbox/giancarlo.riolo/integration.test/
- copied from r1158, projects/zb4osgi/trunk/integration.test/
projects/zb4osgi/sandbox/giancarlo.riolo/it/
- copied from r1158, projects/zb4osgi/trunk/it/
projects/zb4osgi/sandbox/giancarlo.riolo/pom/
- copied from r1158, projects/zb4osgi/trunk/pom/
projects/zb4osgi/sandbox/giancarlo.riolo/pom.xml
- copied, changed from r1158, projects/zb4osgi/trunk/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/testing/
- copied from r1158, projects/zb4osgi/trunk/testing/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/ (props changed)
- copied from r1158, projects/zb4osgi/trunk/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.CC2530.driver/
- copied from r1158, projects/zb4osgi/trunk/zigbee.CC2530.driver/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver/
- copied from r1158, projects/zb4osgi/trunk/zigbee.basedriver/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.api/
- copied from r1158, projects/zb4osgi/trunk/zigbee.basedriver.api/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.stub/
- copied from r1158, projects/zb4osgi/trunk/zigbee.basedriver.stub/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.cc2480.datalink/
- copied from r1158, projects/zb4osgi/trunk/zigbee.cc2480.datalink/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.common/
- copied from r1158, projects/zb4osgi/trunk/zigbee.common/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.dongle.api/
- copied from r1158, projects/zb4osgi/trunk/zigbee.dongle.api/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.eh.driver/
- copied from r1158, projects/zb4osgi/trunk/zigbee.eh.driver/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.eh.zcl.library/
- copied from r1158, projects/zb4osgi/trunk/zigbee.eh.zcl.library/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ez430-rf2480.driver/
- copied from r1158, projects/zb4osgi/trunk/zigbee.ez430-rf2480.driver/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/
- copied from r1158, projects/zb4osgi/trunk/zigbee.ha.driver/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver.stub/
- copied from r1158, projects/zb4osgi/trunk/zigbee.ha.driver.stub/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.hc.driver/
- copied from r1158, projects/zb4osgi/trunk/zigbee.hc.driver/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.karaf.features/
- copied from r1158, projects/zb4osgi/trunk/karaf.features/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.native.driver.zstack-HowTo.txt
- copied unchanged from r1158, projects/zb4osgi/trunk/zigbee.native.driver.zstack-HowTo.txt
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.network.browser/
- copied from r1158, projects/zb4osgi/trunk/zigbee.network.browser/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.se.zcl.library/
- copied from r1158, projects/zb4osgi/trunk/zigbee.se.zcl.library/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/
- copied from r1158, projects/zb4osgi/trunk/zigbee.tester/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zcl.library/
- copied from r1158, projects/zb4osgi/trunk/zigbee.zcl.library/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zhccl.library/
- copied from r1158, projects/zb4osgi/trunk/zigbee.zhccl.library/
Removed:
projects/zb4osgi/sandbox/giancarlo.riolo/boot.sh
projects/zb4osgi/sandbox/giancarlo.riolo/fast.sh
projects/zb4osgi/sandbox/giancarlo.riolo/pax.sh
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/externals/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/firmware/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/integration.test/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/it/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/karaf.features/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/pom/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/testing/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.CC2530.driver/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.basedriver/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.basedriver.api/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.basedriver.stub/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.cc2480.datalink/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.common/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.dongle.api/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.eh.driver/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.eh.zcl.library/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.ez430-rf2480.driver/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.ha.driver/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.ha.driver.stub/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.hc.driver/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.native.driver.zstack-HowTo.txt
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.network.browser/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.se.zcl.library/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.tester/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.zcl.library/
projects/zb4osgi/sandbox/giancarlo.riolo/trunk/zigbee.zhccl.library/
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.noGUI.tester/
Modified:
projects/zb4osgi/sandbox/giancarlo.riolo/externals/bundles/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/externals/bundles/rxtx/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/pom/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.CC2530.driver/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.CC2530.driver/src/main/java/it/cnr/isti/zigbee/dongle/CC2530/impl/DriverCC2530.java
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.api/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.stub/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.cc2480.datalink/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.cc2480.datalink/src/main/java/com/itaca/ztool/api/ZToolPacketStream.java
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.common/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.common/src/test/java/it/cnr/isti/primitivetypes/util/IntegersTest.java
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.dongle.api/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.eh.driver/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.eh.zcl.library/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ez430-rf2480.driver/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.hc.driver/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.karaf.features/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.karaf.features/src/main/resources/features.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.network.browser/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.se.zcl.library/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/pax.args
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zcl.library/pom.xml
projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zhccl.library/pom.xml
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/externals/bundles/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/externals/bundles/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/externals/bundles/pom.xml Fri Feb 13 11:24:03 2015
@@ -5,13 +5,13 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../../pom/pom.xml</relativePath>
</parent>
<groupId>org.aaloa.zb4osgi.bundle</groupId>
<artifactId>org.aaloa.zb4osgi.bundle.builder</artifactId>
- <version>1-SNAPSHOT</version>
+ <version>1.0.0</version>
<packaging>pom</packaging>
<name>A Builder POM for subprojects</name>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/externals/bundles/rxtx/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/externals/bundles/rxtx/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/externals/bundles/rxtx/pom.xml Fri Feb 13 11:24:03 2015
@@ -5,7 +5,7 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../../../pom/pom.xml</relativePath>
</parent>
@@ -17,7 +17,7 @@
<groupId>org.aaloa.zb4osgi.bundle</groupId>
<artifactId>org.aaloa.zb4osgi.externals.rxtx</artifactId>
- <version>2.1.7-${osgiPackaging}-SNAPSHOT</version>
+ <version>1.0.0</version>
<packaging>bundle</packaging>
<name>${pkgArtifactId} Bundle Wrapper</name>
<description>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/pom/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/pom/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/pom/pom.xml Fri Feb 13 11:24:03 2015
@@ -16,7 +16,7 @@
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
<packaging>pom</packaging>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<name>Suite of bundle for integrating ZigBee device in OSGi</name>
<url>http://zb4osgi.aaloa.org/</url>
@@ -191,61 +191,61 @@
<dependency>
<groupId>org.aaloa.zb4osgi.bundle</groupId>
<artifactId>org.aaloa.zb4osgi.externals.rxtx</artifactId>
- <version>2.1.7-2</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.zigbee.common</artifactId>
- <version>0.6.0-SNAPSHOT</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.zigbee.basedriver.api</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.zigbee.dongle.api</artifactId>
- <version>0.8.0-SNAPSHOT</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.zigbee.cc2480.datalink</artifactId>
- <version>0.9.0-SNAPSHOT</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.zigbee.zcl.library</artifactId>
- <version>0.9.0-SNAPSHOT</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.zigbee.ha.driver</artifactId>
- <version>0.8.0-SNAPSHOT</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.zigbee.eh.driver</artifactId>
- <version>0.8.0-SNAPSHOT</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.zigbee.eh.zcl.library</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.zigbee.se.zcl.library</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -253,12 +253,6 @@
<artifactId>trove4j</artifactId>
<version>2.1.0</version>
</dependency>
- <!-- <scope>provided</scope> -->
-
- <!-- WRAPPED BUNDLE -->
- <!--<dependency> <groupId>org.aaloa.zb4osgi.bundle</groupId> <artifactId>org.aaloa.zb4osgi.bundle.net.sf.trove4j</artifactId>
- <version>2.0.4-1</version> <scope>provided</scope> </dependency> -->
-
<!-- OSGi Runtime -->
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
@@ -310,6 +304,12 @@
<version>3.2</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <version>1.8</version>
+</dependency>
+
</dependencies>
</dependencyManagement>
Propchange: projects/zb4osgi/sandbox/giancarlo.riolo/trunk/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Feb 13 11:24:03 2015
@@ -0,0 +1,6 @@
+.git
+.gitignore
+.settings
+.project
+
+runner
Propchange: projects/zb4osgi/sandbox/giancarlo.riolo/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Feb 13 11:24:03 2015
@@ -0,0 +1,2 @@
+/projects/zb4osgi/sandbox/giancarlo.riolo:804-1010
+/projects/zb4osgi/trunk:605-630
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.CC2530.driver/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.CC2530.driver/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.CC2530.driver/pom.xml Fri Feb 13 11:24:03 2015
@@ -16,13 +16,13 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<artifactId>org.aaloa.zb4osgi.zigbee.CC2530.driver</artifactId>
- <version>0.3.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<packaging>bundle</packaging>
<name>ZIC for CC2530/CC2531 chipset dongle</name>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.CC2530.driver/src/main/java/it/cnr/isti/zigbee/dongle/CC2530/impl/DriverCC2530.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.CC2530.driver/src/main/java/it/cnr/isti/zigbee/dongle/CC2530/impl/DriverCC2530.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.CC2530.driver/src/main/java/it/cnr/isti/zigbee/dongle/CC2530/impl/DriverCC2530.java Fri Feb 13 11:24:03 2015
@@ -109,1661 +109,1667 @@
*/
public class DriverCC2530 implements Runnable, SimpleDriver {
- private final static Logger logger = LoggerFactory.getLogger(DriverCC2530.class);
-
- public static final int RESEND_TIMEOUT_DEFAULT = 1000;
- public static final String RESEND_TIMEOUT_KEY = "zigbee.driver.cc2530.resend.timeout";
-
- public static final int RESEND_MAX_RESEND_DEFAULT = 3;
- public static final String RESEND_MAX_RESEND_KEY = "zigbee.driver.cc2530.resend.max";
-
- public static final boolean RESEND_ONLY_EXCEPTION_DEFAULT = true;
- public static final String RESEND_ONLY_EXCEPTION_KEY = "zigbee.driver.cc2530.resend.exceptionally";
-
- private final int TIMEOUT;
- public static final int DEFAULT_TIMEOUT = 5000;
- public static final String TIMEOUT_KEY = "zigbee.driver.cc2530.timeout";
-
- private Thread driver;
-
- private HWHighLevelDriver high;
- private HWLowLevelDriver low;
- private String port;
- private int rate;
- private volatile DriverStatus state;
- private NetworkMode mode;
- private short pan;
- private byte channel;
- private boolean cleanStatus;
-
- private final int RESEND_TIMEOUT;
- private final int RESEND_MAX_RETRY;
- private final boolean RESEND_ONLY_EXCEPTION;
-
- private final HashSet<AnnounceListner> AnnounceListners = new HashSet<AnnounceListner>();
- private final AnnunceListerFilter AnnounceListner = new AnnunceListerFilter(
- AnnounceListners);
-
- private final ArrayList<AFMessageListner> afMessageListners = new ArrayList<AFMessageListner>();
- private final AFMessageListnerFilter afListner = new AFMessageListnerFilter(
- afMessageListners);
-
- private long ieeeAddress = -1;
- private final HashMap<Class<?>, Thread> conversation3Way = new HashMap<Class<?>, Thread>();
-
- private class AnnunceListerFilter implements AsynchrounsCommandListener {
-
- private final Collection<AnnounceListner> listners;
-
- private AnnunceListerFilter(Collection<AnnounceListner> list) {
- listners = list;
- }
-
- public void receivedAsynchrounsCommand(ZToolPacket packet) {
- if (packet.isError())
- return;
- if (packet.getCMD().get16BitValue() == ZToolCMD.ZDO_END_DEVICE_ANNCE_IND) {
- logger.debug("Recieved announce message {} value is {}",
- packet.getClass(), packet);
- ZDO_END_DEVICE_ANNCE_IND annunce = (ZDO_END_DEVICE_ANNCE_IND) packet;
- for (AnnounceListner l : listners) {
- l.notify(annunce.SrcAddr, annunce.IEEEAddr,
- annunce.NwkAddr, annunce.Capabilities);
- }
- } else if (packet.getCMD().get16BitValue() == ZToolCMD.ZDO_STATE_CHANGE_IND) {
- try {
- ZDO_STATE_CHANGE_IND p = ((ZDO_STATE_CHANGE_IND) packet);
- /*
- * DEV_HOLD=0x00, // Initialized - not started automatically
- * DEV_INIT=0x01, // Initialized - not connected to anything
- * DEV_NWK_DISC=0x02, // Discovering PAN's to join
- * DEV_NWK_JOINING=0x03, // Joining a PAN DEV_NWK_=0x04, //
- * ReJoining a PAN, only for end-devices
- * DEV_END_DEVICE_UNAUTH=0x05, // Joined but not yet
- * authenticated by trust center DEV_END_DEVICE=0x06, //
- * Started as device after authentication DEV_ROUTER=0x07,
- * // Device joined, authenticated and is a router
- * DEV_COORD_STARTING=0x08, // Started as Zigbee Coordinator
- * DEV_ZB_COORD=0x09, // Started as Zigbee Coordinator
- * DEV_NWK_ORPHAN=0x0A // Device has lost information about
- * its parent
- */
- switch (p.State) {
- case 0 :
- logger.debug("Initialized - not started automatically");
- break;
- case 1 :
- logger.debug("Initialized - not connected to anything");
- break;
- case 2 :
- logger.debug("Discovering PANs to join or waiting for permit join");
- break;
- case 3 :
- logger.debug("Joining a PAN");
- break;
- case 4 :
- logger.debug("Rejoining a PAN, only for end-devices");
- break;
- case 5 :
- logger.debug("Joined but not yet authenticated by trust center");
- break;
- case 6 :
- logger.debug("Started as device after authentication");
- break;
- case 7 :
- logger.debug("Device joined, authenticated and is a router");
- break;
- case 8 :
- logger.debug("Starting as Zigbee Coordinator");
- break;
- case 9 :
- logger.debug("Started as Zigbee Coordinator");
- break;
- case 10 :
- logger.debug("Device has lost information about its parent");
- break;
- default :
- break;
- }
- } catch (Exception ex) {
- // ignored
- }
- }
- }
- }
-
- private class AFMessageListnerFilter implements AsynchrounsCommandListener {
-
- private final Collection<AFMessageListner> listners;
-
- private AFMessageListnerFilter(Collection<AFMessageListner> list) {
- listners = list;
- }
-
- public void receivedAsynchrounsCommand(ZToolPacket packet) {
- if (packet.isError())
- return;
- if (packet.getCMD().get16BitValue() == ZToolCMD.AF_INCOMING_MSG) {
- AF_INCOMING_MSG msg = (AF_INCOMING_MSG) packet;
- if (listners.isEmpty()) {
- logger.debug(
- "Received AF_INCOMING_MSG but no listeners. Message was: {} ",
- msg);
- } else {
- logger.debug(
- "Received AF_INCOMING_MSG notifying {} listeners of {}",
- listners.size(), msg);
- }
- ArrayList<AFMessageListner> localCopy = null;
- synchronized (listners) {
- localCopy = new ArrayList<AFMessageListner>(listners);
- }
- for (AFMessageListner l : localCopy) {
- l.notify(msg);
- }
- }
- }
- }
-
- public DriverCC2530(String serialPort, int bitRate) throws ZToolException {
-
- this(serialPort, bitRate, NetworkMode.COORDINATOR, 0, 19, false);
- }
-
- public DriverCC2530(String serialPort, int bitRate, NetworkMode mode,
- int pan, int channel) throws ZToolException {
-
- this(serialPort, bitRate, mode, pan, channel, false);
- }
-
- public DriverCC2530(String serialPort, int bitRate, NetworkMode mode,
- int pan, int channel, boolean cleanNetworkStatus)
- throws ZToolException {
-
- this(serialPort, bitRate, mode, pan, channel, cleanNetworkStatus, 20000);
- }
-
- public DriverCC2530(String serialPort, int bitRate, NetworkMode mode,
- int pan, int channel, boolean cleanNetworkStatus, long timeout)
- throws ZToolException {
-
- int aux = RESEND_TIMEOUT_DEFAULT;
- try {
- aux = Integer.parseInt(System.getProperty(RESEND_TIMEOUT_KEY));
- logger.debug("Using RESEND_TIMEOUT set from enviroment {}", aux);
- } catch (NumberFormatException ex) {
- logger.debug("Using RESEND_TIMEOUT set as DEFAULT {}", aux);
- }
- RESEND_TIMEOUT = aux;
-
- aux = (int) Math.max(DEFAULT_TIMEOUT, timeout);
- try {
- aux = Integer.parseInt(System.getProperty(TIMEOUT_KEY));
- logger.debug("Using TIMEOUT set from enviroment {}", aux);
- } catch (NumberFormatException ex) {
- logger.debug("Using TIMEOUT set as DEFAULT {}ms", aux);
- }
- TIMEOUT = aux;
-
- aux = RESEND_MAX_RESEND_DEFAULT;
- try {
- aux = Integer.parseInt(System.getProperty(RESEND_MAX_RESEND_KEY));
- logger.debug("Using RESEND_MAX_RETRY set from enviroment {}", aux);
- } catch (NumberFormatException ex) {
- logger.debug("Using RESEND_MAX_RETRY set as DEFAULT {}", aux);
- }
- RESEND_MAX_RETRY = aux;
-
- String p = System.getProperty(RESEND_ONLY_EXCEPTION_KEY);
- if (p != null ) {
- RESEND_ONLY_EXCEPTION = Boolean.parseBoolean(p);
- logger.debug("Using RESEND_ONLY_EXCEPTION set from environment {}", RESEND_ONLY_EXCEPTION);
- } else {
- RESEND_ONLY_EXCEPTION = RESEND_ONLY_EXCEPTION_DEFAULT;
- logger.debug("Using RESEND_ONLY_EXCEPTION set as DEFAULT {}", RESEND_ONLY_EXCEPTION);
- }
-
- state = DriverStatus.CLOSED;
- this.cleanStatus = cleanNetworkStatus;
- setSerialPort(serialPort, bitRate);
- setZigBeeNetwork((byte) channel, (short) pan);
- setZigBeeNodeMode(mode);
- }
-
- private String buildDriverThreadName(String serialPort, int bitrate,
- int channel) {
- return "SimpleDriver[" + serialPort + "," + bitrate + "]";
- }
-
- public void setZigBeeNodeMode(NetworkMode m) {
- if (state != DriverStatus.CLOSED) {
- throw new IllegalStateException("Network mode can be changed only "
- + "if driver is CLOSED while it is:" + state);
- }
- cleanStatus = mode != m;
- mode = m;
- }
-
- public void setZigBeeNetwork(byte ch, short panId) {
- if (state != DriverStatus.CLOSED) {
- throw new IllegalStateException("Network mode can be changed only "
- + "if driver is CLOSED while it is:" + state);
- }
- cleanStatus = ch != channel || panId != pan;
- channel = ch;
- pan = panId;
- }
-
- public void setSerialPort(String serialName, int bitRate) {
- if (state != DriverStatus.CLOSED) {
- throw new IllegalStateException("Serial port can be changed only "
- + "if driver is CLOSED while it is:" + state);
- }
- port = serialName;
- rate = bitRate;
- }
-
- public void open(boolean cleanCache) {
- cleanStatus = cleanCache;
- open();
- }
-
- public void open() {
- if (state == DriverStatus.CLOSED) {
- state = DriverStatus.CREATED;
- driver = new Thread(this);
- driver.setName(buildDriverThreadName(port, rate, channel));
- driver.start();
- } else {
- throw new IllegalStateException(
- "Driver already opened, current status is:" + state);
- }
- }
-
- public void close() {
- if (state == DriverStatus.CLOSED) {
- logger.debug("Already CLOSED");
- return;
- }
- logger.info("Closing");
- if (Thread.currentThread() != driver) {
- logger.debug("Waiting for initialization operation to complete before closing.");
- try {
- driver.join();
- } catch (InterruptedException ignored) {
- }
- } else {
- logger.debug("Self closing");
- }
- if (state == DriverStatus.NETWORK_READY) {
- logger.debug("Closing NETWORK");
- setState(DriverStatus.HARDWARE_READY);
- }
- if (state == DriverStatus.HARDWARE_READY || state == DriverStatus.NETWORK_INITIALIZING ) {
- logger.debug("Closing HARDWARE");
- high.close();
- logger.debug("Closing LOW HARDWARE");
- low.close();
- setState(DriverStatus.CREATED);
- }
- if (state == DriverStatus.CREATED) {
- setState(DriverStatus.CLOSED);
- }
- logger.info("Closed");
- }
-
- public ZDO_MGMT_LQI_RSP sendLQIRequest(ZDO_MGMT_LQI_REQ request) {
-
- if (waitForNetwork() == false)
- return null;
- ZDO_MGMT_LQI_RSP result = null;
-
- waitAndLock3WayConversation(request);
- final WaitForCommand waiter = new WaitForCommand(
- ZToolCMD.ZDO_MGMT_LQI_RSP, high);
-
- logger.debug("Sending ZDO_MGMT_LQI_REQ {}", request);
- ZDO_MGMT_LQI_REQ_SRSP response = (ZDO_MGMT_LQI_REQ_SRSP) sendSynchrouns(
- high, request);
- if (response == null || response.Status != 0) {
- logger.debug("ZDO_MGMT_LQI_REQ failed, received {}", response);
- waiter.cleanup();
- } else {
- result = (ZDO_MGMT_LQI_RSP) waiter.getCommand(TIMEOUT);
- }
- unLock3WayConversation(request);
- return result;
- }
-
- public ZDO_IEEE_ADDR_RSP sendZDOIEEEAddressRequest(ZDO_IEEE_ADDR_REQ request) {
- if (waitForNetwork() == false)
- return null;
- ZDO_IEEE_ADDR_RSP result = null;
-
- waitAndLock3WayConversation(request);
- final WaitForCommand waiter = new WaitForCommand(
- ZToolCMD.ZDO_IEEE_ADDR_RSP, high);
-
- logger.debug("Sending ZDO_IEEE_ADDR_REQ {}", request);
- ZDO_IEEE_ADDR_REQ_SRSP response = (ZDO_IEEE_ADDR_REQ_SRSP) sendSynchrouns(
- high, request);
- if (response == null || response.Status != 0) {
- logger.debug("ZDO_IEEE_ADDR_REQ failed, received {}", response);
- waiter.cleanup();
- } else {
- result = (ZDO_IEEE_ADDR_RSP) waiter.getCommand(TIMEOUT);
- }
- unLock3WayConversation(request);
- return result;
- }
-
- public ZDO_NODE_DESC_RSP sendZDONodeDescriptionRequest(
- ZDO_NODE_DESC_REQ request) {
- if (waitForNetwork() == false)
- return null;
- ZDO_NODE_DESC_RSP result = null;
-
- waitAndLock3WayConversation(request);
- final WaitForCommand waiter = new WaitForCommand(
- ZToolCMD.ZDO_NODE_DESC_RSP, high);
-
- ZDO_NODE_DESC_REQ_SRSP response = (ZDO_NODE_DESC_REQ_SRSP) sendSynchrouns(
- high, request);
- if (response == null || response.Status != 0) {
- waiter.cleanup();
- } else {
- result = (ZDO_NODE_DESC_RSP) waiter.getCommand(TIMEOUT);
- }
-
- unLock3WayConversation(request);
- return result;
- }
-
- public ZDO_ACTIVE_EP_RSP sendZDOActiveEndPointRequest(
- ZDO_ACTIVE_EP_REQ request) {
- if (waitForNetwork() == false)
- return null;
- ZDO_ACTIVE_EP_RSP result = null;
-
- waitAndLock3WayConversation(request);
- final WaitForCommand waiter = new WaitForCommand(
- ZToolCMD.ZDO_ACTIVE_EP_RSP, high);
-
- logger.debug("Sending ZDO_ACTIVE_EP_REQ {}", request);
- ZDO_ACTIVE_EP_REQ_SRSP response = (ZDO_ACTIVE_EP_REQ_SRSP) sendSynchrouns(
- high, request);
- if (response == null || response.Status != 0) {
- logger.debug("ZDO_ACTIVE_EP_REQ failed, received {}", response);
- waiter.cleanup();
- } else {
- result = (ZDO_ACTIVE_EP_RSP) waiter.getCommand(TIMEOUT);
- }
- unLock3WayConversation(request);
- return result;
- }
-
- /**
- * @param request
- */
- private void waitAndLock3WayConversation(ZToolPacket request) {
- synchronized (conversation3Way) {
- Class<?> clz = request.getClass();
- Thread requestor = null;
- while ((requestor = conversation3Way.get(clz)) != null) {
- if (requestor.isAlive() == false) {
- logger.error("Thread {} whom requested {} DIED before unlocking the conversation");
- logger.debug("The thread {} who was waiting for {} to complete DIED, so we have to remove the lock");
- conversation3Way.put(clz, null);
- break;
- }
- logger.debug(
- "{} is waiting for {} to complete which was issued by {} to complete",
- new Object[]{Thread.currentThread(), clz, requestor});
- try {
- conversation3Way.wait();
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- } catch (IllegalMonitorStateException ex) {
- ex.printStackTrace();
- }
- }
- conversation3Way.put(clz, Thread.currentThread());
- }
- }
-
- /**
- * Release the lock held for the 3-way communication
- *
- * @param request
- */
- private void unLock3WayConversation(ZToolPacket request) {
- Class<?> clz = request.getClass();
- Thread requestor = null;
- synchronized (conversation3Way) {
- requestor = conversation3Way.get(clz);
- conversation3Way.put(clz, null);
- conversation3Way.notifyAll();
- }
- if (requestor == null) {
- logger.error(
- "LOCKING BROKEN - SOMEONE RELEASE THE LOCK WITHOUT LOCKING IN ADVANCE for {}",
- clz);
- } else if (requestor != Thread.currentThread()) {
- logger.error("Thread {} stolen the answer of {} waited by {}",
- new Object[]{Thread.currentThread(), clz, requestor});
- }
- }
-
- public ZDO_SIMPLE_DESC_RSP sendZDOSimpleDescriptionRequest(
- ZDO_SIMPLE_DESC_REQ request) {
- if (waitForNetwork() == false)
- return null;
- ZDO_SIMPLE_DESC_RSP result = null;
- waitAndLock3WayConversation(request);
- final WaitForCommand waiter = new WaitForCommand(
- ZToolCMD.ZDO_SIMPLE_DESC_RSP, high);
-
- ZDO_SIMPLE_DESC_REQ_SRSP response = (ZDO_SIMPLE_DESC_REQ_SRSP) sendSynchrouns(
- high, request);
- if (response == null || response.Status != 0) {
- waiter.cleanup();
- } else {
- result = (ZDO_SIMPLE_DESC_RSP) waiter.getCommand(TIMEOUT);
- }
-
- unLock3WayConversation(request);
- return result;
- }
-
- public void run() {
- logger.info("Initializing");
- setState(DriverStatus.HARDWARE_INITIALIZING);
- if (initializeHardware() == true) {
- setState(DriverStatus.HARDWARE_READY);
- } else {
- close();
- return;
- }
-
- setState(DriverStatus.NETWORK_INITIALIZING);
- if (initializeZigBeeNetwork() == true) {
- setState(DriverStatus.NETWORK_READY);
- } else {
- /*
- * We reset the status of the driver to HARDWARE_READY because the network initialization failed
- */
- setState(DriverStatus.HARDWARE_READY);
- close();
- return;
- }
- }
-
- @SuppressWarnings("unchecked")
- private boolean initializeHardware() {
- String portToOpen = null;
- if ("auto".equalsIgnoreCase(port)) {
- logger.info("Automatic discovery the dongle port by inspecting all the serial ports...");
- Enumeration<CommPortIdentifier> ports = CommPortIdentifier
- .getPortIdentifiers();
- while (ports.hasMoreElements()) {
- CommPortIdentifier com = ports.nextElement();
- if (initializeHardware(com.getName(), rate)) {
- portToOpen = com.getName();
- Thread.currentThread().setName(
- buildDriverThreadName(portToOpen, rate, channel));
- break;
- }
- }
- if (portToOpen == null) {
- logger.error("Automatic discovery FAILED! the dongle couldn't be find on any port: it may be frozen");
- return false;
- }
- } else {
- if (initializeHardware(port, rate) == true) {
- portToOpen = port;
- } else {
- logger.error(
- "Failed to intialize the dongle on port {} at rate {}",
- port, rate);
- return false;
- }
- }
-
- low = new HWLowLevelDriver();
- try {
- low.open(portToOpen, rate);
- } catch (ZToolException e) {
- logger.error(
- "The port was already open in advance but we can't open it now",
- e);
- low.close();
- return false;
- }
- high = new HWHighLevelDriver(low);
- return true;
- }
-
- private void setState(DriverStatus value) {
- logger.info("State changed from {} to {}", this.state, value);
- synchronized (this) {
- state = value;
- notifyAll();
- }
- if (state == DriverStatus.HARDWARE_READY) {
- postHardwareEnabled();
- }
- }
-
- private void postHardwareEnabled() {
- if (!afMessageListners.isEmpty()) {
- high.addAsynchrounsCommandListener(afListner);
- }
- if (!AnnounceListners.isEmpty()) {
- high.addAsynchrounsCommandListener(AnnounceListner);
- }
- }
-
- boolean initializeHardware(String portName, int baudRate) {
- boolean result = false;
- final int received[] = new int[1];
- final HWLowLevelDriver probingDriver = new HWLowLevelDriver();
- final PacketListener monitor = new PacketListener() {
- public void packetReceived(ZToolPacket packet) {
- logger.debug("Received initializing SYS VERSION candidate");
- if (packet.getCommandId() == ZToolCMD.SYS_VERSION_RESPONSE) {
- logger.debug("Initializing Hardware: Received correctly SYS_VERSION_RESPONSE");
- synchronized (received) {
- received[0] = 3;
- }
- } else if (packet.isError()) {
- logger.debug(
- "Initializing Hardware: Received erroneous packet: {}",
- packet.getErrorMsg());
- synchronized (received) {
- received[0] += 1;
- }
- } else {
- logger.debug("Initializing Hardware: Received {}", packet
- .getClass().getName());
- synchronized (received) {
- received[0] += 1;
- }
- }
- }
- };
- probingDriver.addPacketListener(monitor);
- try {
- probingDriver.open(portName, baudRate);
- probingDriver.sendPacket(new SYS_VERSION());
- final long ready = System.currentTimeMillis() + TIMEOUT; // manlio
- // 5000;
- while (ready > System.currentTimeMillis()) {
- synchronized (received) {
- if (received[0] == 3) {
- logger.debug("Received initializing SYS VERSION");
- break;
- }
- }
-
- try {
- Thread.sleep(500);
- } catch (InterruptedException ignored) {
- logger.debug("Exception SYS VERSION");
- }
- }
- logger.debug("End of waiting for SYS VERSION");
- synchronized (received) {
- if (received[0] == 3) {
- logger.debug("Succeeded initializing SYS VERSION");
- result = true;
- }
- }
- } catch (ZToolException e) {
- logger.info("Unable to open serial port: {}", portName);
- logger.error("Unable to open serial port, due to:", e);
- } catch (IOException e) {
- logger.error("Hardware initialization failed", e);
- }
- probingDriver.close();
- probingDriver.removePacketListener(monitor);
- return result;
- }
-
- private boolean waitForHardware() {
- synchronized (this) {
- while (state == DriverStatus.CREATED
- || state == DriverStatus.CLOSED) {
- logger.debug("Waiting for HARDWARE to become ready");
- try {
- wait();
- } catch (InterruptedException ignored) {
- }
- }
- return isHardwareReady();
- }
- }
-
- private boolean waitForNetwork() {
- synchronized (this) {
- while (state != DriverStatus.NETWORK_READY
- && state != DriverStatus.CLOSED) {
- logger.debug("Waiting for NETWORK to become ready");
- try {
- wait();
- } catch (InterruptedException ignored) {
- }
- }
- return isNetworkReady();
- }
- }
-
- private boolean dongleReset() {
- if (waitForHardware() == false)
- return false;
-
- final WaitForCommand waiter = new WaitForCommand(
- ZToolCMD.SYS_RESET_RESPONSE, high);
-
- try {
- high.sendAsynchrounsCommand(new SYS_RESET(
- SYS_RESET.RESET_TYPE.SERIAL_BOOTLOADER));
- } catch (IOException e) {
- logger.error("DongleReset failed", e);
- return false;
- }
-
- SYS_RESET_RESPONSE response = (SYS_RESET_RESPONSE) waiter
- .getCommand(TIMEOUT);
-
- return response != null;
- }
-
- private boolean dongleClearState() {
- dongleSetCleanState(true);
-
- boolean result = dongleReset();
-
- dongleSetCleanState(false);
-
- return result;
- }
-
- private boolean dongleSetCleanState(boolean clean) {
- ZB_WRITE_CONFIGURATION_RSP response;
- if (clean) {
- response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchrouns(
- high,
- new ZB_WRITE_CONFIGURATION(
- ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_STARTUP_OPTION,
- new int[]{0x00000002}));
-
- if (response == null || response.Status != 0) {
- logger.info("Couldn't set ZCD_NV_STARTUP_OPTION to CLEAN_STATE");
- return false;
- } else {
- logger.info("Set ZCD_NV_STARTUP_OPTION to CLEAN_STATE");
- }
- } else {
- response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchrouns(
- high,
- new ZB_WRITE_CONFIGURATION(
- ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_STARTUP_OPTION,
- new int[]{0x00000000}));
-
- if (response == null || response.Status != 0) {
- logger.info("Couldn't set ZCD_NV_STARTUP_OPTION back to DO_NOTHING");
- return false;
- }
- }
- return true;
- }
-
- static final int[] buildChannelMask(int channel) {
- int channelMask = 1 << channel;
- int[] mask = new int[4];
- for (int i = 0; i < mask.length; i++) {
- mask[i] = Integers.getByteAsInteger(channelMask, i);
- }
- return mask;
- }
-
- private boolean dongleSetChannel(int[] channelMask) {
-
- logger.info(
- "Setting the channel to {}{}{}{}",
- new Object[]{Integer.toHexString(channelMask[0]),
- Integer.toHexString(channelMask[1]),
- Integer.toHexString(channelMask[2]),
- Integer.toHexString(channelMask[3])});
-
- ZB_WRITE_CONFIGURATION_RSP response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchrouns(
- high, new ZB_WRITE_CONFIGURATION(
- ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_CHANLIST,
- channelMask));
-
- return response != null && response.Status == 0;
- }
-
- private boolean dongleSetChannel(int ch) {
- int[] channelMask = buildChannelMask(ch);
-
- return dongleSetChannel(channelMask);
- }
-
- private boolean dongleSetChannel() {
- int[] channelMask = buildChannelMask(channel);
-
- return dongleSetChannel(channelMask);
- }
-
- private boolean dongleSetNetworkMode() {
- logger.info("Changing the Network Mode to {}", mode);
-
- ZB_WRITE_CONFIGURATION_RSP response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchrouns(
- high, new ZB_WRITE_CONFIGURATION(
- ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_LOGICAL_TYPE,
- new int[]{mode.ordinal()}));
-
- return response != null && response.Status == 0;
- }
-
- private boolean dongleSetPanId() {
- ZB_WRITE_CONFIGURATION_RSP response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchrouns(
- high,
- new ZB_WRITE_CONFIGURATION(
- ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_PANID,
- new int[]{Integers.getByteAsInteger(pan, 0),
- Integers.getByteAsInteger(pan, 1)}));
-
- return response != null && response.Status == 0;
- }
-
- private boolean createZigBeeNetwork() {
- /*
- * NOTE:The dongle has to be reset all the time to avoid that the
- * endpoints register on the dongle itself break the code at upper level
- */
- // if( reset && dongleReset() ) {
- // logger.debug("Reset the dongle before Creating ZigBee Network");
- // } else if (reset) {
- // logger.debug("FAILED to reset the dongle before Creating ZigBee Network");
- // } else {
- // logger.debug("Dongle has already been reset so no endpoint registered");
- // }
-
- createCustomDevicesOnDongle();
-
- switch (mode) {
- case COORDINATOR :
- return doCoordinatorCreateNetwork();
- case ROUTER :
- return doRouterCreateNetwok();
- case END_DEVICE :
- return doEndDeviceCreateNetwok();
- }
-
- /*
- * This code is unreachable but compiler can't find this out yet. It may
- * introduce a compilation issue of future compilers
- */
- return false;
- }
-
- /**
- * @return
- */
- private boolean doRouterCreateNetwok() {
- logger.debug("Creating network as Router");
- ZDO_STARTUP_FROM_APP_SRSP response = (ZDO_STARTUP_FROM_APP_SRSP) sendSynchrouns(
- high, new ZDO_STARTUP_FROM_APP(
- ZDO_STARTUP_FROM_APP.RESET_TYPE.TARGET_DEVICE));
- if (response == null) {
- return false;
- } else {
- return true;// TODO: response.Status ==
- // ZDO_STARTUP_FROM_APP_SRSP.AF_STATUS.SUCCESS;
- }
- }
-
- private boolean doEndDeviceCreateNetwok() {
- logger.debug("Creating network as EndDevice");
-
- ZDO_STARTUP_FROM_APP_SRSP response = (ZDO_STARTUP_FROM_APP_SRSP) sendSynchrouns(
- high, new ZDO_STARTUP_FROM_APP(
- ZDO_STARTUP_FROM_APP.RESET_TYPE.TARGET_DEVICE));
- if (response == null) {
- return false;
- } else {
- return true;// TODO: response.Status ==
- // ZDO_STARTUP_FROM_APP_SRSP.AF_STATUS.SUCCESS;
- }
- }
-
- private boolean doCoordinatorCreateNetwork() {
- logger.info("Creating network as Coordinator");
-
- ZDO_STARTUP_FROM_APP_SRSP response2 = (ZDO_STARTUP_FROM_APP_SRSP) sendSynchrouns(
- high, new ZDO_STARTUP_FROM_APP(
- ZDO_STARTUP_FROM_APP.RESET_TYPE.TARGET_DEVICE));
- if (response2 == null) {
- return false;
- } else {
- return true;// TODO response.Status ==
- // ZDO_STARTUP_FROM_APP_SRSP.AF_STATUS.SUCCESS;
- }
- }
-
- /*
- * //TODO We should check if the current setting differs from the setting
- * stored on the dongle and later define whetever to clean or not the cache
- * private boolean mustCleanStatus(){ if( cleanStatus ) { return true; }
- *
- * createZigBeeNetwork();
- *
- * int[] value;
- *
- * value = getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.CHANNEL); if (
- * value == null){ logger.error(
- * "Method getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.CHANNEL) returned null"
- * ); return true; } else if ( value[0] != this.channel ) { logger.debug(
- * "Dongle network state must be reset because channel is changed. " +
- * "Old was = {} while new is {}", value[0], this.channel); return true; }
- *
- * value = getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.PAN_ID); if (
- * value == null){ logger.error(
- * "Method getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.PAN_ID) returned null"
- * ); return true; } else if ( Integers.shortFromInts(value, 1, 0) !=
- * this.pan) {
- * logger.debug("Dongle network state must be reset because PanId is changed. "
- * + "Old was = {} while new is {}", Integers.shortFromInts(value, 1, 0),
- * this.pan); return true; }
- *
- * dongleReset();
- *
- * return false; }
- */
-
- private boolean initializeZigBeeNetwork() {
-
- boolean cleanNetworkState = cleanStatus;
-
- if (cleanNetworkState) {
- if (doCleanAndSetConfiguration() == false) {
- return false;
- }
- }
- boolean creation = createZigBeeNetwork();
- if (creation == false) {
- return false;
- }
- setState(DriverStatus.NETWORK_READY);
- if (doesCurrentConfigurationMatchZStackConfiguration()) {
- logger.warn("ZigBee Network has been initialized but it seems that " +
- "the Dongle configuration does not match the specified configuration." +
- "We are continuing to execute anyhow but the dongle may be using a" +
- "wrong ZigBee channle or connected to a different PanId or others");
- }
-
- return creation;
- }
-
- private boolean doesCurrentConfigurationMatchZStackConfiguration() {
- int value = -1;
- boolean mismatch = false;
- if ((value = getCurrentChannel()) != channel) {
- logger.warn(
- "The channel configuration differ from the channel configuration in use: "
- + "in use {}, while the configured is {}.\n"
- + "The ZigBee Stack should be flushed, try to set "
- + ConfigurationProperties.NETWORK_FLUSH
- + " to TRUE", value, channel);
- mismatch = true;
- }
- if ((value = getCurrentPanId()) != pan) {
- logger.warn(
- "The PanId configuration differ from the channel configuration in use: "
- + "in use {}, while the configured is {}.\n"
- + "The ZigBee Stack should be flushed, try to set "
- + ConfigurationProperties.NETWORK_FLUSH
- + " to TRUE", value, pan);
- mismatch = true;
- }
- if ((value = getZigBeeNodeMode()) != mode.ordinal()) {
- logger.warn(
- "The NetworkMode configuration differ from the channel configuration in use: "
- + "in use {}, while the configured is {}.\n"
- + "The ZigBee Stack should be flushed, try to set "
- + ConfigurationProperties.NETWORK_FLUSH
- + " to TRUE", value, mode.ordinal());
- mismatch = true;
- }
-
- return mismatch;
- }
-
- private boolean doCleanAndSetConfiguration() {
- logger.debug("Cleaning dongle networks stack status");
- // if( ! dongleClearState() ){
- // logger.error("Unable to CLEAN the ZigBee network stack staus");
- // return false;
- // } else {
- // logger.info("ZigBee network stack status CLEANED");
- // }
- if (!dongleSetCleanState(true)) {
- logger.error("Unable to set clean state for dongle");
- return false;
- }
- if (!dongleSetChannel()) {
- logger.error("Unable to set CHANNEL for ZigBee Network");
- return false;
- } else {
- logger.info("CHANNEL set");
- }
- if (!dongleSetPanId()) {
- logger.error("Unable to set PANID for ZigBee Network");
- return false;
- } else {
- logger.info("PANID set");
- }
- if (dongleSetNetworkMode() == false) {
- logger.error("Unable to set NETWORK_MODE for ZigBee Network");
- return false;
- } else {
- logger.info("NETWORK_MODE set");
- }
- if (!dongleReset()) {
- logger.error("Unable to reset dongle");
- return false;
- }
- if (!dongleSetCleanState(false)) {
- logger.error("Unable to unset clean state for dongle");
- return false;
- }
- // if ( dongleMasterReset() == false ) {
- // logger.error("Unable to send the master reset for ZigBee Network");
- // return false;
- // } else {
- // logger.info("master reset sent");
- // }
- return true;
- }
-
- /**
- * It was developed by TSB for their custom firmware and their custom need,
- * it is not clear what it does. Please keep it for reference but ignore the
- * method
- *
- * @deprecated
- */
- protected boolean dongleMasterReset() {
- // ---------START FROM APP
- logger.debug("Reset seq: Trying STARTFROMAPP");
- ZDO_STARTUP_FROM_APP_SRSP responseA1 = (ZDO_STARTUP_FROM_APP_SRSP) sendSynchrouns(
- high, new ZDO_STARTUP_FROM_APP(
- ZDO_STARTUP_FROM_APP.RESET_TYPE.TARGET_DEVICE));
- if (responseA1 == null) {
- logger.error("Reset seq: Failed STARTFROMAPP");
- return false;
- }
- // ---------ZB WRITE CONF
- logger.debug("Reset seq: Trying WRITECONF");
- ZB_WRITE_CONFIGURATION_RSP responseA2 = (ZB_WRITE_CONFIGURATION_RSP) sendSynchrouns(
- high, new ZB_WRITE_CONFIGURATION(3, new int[]{2}));
- if (responseA2 == null) {
- logger.error("Reset seq: Failed WRITECONF");
- return false;
- }
- // ---------GET DEVICE INFO
- logger.debug("Reset seq: Trying GETDEVICEINFO");
- // final WaitForCommand waiter1 = new WaitForCommand(
- // ZToolCMD.UTIL_GET_DEVICE_INFO_RESPONSE,
- // high
- // );
- // try{
- // high.sendAsynchrounsCommand(new UTIL_GET_DEVICE_INFO());
- // } catch (IOException e) {
- // logger.error("GetDeviceInfo of Master Reset failed", e);
- // return false;
- // }
- // UTIL_GET_DEVICE_INFO_RESPONSE responseA3 =
- // (UTIL_GET_DEVICE_INFO_RESPONSE) waiter1.getCommand(TIMEOUT);
- UTIL_GET_DEVICE_INFO_RESPONSE responseA3 = (UTIL_GET_DEVICE_INFO_RESPONSE) sendSynchrouns(
- high, new UTIL_GET_DEVICE_INFO());
- if (responseA3 == null) {
- logger.error("Reset seq: Failed GETDEVICEINFO");
- return false;
- }
- ZToolAddress16[] addresses = new ZToolAddress16[responseA3.AssocDevicesList.length];
- for (int k = 0; k < responseA3.AssocDevicesList.length; k++) {
- addresses[k] = new ZToolAddress16(
- responseA3.AssocDevicesList[k].getMsb(),
- responseA3.AssocDevicesList[k].getLsb());
- }
- // ---------ZDO GET IEEE ADDR
- logger.debug("Reset seq: Trying GETIEEEADDR");
- ZToolAddress64[] longAddresses = new ZToolAddress64[addresses.length];
- for (int k = 0; k < addresses.length; k++) {
- // ZDO_IEEE_ADDR_RSP responseA4 = sendZDOIEEEAddressRequest(new
- // ZDO_IEEE_ADDR_REQ(addresses[k],ZDO_IEEE_ADDR_REQ.REQ_TYPE.EXTENDED.getValue(),0));
-
- ZDO_IEEE_ADDR_RSP responseA4 = null;
- WaitForCommand waiter = new WaitForCommand(
- ZToolCMD.ZDO_IEEE_ADDR_RSP, high);
- logger.debug("Sending ZDO_IEEE_ADDR_REQ");
- ZDO_IEEE_ADDR_REQ_SRSP response = (ZDO_IEEE_ADDR_REQ_SRSP) sendSynchrouns(
- high, new ZDO_IEEE_ADDR_REQ(addresses[k],
- ZDO_IEEE_ADDR_REQ.REQ_TYPE.EXTENDED.getValue(), 0));
- if (response == null || response.Status != 0) {
- logger.debug("ZDO_IEEE_ADDR_REQ failed, received {}", response);
- waiter.cleanup();
- } else {
- responseA4 = (ZDO_IEEE_ADDR_RSP) waiter.getCommand(TIMEOUT);
- }
-
- if (responseA4 != null) {
- longAddresses[k] = responseA4.getIEEEAddress();
- } else {
- longAddresses[k] = null;
- }
- }
- // ---------ZDO MGMT LEAVE
- logger.debug("Reset seq: Trying LEAVE");
- long start = System.currentTimeMillis();
- for (int k = 0; k < longAddresses.length; k++) {
- if (longAddresses[k] != null) {
- WaitForCommand waiter3 = new WaitForCommand(
- ZToolCMD.ZDO_MGMT_LEAVE_RSP, high);
-
- ZDO_MGMT_LEAVE_REQ_SRSP response = (ZDO_MGMT_LEAVE_REQ_SRSP) sendSynchrouns(
- high, new ZDO_MGMT_LEAVE_REQ(addresses[k],
- longAddresses[k], 3));
- if ((System.currentTimeMillis() - start) > TIMEOUT) {
- logger.error("Reset seq: Failed LEAVE");
- return false;
- }
- if (response == null || response.Status != 0) {
- waiter3.cleanup();
- logger.error("Reset seq: Failed LEAVE");
- return false;
- } else {
- if ((System.currentTimeMillis() - start) > TIMEOUT) {
- logger.error("Reset seq: Failed LEAVE");
- return false;
- }
- ZDO_MGMT_LEAVE_RSP responseA5 = (ZDO_MGMT_LEAVE_RSP) waiter3
- .getCommand(TIMEOUT);
- if ((System.currentTimeMillis() - start) > TIMEOUT) {
- logger.error("Reset seq: Failed LEAVE");
- return false;
- }
- if (responseA5 == null
- || responseA5.Status != ZDO_MGMT_LEAVE_RSP.ZDO_STATUS.ZDP_SUCCESS) {
- logger.error("Reset seq: Failed LEAVE");
- return false;
- }
- }
- }
- if ((System.currentTimeMillis() - start) > TIMEOUT) {
- logger.error("Reset seq: Failed LEAVE");
- return false;
- }
- }
-
- // ---------SYS RESET
- logger.debug("Reset seq: Trying SYSRESET");
- if (!dongleReset()) {
- logger.error("Reset seq: Failed SYSRESET");
- return false;
- }
- // ---------START FROM APP
- // //already in initializeZigBeeNetwork
- // ZDO_STARTUP_FROM_APP_SRSP responseA7 = (ZDO_STARTUP_FROM_APP_SRSP)
- // sendSynchrouns(
- // high, new
- // ZDO_STARTUP_FROM_APP(ZDO_STARTUP_FROM_APP.RESET_TYPE.TARGET_DEVICE)
- // );
- // if (responseA7==null)return false;
- return true;
- }
-
- private ZToolPacket sendSynchrouns(final HWHighLevelDriver hwDriver,
- final ZToolPacket request) {
- final ZToolPacket[] response = new ZToolPacket[]{null};
- // final int TIMEOUT = 1000, MAX_SEND = 3;
- int sending = 1;
-
- logger.info("Sending Synchrouns {}", request.getClass().getName());
-
- SynchrounsCommandListner listener = new SynchrounsCommandListner() {
-
- public void receivedCommandResponse(ZToolPacket packet) {
- logger.info("Received Synchrouns Response {}", packet
- .getClass().getName());
- synchronized (response) {
- response[0] = packet;
- response.notify();
- }
- }
- };
-
- while (sending <= RESEND_MAX_RETRY) {
- try {
- try {
- hwDriver.sendSynchrounsCommand(request, listener,
- RESEND_TIMEOUT);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- logger.info("Sent {} during the {}-th tentative", request
- .getClass().getName(), sending);
- synchronized (response) {
- long wakeUpTime = System.currentTimeMillis()
- + RESEND_TIMEOUT;
- while (response[0] == null
- && wakeUpTime > System.currentTimeMillis()) {
- final long sleeping = wakeUpTime
- - System.currentTimeMillis();
- logger.debug(
- "Waiting for synchronous command up to {}ms till {} Unixtime",
- sleeping, wakeUpTime);
- if (sleeping <= 0) {
- break;
- }
- try {
- response.wait(sleeping);
- } catch (InterruptedException ignored) {
- }
- }
- }
- if (response[0] != null) {
- logger.debug(
- "Received synchronous command {} before timeout",
- response[0]);
- } else {
- logger.debug(
- "Timeout fired and no synchronous command received",
- response[0]);
- }
- if (RESEND_ONLY_EXCEPTION) {
- break;
- } else {
- logger.info("Failed to send {} during the {}-th tentative",
- request.getClass().getName(), sending);
- sending++;
- }
- } catch (Exception ignored) {
- logger.info("Failed to send {} during the {}-th tentative",
- request.getClass().getName(), sending);
- logger.debug("Sending operation failed due to ", ignored);
- sending++;
- }
- }
-
- return response[0];
- }
-
- public boolean addAnnounceListener(AnnounceListner listner) {
- if (AnnounceListners.isEmpty() && isHardwareReady()) {
- high.addAsynchrounsCommandListener(AnnounceListner);
- }
- return AnnounceListners.add(listner);
- }
-
- public boolean removeAnnounceListener(AnnounceListner listner) {
- boolean result = AnnounceListners.remove(listner);
- if (AnnounceListners.isEmpty() && isHardwareReady()) {
- high.removeAsynchrounsCommandListener(AnnounceListner);
- }
- return result;
- }
-
- public AF_REGISTER_SRSP sendAFRegister(AF_REGISTER request) {
- if (waitForNetwork() == false)
- return null;
-
- AF_REGISTER_SRSP response = (AF_REGISTER_SRSP) sendSynchrouns(high,
- request);
- return response;
- }
-
- public AF_DATA_CONFIRM sendAFDataRequest(AF_DATA_REQUEST request) {
- if (waitForNetwork() == false)
- return null;
- AF_DATA_CONFIRM result = null;
-
- waitAndLock3WayConversation(request);
- final WaitForCommand waiter = new WaitForCommand(
- ZToolCMD.AF_DATA_CONFIRM, high);
-
- AF_DATA_SRSP response = (AF_DATA_SRSP) sendSynchrouns(high, request);
- if (response == null || response.Status != 0) {
- waiter.cleanup();
- } else {
- result = (AF_DATA_CONFIRM) waiter.getCommand(TIMEOUT);
- }
- unLock3WayConversation(request);
- return result;
- }
-
- public ZDO_BIND_RSP sendZDOBind(ZDO_BIND_REQ request) {
- if (waitForNetwork() == false)
- return null;
- ZDO_BIND_RSP result = null;
-
- waitAndLock3WayConversation(request);
- final WaitForCommand waiter = new WaitForCommand(ZToolCMD.ZDO_BIND_RSP,
- high);
-
- ZDO_BIND_REQ_SRSP response = (ZDO_BIND_REQ_SRSP) sendSynchrouns(high,
- request);
- if (response == null || response.Status != 0) {
- waiter.cleanup();
- } else {
- result = (ZDO_BIND_RSP) waiter.getCommand(TIMEOUT);
- }
- unLock3WayConversation(request);
- return result;
- }
-
- public ZDO_UNBIND_RSP sendZDOUnbind(ZDO_UNBIND_REQ request) {
- if (waitForNetwork() == false)
- return null;
- ZDO_UNBIND_RSP result = null;
-
- waitAndLock3WayConversation(request);
- final WaitForCommand waiter = new WaitForCommand(
- ZToolCMD.ZDO_UNBIND_RSP, high);
-
- ZDO_UNBIND_REQ_SRSP response = (ZDO_UNBIND_REQ_SRSP) sendSynchrouns(
- high, request);
- if (response == null || response.Status != 0) {
- waiter.cleanup();
- } else {
- result = (ZDO_UNBIND_RSP) waiter.getCommand(TIMEOUT);
- }
-
- unLock3WayConversation(request);
- return result;
- }
-
- public boolean removeAFMessageListener(AFMessageListner listner) {
- boolean result = false;
- synchronized (afMessageListners) {
- result = afMessageListners.remove(listner);
- }
-
- if (afMessageListners.isEmpty() && isHardwareReady()) {
- if (high.removeAsynchrounsCommandListener(afListner)) {
- logger.debug(
- "Removed AsynchrounsCommandListener {} to HWHighLevelDriver",
- afListner.getClass().getName());
- } else {
- logger.debug(
- "Could not remove AsynchrounsCommandListener {} to HWHighLevelDriver",
- afListner.getClass().getName());
- }
- }
- if (result) {
- logger.debug("Removed AFMessageListner {}:{}", listner, listner
- .getClass().getName());
- return true;
- } else {
- logger.debug("Could not remove AFMessageListner {}:{}", listner,
- listner.getClass().getName());
- return false;
- }
- }
-
- public boolean addAFMessageListner(AFMessageListner listner) {
- if (afMessageListners.isEmpty() && isHardwareReady()) {
- if (high.addAsynchrounsCommandListener(afListner)) {
- logger.debug(
- "Added AsynchrounsCommandListener {} to HWHighLevelDriver",
- afListner.getClass().getName());
- } else {
- logger.debug(
- "Could not add AsynchrounsCommandListener {} to HWHighLevelDriver",
- afListner.getClass().getName());
- }
- }
- boolean result = false;
- synchronized (afMessageListners) {
- result = afMessageListners.add(listner);
- }
-
- if (result) {
- logger.debug("Added AFMessageListner {}:{}", listner, listner
- .getClass().getName());
- return true;
- } else {
- logger.debug("Could not add AFMessageListner {}:{}", listner,
- listner.getClass().getName());
- return false;
- }
- }
-
- private boolean isNetworkReady() {
- synchronized (this) {
- return state.ordinal() >= DriverStatus.NETWORK_READY.ordinal()
- && state.ordinal() < DriverStatus.CLOSED.ordinal();
- }
- }
-
- private boolean isHardwareReady() {
- synchronized (this) {
- return state.ordinal() >= DriverStatus.HARDWARE_READY.ordinal()
- && state.ordinal() < DriverStatus.CLOSED.ordinal();
- }
- }
-
- /**
- *
- * @return
- * @since 0.2.0
- */
- public long getExtendedPanId() {
- if (waitForNetwork() == false) {
- logger.info(
- "Failed to reach the {} level: getExtendedPanId() failed",
- DriverStatus.NETWORK_READY);
- return -1;
- }
-
- int[] result = getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.EXT_PAN_ID);
-
- if (result == null) {
- return -1;
- } else {
- return Integers.shortFromInts(result, 7, 0);
- }
- }
-
- /**
- *
- * @return
- * @since 0.2.0
- */
- public long getIEEEAddress() {
-
- if (ieeeAddress != -1) {
- return ieeeAddress;
- }
-
- if (waitForNetwork() == false) {
- logger.info(
- "Failed to reach the {} level: getIEEEAddress() failed",
- DriverStatus.NETWORK_READY);
- return -1;
- }
-
- int[] result = getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.IEEE_ADDR);
-
- if (result == null) {
- return -1;
- } else {
- ieeeAddress = Integers.longFromInts(result, 7, 0);
- return ieeeAddress;
- }
- }
-
- /**
- *
- * @return
- * @since 0.2.0
- */
- public int getCurrentPanId() {
- if (waitForNetwork() == false) {
- logger.info(
- "Failed to reach the {} level: getCurrentPanId() failed",
- DriverStatus.NETWORK_READY);
- return -1;
- }
-
- int[] result = getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.PAN_ID);
-
- if (result == null) {
- return -1;
- } else {
- return Integers.shortFromInts(result, 1, 0);
- }
- }
-
- /**
- *
- * @return
- * @since 0.2.0
- */
- public int getCurrentChannel() {
- if (waitForNetwork() == false) {
- logger.info(
- "Failed to reach the {} level: getCurrentChannel() failed",
- DriverStatus.NETWORK_READY);
- return -1;
- }
-
- int[] result = getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.CHANNEL);
-
- if (result == null) {
- return -1;
- } else {
- return result[0];
- }
- }
-
- /**
- *
- * @return
- * @since 0.2.0
- */
- public int getCurrentState() {
- if (waitForNetwork() == false) {
- logger.info(
- "Failed to reach the {} level: getCurrentChannel() failed",
- DriverStatus.NETWORK_READY);
- return -1;
- }
-
- int[] result = getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.STATE);
-
- if (result == null) {
- return -1;
- } else {
- return result[0];
- }
- }
-
- private int[] getDeviceInfo(int type) {
- ZB_GET_DEVICE_INFO_RSP response = (ZB_GET_DEVICE_INFO_RSP) sendSynchrouns(
- high, new ZB_GET_DEVICE_INFO(type));
-
- if (response == null) {
- logger.debug("Failed getDeviceInfo for {} due to null value", type);
- return null;
- } else if (response.Param != type) {
- logger.debug(
- "Failed getDeviceInfo for {} non matching response returned {}",
- type, response.Param);
- return null;
- } else {
- logger.debug("Successed getDeviceInfo for {}", type);
- return response.Value;
- }
- }
-
- public int getZigBeeNodeMode() {
- ZB_READ_CONFIGURATION_RSP response = (ZB_READ_CONFIGURATION_RSP) sendSynchrouns(
- high, new ZB_READ_CONFIGURATION(
- ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_LOGICAL_TYPE));
- if (response != null && response.Status == 0) {
- return response.Value[0];
- } else {
- return -1;
- }
- }
-
- public DriverStatus getDriverStatus() {
- return state;
- }
-
- private int[] ep, prof, dev, ver;
- private short[][] inp, out;
- public void addCustomDevice(String endpointNumber, String profileID,
- String deviceID, String version, String inputClusters,
- String outputCluster) {
-
- String[] inputGroupsNumber = null, outputGroupsNumber = null, inputClusterGroup = null, outputClusterGroup = null;
- if (checkString(inputClusters))
- inputGroupsNumber = inputClusters.trim().split("]");
- if (checkString(outputCluster))
- outputGroupsNumber = outputCluster.trim().split("]");
-
- if (inputGroupsNumber != null && outputGroupsNumber != null
- && inputGroupsNumber.length > 0
- && inputGroupsNumber.length == outputGroupsNumber.length) {
-
- int max = -1;
- for (int i = 0; i < inputGroupsNumber.length; i++) {
- inputGroupsNumber[i] = inputGroupsNumber[i].replace("[", "");
- inputGroupsNumber[i] = inputGroupsNumber[i].replace("]", "");
- inputGroupsNumber[i] = inputGroupsNumber[i].replace(" ", "");
-
- int temp = inputGroupsNumber[i].trim().split(",").length;
- if (temp > max)
- max = temp;
- }
- inp = new short[inputGroupsNumber.length][max];
- for (int i = 0; i < inputGroupsNumber.length; i++) {
- inputClusterGroup = inputGroupsNumber[i].trim().split(",");
- for (int j = 0; j < inputClusterGroup.length; j++) {
- if (toShort(inputClusterGroup[j]) != -1)
- inp[i][j] = toShort(inputClusterGroup[j]);
- }
- }
-
- max = -1;
- for (int i = 0; i < outputGroupsNumber.length; i++) {
- outputGroupsNumber[i] = outputGroupsNumber[i].replace("[", "");
- outputGroupsNumber[i] = outputGroupsNumber[i].replace("]", "");
- outputGroupsNumber[i] = outputGroupsNumber[i].replace(" ", "");
-
- int temp = outputGroupsNumber[i].trim().split(",").length;
- if (temp > max)
- max = temp;
- }
- out = new short[outputGroupsNumber.length][max];
- for (int i = 0; i < outputGroupsNumber.length; i++) {
- outputClusterGroup = outputGroupsNumber[i].trim().split(",");
- for (int j = 0; j < outputClusterGroup.length; j++) {
- if (toShort(outputClusterGroup[j]) != -1)
- out[i][j] = toShort(outputClusterGroup[j]);
- }
- }
-
- ep = new int[inputGroupsNumber.length];
- prof = new int[inputGroupsNumber.length];
- dev = new int[inputGroupsNumber.length];
- ver = new int[inputGroupsNumber.length];
-
- String[] eps = endpointNumber.trim().split(",");
- for (int i = 0; i < eps.length; i++) {
- ep[i] = toShort(eps[i]);
- }
- String[] profs = profileID.trim().split(",");
- for (int i = 0; i < profs.length; i++) {
- prof[i] = toShort(profs[i]);
- }
- String[] devs = deviceID.trim().split(",");
- for (int i = 0; i < devs.length; i++) {
- dev[i] = toShort(devs[i]);
- }
- String[] vers = version.trim().split(",");
- for (int i = 0; i < vers.length; i++) {
- ver[i] = toShort(vers[i]);
- }
- }
- }
-
- private boolean checkString(String s) {
- if (s != null && !s.isEmpty())
- return true;
-
- return false;
- }
-
- private Short toShort(String s) {
-
- try {
- return Short.parseShort(s);
- } catch (Exception ex) {
- return -1;
- }
- }
-
- public void createCustomDevicesOnDongle() {
-
- short[] input, output;
-
- if (this.ep != null)
- for (int i = 0; i < this.ep.length; i++) {
- // input
- int size = 0;
- for (int j = 0; j < this.inp[i].length; j++) {
-
- if (this.inp[i][j] != 0 && this.inp[i][j] != -1)
- size++;
- }
-
- input = new short[size];
- for (int j = 0; j < this.inp[i].length; j++) {
-
- if (this.inp[i][j] != 0 && this.inp[i][j] != -1)
- input[j] = this.inp[i][j];
- }
-
- // output
- size = 0;
- for (int j = 0; j < this.out[i].length; j++) {
-
- if (this.out[i][j] != 0 && this.out[i][j] != -1)
- size++;
- }
-
- output = new short[size];
- for (int j = 0; j < this.out[i].length; j++) {
-
- if (this.out[i][j] != 0 && this.out[i][j] != -1)
- output[j] = this.out[i][j];
- }
-
- if (newDevice(new AF_REGISTER(new Byte(this.ep[i] + ""),
- new Short(this.prof[i] + ""), new Short(this.dev[i]
- + ""), new Byte(this.ver[i] + ""), input,
- output)))
- logger.debug(
- "Custom device {} corrected registered at endpoint {}",
- this.dev[i], this.ep[i]);
- else
- logger.debug(
- "Custom device {} registration failed at endpoint {}",
- this.dev[i], this.ep[i]);
- }
- }
-
- public boolean newDevice(AF_REGISTER request) {
-
- try {
- AF_REGISTER_SRSP response = (AF_REGISTER_SRSP) sendSynchrouns(high,
- request);
- if (response != null && response.Status == 0)
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return false;
- }
-
- public boolean isResendOnlyOnException() {
- return RESEND_ONLY_EXCEPTION;
- }
+ private final static Logger logger = LoggerFactory
+ .getLogger(DriverCC2530.class);
+
+ public static final int RESEND_TIMEOUT_DEFAULT = 1000;
+ public static final String RESEND_TIMEOUT_KEY = "zigbee.driver.cc2530.resend.timeout";
+
+ public static final int RESEND_MAX_RESEND_DEFAULT = 3;
+ public static final String RESEND_MAX_RESEND_KEY = "zigbee.driver.cc2530.resend.max";
+
+ public static final boolean RESEND_ONLY_EXCEPTION_DEFAULT = true;
+ public static final String RESEND_ONLY_EXCEPTION_KEY = "zigbee.driver.cc2530.resend.exceptionally";
+
+ private final int TIMEOUT;
+ public static final int DEFAULT_TIMEOUT = 5000;
+ public static final String TIMEOUT_KEY = "zigbee.driver.cc2530.timeout";
+
+ private Thread driver;
+
+ private HWHighLevelDriver high;
+ private HWLowLevelDriver low;
+ private String port;
+ private int rate;
+ private volatile DriverStatus state;
+ private NetworkMode mode;
+ private short pan;
+ private byte channel;
+ private boolean cleanStatus;
+
+ private final int RESEND_TIMEOUT;
+ private final int RESEND_MAX_RETRY;
+ private final boolean RESEND_ONLY_EXCEPTION;
+
+ private final HashSet<AnnounceListner> AnnounceListners = new HashSet<AnnounceListner>();
+ private final AnnunceListerFilter AnnounceListner = new AnnunceListerFilter(
+ AnnounceListners);
+
+ private final ArrayList<AFMessageListner> afMessageListners = new ArrayList<AFMessageListner>();
+ private final AFMessageListnerFilter afListner = new AFMessageListnerFilter(
+ afMessageListners);
+
+ private long ieeeAddress = -1;
+ private final HashMap<Class<?>, Thread> conversation3Way = new HashMap<Class<?>, Thread>();
+
+ private class AnnunceListerFilter implements AsynchrounsCommandListener {
+
+ private final Collection<AnnounceListner> listners;
+
+ private AnnunceListerFilter(Collection<AnnounceListner> list) {
+ listners = list;
+ }
+
+ public void receivedAsynchrounsCommand(ZToolPacket packet) {
+ if (packet.isError())
+ return;
+ if (packet.getCMD().get16BitValue() == ZToolCMD.ZDO_END_DEVICE_ANNCE_IND) {
+ logger.debug("Recieved announce message {} value is {}",
+ packet.getClass(), packet);
+ ZDO_END_DEVICE_ANNCE_IND annunce = (ZDO_END_DEVICE_ANNCE_IND) packet;
+ for (AnnounceListner l : listners) {
+ l.notify(annunce.SrcAddr, annunce.IEEEAddr,
+ annunce.NwkAddr, annunce.Capabilities);
+ }
+ } else if (packet.getCMD().get16BitValue() == ZToolCMD.ZDO_STATE_CHANGE_IND) {
+ try {
+ ZDO_STATE_CHANGE_IND p = ((ZDO_STATE_CHANGE_IND) packet);
+ /*
+ * DEV_HOLD=0x00, // Initialized - not started automatically
+ * DEV_INIT=0x01, // Initialized - not connected to anything
+ * DEV_NWK_DISC=0x02, // Discovering PAN's to join
+ * DEV_NWK_JOINING=0x03, // Joining a PAN DEV_NWK_=0x04, //
+ * ReJoining a PAN, only for end-devices
+ * DEV_END_DEVICE_UNAUTH=0x05, // Joined but not yet
+ * authenticated by trust center DEV_END_DEVICE=0x06, //
+ * Started as device after authentication DEV_ROUTER=0x07,
+ * // Device joined, authenticated and is a router
+ * DEV_COORD_STARTING=0x08, // Started as Zigbee Coordinator
+ * DEV_ZB_COORD=0x09, // Started as Zigbee Coordinator
+ * DEV_NWK_ORPHAN=0x0A // Device has lost information about
+ * its parent
+ */
+ switch (p.State) {
+ case 0:
+ logger.debug("Initialized - not started automatically");
+ break;
+ case 1:
+ logger.debug("Initialized - not connected to anything");
+ break;
+ case 2:
+ logger.debug("Discovering PANs to join or waiting for permit join");
+ break;
+ case 3:
+ logger.debug("Joining a PAN");
+ break;
+ case 4:
+ logger.debug("Rejoining a PAN, only for end-devices");
+ break;
+ case 5:
+ logger.debug("Joined but not yet authenticated by trust center");
+ break;
+ case 6:
+ logger.debug("Started as device after authentication");
+ break;
+ case 7:
+ logger.debug("Device joined, authenticated and is a router");
+ break;
+ case 8:
+ logger.debug("Starting as Zigbee Coordinator");
+ break;
+ case 9:
+ logger.debug("Started as Zigbee Coordinator");
+ break;
+ case 10:
+ logger.debug("Device has lost information about its parent");
+ break;
+ default:
+ break;
+ }
+ } catch (Exception ex) {
+ // ignored
+ }
+ }
+ }
+ }
+
+ private class AFMessageListnerFilter implements AsynchrounsCommandListener {
+
+ private final Collection<AFMessageListner> listners;
+
+ private AFMessageListnerFilter(Collection<AFMessageListner> list) {
+ listners = list;
+ }
+
+ public void receivedAsynchrounsCommand(ZToolPacket packet) {
+ if (packet.isError())
+ return;
+ if (packet.getCMD().get16BitValue() == ZToolCMD.AF_INCOMING_MSG) {
+ AF_INCOMING_MSG msg = (AF_INCOMING_MSG) packet;
+ if (listners.isEmpty()) {
+ logger.debug(
+ "Received AF_INCOMING_MSG but no listeners. Message was: {} ",
+ msg);
+ } else {
+ logger.debug(
+ "Received AF_INCOMING_MSG notifying {} listeners of {}",
+ listners.size(), msg);
+ }
+ ArrayList<AFMessageListner> localCopy = null;
+ synchronized (listners) {
+ localCopy = new ArrayList<AFMessageListner>(listners);
+ }
+ for (AFMessageListner l : localCopy) {
+ l.notify(msg);
+ }
+ }
+ }
+ }
+
+ public DriverCC2530(String serialPort, int bitRate) throws ZToolException {
+
+ this(serialPort, bitRate, NetworkMode.COORDINATOR, 0, 19, false);
+ }
+
+ public DriverCC2530(String serialPort, int bitRate, NetworkMode mode,
+ int pan, int channel) throws ZToolException {
+
+ this(serialPort, bitRate, mode, pan, channel, false);
+ }
+
+ public DriverCC2530(String serialPort, int bitRate, NetworkMode mode,
+ int pan, int channel, boolean cleanNetworkStatus)
+ throws ZToolException {
+
+ this(serialPort, bitRate, mode, pan, channel, cleanNetworkStatus, 20000);
+ }
+
+ public DriverCC2530(String serialPort, int bitRate, NetworkMode mode,
+ int pan, int channel, boolean cleanNetworkStatus, long timeout)
+ throws ZToolException {
+
+ int aux = RESEND_TIMEOUT_DEFAULT;
+ try {
+ aux = Integer.parseInt(System.getProperty(RESEND_TIMEOUT_KEY));
+ logger.debug("Using RESEND_TIMEOUT set from enviroment {}", aux);
+ } catch (NumberFormatException ex) {
+ logger.debug("Using RESEND_TIMEOUT set as DEFAULT {}", aux);
+ }
+ RESEND_TIMEOUT = aux;
+
+ aux = (int) Math.max(DEFAULT_TIMEOUT, timeout);
+ try {
+ aux = Integer.parseInt(System.getProperty(TIMEOUT_KEY));
+ logger.debug("Using TIMEOUT set from enviroment {}", aux);
+ } catch (NumberFormatException ex) {
+ logger.debug("Using TIMEOUT set as DEFAULT {}ms", aux);
+ }
+ TIMEOUT = aux;
+
+ aux = RESEND_MAX_RESEND_DEFAULT;
+ try {
+ aux = Integer.parseInt(System.getProperty(RESEND_MAX_RESEND_KEY));
+ logger.debug("Using RESEND_MAX_RETRY set from enviroment {}", aux);
+ } catch (NumberFormatException ex) {
+ logger.debug("Using RESEND_MAX_RETRY set as DEFAULT {}", aux);
+ }
+ RESEND_MAX_RETRY = aux;
+
+ String p = System.getProperty(RESEND_ONLY_EXCEPTION_KEY);
+ if (p != null) {
+ RESEND_ONLY_EXCEPTION = Boolean.parseBoolean(p);
+ logger.debug("Using RESEND_ONLY_EXCEPTION set from environment {}",
+ RESEND_ONLY_EXCEPTION);
+ } else {
+ RESEND_ONLY_EXCEPTION = RESEND_ONLY_EXCEPTION_DEFAULT;
+ logger.debug("Using RESEND_ONLY_EXCEPTION set as DEFAULT {}",
+ RESEND_ONLY_EXCEPTION);
+ }
+
+ state = DriverStatus.CLOSED;
+ this.cleanStatus = cleanNetworkStatus;
+ setSerialPort(serialPort, bitRate);
+ setZigBeeNetwork((byte) channel, (short) pan);
+ setZigBeeNodeMode(mode);
+ }
+
+ private String buildDriverThreadName(String serialPort, int bitrate,
+ int channel) {
+ return "SimpleDriver[" + serialPort + "," + bitrate + "]";
+ }
+
+ public void setZigBeeNodeMode(NetworkMode m) {
+ if (state != DriverStatus.CLOSED) {
+ throw new IllegalStateException("Network mode can be changed only "
+ + "if driver is CLOSED while it is:" + state);
+ }
+ cleanStatus = mode != m;
+ mode = m;
+ }
+
+ public void setZigBeeNetwork(byte ch, short panId) {
+ if (state != DriverStatus.CLOSED) {
+ throw new IllegalStateException("Network mode can be changed only "
+ + "if driver is CLOSED while it is:" + state);
+ }
+ cleanStatus = ch != channel || panId != pan;
+ channel = ch;
+ pan = panId;
+ }
+
+ public void setSerialPort(String serialName, int bitRate) {
+ if (state != DriverStatus.CLOSED) {
+ throw new IllegalStateException("Serial port can be changed only "
+ + "if driver is CLOSED while it is:" + state);
+ }
+ port = serialName;
+ rate = bitRate;
+ }
+
+ public void open(boolean cleanCache) {
+ cleanStatus = cleanCache;
+ open();
+ }
+
+ public void open() {
+ if (state == DriverStatus.CLOSED) {
+ state = DriverStatus.CREATED;
+ driver = new Thread(this);
+ driver.setName(buildDriverThreadName(port, rate, channel));
+ driver.start();
+ } else {
+ throw new IllegalStateException(
+ "Driver already opened, current status is:" + state);
+ }
+ }
+
+ public void close() {
+ if (state == DriverStatus.CLOSED) {
+ logger.debug("Already CLOSED");
+ return;
+ }
+ logger.info("Closing");
+ if (Thread.currentThread() != driver) {
+ logger.debug("Waiting for initialization operation to complete before closing.");
+ try {
+ driver.join();
+ } catch (InterruptedException ignored) {
+ }
+ } else {
+ logger.debug("Self closing");
+ }
+ if (state == DriverStatus.NETWORK_READY) {
+ logger.debug("Closing NETWORK");
+ setState(DriverStatus.HARDWARE_READY);
+ }
+ if (state == DriverStatus.HARDWARE_READY
+ || state == DriverStatus.NETWORK_INITIALIZING) {
+ logger.debug("Closing HARDWARE");
+ high.close();
+ logger.debug("Closing LOW HARDWARE");
+ low.close();
+ setState(DriverStatus.CREATED);
+ }
+ if (state == DriverStatus.CREATED) {
+ setState(DriverStatus.CLOSED);
+ }
+ logger.info("Closed");
+ }
+
+ public ZDO_MGMT_LQI_RSP sendLQIRequest(ZDO_MGMT_LQI_REQ request) {
+
+ if (waitForNetwork() == false)
+ return null;
+ ZDO_MGMT_LQI_RSP result = null;
+
+ waitAndLock3WayConversation(request);
+ final WaitForCommand waiter = new WaitForCommand(
+ ZToolCMD.ZDO_MGMT_LQI_RSP, high);
+
+ logger.debug("Sending ZDO_MGMT_LQI_REQ {}", request);
+ ZDO_MGMT_LQI_REQ_SRSP response = (ZDO_MGMT_LQI_REQ_SRSP) sendSynchrouns(
+ high, request);
+ if (response == null || response.Status != 0) {
+ logger.debug("ZDO_MGMT_LQI_REQ failed, received {}", response);
+ waiter.cleanup();
+ } else {
+ result = (ZDO_MGMT_LQI_RSP) waiter.getCommand(TIMEOUT);
+ }
+ unLock3WayConversation(request);
+ return result;
+ }
+
+ public ZDO_IEEE_ADDR_RSP sendZDOIEEEAddressRequest(ZDO_IEEE_ADDR_REQ request) {
+ if (waitForNetwork() == false)
+ return null;
+ ZDO_IEEE_ADDR_RSP result = null;
+
+ waitAndLock3WayConversation(request);
+ final WaitForCommand waiter = new WaitForCommand(
+ ZToolCMD.ZDO_IEEE_ADDR_RSP, high);
+
+ logger.debug("Sending ZDO_IEEE_ADDR_REQ {}", request);
+ ZDO_IEEE_ADDR_REQ_SRSP response = (ZDO_IEEE_ADDR_REQ_SRSP) sendSynchrouns(
+ high, request);
+ if (response == null || response.Status != 0) {
+ logger.debug("ZDO_IEEE_ADDR_REQ failed, received {}", response);
+ waiter.cleanup();
+ } else {
+ result = (ZDO_IEEE_ADDR_RSP) waiter.getCommand(TIMEOUT);
+ }
+ unLock3WayConversation(request);
+ return result;
+ }
+
+ public ZDO_NODE_DESC_RSP sendZDONodeDescriptionRequest(
+ ZDO_NODE_DESC_REQ request) {
+ if (waitForNetwork() == false)
+ return null;
+ ZDO_NODE_DESC_RSP result = null;
+
+ waitAndLock3WayConversation(request);
+ final WaitForCommand waiter = new WaitForCommand(
+ ZToolCMD.ZDO_NODE_DESC_RSP, high);
+
+ ZDO_NODE_DESC_REQ_SRSP response = (ZDO_NODE_DESC_REQ_SRSP) sendSynchrouns(
+ high, request);
+ if (response == null || response.Status != 0) {
+ waiter.cleanup();
+ } else {
+ result = (ZDO_NODE_DESC_RSP) waiter.getCommand(TIMEOUT);
+ }
+
+ unLock3WayConversation(request);
+ return result;
+ }
+
+ public ZDO_ACTIVE_EP_RSP sendZDOActiveEndPointRequest(
+ ZDO_ACTIVE_EP_REQ request) {
+ if (waitForNetwork() == false)
+ return null;
+ ZDO_ACTIVE_EP_RSP result = null;
+
+ waitAndLock3WayConversation(request);
+ final WaitForCommand waiter = new WaitForCommand(
+ ZToolCMD.ZDO_ACTIVE_EP_RSP, high);
+
+ logger.debug("Sending ZDO_ACTIVE_EP_REQ {}", request);
+ ZDO_ACTIVE_EP_REQ_SRSP response = (ZDO_ACTIVE_EP_REQ_SRSP) sendSynchrouns(
+ high, request);
+ if (response == null || response.Status != 0) {
+ logger.debug("ZDO_ACTIVE_EP_REQ failed, received {}", response);
+ waiter.cleanup();
+ } else {
+ result = (ZDO_ACTIVE_EP_RSP) waiter.getCommand(TIMEOUT);
+ }
+ unLock3WayConversation(request);
+ return result;
+ }
+
+ /**
+ * @param request
+ */
+ private void waitAndLock3WayConversation(ZToolPacket request) {
+ synchronized (conversation3Way) {
+ Class<?> clz = request.getClass();
+ Thread requestor = null;
+ while ((requestor = conversation3Way.get(clz)) != null) {
+ if (requestor.isAlive() == false) {
+ logger.error("Thread {} whom requested {} DIED before unlocking the conversation");
+ logger.debug("The thread {} who was waiting for {} to complete DIED, so we have to remove the lock");
+ conversation3Way.put(clz, null);
+ break;
+ }
+ logger.debug(
+ "{} is waiting for {} to complete which was issued by {} to complete",
+ new Object[] { Thread.currentThread(), clz, requestor });
+ try {
+ conversation3Way.wait();
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ } catch (IllegalMonitorStateException ex) {
+ ex.printStackTrace();
+ }
+ }
+ conversation3Way.put(clz, Thread.currentThread());
+ }
+ }
+
+ /**
+ * Release the lock held for the 3-way communication
+ *
+ * @param request
+ */
+ private void unLock3WayConversation(ZToolPacket request) {
+ Class<?> clz = request.getClass();
+ Thread requestor = null;
+ synchronized (conversation3Way) {
+ requestor = conversation3Way.get(clz);
+ conversation3Way.put(clz, null);
+ conversation3Way.notifyAll();
+ }
+ if (requestor == null) {
+ logger.error(
+ "LOCKING BROKEN - SOMEONE RELEASE THE LOCK WITHOUT LOCKING IN ADVANCE for {}",
+ clz);
+ } else if (requestor != Thread.currentThread()) {
+ logger.error("Thread {} stolen the answer of {} waited by {}",
+ new Object[] { Thread.currentThread(), clz, requestor });
+ }
+ }
+
+ public ZDO_SIMPLE_DESC_RSP sendZDOSimpleDescriptionRequest(
+ ZDO_SIMPLE_DESC_REQ request) {
+ if (waitForNetwork() == false)
+ return null;
+ ZDO_SIMPLE_DESC_RSP result = null;
+ waitAndLock3WayConversation(request);
+ final WaitForCommand waiter = new WaitForCommand(
+ ZToolCMD.ZDO_SIMPLE_DESC_RSP, high);
+
+ ZDO_SIMPLE_DESC_REQ_SRSP response = (ZDO_SIMPLE_DESC_REQ_SRSP) sendSynchrouns(
+ high, request);
+ if (response == null || response.Status != 0) {
+ waiter.cleanup();
+ } else {
+ result = (ZDO_SIMPLE_DESC_RSP) waiter.getCommand(TIMEOUT);
+ }
+
+ unLock3WayConversation(request);
+ return result;
+ }
+
+ public void run() {
+ logger.info("Initializing");
+ setState(DriverStatus.HARDWARE_INITIALIZING);
+ if (initializeHardware() == true) {
+ setState(DriverStatus.HARDWARE_READY);
+ } else {
+ close();
+ return;
+ }
+
+ setState(DriverStatus.NETWORK_INITIALIZING);
+ if (initializeZigBeeNetwork() == true) {
+ setState(DriverStatus.NETWORK_READY);
+ } else {
+ /*
+ * We reset the status of the driver to HARDWARE_READY because the
+ * network initialization failed
+ */
+ setState(DriverStatus.HARDWARE_READY);
+ close();
+ return;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private boolean initializeHardware() {
+ String portToOpen = null;
+ if ("auto".equalsIgnoreCase(port)) {
+ logger.info("Automatic discovery the dongle port by inspecting all the serial ports...");
+ Enumeration<CommPortIdentifier> ports = CommPortIdentifier
+ .getPortIdentifiers();
+ while (ports.hasMoreElements()) {
+ CommPortIdentifier com = ports.nextElement();
+ if (initializeHardware(com.getName(), rate)) {
+ portToOpen = com.getName();
+ Thread.currentThread().setName(
+ buildDriverThreadName(portToOpen, rate, channel));
+ break;
+ }
+ }
+ if (portToOpen == null) {
+ logger.error("Automatic discovery FAILED! the dongle couldn't be find on any port: it may be frozen");
+ return false;
+ }
+ } else {
+ if (initializeHardware(port, rate) == true) {
+ portToOpen = port;
+ } else {
+ logger.error(
+ "Failed to intialize the dongle on port {} at rate {}",
+ port, rate);
+ return false;
+ }
+ }
+
+ low = new HWLowLevelDriver();
+ try {
+ low.open(portToOpen, rate);
+ } catch (ZToolException e) {
+ logger.error(
+ "The port was already open in advance but we can't open it now",
+ e);
+ low.close();
+ return false;
+ }
+ high = new HWHighLevelDriver(low);
+ return true;
+ }
+
+ private void setState(DriverStatus value) {
+ logger.info("State changed from {} to {}", this.state, value);
+ synchronized (this) {
+ state = value;
+ notifyAll();
+ }
+ if (state == DriverStatus.HARDWARE_READY) {
+ postHardwareEnabled();
+ }
+ }
+
+ private void postHardwareEnabled() {
+ if (!afMessageListners.isEmpty()) {
+ high.addAsynchrounsCommandListener(afListner);
+ }
+ if (!AnnounceListners.isEmpty()) {
+ high.addAsynchrounsCommandListener(AnnounceListner);
+ }
+ }
+
+ boolean initializeHardware(String portName, int baudRate) {
+ boolean result = false;
+ final int received[] = new int[1];
+ final HWLowLevelDriver probingDriver = new HWLowLevelDriver();
+ final PacketListener monitor = new PacketListener() {
+ public void packetReceived(ZToolPacket packet) {
+ logger.debug("Received initializing SYS VERSION candidate");
+ if (packet.getCommandId() == ZToolCMD.SYS_VERSION_RESPONSE) {
+ logger.debug("Initializing Hardware: Received correctly SYS_VERSION_RESPONSE");
+ synchronized (received) {
+ received[0] = 3;
+ }
+ } else if (packet.isError()) {
+ logger.debug(
+ "Initializing Hardware: Received erroneous packet: {}",
+ packet.getErrorMsg());
+ synchronized (received) {
+ received[0] += 1;
+ }
+ } else {
+ logger.debug("Initializing Hardware: Received {}", packet
+ .getClass().getName());
+ synchronized (received) {
+ received[0] += 1;
+ }
+ }
+ }
+ };
+ probingDriver.addPacketListener(monitor);
+ try {
+ probingDriver.open(portName, baudRate);
+ probingDriver.sendPacket(new SYS_VERSION());
+ final long ready = System.currentTimeMillis() + TIMEOUT; // manlio
+ // 5000;
+ while (ready > System.currentTimeMillis()) {
+ synchronized (received) {
+ if (received[0] == 3) {
+ logger.debug("Received initializing SYS VERSION");
+ break;
+ }
+ }
+
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException ignored) {
+ logger.debug("Exception SYS VERSION");
+ }
+ }
+ logger.debug("End of waiting for SYS VERSION");
+ synchronized (received) {
+ if (received[0] == 3) {
+ logger.debug("Succeeded initializing SYS VERSION");
+ result = true;
+ }
+ }
+ } catch (ZToolException e) {
+ logger.info("Unable to open serial port: {}", portName);
+ logger.error("Unable to open serial port, due to:", e);
+ } catch (IOException e) {
+ logger.error("Hardware initialization failed", e);
+ }
+ probingDriver.close();
+ probingDriver.removePacketListener(monitor);
+ return result;
+ }
+
+ private boolean waitForHardware() {
+ synchronized (this) {
+ while (state == DriverStatus.CREATED
+ || state == DriverStatus.CLOSED) {
+ logger.debug("Waiting for HARDWARE to become ready");
+ try {
+ wait();
+ } catch (InterruptedException ignored) {
+ }
+ }
+ return isHardwareReady();
+ }
+ }
+
+ private boolean waitForNetwork() {
+ synchronized (this) {
+ while (state != DriverStatus.NETWORK_READY
+ && state != DriverStatus.CLOSED) {
+ logger.debug("Waiting for NETWORK to become ready");
+ try {
+ wait();
+ } catch (InterruptedException ignored) {
+ }
+ }
+ return isNetworkReady();
+ }
+ }
+
+ private boolean dongleReset() {
+ if (waitForHardware() == false)
+ return false;
+
+ final WaitForCommand waiter = new WaitForCommand(
+ ZToolCMD.SYS_RESET_RESPONSE, high);
+
+ try {
+ high.sendAsynchrounsCommand(new SYS_RESET(
+ SYS_RESET.RESET_TYPE.SERIAL_BOOTLOADER));
+ } catch (IOException e) {
+ logger.error("DongleReset failed", e);
+ return false;
+ }
+
+ SYS_RESET_RESPONSE response = (SYS_RESET_RESPONSE) waiter
+ .getCommand(TIMEOUT);
+
+ return response != null;
+ }
+
+ private boolean dongleClearState() {
+ dongleSetCleanState(true);
+
+ boolean result = dongleReset();
+
+ dongleSetCleanState(false);
+
+ return result;
+ }
+
+ private boolean dongleSetCleanState(boolean clean) {
+ ZB_WRITE_CONFIGURATION_RSP response;
+ if (clean) {
+ response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchrouns(
+ high,
+ new ZB_WRITE_CONFIGURATION(
+ ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_STARTUP_OPTION,
+ new int[] { 0x00000002 }));
+
+ if (response == null || response.Status != 0) {
+ logger.info("Couldn't set ZCD_NV_STARTUP_OPTION to CLEAN_STATE");
+ return false;
+ } else {
+ logger.info("Set ZCD_NV_STARTUP_OPTION to CLEAN_STATE");
+ }
+ } else {
+ response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchrouns(
+ high,
+ new ZB_WRITE_CONFIGURATION(
+ ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_STARTUP_OPTION,
+ new int[] { 0x00000000 }));
+
+ if (response == null || response.Status != 0) {
+ logger.info("Couldn't set ZCD_NV_STARTUP_OPTION back to DO_NOTHING");
+ return false;
+ }
+ }
+ return true;
+ }
+
+ static final int[] buildChannelMask(int channel) {
+ int channelMask = 1 << channel;
+ int[] mask = new int[4];
+ for (int i = 0; i < mask.length; i++) {
+ mask[i] = Integers.getByteAsInteger(channelMask, i);
+ }
+ return mask;
+ }
+
+ private boolean dongleSetChannel(int[] channelMask) {
+
+ logger.info(
+ "Setting the channel to {}{}{}{}",
+ new Object[] { Integer.toHexString(channelMask[0]),
+ Integer.toHexString(channelMask[1]),
+ Integer.toHexString(channelMask[2]),
+ Integer.toHexString(channelMask[3]) });
+
+ ZB_WRITE_CONFIGURATION_RSP response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchrouns(
+ high, new ZB_WRITE_CONFIGURATION(
+ ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_CHANLIST,
+ channelMask));
+
+ return response != null && response.Status == 0;
+ }
+
+ private boolean dongleSetChannel(int ch) {
+ int[] channelMask = buildChannelMask(ch);
+
+ return dongleSetChannel(channelMask);
+ }
+
+ private boolean dongleSetChannel() {
+ int[] channelMask = buildChannelMask(channel);
+
+ return dongleSetChannel(channelMask);
+ }
+
+ private boolean dongleSetNetworkMode() {
+ logger.info("Changing the Network Mode to {}", mode);
+
+ ZB_WRITE_CONFIGURATION_RSP response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchrouns(
+ high, new ZB_WRITE_CONFIGURATION(
+ ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_LOGICAL_TYPE,
+ new int[] { mode.ordinal() }));
+
+ return response != null && response.Status == 0;
+ }
+
+ private boolean dongleSetPanId() {
+ ZB_WRITE_CONFIGURATION_RSP response = (ZB_WRITE_CONFIGURATION_RSP) sendSynchrouns(
+ high,
+ new ZB_WRITE_CONFIGURATION(
+ ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_PANID,
+ new int[] { Integers.getByteAsInteger(pan, 0),
+ Integers.getByteAsInteger(pan, 1) }));
+
+ return response != null && response.Status == 0;
+ }
+
+ private boolean createZigBeeNetwork() {
+ /*
+ * NOTE:The dongle has to be reset all the time to avoid that the
+ * endpoints register on the dongle itself break the code at upper level
+ */
+ // if( reset && dongleReset() ) {
+ // logger.debug("Reset the dongle before Creating ZigBee Network");
+ // } else if (reset) {
+ // logger.debug("FAILED to reset the dongle before Creating ZigBee Network");
+ // } else {
+ // logger.debug("Dongle has already been reset so no endpoint registered");
+ // }
+
+ createCustomDevicesOnDongle();
+
+ switch (mode) {
+ case COORDINATOR:
+ return doCoordinatorCreateNetwork();
+ case ROUTER:
+ return doRouterCreateNetwok();
+ case END_DEVICE:
+ return doEndDeviceCreateNetwok();
+ }
+
+ /*
+ * This code is unreachable but compiler can't find this out yet. It may
+ * introduce a compilation issue of future compilers
+ */
+ return false;
+ }
+
+ /**
+ * @return
+ */
+ private boolean doRouterCreateNetwok() {
+ logger.debug("Creating network as Router");
+ ZDO_STARTUP_FROM_APP_SRSP response = (ZDO_STARTUP_FROM_APP_SRSP) sendSynchrouns(
+ high, new ZDO_STARTUP_FROM_APP(
+ ZDO_STARTUP_FROM_APP.RESET_TYPE.TARGET_DEVICE));
+ if (response == null) {
+ return false;
+ } else {
+ return true;// TODO: response.Status ==
+ // ZDO_STARTUP_FROM_APP_SRSP.AF_STATUS.SUCCESS;
+ }
+ }
+
+ private boolean doEndDeviceCreateNetwok() {
+ logger.debug("Creating network as EndDevice");
+
+ ZDO_STARTUP_FROM_APP_SRSP response = (ZDO_STARTUP_FROM_APP_SRSP) sendSynchrouns(
+ high, new ZDO_STARTUP_FROM_APP(
+ ZDO_STARTUP_FROM_APP.RESET_TYPE.TARGET_DEVICE));
+ if (response == null) {
+ return false;
+ } else {
+ return true;// TODO: response.Status ==
+ // ZDO_STARTUP_FROM_APP_SRSP.AF_STATUS.SUCCESS;
+ }
+ }
+
+ private boolean doCoordinatorCreateNetwork() {
+ logger.info("Creating network as Coordinator");
+
+ ZDO_STARTUP_FROM_APP_SRSP response2 = (ZDO_STARTUP_FROM_APP_SRSP) sendSynchrouns(
+ high, new ZDO_STARTUP_FROM_APP(
+ ZDO_STARTUP_FROM_APP.RESET_TYPE.TARGET_DEVICE));
+ if (response2 == null) {
+ return false;
+ } else {
+ return true;// TODO response.Status ==
+ // ZDO_STARTUP_FROM_APP_SRSP.AF_STATUS.SUCCESS;
+ }
+ }
+
+ /*
+ * //TODO We should check if the current setting differs from the setting
+ * stored on the dongle and later define whetever to clean or not the cache
+ * private boolean mustCleanStatus(){ if( cleanStatus ) { return true; }
+ *
+ * createZigBeeNetwork();
+ *
+ * int[] value;
+ *
+ * value = getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.CHANNEL); if (
+ * value == null){ logger.error(
+ * "Method getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.CHANNEL) returned null"
+ * ); return true; } else if ( value[0] != this.channel ) { logger.debug(
+ * "Dongle network state must be reset because channel is changed. " +
+ * "Old was = {} while new is {}", value[0], this.channel); return true; }
+ *
+ * value = getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.PAN_ID); if (
+ * value == null){ logger.error(
+ * "Method getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.PAN_ID) returned null"
+ * ); return true; } else if ( Integers.shortFromInts(value, 1, 0) !=
+ * this.pan) {
+ * logger.debug("Dongle network state must be reset because PanId is changed. "
+ * + "Old was = {} while new is {}", Integers.shortFromInts(value, 1, 0),
+ * this.pan); return true; }
+ *
+ * dongleReset();
+ *
+ * return false; }
+ */
+
+ private boolean initializeZigBeeNetwork() {
+
+ boolean cleanNetworkState = cleanStatus;
+
+ if (cleanNetworkState) {
+ if (doCleanAndSetConfiguration() == false) {
+ return false;
+ }
+ }
+ boolean creation = createZigBeeNetwork();
+ if (creation == false) {
+ return false;
+ }
+ setState(DriverStatus.NETWORK_READY);
+ if (doesCurrentConfigurationMatchZStackConfiguration()) {
+ logger.warn("ZigBee Network has been initialized but it seems that "
+ + "the Dongle configuration does not match the specified configuration."
+ + "We are continuing to execute anyhow but the dongle may be using a"
+ + "wrong ZigBee channle or connected to a different PanId or others");
+ }
+
+ return creation;
+ }
+
+ private boolean doesCurrentConfigurationMatchZStackConfiguration() {
+ int value = -1;
+ boolean mismatch = false;
+ if ((value = getCurrentChannel()) != channel) {
+ logger.warn(
+ "The channel configuration differ from the channel configuration in use: "
+ + "in use {}, while the configured is {}.\n"
+ + "The ZigBee Stack should be flushed, try to set "
+ + ConfigurationProperties.NETWORK_FLUSH
+ + " to TRUE", value, channel);
+ mismatch = true;
+ }
+ if ((value = getCurrentPanId()) != pan) {
+ logger.warn(
+ "The PanId configuration differ from the channel configuration in use: "
+ + "in use {}, while the configured is {}.\n"
+ + "The ZigBee Stack should be flushed, try to set "
+ + ConfigurationProperties.NETWORK_FLUSH
+ + " to TRUE", value, pan);
+ mismatch = true;
+ }
+ if ((value = getZigBeeNodeMode()) != mode.ordinal()) {
+ logger.warn(
+ "The NetworkMode configuration differ from the channel configuration in use: "
+ + "in use {}, while the configured is {}.\n"
+ + "The ZigBee Stack should be flushed, try to set "
+ + ConfigurationProperties.NETWORK_FLUSH
+ + " to TRUE", value, mode.ordinal());
+ mismatch = true;
+ }
+
+ return mismatch;
+ }
+
+ private boolean doCleanAndSetConfiguration() {
+ logger.debug("Cleaning dongle networks stack status");
+ // if( ! dongleClearState() ){
+ // logger.error("Unable to CLEAN the ZigBee network stack staus");
+ // return false;
+ // } else {
+ // logger.info("ZigBee network stack status CLEANED");
+ // }
+ if (!dongleSetCleanState(true)) {
+ logger.error("Unable to set clean state for dongle");
+ return false;
+ }
+ if (!dongleSetChannel()) {
+ logger.error("Unable to set CHANNEL for ZigBee Network");
+ return false;
+ } else {
+ logger.info("CHANNEL set");
+ }
+ if (!dongleSetPanId()) {
+ logger.error("Unable to set PANID for ZigBee Network");
+ return false;
+ } else {
+ logger.info("PANID set");
+ }
+ if (dongleSetNetworkMode() == false) {
+ logger.error("Unable to set NETWORK_MODE for ZigBee Network");
+ return false;
+ } else {
+ logger.info("NETWORK_MODE set");
+ }
+ if (!dongleReset()) {
+ logger.error("Unable to reset dongle");
+ return false;
+ }
+ if (!dongleSetCleanState(false)) {
+ logger.error("Unable to unset clean state for dongle");
+ return false;
+ }
+ // if ( dongleMasterReset() == false ) {
+ // logger.error("Unable to send the master reset for ZigBee Network");
+ // return false;
+ // } else {
+ // logger.info("master reset sent");
+ // }
+ return true;
+ }
+
+ /**
+ * It was developed by TSB for their custom firmware and their custom need,
+ * it is not clear what it does. Please keep it for reference but ignore the
+ * method
+ *
+ * @deprecated
+ */
+ protected boolean dongleMasterReset() {
+ // ---------START FROM APP
+ logger.debug("Reset seq: Trying STARTFROMAPP");
+ ZDO_STARTUP_FROM_APP_SRSP responseA1 = (ZDO_STARTUP_FROM_APP_SRSP) sendSynchrouns(
+ high, new ZDO_STARTUP_FROM_APP(
+ ZDO_STARTUP_FROM_APP.RESET_TYPE.TARGET_DEVICE));
+ if (responseA1 == null) {
+ logger.error("Reset seq: Failed STARTFROMAPP");
+ return false;
+ }
+ // ---------ZB WRITE CONF
+ logger.debug("Reset seq: Trying WRITECONF");
+ ZB_WRITE_CONFIGURATION_RSP responseA2 = (ZB_WRITE_CONFIGURATION_RSP) sendSynchrouns(
+ high, new ZB_WRITE_CONFIGURATION(3, new int[] { 2 }));
+ if (responseA2 == null) {
+ logger.error("Reset seq: Failed WRITECONF");
+ return false;
+ }
+ // ---------GET DEVICE INFO
+ logger.debug("Reset seq: Trying GETDEVICEINFO");
+ // final WaitForCommand waiter1 = new WaitForCommand(
+ // ZToolCMD.UTIL_GET_DEVICE_INFO_RESPONSE,
+ // high
+ // );
+ // try{
+ // high.sendAsynchrounsCommand(new UTIL_GET_DEVICE_INFO());
+ // } catch (IOException e) {
+ // logger.error("GetDeviceInfo of Master Reset failed", e);
+ // return false;
+ // }
+ // UTIL_GET_DEVICE_INFO_RESPONSE responseA3 =
+ // (UTIL_GET_DEVICE_INFO_RESPONSE) waiter1.getCommand(TIMEOUT);
+ UTIL_GET_DEVICE_INFO_RESPONSE responseA3 = (UTIL_GET_DEVICE_INFO_RESPONSE) sendSynchrouns(
+ high, new UTIL_GET_DEVICE_INFO());
+ if (responseA3 == null) {
+ logger.error("Reset seq: Failed GETDEVICEINFO");
+ return false;
+ }
+ ZToolAddress16[] addresses = new ZToolAddress16[responseA3.AssocDevicesList.length];
+ for (int k = 0; k < responseA3.AssocDevicesList.length; k++) {
+ addresses[k] = new ZToolAddress16(
+ responseA3.AssocDevicesList[k].getMsb(),
+ responseA3.AssocDevicesList[k].getLsb());
+ }
+ // ---------ZDO GET IEEE ADDR
+ logger.debug("Reset seq: Trying GETIEEEADDR");
+ ZToolAddress64[] longAddresses = new ZToolAddress64[addresses.length];
+ for (int k = 0; k < addresses.length; k++) {
+ // ZDO_IEEE_ADDR_RSP responseA4 = sendZDOIEEEAddressRequest(new
+ // ZDO_IEEE_ADDR_REQ(addresses[k],ZDO_IEEE_ADDR_REQ.REQ_TYPE.EXTENDED.getValue(),0));
+
+ ZDO_IEEE_ADDR_RSP responseA4 = null;
+ WaitForCommand waiter = new WaitForCommand(
+ ZToolCMD.ZDO_IEEE_ADDR_RSP, high);
+ logger.debug("Sending ZDO_IEEE_ADDR_REQ");
+ ZDO_IEEE_ADDR_REQ_SRSP response = (ZDO_IEEE_ADDR_REQ_SRSP) sendSynchrouns(
+ high, new ZDO_IEEE_ADDR_REQ(addresses[k],
+ ZDO_IEEE_ADDR_REQ.REQ_TYPE.EXTENDED.getValue(), 0));
+ if (response == null || response.Status != 0) {
+ logger.debug("ZDO_IEEE_ADDR_REQ failed, received {}", response);
+ waiter.cleanup();
+ } else {
+ responseA4 = (ZDO_IEEE_ADDR_RSP) waiter.getCommand(TIMEOUT);
+ }
+
+ if (responseA4 != null) {
+ longAddresses[k] = responseA4.getIEEEAddress();
+ } else {
+ longAddresses[k] = null;
+ }
+ }
+ // ---------ZDO MGMT LEAVE
+ logger.debug("Reset seq: Trying LEAVE");
+ long start = System.currentTimeMillis();
+ for (int k = 0; k < longAddresses.length; k++) {
+ if (longAddresses[k] != null) {
+ WaitForCommand waiter3 = new WaitForCommand(
+ ZToolCMD.ZDO_MGMT_LEAVE_RSP, high);
+
+ ZDO_MGMT_LEAVE_REQ_SRSP response = (ZDO_MGMT_LEAVE_REQ_SRSP) sendSynchrouns(
+ high, new ZDO_MGMT_LEAVE_REQ(addresses[k],
+ longAddresses[k], 3));
+ if ((System.currentTimeMillis() - start) > TIMEOUT) {
+ logger.error("Reset seq: Failed LEAVE");
+ return false;
+ }
+ if (response == null || response.Status != 0) {
+ waiter3.cleanup();
+ logger.error("Reset seq: Failed LEAVE");
+ return false;
+ } else {
+ if ((System.currentTimeMillis() - start) > TIMEOUT) {
+ logger.error("Reset seq: Failed LEAVE");
+ return false;
+ }
+ ZDO_MGMT_LEAVE_RSP responseA5 = (ZDO_MGMT_LEAVE_RSP) waiter3
+ .getCommand(TIMEOUT);
+ if ((System.currentTimeMillis() - start) > TIMEOUT) {
+ logger.error("Reset seq: Failed LEAVE");
+ return false;
+ }
+ if (responseA5 == null
+ || responseA5.Status != ZDO_MGMT_LEAVE_RSP.ZDO_STATUS.ZDP_SUCCESS) {
+ logger.error("Reset seq: Failed LEAVE");
+ return false;
+ }
+ }
+ }
+ if ((System.currentTimeMillis() - start) > TIMEOUT) {
+ logger.error("Reset seq: Failed LEAVE");
+ return false;
+ }
+ }
+
+ // ---------SYS RESET
+ logger.debug("Reset seq: Trying SYSRESET");
+ if (!dongleReset()) {
+ logger.error("Reset seq: Failed SYSRESET");
+ return false;
+ }
+ // ---------START FROM APP
+ // //already in initializeZigBeeNetwork
+ // ZDO_STARTUP_FROM_APP_SRSP responseA7 = (ZDO_STARTUP_FROM_APP_SRSP)
+ // sendSynchrouns(
+ // high, new
+ // ZDO_STARTUP_FROM_APP(ZDO_STARTUP_FROM_APP.RESET_TYPE.TARGET_DEVICE)
+ // );
+ // if (responseA7==null)return false;
+ return true;
+ }
+
+ private ZToolPacket sendSynchrouns(final HWHighLevelDriver hwDriver,
+ final ZToolPacket request) {
+ final ZToolPacket[] response = new ZToolPacket[] { null };
+ // final int TIMEOUT = 1000, MAX_SEND = 3;
+ int sending = 1;
+
+ logger.info("Sending Synchrouns {}", request.getClass().getName());
+
+ SynchrounsCommandListner listener = new SynchrounsCommandListner() {
+
+ public void receivedCommandResponse(ZToolPacket packet) {
+ logger.info("Received Synchrouns Response {}", packet
+ .getClass().getName());
+ synchronized (response) {
+ response[0] = packet;
+ response.notify();
+ }
+ }
+ };
+
+ while (sending <= RESEND_MAX_RETRY) {
+ try {
+ try {
+ hwDriver.sendSynchrounsCommand(request, listener,
+ RESEND_TIMEOUT);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ logger.info("Sent {} during the {}-th tentative", request
+ .getClass().getName(), sending);
+ synchronized (response) {
+ long wakeUpTime = System.currentTimeMillis()
+ + RESEND_TIMEOUT;
+ while (response[0] == null
+ && wakeUpTime > System.currentTimeMillis()) {
+ final long sleeping = wakeUpTime
+ - System.currentTimeMillis();
+ logger.debug(
+ "Waiting for synchronous command up to {}ms till {} Unixtime",
+ sleeping, wakeUpTime);
+ if (sleeping <= 0) {
+ break;
+ }
+ try {
+ response.wait(sleeping);
+ } catch (InterruptedException ignored) {
+ }
+ }
+ }
+ if (response[0] != null) {
+ logger.debug(
+ "Received synchronous command {} before timeout",
+ response[0]);
+ } else {
+ logger.debug(
+ "Timeout fired and no synchronous command received",
+ response[0]);
+ }
+ if (RESEND_ONLY_EXCEPTION) {
+ break;
+ } else {
+ logger.info("Failed to send {} during the {}-th tentative",
+ request.getClass().getName(), sending);
+ sending++;
+ }
+ } catch (Exception ignored) {
+ logger.info("Failed to send {} during the {}-th tentative",
+ request.getClass().getName(), sending);
+ logger.debug("Sending operation failed due to ", ignored);
+ sending++;
+ }
+ }
+
+ return response[0];
+ }
+
+ public boolean addAnnounceListener(AnnounceListner listner) {
+ if (AnnounceListners.isEmpty() && isHardwareReady()) {
+ high.addAsynchrounsCommandListener(AnnounceListner);
+ }
+ return AnnounceListners.add(listner);
+ }
+
+ public boolean removeAnnounceListener(AnnounceListner listner) {
+ boolean result = AnnounceListners.remove(listner);
+ if (AnnounceListners.isEmpty() && isHardwareReady()) {
+ high.removeAsynchrounsCommandListener(AnnounceListner);
+ }
+ return result;
+ }
+
+ public AF_REGISTER_SRSP sendAFRegister(AF_REGISTER request) {
+ if (waitForNetwork() == false)
+ return null;
+
+ AF_REGISTER_SRSP response = (AF_REGISTER_SRSP) sendSynchrouns(high,
+ request);
+ return response;
+ }
+
+ public AF_DATA_CONFIRM sendAFDataRequest(AF_DATA_REQUEST request) {
+ if (waitForNetwork() == false)
+ return null;
+ AF_DATA_CONFIRM result = null;
+
+ waitAndLock3WayConversation(request);
+ final WaitForCommand waiter = new WaitForCommand(
+ ZToolCMD.AF_DATA_CONFIRM, high);
+
+ AF_DATA_SRSP response = (AF_DATA_SRSP) sendSynchrouns(high, request);
+ if (response == null || response.Status != 0) {
+ waiter.cleanup();
+ } else {
+ result = (AF_DATA_CONFIRM) waiter.getCommand(TIMEOUT);
+ }
+ unLock3WayConversation(request);
+ return result;
+ }
+
+ public ZDO_BIND_RSP sendZDOBind(ZDO_BIND_REQ request) {
+ if (waitForNetwork() == false)
+ return null;
+ ZDO_BIND_RSP result = null;
+
+ waitAndLock3WayConversation(request);
+ final WaitForCommand waiter = new WaitForCommand(ZToolCMD.ZDO_BIND_RSP,
+ high);
+
+ ZDO_BIND_REQ_SRSP response = (ZDO_BIND_REQ_SRSP) sendSynchrouns(high,
+ request);
+ if (response == null || response.Status != 0) {
+ waiter.cleanup();
+ } else {
+ result = (ZDO_BIND_RSP) waiter.getCommand(TIMEOUT);
+ }
+ unLock3WayConversation(request);
+ return result;
+ }
+
+ public ZDO_UNBIND_RSP sendZDOUnbind(ZDO_UNBIND_REQ request) {
+ if (waitForNetwork() == false)
+ return null;
+ ZDO_UNBIND_RSP result = null;
+
+ waitAndLock3WayConversation(request);
+ final WaitForCommand waiter = new WaitForCommand(
+ ZToolCMD.ZDO_UNBIND_RSP, high);
+
+ ZDO_UNBIND_REQ_SRSP response = (ZDO_UNBIND_REQ_SRSP) sendSynchrouns(
+ high, request);
+ if (response == null || response.Status != 0) {
+ waiter.cleanup();
+ } else {
+ result = (ZDO_UNBIND_RSP) waiter.getCommand(TIMEOUT);
+ }
+
+ unLock3WayConversation(request);
+ return result;
+ }
+
+ public boolean removeAFMessageListener(AFMessageListner listner) {
+ boolean result = false;
+ synchronized (afMessageListners) {
+ result = afMessageListners.remove(listner);
+ }
+
+ if (afMessageListners.isEmpty() && isHardwareReady()) {
+ if (high.removeAsynchrounsCommandListener(afListner)) {
+ logger.debug(
+ "Removed AsynchrounsCommandListener {} to HWHighLevelDriver",
+ afListner.getClass().getName());
+ } else {
+ logger.debug(
+ "Could not remove AsynchrounsCommandListener {} to HWHighLevelDriver",
+ afListner.getClass().getName());
+ }
+ }
+ if (result) {
+ logger.debug("Removed AFMessageListner {}:{}", listner, listner
+ .getClass().getName());
+ return true;
+ } else {
+ logger.debug("Could not remove AFMessageListner {}:{}", listner,
+ listner.getClass().getName());
+ return false;
+ }
+ }
+
+ public boolean addAFMessageListner(AFMessageListner listner) {
+ if (afMessageListners.isEmpty() && isHardwareReady()) {
+ if (high.addAsynchrounsCommandListener(afListner)) {
+ logger.debug(
+ "Added AsynchrounsCommandListener {} to HWHighLevelDriver",
+ afListner.getClass().getName());
+ } else {
+ logger.debug(
+ "Could not add AsynchrounsCommandListener {} to HWHighLevelDriver",
+ afListner.getClass().getName());
+ }
+ }
+ boolean result = false;
+ synchronized (afMessageListners) {
+ result = afMessageListners.add(listner);
+ }
+
+ if (result) {
+ logger.debug("Added AFMessageListner {}:{}", listner, listner
+ .getClass().getName());
+ return true;
+ } else {
+ logger.debug("Could not add AFMessageListner {}:{}", listner,
+ listner.getClass().getName());
+ return false;
+ }
+ }
+
+ private boolean isNetworkReady() {
+ synchronized (this) {
+ return state.ordinal() >= DriverStatus.NETWORK_READY.ordinal()
+ && state.ordinal() < DriverStatus.CLOSED.ordinal();
+ }
+ }
+
+ private boolean isHardwareReady() {
+ synchronized (this) {
+ return state.ordinal() >= DriverStatus.HARDWARE_READY.ordinal()
+ && state.ordinal() < DriverStatus.CLOSED.ordinal();
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @since 0.2.0
+ */
+ public long getExtendedPanId() {
+ if (waitForNetwork() == false) {
+ logger.info(
+ "Failed to reach the {} level: getExtendedPanId() failed",
+ DriverStatus.NETWORK_READY);
+ return -1;
+ }
+
+ int[] result = getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.EXT_PAN_ID);
+
+ if (result == null) {
+ return -1;
+ } else {
+ return Integers.shortFromInts(result, 7, 0);
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @since 0.2.0
+ */
+ public long getIEEEAddress() {
+
+ if (ieeeAddress != -1) {
+ return ieeeAddress;
+ }
+
+ if (waitForNetwork() == false) {
+ logger.info(
+ "Failed to reach the {} level: getIEEEAddress() failed",
+ DriverStatus.NETWORK_READY);
+ return -1;
+ }
+
+ int[] result = getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.IEEE_ADDR);
+
+ if (result == null) {
+ return -1;
+ } else {
+ ieeeAddress = Integers.longFromInts(result, 7, 0);
+ return ieeeAddress;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @since 0.2.0
+ */
+ public int getCurrentPanId() {
+ if (waitForNetwork() == false) {
+ logger.info(
+ "Failed to reach the {} level: getCurrentPanId() failed",
+ DriverStatus.NETWORK_READY);
+ return -1;
+ }
+
+ int[] result = getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.PAN_ID);
+
+ if (result == null) {
+ return -1;
+ } else {
+ return Integers.shortFromInts(result, 1, 0);
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @since 0.2.0
+ */
+ public int getCurrentChannel() {
+ if (waitForNetwork() == false) {
+ logger.info(
+ "Failed to reach the {} level: getCurrentChannel() failed",
+ DriverStatus.NETWORK_READY);
+ return -1;
+ }
+
+ int[] result = getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.CHANNEL);
+
+ if (result == null) {
+ return -1;
+ } else {
+ return result[0];
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @since 0.2.0
+ */
+ public int getCurrentState() {
+ if (waitForNetwork() == false) {
+ logger.info(
+ "Failed to reach the {} level: getCurrentChannel() failed",
+ DriverStatus.NETWORK_READY);
+ return -1;
+ }
+
+ int[] result = getDeviceInfo(ZB_GET_DEVICE_INFO.DEV_INFO_TYPE.STATE);
+
+ if (result == null) {
+ return -1;
+ } else {
+ return result[0];
+ }
+ }
+
+ private int[] getDeviceInfo(int type) {
+ ZB_GET_DEVICE_INFO_RSP response = (ZB_GET_DEVICE_INFO_RSP) sendSynchrouns(
+ high, new ZB_GET_DEVICE_INFO(type));
+
+ if (response == null) {
+ logger.debug("Failed getDeviceInfo for {} due to null value", type);
+ return null;
+ } else if (response.Param != type) {
+ logger.debug(
+ "Failed getDeviceInfo for {} non matching response returned {}",
+ type, response.Param);
+ return null;
+ } else {
+ logger.debug("Successed getDeviceInfo for {}", type);
+ return response.Value;
+ }
+ }
+
+ public int getZigBeeNodeMode() {
+ ZB_READ_CONFIGURATION_RSP response = (ZB_READ_CONFIGURATION_RSP) sendSynchrouns(
+ high, new ZB_READ_CONFIGURATION(
+ ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_LOGICAL_TYPE));
+ if (response != null && response.Status == 0) {
+ return response.Value[0];
+ } else {
+ return -1;
+ }
+ }
+
+ public DriverStatus getDriverStatus() {
+ return state;
+ }
+
+ private int[] ep, prof, dev, ver;
+ private short[][] inp, out;
+
+ public void addCustomDevice(String endpointNumber, String profileID,
+ String deviceID, String version, String inputClusters,
+ String outputCluster) {
+
+ String[] inputGroupsNumber = null, outputGroupsNumber = null, inputClusterGroup = null, outputClusterGroup = null;
+ if (checkString(inputClusters))
+ inputGroupsNumber = inputClusters.trim().split("]");
+ if (checkString(outputCluster))
+ outputGroupsNumber = outputCluster.trim().split("]");
+
+ if (inputGroupsNumber != null && outputGroupsNumber != null
+ && inputGroupsNumber.length > 0
+ && inputGroupsNumber.length == outputGroupsNumber.length) {
+
+ int max = -1;
+ for (int i = 0; i < inputGroupsNumber.length; i++) {
+ inputGroupsNumber[i] = inputGroupsNumber[i].replace("[", "");
+ inputGroupsNumber[i] = inputGroupsNumber[i].replace("]", "");
+ inputGroupsNumber[i] = inputGroupsNumber[i].replace(" ", "");
+
+ int temp = inputGroupsNumber[i].trim().split(",").length;
+ if (temp > max)
+ max = temp;
+ }
+ inp = new short[inputGroupsNumber.length][max];
+ for (int i = 0; i < inputGroupsNumber.length; i++) {
+ inputClusterGroup = inputGroupsNumber[i].trim().split(",");
+ for (int j = 0; j < inputClusterGroup.length; j++) {
+ if (toShort(inputClusterGroup[j]) != -1)
+ inp[i][j] = toShort(inputClusterGroup[j]);
+ }
+ }
+
+ max = -1;
+ for (int i = 0; i < outputGroupsNumber.length; i++) {
+ outputGroupsNumber[i] = outputGroupsNumber[i].replace("[", "");
+ outputGroupsNumber[i] = outputGroupsNumber[i].replace("]", "");
+ outputGroupsNumber[i] = outputGroupsNumber[i].replace(" ", "");
+
+ int temp = outputGroupsNumber[i].trim().split(",").length;
+ if (temp > max)
+ max = temp;
+ }
+ out = new short[outputGroupsNumber.length][max];
+ for (int i = 0; i < outputGroupsNumber.length; i++) {
+ outputClusterGroup = outputGroupsNumber[i].trim().split(",");
+ for (int j = 0; j < outputClusterGroup.length; j++) {
+ if (toShort(outputClusterGroup[j]) != -1)
+ out[i][j] = toShort(outputClusterGroup[j]);
+ }
+ }
+
+ ep = new int[inputGroupsNumber.length];
+ prof = new int[inputGroupsNumber.length];
+ dev = new int[inputGroupsNumber.length];
+ ver = new int[inputGroupsNumber.length];
+
+ String[] eps = endpointNumber.trim().split(",");
+ for (int i = 0; i < eps.length; i++) {
+ ep[i] = toShort(eps[i]);
+ }
+ String[] profs = profileID.trim().split(",");
+ for (int i = 0; i < profs.length; i++) {
+ prof[i] = toShort(profs[i]);
+ }
+ String[] devs = deviceID.trim().split(",");
+ for (int i = 0; i < devs.length; i++) {
+ dev[i] = toShort(devs[i]);
+ }
+ String[] vers = version.trim().split(",");
+ for (int i = 0; i < vers.length; i++) {
+ ver[i] = toShort(vers[i]);
+ }
+ }
+ }
+
+ private boolean checkString(String s) {
+ if (s != null && !s.isEmpty())
+ return true;
+
+ return false;
+ }
+
+ private Short toShort(String s) {
+
+ try {
+ return Short.parseShort(s);
+ } catch (Exception ex) {
+ return -1;
+ }
+ }
+
+ public void createCustomDevicesOnDongle() {
+
+ short[] input, output;
+
+ if (this.ep != null)
+ for (int i = 0; i < this.ep.length; i++) {
+ // input
+ int size = 0;
+ for (int j = 0; j < this.inp[i].length; j++) {
+
+ if (this.inp[i][j] != 0 && this.inp[i][j] != -1)
+ size++;
+ }
+
+ input = new short[size];
+ for (int j = 0; j < this.inp[i].length; j++) {
+
+ if (this.inp[i][j] != 0 && this.inp[i][j] != -1)
+ input[j] = this.inp[i][j];
+ }
+
+ // output
+ size = 0;
+ for (int j = 0; j < this.out[i].length; j++) {
+
+ if (this.out[i][j] != 0 && this.out[i][j] != -1)
+ size++;
+ }
+
+ output = new short[size];
+ for (int j = 0; j < this.out[i].length; j++) {
+
+ if (this.out[i][j] != 0 && this.out[i][j] != -1)
+ output[j] = this.out[i][j];
+ }
+
+ if (newDevice(new AF_REGISTER(new Byte(this.ep[i] + ""),
+ new Short(this.prof[i] + ""), new Short(this.dev[i]
+ + ""), new Byte(this.ver[i] + ""), input,
+ output)))
+ logger.debug(
+ "Custom device {} corrected registered at endpoint {}",
+ this.dev[i], this.ep[i]);
+ else
+ logger.debug(
+ "Custom device {} registration failed at endpoint {}",
+ this.dev[i], this.ep[i]);
+ }
+ }
+
+ public boolean newDevice(AF_REGISTER request) {
+
+ try {
+ AF_REGISTER_SRSP response = (AF_REGISTER_SRSP) sendSynchrouns(high,
+ request);
+ if (response != null && response.Status == 0)
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return false;
+ }
+
+ public boolean isResendOnlyOnException() {
+ return RESEND_ONLY_EXCEPTION;
+ }
}
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.api/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.api/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.api/pom.xml Fri Feb 13 11:24:03 2015
@@ -16,13 +16,13 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<artifactId>org.aaloa.zb4osgi.zigbee.basedriver.api</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<packaging>bundle</packaging>
<name>ZigBee Base Driver API for OSGi</name>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.stub/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.stub/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.stub/pom.xml Fri Feb 13 11:24:03 2015
@@ -16,13 +16,13 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<artifactId>org.aaloa.zb4osgi.zigbee.basedriver.stub</artifactId>
- <version>0.2.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<packaging>bundle</packaging>
<name>STUB implementation of:OSGi ZigBee Base Driver</name>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver/pom.xml Fri Feb 13 11:24:03 2015
@@ -15,12 +15,11 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<artifactId>org.aaloa.zb4osgi.zigbee.basedriver</artifactId>
- <version>0.8.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>ZigBee Base Driver</name>
@@ -204,4 +203,5 @@
</plugin>
</plugins>
</reporting>
+ <version>1.0.0</version>
</project>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.cc2480.datalink/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.cc2480.datalink/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.cc2480.datalink/pom.xml Fri Feb 13 11:24:03 2015
@@ -16,13 +16,13 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<artifactId>org.aaloa.zb4osgi.zigbee.cc2480.datalink</artifactId>
- <version>0.9.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<packaging>bundle</packaging>
<name>CC2480 Data Link protocol library</name>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.cc2480.datalink/src/main/java/com/itaca/ztool/api/ZToolPacketStream.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.cc2480.datalink/src/main/java/com/itaca/ztool/api/ZToolPacketStream.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.cc2480.datalink/src/main/java/com/itaca/ztool/api/ZToolPacketStream.java Fri Feb 13 11:24:03 2015
@@ -202,7 +202,8 @@
return response;
}
- public ZToolPacket parsePacket()
+ @SuppressWarnings("unused")
+ public ZToolPacket parsePacket()
throws IOException {
ErrorType error = null;
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.common/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.common/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.common/pom.xml Fri Feb 13 11:24:03 2015
@@ -16,13 +16,13 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<artifactId>org.aaloa.zb4osgi.zigbee.common</artifactId>
- <version>0.6.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<packaging>bundle</packaging>
<name>OSGi and Primitive Types Utility</name>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.common/src/test/java/it/cnr/isti/primitivetypes/util/IntegersTest.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.common/src/test/java/it/cnr/isti/primitivetypes/util/IntegersTest.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.common/src/test/java/it/cnr/isti/primitivetypes/util/IntegersTest.java Fri Feb 13 11:24:03 2015
@@ -29,8 +29,6 @@
import static org.junit.Assert.fail;
import java.math.BigInteger;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
import java.util.Arrays;
import org.junit.Test;
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.dongle.api/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.dongle.api/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.dongle.api/pom.xml Fri Feb 13 11:24:03 2015
@@ -16,13 +16,13 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<artifactId>org.aaloa.zb4osgi.zigbee.dongle.api</artifactId>
- <version>0.8.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<packaging>bundle</packaging>
<name>ZigBee Interface Controller API</name>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.eh.driver/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.eh.driver/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.eh.driver/pom.xml Fri Feb 13 11:24:03 2015
@@ -16,13 +16,13 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<artifactId>org.aaloa.zb4osgi.zigbee.eh.driver</artifactId>
<packaging>bundle</packaging>
- <version>0.1.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<name>ZigBee Energy at Home Profile Driver</name>
<url>http://zb4osgi.aaloa.org/</url>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.eh.zcl.library/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.eh.zcl.library/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.eh.zcl.library/pom.xml Fri Feb 13 11:24:03 2015
@@ -16,13 +16,13 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<artifactId>org.aaloa.zb4osgi.zigbee.eh.zcl.library</artifactId>
<packaging>bundle</packaging>
- <version>0.1.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<name>Energy at Home Cluster Library</name>
<url>http://zb4osgi.aaloa.org/</url>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ez430-rf2480.driver/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ez430-rf2480.driver/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ez430-rf2480.driver/pom.xml Fri Feb 13 11:24:03 2015
@@ -16,13 +16,13 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<artifactId>org.aaloa.zb4osgi.zigbee.ez430-rf2480.driver</artifactId>
- <version>0.8.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<packaging>bundle</packaging>
<name>ZIC for EZ430-RF2480 dongle</name>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/pom.xml Fri Feb 13 11:24:03 2015
@@ -16,13 +16,13 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<artifactId>org.aaloa.zb4osgi.zigbee.ha.driver</artifactId>
<packaging>bundle</packaging>
- <version>0.8.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<name>ZigBee Home Automation Profile Driver</name>
<url>http://zb4osgi.aaloa.org/</url>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.hc.driver/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.hc.driver/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.hc.driver/pom.xml Fri Feb 13 11:24:03 2015
@@ -23,13 +23,13 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<artifactId>org.aaloa.zb4osgi.zigbee.hc.driver</artifactId>
<packaging>bundle</packaging>
- <version>0.1.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<name>ZigBee Health Care Profile Driver</name>
<url>http://zb4osgi.aaloa.org/</url>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.karaf.features/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.karaf.features/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.karaf.features/pom.xml Fri Feb 13 11:24:03 2015
@@ -5,12 +5,11 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
- <artifactId>org.aaloa.zb4osgi.features</artifactId>
- <version>0.0.1-SNAPSHOT</version>
+ <artifactId>org.aaloa.zb4osgi.features</artifactId>
<name>Karaf Features</name>
<packaging>pom</packaging>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.karaf.features/src/main/resources/features.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.karaf.features/src/main/resources/features.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.karaf.features/src/main/resources/features.xml Fri Feb 13 11:24:03 2015
@@ -4,53 +4,53 @@
<!-- Deps -->
<bundle>wrap:mvn:net.sf.trove4j/trove4j/2.1.0</bundle>
<!-- ZB4O modules -->
- <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.common/0.6.0-SNAPSHOT
+ <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.common/${project.version}
</bundle>
- <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.basedriver.api/0.7.0-SNAPSHOT
+ <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.basedriver.api/${project.version}
</bundle>
- <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.basedriver/0.8.0-SNAPSHOT
+ <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.basedriver/${project.version}
</bundle>
- <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.ha.driver/0.8.0-SNAPSHOT
+ <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.ha.driver/${project.version}
</bundle>
- <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.hc.driver/0.1.0-SNAPSHOT
+ <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.hc.driver/${project.version}
</bundle>
- <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.eh.driver/0.1.0-SNAPSHOT
+ <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.eh.driver/${project.version}
</bundle>
- <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.zcl.library/0.9.0-SNAPSHOT
+ <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.zcl.library/${project.version}
</bundle>
- <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.zhccl.library/0.1.0-SNAPSHOT
+ <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.zhccl.library/${project.version}
</bundle>
- <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.se.zcl.library/0.1.0-SNAPSHOT
+ <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.se.zcl.library/${project.version}
</bundle>
- <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.eh.zcl.library/0.1.0-SNAPSHOT
+ <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.eh.zcl.library/${project.version}
</bundle>
- <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.cc2480.datalink/0.9.0-SNAPSHOT
+ <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.cc2480.datalink/${project.version}
</bundle>
- <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.dongle.api/0.8.0-SNAPSHOT
+ <bundle>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.dongle.api/${project.version}
</bundle>
</feature>
<feature name="zb4o-driver-stub" version="${project.version}"> <!-- OK -->
<feature version="${project.version}">zb4o-base</feature>
<feature version="${project.version}">zb4o-tester</feature>
- <bundle start='false'>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.basedriver.stub/0.2.0-SNAPSHOT
+ <bundle start='false'>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.basedriver.stub/${project.version}
</bundle>
</feature>
<feature name="zb4o-driver-CC2530" version="${project.version}">
<feature version="${project.version}">zb4o-base</feature>
<feature version="${project.version}">zb4o-rxtx</feature>
- <bundle start='false'>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.CC2530.driver/0.3.0-SNAPSHOT
+ <bundle start='false'>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.CC2530.driver/${project.version}
</bundle>
</feature>
<feature name="zb4o-driver-EZ430" version="${project.version}">
<feature version="${project.version}">zb4o-base</feature>
<feature version="${project.version}">zb4o-rxtx</feature>
- <bundle start='false'>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.ez430-rf2480.driver/0.8.0-SNAPSHOT
+ <bundle start='false'>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.ez430-rf2480.driver/${project.version}
</bundle>
</feature>
<feature name="zb4o-tester" version="${project.version}">
<feature version="${project.version}">zb4o-base</feature>
- <bundle start='true'>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.tester/0.5.0-SNAPSHOT
+ <bundle start='true'>mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.tester/${project.version}
</bundle>
</feature>
<feature name="zb4o" version="${project.version}">
@@ -68,7 +68,7 @@
</feature>
<feature name="zb4o-rxtx" version="${project.version}">
- <bundle>mvn:org.aaloa.zb4osgi.bundle/org.aaloa.zb4osgi.externals.rxtx/2.1.7-2
+ <bundle>mvn:org.aaloa.zb4osgi.bundle/org.aaloa.zb4osgi.externals.rxtx/${project.version}
</bundle>
</feature>
</features>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.network.browser/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.network.browser/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.network.browser/pom.xml Fri Feb 13 11:24:03 2015
@@ -15,7 +15,7 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
@@ -24,7 +24,7 @@
<artifactId>org.aaloa.zb4osgi.zigbee.network.browser</artifactId>
<packaging>bundle</packaging>
<name>Zigbee Network Browser</name>
- <version>0.1.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<inceptionYear>2010</inceptionYear>
<organization>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.se.zcl.library/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.se.zcl.library/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.se.zcl.library/pom.xml Fri Feb 13 11:24:03 2015
@@ -23,13 +23,13 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<artifactId>org.aaloa.zb4osgi.zigbee.se.zcl.library</artifactId>
<packaging>bundle</packaging>
- <version>0.1.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<name>ZigBee Smart Energy v.1 Cluster Library</name>
<url>http://zb4osgi.aaloa.org/</url>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/pax.args
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/pax.args (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/pax.args Fri Feb 13 11:24:03 2015
@@ -18,24 +18,24 @@
# ZigBee Stack General Dependencies & Tool
-mvn:org.aaloa.zb4osgi.bundle/org.aaloa.zb4osgi.externals.rxtx/2.1.7-2
+mvn:org.aaloa.zb4osgi.bundle/org.aaloa.zb4osgi.externals.rxtx/1.0.0
wrap:mvn:net.sf.trove4j/trove4j/2.1.0
# ZigBee Hardware Access Layer
-mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.dongle.api
-mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.CC2530.driver at nostart
-mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.ez430-rf2480.driver at nostart
-mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.cc2480.datalink
-mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.common
+mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.dongle.api/1.0.0
+mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.CC2530.driver/1.0.0 at nostart
+mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.ez430-rf2480.driver/1.0.0 at nostart
+mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.cc2480.datalink/1.0.0
+mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.common/1.0.0
# ZigBee Base Driver
-mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.basedriver
-mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.basedriver.stub at nostart
+mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.basedriver/1.0.0
+mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.basedriver.stub/1.0.0 at nostart
# ZigBee Refinement Architecture
-mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.ha.driver
-mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.hc.driver
-mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.eh.driver
-mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.zhccl.library
-mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.se.zcl.library
-mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.eh.zcl.library
+mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.ha.driver/1.0.0
+mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.hc.driver/1.0.0
+mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.eh.driver/1.0.0
+mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.zhccl.library/1.0.0
+mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.se.zcl.library/1.0.0
+mvn:org.aaloa.zb4osgi/org.aaloa.zb4osgi.zigbee.eh.zcl.library/1.0.0
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/pom.xml Fri Feb 13 11:24:03 2015
@@ -15,7 +15,7 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
@@ -23,7 +23,7 @@
<artifactId>org.aaloa.zb4osgi.zigbee.tester</artifactId>
- <version>0.5.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<packaging>bundle</packaging>
<name>Zigbee Tester</name>
@@ -65,8 +65,15 @@
<organizationUrl>http://www.isti.cnr.it/</organizationUrl>
<timezone>+1</timezone>
</developer>
+ <developer>
+ <id>giancarlo.riolo</id>
+ <name>Giancarlo Riolo</name>
+ <email>giancarlo.riolo at isti.cnr.it</email>
+ <organization>Institute of Information Science and Technologies of the Italian National Research Council</organization>
+ <organizationUrl>http://www.isti.cnr.it/</organizationUrl>
+ <timezone>+1</timezone>
+ </developer>
</developers>
-
<scm>
<connection>scm:svn:svn://svn.aaloa.org/projects/zb4osgi/trunk/zigbee.tester</connection>
<developerConnection>scm:svn:svn://svn.aaloa.org/projects/zb4osgi/trunk/zigbee.tester</developerConnection>
@@ -88,7 +95,8 @@
Stefano "Kismet" Lenzi <stefano.lenzi at isti.cnr.it>
]]></Bundle-Author>
<Bundle-Description>
- OSGi Generic Control Point to control ZigBeeDevice services
+ OSGi Generic Control Point to control
+ ZigBeeDevice services
</Bundle-Description>
<Bundle-SymbolicName>org.aal-persona.zigbee.tester</Bundle-SymbolicName>
<Bundle-Activator>org.persona.zigbee.tester.Activator</Bundle-Activator>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zcl.library/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zcl.library/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zcl.library/pom.xml Fri Feb 13 11:24:03 2015
@@ -23,13 +23,13 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<artifactId>org.aaloa.zb4osgi.zigbee.zcl.library</artifactId>
<packaging>bundle</packaging>
- <version>0.9.0-SNAPSHOT</version>
+ <version>1.0.0</version>
<name>ZigBee Common Cluster Library</name>
<url>http://zb4osgi.aaloa.org/</url>
Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zhccl.library/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zhccl.library/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zhccl.library/pom.xml Fri Feb 13 11:24:03 2015
@@ -23,13 +23,13 @@
<parent>
<groupId>org.aaloa.zb4osgi</groupId>
<artifactId>org.aaloa.zb4osgi.pom</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>1.0.0</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<artifactId>org.aaloa.zb4osgi.zigbee.zhccl.library</artifactId>
<packaging>bundle</packaging>
- <version>0.1.0-SNAPSHOT</version>
+
<name>ZigBee Health Care Cluster Library</name>
<url>http://zb4osgi.aaloa.org/</url>
More information about the Commit
mailing list