[zb4osgi-changeset] [scm] ZigBee 4 OSGi repository change: r997 - in /projects/zb4osgi/sandbox/giancarlo.riolo: zigbee.noGUI.tester/src/main/java/it/cnr/isti/zb4osgi/zigbee/noGUI/tester/ zigbee.tester/configurations/services/

scm-notify at zb4osgi.aaloa.org scm-notify at zb4osgi.aaloa.org
Mon Apr 14 18:42:49 CEST 2014


Author: giancarlo.riolo
Date: Mon Apr 14 18:42:48 2014
New Revision: 997

Log:
NoGUI text file configuration errors treatment and log messages.

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.tester/configurations/services/it.cnr.isti.zigbee.driver.configuration.properties
    projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/configurations/services/it.cnr.isti.zigbee.noGUI.reporting.configuration.properties

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 Mon Apr 14 18:42:48 2014
@@ -95,7 +95,6 @@
 
 	private void findMatchesBeetweenConfigAndDeviceList(
 			List<ServiceReference> newdeviceList, List<String[]> newParsedConfig) {
-
 		for (ServiceReference elem : newdeviceList) {
 
 			String endPoint = (String) elem
@@ -103,30 +102,37 @@
 			String macAddress = (String) elem
 					.getProperty("zigbee.device.macaddress");
 
-			for (String[] entry : newParsedConfig) {
-
+			logger.debug("Finding match for device {}  with EndPoint "
+					+ endPoint + " and MacAddress " + macAddress, elem);
+			loop : for (String[] entry : newParsedConfig) {
+
+				boolean match = false;
 				if (macAddress.equalsIgnoreCase(entry[0])) {
 					if (endPoint.equalsIgnoreCase(entry[1])) {
+						match = true;
+						logger.debug("Match Found. Trying to subscribe reporting  for endpoint :"
+								+ endPoint + " and mac address " + macAddress);
+
 						doSubscribe(elem, Integer.parseInt(entry[2]),
 								Integer.parseInt(entry[3]),
 								Integer.parseInt(entry[4]),
 								Integer.parseInt(entry[5]),
-								Integer.parseInt(entry[6])
-
-						);
+								Integer.parseInt(entry[6]));
+						break loop;
+
+					}
+					if (!match) {
 						logger.debug(
-								"Posso mandare il comando di reporting per {} {}",
-								macAddress, endPoint);
-
-					}
-				};
-
+								"Match not Found for device {}  with EndPoint "
+										+ endPoint + " and MacAddress "
+										+ macAddress, elem);
+					}
+
+				}
 			}
-
-		}
-
-	}
-
+		}
+
+	}
 	private List<String[]> doParseConfiguration() {
 		List<String[]> list = new ArrayList<String[]>();
 		for (String key : configuration.keySet()) {
@@ -153,42 +159,69 @@
 
 		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");
-//		 }
-
+		if (cluster != null) {
+			logger.debug("Cluster ID {} found", clusterID);
+			Attribute attribute = cluster.getAttribute(attributeID);
+
+			if (attribute != null) {
+				logger.debug("Attribute ID {} found", attributeID);
+				final Subscription sub = attribute.getSubscription();
+				if (sub != null) {
+					logger.debug(
+							"Subscription found for clusterID {} and attributeID {}",
+							clusterID, attributeID);
+					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);
+						}
+						logger.debug(
+								"Subscribed reporting  ClusterID {} AttributeID {}:",
+								clusterID, attributeID);
+
+					}
+
+					// if
+					// (attribute.getSubscription().addReportListener(listener))
+					// {
+					// logger.debug("Subscribed to " + attribute.getName()
+					// + "\n\t" + "Status: SUCCESS\n");
+					// HashMap<String, Object> subscription;
+					// subscription.put(attribute, listener);
+					// } else {
+					// logger.debug("Subscribed to " + attribute.getName()
+					// + "\n\t" + "Status: FAILED\n");
+					// }
+				} else {
+					logger.debug(
+							"Not reportable AttributeID {} and ClusterID {}",
+							attributeID, clusterID);
+				}
+			} else {
+				logger.debug(
+						"Trying to use an Attribute id: {} not present in Cluster id: {}",
+						attributeID, clusterID);
+			}
+		} else {
+			logger.debug(
+					"Trying to use a Cluster (id: {}) not present in device (Service {}).",
+					(Integer) clusterID, device.getName());
+		}
 	}
 }

Modified: projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/configurations/services/it.cnr.isti.zigbee.driver.configuration.properties
==============================================================================
--- projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/configurations/services/it.cnr.isti.zigbee.driver.configuration.properties (original)
+++ projects/zb4osgi/sandbox/giancarlo.riolo/zigbee.tester/configurations/services/it.cnr.isti.zigbee.driver.configuration.properties Mon Apr 14 18:42:48 2014
@@ -1,5 +1,5 @@
 it.cnr.isti.zigbee.driver.serial.portname=/dev/ttyACM0
-it.cnr.isti.zigbee.pan.channel=22
+it.cnr.isti.zigbee.pan.channel=11
 #it.cnr.isti.zigbee.driver.flush=true
 #it.cnr.isti.zigbee.driver.serial.baudrate=115200
 it.cnr.isti.zigbee.driver.mode=Coordinator

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 Mon Apr 14 18:42:48 2014
@@ -5,6 +5,6 @@
 ## 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_3=00:12:4B:00:02:6F:99:3A,1,12,85,4,60,1
+Reporting_4=00:12:4B:00:02:6F:99:3A,2,12,85,4,60,1
 Reporting_5=00:00:00:00:00:00:FF:00,8,0,1,3,5,1




More information about the Commit mailing list