[zb4osgi-changeset] [scm] ZigBee 4 OSGi repository change: r996 - in /projects/zb4osgi/sandbox/giancarlo.riolo: zigbee.basedriver.api/src/main/java/it/cnr/isti/zigbee/api/ zigbee.basedriver.stub/src/main/java/it/cnr/isti/basedriver/stub/ zigbee.basedriver/src/main/java/it/cnr/isti/zigbee/basedriver/api/impl/ zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/ zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/driver/ zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/driver/core/ zigbee.noGUI.tester/ zigbee.noGUI.tester/src/main/java/it/cnr/isti/zb4osgi/zigbee/noGUI/tester/ zigbee.tester/configurations/services/ zigbee.tester/src/main/java/org/persona/zigbee/tester/gui/ zigbee.zcl.library/src/main/java/it/cnr/isti/zigbee/zcl/library/api/core/ zigbee.zcl.library/src/main/java/it/cnr/isti/zigbee/zcl/library/impl/core/

scm-notify at zb4osgi.aaloa.org scm-notify at zb4osgi.aaloa.org
Fri Apr 11 18:22:31 CEST 2014


Author: giancarlo.riolo
Date: Fri Apr 11 18:22:30 2014
New Revision: 996

Log:
Refactor, Added Property to BaseDriver and HADevice services, fixes, noGUI bundle.

Modified:
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.api/src/main/java/it/cnr/isti/zigbee/api/ZigBeeDevice.java
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.stub/src/main/java/it/cnr/isti/basedriver/stub/Activator.java
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver/src/main/java/it/cnr/isti/zigbee/basedriver/api/impl/ZigBeeDeviceImpl.java
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/CurrentLevelBridgeListeners.java
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/MeasuredValueBridgeListeners.java
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/OccupancyBridgeListeners.java
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/OnOffBridgeListeners.java
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/PresentValueBridgeListeners.java
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/ToleranceBridgeListeners.java
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/driver/HAImporter.java
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/driver/core/HADevice.java
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.noGUI.tester/pom.xml
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.noGUI.tester/src/main/java/it/cnr/isti/zb4osgi/zigbee/noGUI/tester/ReportingConfiguratorDaemon.java
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.noGUI.tester/src/main/java/it/cnr/isti/zb4osgi/zigbee/noGUI/tester/TesterConfiguration.java
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/configurations/services/it.cnr.isti.zigbee.noGUI.reporting.configuration.properties
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/src/main/java/org/persona/zigbee/tester/gui/AttributeActionPanel.java
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zcl.library/src/main/java/it/cnr/isti/zigbee/zcl/library/api/core/Subscription.java
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zcl.library/src/main/java/it/cnr/isti/zigbee/zcl/library/impl/core/SubscriptionBase.java

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.api/src/main/java/it/cnr/isti/zigbee/api/ZigBeeDevice.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.api/src/main/java/it/cnr/isti/zigbee/api/ZigBeeDevice.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.api/src/main/java/it/cnr/isti/zigbee/api/ZigBeeDevice.java Fri Apr 11 18:22:30 2014
@@ -118,6 +118,8 @@
 	 * the ZigBee device
 	 */
     public final String ZIGBEE_IMPORT = "zigbee.import.id";
+
+	public final String IEEE_ADDRESS = "zigbee.node.address.ieee";
 	
 	/**
 	 * Constant for the ZigBee device match scale, indicating a match with the ProfileId. Value is 1024.

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.stub/src/main/java/it/cnr/isti/basedriver/stub/Activator.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.stub/src/main/java/it/cnr/isti/basedriver/stub/Activator.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver.stub/src/main/java/it/cnr/isti/basedriver/stub/Activator.java Fri Apr 11 18:22:30 2014
@@ -18,12 +18,12 @@
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-*/
+ */
 package it.cnr.isti.basedriver.stub;
 
 import it.cnr.isti.basedriver.stub.api.impl.StubZigBeeNode;
 import it.cnr.isti.basedriver.stub.api.impl.StubZigbeeDeviceBase;
-import it.cnr.isti.basedriver.stub.api.impl.EH.EnergyDummyDevice;
+import it.cnr.isti.basedriver.stub.api.impl.HA.OnOffSwitchDevice;
 import it.cnr.isti.zigbee.api.ZigBeeDevice;
 import it.cnr.isti.zigbee.api.ZigBeeNode;
 
@@ -35,87 +35,93 @@
 
 /**
  * @author <a href="mailto:stefano.lenzi at isti.cnr.it">Stefano "Kismet" Lenzi</a>
- * @version $LastChangedRevision$ ($LastChangedDate$)
+ * @version $LastChangedRevision$ ($LastChangedDate: 2014-02-07 18:52:09
+ *          +0100(ven, 07 feb 2014) $)
  * @since 0.1.0
- *
+ * 
  */
 public class Activator implements BundleActivator {
 
-    private ArrayList<ServiceRegistration> services = new ArrayList<ServiceRegistration>();
-    
-    /**
-     * 
-     * @param bc
-     * @param device 
-     * @since 0.2.0 - Revision 118
-     */
-    private void registerDevice( BundleContext bc, StubZigbeeDeviceBase device ) {
-        
-        System.out.println("Registering {} "+ device.getClass().getName());
-        
-        ServiceRegistration reg = bc.registerService(
-            ZigBeeDevice.class.getName(),
-            device,
-            device.getDescription()
-        );
-        
-        services.add( reg );
-        
-    }
-    
+	private ArrayList<ServiceRegistration> services = new ArrayList<ServiceRegistration>();
+
+	/**
+	 * 
+	 * @param bc
+	 * @param device
+	 * @since 0.2.0 - Revision 118
+	 */
+	private void registerDevice(BundleContext bc, StubZigbeeDeviceBase device) {
+
+		System.out.println("Registering {} " + device.getClass().getName());
+
+		ServiceRegistration reg = bc.registerService(
+				ZigBeeDevice.class.getName(), device, device.getDescription());
+
+		services.add(reg);
+
+	}
+
 	public void start(BundleContext context) throws Exception {
-		
-		ZigBeeNode alpha = new StubZigBeeNode("11:22:33:44:55:66:77:88",0x0100);
-		ZigBeeNode beta = new StubZigBeeNode("01:02:03:04:05:06:07:08",0x0010);
-		ZigBeeNode gamma = new StubZigBeeNode("99:AA:BB:CC:DD:EE:FF:00",0x1000);
-		
-		/*
-		OnOffOutputDevice[] devices = new OnOffOutputDevice[3];
-		OnOffLightDevice[] lights = new OnOffLightDevice[4];
-        OnOffSwitchDevice[] switches = new OnOffSwitchDevice[2];
-        for ( int i = 0; i < switches.length; i++ ) {
-            switches[i] = new OnOffSwitchDevice((i+2)*3,gamma); 
-            registerDevice( context, switches[i] );
-        }
-		int  i = 0;
-		while ( i < devices.length && i < lights.length ){
-			devices[i] = new OnOffOutputDevice((i+2)*3,alpha); 
-            registerDevice( context, devices[i] );
-			
-			lights[i] = new OnOffLightDevice((i+2)*3+1,alpha);
-            registerDevice( context, lights[i] );
-			i++;
-		}
-		while ( i < devices.length ){
-			devices[i] = new OnOffOutputDevice(i*3,beta);
-            registerDevice( context, devices[i] );
-			i++;
-		}
-		while ( i < lights.length ){
-			lights[i] = new OnOffLightDevice(i*3,beta);
-            registerDevice( context, lights[i] );
-			i++;
-		}
-		  DosageSensorDevice HCdummy = new DosageSensorDevice(75,beta);
-	        registerDevice( context, HCdummy );
-	        
-	      FloodDetectorDevice flood = new FloodDetectorDevice(78,gamma);
-	        registerDevice( context, flood );
-		
-		CurtainActuatorDevice curtain = new CurtainActuatorDevice(77,alpha);
-       registerDevice( context, curtain );*/
 
-        EnergyDummyDevice EHdummy = new EnergyDummyDevice(75,beta);
-        registerDevice( context, EHdummy );
-        
-      
-		
+		ZigBeeNode alpha = new StubZigBeeNode("11:22:33:44:55:66:77:88", 0x0100);
+		ZigBeeNode beta = new StubZigBeeNode("01:02:03:04:05:06:07:08", 0x0010);
+		ZigBeeNode gamma = new StubZigBeeNode("99:AA:BB:CC:DD:EE:FF:00", 0x1000);
+
+		// OnOffOutputDevice[] devices = new OnOffOutputDevice[3];
+		// OnOffLightDevice[] lights = new OnOffLightDevice[4];
+		OnOffSwitchDevice[] switches = new OnOffSwitchDevice[5];
+		switches[0] = new OnOffSwitchDevice(111, gamma);
+		switches[1] = new OnOffSwitchDevice(145, gamma);
+		switches[2] = new OnOffSwitchDevice(21, gamma);
+		switches[3] = new OnOffSwitchDevice(5, gamma);
+		switches[4] = new OnOffSwitchDevice(77, gamma);
+		registerDevice(context, switches[0]);
+		registerDevice(context, switches[1]);
+		registerDevice(context, switches[2]);
+		registerDevice(context, switches[3]);
+		registerDevice(context, switches[4]);
+
+		// for ( int i = 0; i < switches.length; i++ ) {
+		// switches[i] = new OnOffSwitchDevice((i+2)*3,gamma);
+		// registerDevice( context, switches[i] );
+		// }
+		// int i = 0;
+		// while ( i < devices.length && i < lights.length ){
+		// devices[i] = new OnOffOutputDevice((i+2)*3,alpha);
+		// registerDevice( context, devices[i] );
+		//
+		// lights[i] = new OnOffLightDevice((i+2)*3+1,alpha);
+		// registerDevice( context, lights[i] );
+		// i++;
+		// }
+		// while ( i < devices.length ){
+		// devices[i] = new OnOffOutputDevice(i*3,beta);
+		// registerDevice( context, devices[i] );
+		// i++;
+		// }
+		// while ( i < lights.length ){
+		// lights[i] = new OnOffLightDevice(i*3,beta);
+		// registerDevice( context, lights[i] );
+		// i++;
+		// }
+		// DosageSensorDevice HCdummy = new DosageSensorDevice(75,beta);
+		// registerDevice( context, HCdummy );
+		//
+		// FloodDetectorDevice flood = new FloodDetectorDevice(78,gamma);
+		// registerDevice( context, flood );
+		//
+		// CurtainActuatorDevice curtain = new CurtainActuatorDevice(77,alpha);
+		// registerDevice( context, curtain );
+		//
+		// EnergyDummyDevice EHdummy = new EnergyDummyDevice(75,beta);
+		// registerDevice( context, EHdummy );
+
 	}
 
 	public void stop(BundleContext context) throws Exception {
-	    for ( ServiceRegistration registration : services ) {
-            registration.unregister();
-        }
+		for (ServiceRegistration registration : services) {
+			registration.unregister();
+		}
 	}
 
 }

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver/src/main/java/it/cnr/isti/zigbee/basedriver/api/impl/ZigBeeDeviceImpl.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver/src/main/java/it/cnr/isti/zigbee/basedriver/api/impl/ZigBeeDeviceImpl.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.basedriver/src/main/java/it/cnr/isti/zigbee/basedriver/api/impl/ZigBeeDeviceImpl.java Fri Apr 11 18:22:30 2014
@@ -136,6 +136,7 @@
 		properties.put(ZigBeeDevice.CLUSTERS_INPUT_ID, inputs);
 		properties.put(ZigBeeDevice.CLUSTERS_OUTPUT_ID, outputs);
 		properties.put(ZigBeeDevice.ZIGBEE_IMPORT, drv.getClass());
+		properties.put(ZigBeeDevice.IEEE_ADDRESS, node.getIEEEAddress());
 
 		properties.put(Constants.DEVICE_CATEGORY,
 				new String[]{ZigBeeDevice.DEVICE_CATEGORY});

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/CurrentLevelBridgeListeners.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/CurrentLevelBridgeListeners.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/CurrentLevelBridgeListeners.java Fri Apr 11 18:22:30 2014
@@ -101,7 +101,7 @@
 					subscription.setReportableChange(configuration.getReportingChange());
 					subscription.updateConfiguration();
 				}
-				if ( subscription.addReportListner(this) == false ) {
+				if ( subscription.addReportListener(this) == false ) {
 					return false;
 				}
 			}

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/MeasuredValueBridgeListeners.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/MeasuredValueBridgeListeners.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/MeasuredValueBridgeListeners.java Fri Apr 11 18:22:30 2014
@@ -101,7 +101,7 @@
 					subscription.setReportableChange(configuration.getReportingChange());
 					subscription.updateConfiguration();
 				}
-				if ( subscription.addReportListner(this) == false ) {
+				if ( subscription.addReportListener(this) == false ) {
 					return false;
 				}
 			}

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/OccupancyBridgeListeners.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/OccupancyBridgeListeners.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/OccupancyBridgeListeners.java Fri Apr 11 18:22:30 2014
@@ -99,7 +99,7 @@
 					subscription.setMinimumReportingInterval(configuration.getReportingMinimum());
 					subscription.updateConfiguration();
 				}
-				if ( subscription.addReportListner(this) == false ) {
+				if ( subscription.addReportListener(this) == false ) {
 					return false;
 				}
 			}

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/OnOffBridgeListeners.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/OnOffBridgeListeners.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/OnOffBridgeListeners.java Fri Apr 11 18:22:30 2014
@@ -99,7 +99,7 @@
 					subscription.setMinimumReportingInterval(configuration.getReportingMinimum());
 					subscription.updateConfiguration();
 				}
-				if ( subscription.addReportListner(this) == false ) {
+				if ( subscription.addReportListener(this) == false ) {
 					return false;
 				}
 			}

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/PresentValueBridgeListeners.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/PresentValueBridgeListeners.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/PresentValueBridgeListeners.java Fri Apr 11 18:22:30 2014
@@ -98,7 +98,7 @@
                     subscription.setMinimumReportingInterval(configuration.getReportingMinimum());
                     subscription.updateConfiguration();
                 }
-                if ( subscription.addReportListner(this) == false ) {
+                if ( subscription.addReportListener(this) == false ) {
                     return false;
                 }
             }

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/ToleranceBridgeListeners.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/ToleranceBridgeListeners.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/impl/event/ToleranceBridgeListeners.java Fri Apr 11 18:22:30 2014
@@ -101,7 +101,7 @@
 					subscription.setReportableChange(configuration.getReportingChange());
 					subscription.updateConfiguration();
 				}
-				if ( subscription.addReportListner(this) == false ) {
+				if ( subscription.addReportListener(this) == false ) {
 					return false;
 				}
 			}

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/driver/HAImporter.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/driver/HAImporter.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/driver/HAImporter.java Fri Apr 11 18:22:30 2014
@@ -211,6 +211,8 @@
         properties.put(HADevice.HA_DEVICE_NAME, refined.getName());
         properties.put(HADevice.HA_DEVICE_GROUP, ""); //TODO
         properties.put(HADevice.HA_DEVICE_STANDARD, Boolean.TRUE);
+        properties.put(HADevice.ENDPOINT_ADDRESS, zbDeviceSR.getProperty(ZigBeeDevice.ENDPOINT));
+        properties.put(HADevice.MAC_ADDRESS, zbDeviceSR.getProperty(ZigBeeDevice.IEEE_ADDRESS));
 
 
         ServiceRegistration registration = context.registerService(directInterfaces, refined, properties);

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/driver/core/HADevice.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/driver/core/HADevice.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.ha.driver/src/main/java/it/cnr/isti/zigbee/ha/driver/core/HADevice.java Fri Apr 11 18:22:30 2014
@@ -48,6 +48,8 @@
 	public static final String HA_DEVICE_NAME = "zigbee.ha.name";
 	public static final String HA_DEVICE_GROUP = "zigbee.ha.group";
 	public static final String HA_DEVICE_STANDARD = "zigbee.ha.standard";
+	public static final String ENDPOINT_ADDRESS = "zigbee.device.endpoint";
+	public static final String MAC_ADDRESS = "zigbee.device.macaddress";
 	
 	public static final int[] MANDATORY = {HAProfile.BASIC,HAProfile.IDENTIFY};
 	public static final int[] OPTIONAL = {HAProfile.POWER_CONFIGURATION, HAProfile.DEVICE_TEMPERATURE_CONFIGURATION, HAProfile.ALARMS};

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.noGUI.tester/pom.xml
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.noGUI.tester/pom.xml (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.noGUI.tester/pom.xml Fri Apr 11 18:22:30 2014
@@ -92,6 +92,7 @@
 							com.itaca.ztool.util
 						</Private-Package>
 						<Import-Package>
+							it.cnr.isti.zigbee.zcl.library.api.core,
 							it.cnr.isti.osgi.util,
 							it.cnr.isti.zigbee.ha.*,
 							org.osgi.*,

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.noGUI.tester/src/main/java/it/cnr/isti/zb4osgi/zigbee/noGUI/tester/ReportingConfiguratorDaemon.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.noGUI.tester/src/main/java/it/cnr/isti/zb4osgi/zigbee/noGUI/tester/ReportingConfiguratorDaemon.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.noGUI.tester/src/main/java/it/cnr/isti/zb4osgi/zigbee/noGUI/tester/ReportingConfiguratorDaemon.java Fri Apr 11 18:22:30 2014
@@ -58,14 +58,13 @@
 		log.info(ReportingConfiguratorDaemon.class.getName() + " STARTING");
 		monitor.start();
 		log.info(ReportingConfiguratorDaemon.class.getName() + ": STARTED");
-		doRegisterConfigurationService(context);
-
+		doRegisterConfigurationService();
 	}
 
-	private void doRegisterConfigurationService(BundleContext context) {
+	private void doRegisterConfigurationService() {
 		Properties properties = new Properties();
 		properties.setProperty(Constants.SERVICE_PID, NOGUI_CONFIG_PID);
-		configuration = new TesterConfiguration(context);
+		configuration = new TesterConfiguration(context,monitor);
 		log.info(ManagedService.class.getName() + " STARTING");
 		configRegistration = context.registerService(
 				ManagedService.class.getName(), getCurrentConfiguration(),

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.noGUI.tester/src/main/java/it/cnr/isti/zb4osgi/zigbee/noGUI/tester/TesterConfiguration.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.noGUI.tester/src/main/java/it/cnr/isti/zb4osgi/zigbee/noGUI/tester/TesterConfiguration.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.noGUI.tester/src/main/java/it/cnr/isti/zb4osgi/zigbee/noGUI/tester/TesterConfiguration.java Fri Apr 11 18:22:30 2014
@@ -23,12 +23,20 @@
 package it.cnr.isti.zb4osgi.zigbee.noGUI.tester;
 
 import it.cnr.isti.osgi.util.DictionaryHelper;
+import it.cnr.isti.zigbee.ha.cluster.glue.Cluster;
+import it.cnr.isti.zigbee.ha.driver.core.HADevice;
+import it.cnr.isti.zigbee.zcl.library.api.core.AnalogSubscription;
+import it.cnr.isti.zigbee.zcl.library.api.core.Attribute;
+import it.cnr.isti.zigbee.zcl.library.api.core.Subscription;
+import it.cnr.isti.zigbee.zcl.library.api.core.ZigBeeType;
 
 import java.util.ArrayList;
 import java.util.Dictionary;
 import java.util.HashMap;
+import java.util.List;
 
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedService;
 import org.slf4j.Logger;
@@ -46,10 +54,13 @@
 			.getLogger(TesterConfiguration.class);
 
 	private final HashMap<String, Object> configuration = new HashMap<String, Object>();
-	private final BundleContext context;
+	private BundleContext context;
+	private DeviceMonitor monitor;
 
-	public TesterConfiguration(BundleContext bundleContext) {
+	public TesterConfiguration(BundleContext bundleContext,
+			DeviceMonitor deviceMonitor) {
 		context = bundleContext;
+		monitor = deviceMonitor;
 		synchronized (configuration) {
 			logger.debug("Initialized {} with {}", this, configuration);
 		}
@@ -75,10 +86,49 @@
 					configuration);
 		}
 
+		List<ServiceReference> newdeviceList = monitor
+				.getAvailableServiceRefs();
+		List<String[]> newParsedConfig = doParseConfiguration();
+		findMatchesBeetweenConfigAndDeviceList(newdeviceList, newParsedConfig);
+
 	}
 
-	private ArrayList<String[]> doParseConfiguration() {
-		ArrayList<String[]> list = new ArrayList<String[]>();
+	private void findMatchesBeetweenConfigAndDeviceList(
+			List<ServiceReference> newdeviceList, List<String[]> newParsedConfig) {
+
+		for (ServiceReference elem : newdeviceList) {
+
+			String endPoint = (String) elem
+					.getProperty("zigbee.device.endpoint");
+			String macAddress = (String) elem
+					.getProperty("zigbee.device.macaddress");
+
+			for (String[] entry : newParsedConfig) {
+
+				if (macAddress.equalsIgnoreCase(entry[0])) {
+					if (endPoint.equalsIgnoreCase(entry[1])) {
+						doSubscribe(elem, Integer.parseInt(entry[2]),
+								Integer.parseInt(entry[3]),
+								Integer.parseInt(entry[4]),
+								Integer.parseInt(entry[5]),
+								Integer.parseInt(entry[6])
+
+						);
+						logger.debug(
+								"Posso mandare il comando di reporting per {} {}",
+								macAddress, endPoint);
+
+					}
+				};
+
+			}
+
+		}
+
+	}
+
+	private List<String[]> doParseConfiguration() {
+		List<String[]> list = new ArrayList<String[]>();
 		for (String key : configuration.keySet()) {
 			String[] reporting = ((String) configuration.get(key)).split(",");
 			list.add(reporting);
@@ -97,4 +147,48 @@
 		return true;
 	}
 
+	public void doSubscribe(ServiceReference service, int clusterID,
+			int attributeID, int reportingTimeMin, int reportingTimeMax,
+			int delta) {
+
+		HADevice device = (HADevice) context.getService(service);
+		Cluster cluster = device.getCluster(clusterID);
+		Attribute attribute = cluster.getAttribute(attributeID);
+
+		 final Subscription sub = attribute.getSubscription();
+		 try {
+		 sub.setMaximumReportingInterval(reportingTimeMax);
+		 } catch (NumberFormatException ex) {
+		
+		 sub.setMaximumReportingInterval(Subscription.DEFAULT_MAX_REPORTING_INTERVAL);
+		 }
+		 try {
+		 sub.setMinimumReportingInterval(reportingTimeMin);
+		 } catch (NumberFormatException ex) {
+		
+		 sub.setMinimumReportingInterval(Subscription.DEFAULT_MIN_REPORTING_INTERVAL);
+		 }
+		 if (sub instanceof AnalogSubscription) {
+		 AnalogSubscription asub = (AnalogSubscription) sub;
+		 final ZigBeeType type = attribute.getZigBeeType();
+		 try {
+		 asub.setReportableChange(delta);
+		 } catch (NumberFormatException ex) {
+		
+		 asub.setReportableChange(AnalogSubscription.DEFAULT_REPORTABLE_CHANGE_INTERVAL);
+		 }
+		 }
+		
+//		 if (attribute.getSubscription().addReportListener(listener)) {
+//		 logger.debug("Subscribed to " + attribute.getName() + "\n\t"
+//		 + "Status: SUCCESS\n");
+//		 updateCategory(HADeviceTreeNode.SUBSCRIBED_STATE);
+//		 subscription.put(attribute, listener);
+//		 getSubscribeButton().setText("Unsubscribe");
+//		 } else {
+//		 logger.debug("Subscribed to " + attribute.getName() + "\n\t"
+//		 + "Status: FAILED\n");
+//		 }
+
+	}
 }

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/configurations/services/it.cnr.isti.zigbee.noGUI.reporting.configuration.properties
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/configurations/services/it.cnr.isti.zigbee.noGUI.reporting.configuration.properties (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/configurations/services/it.cnr.isti.zigbee.noGUI.reporting.configuration.properties Fri Apr 11 18:22:30 2014
@@ -2,9 +2,9 @@
 ## 1) "stop  11"   che è "OPS4J Pax ConfMan - Properties Loader (0.2.2)" per ora e poi start dello stesso
 ## 2)  "stop  10"   che è "Apache Felix Configuration Admin Service (1.2.4)" per ora e poi start dello stesso
 ##
-## reporting_x = MAC ADDRESS, ENDPOINT, CLUSTER ID, ATTRIBUTE ID , MIN , MAX , DELTA
-Reporting_1="00:00:00:00:00:00,1,0,1,3,5,1"
-Reporting_2="00:00:00:00:00:00,2,0,1,3,5,1"
-Reporting_3="00:00:00:00:00:00,3,0,1,3,5,1"
-Reporting_4="00:00:00:00:00:00,4,0,1,3,5,1"
-Reporting_5="00:00:00:00:00:00,7,0,1,3,5,1"
+## reporting_x = MAC ADDRESS (da 00 a FF xx:yy:zz:aa:bb:cc:ee:ff), ENDPOINT (1-240), CLUSTER ID, ATTRIBUTE ID , MIN , MAX , DELTA
+Reporting_1=00:13:7A:00:00:00:6D:65,1,6,0,3,5,1
+Reporting_2=99:AA:BB:CC:DD:EE:FF:00,145,9,0,3,5,1
+Reporting_3=00:00:00:00:00:00:FF:00,6,0,1,3,5,1
+Reporting_4=00:00:00:00:00:00:FF:00,7,0,1,3,5,1
+Reporting_5=00:00:00:00:00:00:FF:00,8,0,1,3,5,1

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/src/main/java/org/persona/zigbee/tester/gui/AttributeActionPanel.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/src/main/java/org/persona/zigbee/tester/gui/AttributeActionPanel.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/src/main/java/org/persona/zigbee/tester/gui/AttributeActionPanel.java Fri Apr 11 18:22:30 2014
@@ -145,7 +145,7 @@
 					}catch(NumberFormatException ex){
 						LogPanel.log(
 								"Invalid value for " + attribute.getName() + " we where expecting a number." +
-								"\n\tStatus: SKYPPED"
+								"\n\tStatus: SKIPPED"
 						);
 						return;
 					}
@@ -249,7 +249,7 @@
 					}
                 }
                 
-                if ( attribute.getSubscription().addReportListner(listener) ) {
+                if ( attribute.getSubscription().addReportListener(listener) ) {
                     LogPanel.log(
                             "Subscribed to " + attribute.getName() + "\n\t" +
                                     "Status: SUCCESS\n"

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zcl.library/src/main/java/it/cnr/isti/zigbee/zcl/library/api/core/Subscription.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zcl.library/src/main/java/it/cnr/isti/zigbee/zcl/library/api/core/Subscription.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zcl.library/src/main/java/it/cnr/isti/zigbee/zcl/library/api/core/Subscription.java Fri Apr 11 18:22:30 2014
@@ -43,8 +43,8 @@
 	 */
 	public static final int DEFAULT_MIN_REPORTING_INTERVAL = 0;
 		
-	public boolean addReportListner(ReportListener listner);	
-	public boolean removeReportListner(ReportListener listner);
+	public boolean addReportListener(ReportListener listener);	
+	public boolean removeReportListner(ReportListener listener);
 	
 	public int getMinimumReportingInterval();
 	public int setMinimumReportingInterval(int value);

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zcl.library/src/main/java/it/cnr/isti/zigbee/zcl/library/impl/core/SubscriptionBase.java
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zcl.library/src/main/java/it/cnr/isti/zigbee/zcl/library/impl/core/SubscriptionBase.java (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.zcl.library/src/main/java/it/cnr/isti/zigbee/zcl/library/impl/core/SubscriptionBase.java Fri Apr 11 18:22:30 2014
@@ -83,13 +83,13 @@
                     localCopy = new ArrayList<ReportListener>(listeners);
                 }
                 log.debug("Notifying {} ReportListener", localCopy.size());
-                for (ReportListener reportListner : localCopy) {
+                for (ReportListener reportListener : localCopy) {
                     try{
-                        log.debug("Notifying {}:{}", reportListner.getClass().getName(), reportListner);
-                        reportListner.receivedReport(event);
+                        log.debug("Notifying {}:{}", reportListener.getClass().getName(), reportListener);
+                        reportListener.receivedReport(event);
                     }catch(Exception e){
                         log.error("Error while notifying {}:{} caused by {}",new Object[]{
-                                reportListner.getClass().getName(), reportListner, e.getStackTrace()
+                                reportListener.getClass().getName(), reportListener, e.getStackTrace()
                         });
                     }
                 }
@@ -136,7 +136,7 @@
 
     protected abstract boolean doConfigureServer() throws ZigBeeClusterException;
 
-    public boolean addReportListner(ReportListener listener) {
+    public boolean addReportListener(ReportListener listener) {
         synchronized (listeners) {
             if ( listeners.size() == 0 ) {
                 if( ! doBindToDevice() ) {




More information about the Commit mailing list