Permalink
Browse files

first rev of XBeeMonitor with RemoteMonDemoAPI test code, refactored …

…XBeeAPITest->RemoteMonDemoSimple. Weatherboard protocol implemented, XBeeMonitor does not yet support whiteboard -> merely prints the retrieved data.
  • Loading branch information...
theterg committed Sep 23, 2011
1 parent f44d0ef commit 4db20c1a96ac0aacfcd9d56370a389984934a8bb
Showing with 553 additions and 8 deletions.
  1. 0 {XBeeAPITest → RemoteMonDemoAPI}/.classpath
  2. +1 −1 {XBeeAPITest → RemoteMonDemoAPI}/.project
  3. +7 −0 RemoteMonDemoAPI/.settings/org.eclipse.jdt.core.prefs
  4. +17 −0 RemoteMonDemoAPI/META-INF/MANIFEST.MF
  5. +52 −0 RemoteMonDemoAPI/remotemondemoapi/Activator.java
  6. +43 −0 RemoteMonDemoAPI/remotemondemoapi/RemoteMonDemoAPIApplication.java
  7. +8 −0 RemoteMonDemoSimple/.classpath
  8. +29 −0 RemoteMonDemoSimple/.project
  9. 0 {XBeeAPITest → RemoteMonDemoSimple}/.settings/org.eclipse.jdt.core.prefs
  10. +3 −3 {XBeeAPITest → RemoteMonDemoSimple}/META-INF/MANIFEST.MF
  11. +2 −2 {XBeeAPITest/xbeeapitest → RemoteMonDemoSimple/remotemondemosimple}/Activator.java
  12. +2 −2 ...eeAPITestApplication.java → RemoteMonDemoSimple/remotemondemosimple/RemoteMonDemoApplication.java
  13. BIN XBeeAPITest/xbeeapitest/Activator.class
  14. BIN XBeeAPITest/xbeeapitest/XBeeAPITestApplication$PacketParser.class
  15. BIN XBeeAPITest/xbeeapitest/XBeeAPITestApplication.class
  16. +8 −0 com.buglabs.xbee/.classpath
  17. +29 −0 com.buglabs.xbee/.project
  18. +7 −0 com.buglabs.xbee/.settings/org.eclipse.jdt.core.prefs
  19. +26 −0 com.buglabs.xbee/META-INF/MANIFEST.MF
  20. +52 −0 com.buglabs.xbee/com/buglabs/xbee/Activator.java
  21. +10 −0 com.buglabs.xbee/com/buglabs/xbee/XBeeController.java
  22. +184 −0 com.buglabs.xbee/com/buglabs/xbee/XBeeMonitor.java
  23. +61 −0 com.buglabs.xbee/com/buglabs/xbee/protocol/SparkfunWeatherboard.java
  24. +12 −0 com.buglabs.xbee/com/buglabs/xbee/protocol/XBeeProtocol.java
File renamed without changes.
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>XBeeAPITest</name>
+ <name>RemoteMonDemoAPI</name>
<comment></comment>
<projects>
</projects>
@@ -0,0 +1,7 @@
+#Fri Sep 23 18:15:45 EDT 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.6
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: RemoteMonDemoAPI
+Bundle-Activator: remotemondemoapi.Activator
+Bundle-SymbolicName: RemoteMonDemoAPI
+Bundle-Version: 1.0.0
+Bundle-Vendor: theterg
+Bundle-Description: The Remote Monitoring demo - using com.buglabs.xbee
+Bug-Bundle-Type: Application
+BUG-API-Version: 2.0.2
+Import-Package: com.buglabs.application,
+ com.buglabs.util,
+ com.buglabs.xbee,
+ com.buglabs.xbee.protocol,
+ org.osgi.framework,
+ org.osgi.service.log,
+ org.osgi.util.tracker
@@ -0,0 +1,52 @@
+/**
+ * Generated by Dragonfly SDK.
+ */
+package remotemondemoapi;
+
+
+import com.buglabs.xbee.XBeeController;
+import org.osgi.service.log.LogService;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+import com.buglabs.application.ServiceTrackerHelper;
+
+
+/**
+ * BundleActivator for RemoteMonDemoAPI. The OSGi entry point to the application.
+ *
+ */
+public class Activator implements BundleActivator {
+ /**
+ * OSGi services the application depends on.
+ */
+ private static final String [] services = {
+ XBeeController.class.getName(),
+ LogService.class.getName(),
+ };
+ private ServiceTracker serviceTracker;
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ //Begin tracking services, and when all services are available, create thread and call ManagedRunnable.run().
+ serviceTracker = ServiceTrackerHelper.openServiceTracker(context, services, new RemoteMonDemoAPIApplication());
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+
+ //Will cause the ManagedRunnable.shutdown() to be called.
+ serviceTracker.close();
+ }
+
+
+}
@@ -0,0 +1,43 @@
+package remotemondemoapi;
+
+import java.util.Map;
+
+import com.buglabs.xbee.XBeeController;
+import com.buglabs.xbee.protocol.SparkfunWeatherboard;
+import com.buglabs.xbee.protocol.XBeeProtocol;
+
+import org.osgi.service.log.LogService;
+
+import com.buglabs.application.ServiceTrackerHelper.ManagedRunnable;
+/**
+ * This class represents the running application when all service dependencies are fulfilled.
+ *
+ * The run() method will be called with a map containing all the services specified in ServiceTrackerHelper.openServiceTracker().
+ * The application will run in a separate thread than the caller of start() in the Activator. See
+ * ManagedInlineRunnable for a thread-less application.
+ *
+ * By default, the application will only be started when all service dependencies are fulfilled. For
+ * finer grained service binding logic, see ServiceTrackerHelper.openServiceTracker(BundleContext context, String[] services, Filter filter, ServiceTrackerCustomizer customizer)
+ */
+public class RemoteMonDemoAPIApplication implements ManagedRunnable {
+ final int[] address = {0x00, 0x03};
+
+ private XBeeController xbc;
+ private LogService ls;
+
+ @Override
+ public void run(Map<Object, Object> services) {
+ xbc = (XBeeController) services.get(XBeeController.class.getName());
+ ls = (LogService) services.get(LogService.class.getName());
+ ilog("start");
+ xbc.addListener(new SparkfunWeatherboard(address));
+ }
+
+ @Override
+ public void shutdown() {
+ xbc.removeListener(address);
+ ilog("Stop");
+ }
+
+ void ilog(String message){ ls.log(ls.LOG_INFO, "["+this.getClass().getSimpleName()+"] "+message); }
+}
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path=""/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="com.buglabs.dragonfly.jdt.BugClasspathContainerInitializer"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>RemoteMonDemoSimple</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.buglabs.dragonfly.BugApplicationNature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -1,8 +1,8 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: XBeeAPITest
-Bundle-Activator: xbeeapitest.Activator
-Bundle-SymbolicName: XBeeAPITest
+Bundle-Name: RemoteMonDemoSimple
+Bundle-Activator: remotemondemosimple.Activator
+Bundle-SymbolicName: RemoteMonDemoSimple
Bundle-Version: 1.0.0
Bundle-Vendor: terg
Bug-Bundle-Type: Application
@@ -1,7 +1,7 @@
/**
* Generated by Dragonfly SDK.
*/
-package xbeeapitest;
+package remotemondemosimple;
import org.osgi.service.log.LogService;
@@ -32,7 +32,7 @@
*/
public void start(BundleContext context) throws Exception {
//Begin tracking services, and when all services are available, create thread and call ManagedRunnable.run().
- serviceTracker = ServiceTrackerHelper.openServiceTracker(context, services, new XBeeAPITestApplication());
+ serviceTracker = ServiceTrackerHelper.openServiceTracker(context, services, new RemoteMonDemoApplication());
}
@@ -1,4 +1,4 @@
-package xbeeapitest;
+package remotemondemosimple;
import java.util.Map;
import java.util.Properties;
@@ -28,7 +28,7 @@
* By default, the application will only be started when all service dependencies are fulfilled. For
* finer grained service binding logic, see ServiceTrackerHelper.openServiceTracker(BundleContext context, String[] services, Filter filter, ServiceTrackerCustomizer customizer)
*/
-public class XBeeAPITestApplication implements ManagedRunnable {
+public class RemoteMonDemoApplication implements ManagedRunnable {
private LogService ls;
private XBee xb;
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path=""/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="com.buglabs.dragonfly.jdt.BugClasspathContainerInitializer"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
View
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>com.buglabs.xbee</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.buglabs.dragonfly.BugApplicationNature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,7 @@
+#Fri Sep 23 13:49:29 EDT 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.6
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: com.buglabs.xbee
+Bundle-Activator: com.buglabs.xbee.Activator
+Bundle-SymbolicName: com.buglabs.xbee
+Bundle-Version: 1.0.0
+Bundle-Vendor: theterg
+Bundle-Description: Utilities to handle XBee communcation with bug applications
+Bug-Bundle-Type: Application
+BUG-API-Version: 2.0.2
+Import-Package: com.buglabs.application,
+ com.buglabs.util,
+ com.rapplogic.xbee,
+ com.rapplogic.xbee.api,
+ com.rapplogic.xbee.api.wpan,
+ com.rapplogic.xbee.api.zigbee,
+ com.rapplogic.xbee.examples,
+ com.rapplogic.xbee.examples.wpan,
+ com.rapplogic.xbee.examples.zigbee,
+ com.rapplogic.xbee.test,
+ com.rapplogic.xbee.util,
+ org.osgi.framework,
+ org.osgi.service.log,
+ org.osgi.util.tracker
+Export-Package: com.buglabs.xbee,
+ com.buglabs.xbee.protocol
@@ -0,0 +1,52 @@
+/**
+ * Generated by Dragonfly SDK.
+ */
+package com.buglabs.xbee;
+
+
+import java.util.Map;
+
+import org.osgi.service.log.LogService;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+import com.buglabs.application.ServiceTrackerHelper;
+
+
+/**
+ * BundleActivator for Com_buglabs_xbee. The OSGi entry point to the application.
+ *
+ */
+public class Activator implements BundleActivator {
+ /**
+ * OSGi services the application depends on.
+ */
+ private static final String [] services = {
+ LogService.class.getName(),
+ };
+ private ServiceTracker serviceTracker;
+ private XBeeMonitor mon;
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ mon = new XBeeMonitor(context);
+ serviceTracker = ServiceTrackerHelper.openServiceTracker(context, services, mon);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+
+ //Will cause the ManagedRunnable.shutdown() to be called.
+ serviceTracker.close();
+ }
+
+
+}
@@ -0,0 +1,10 @@
+package com.buglabs.xbee;
+
+import com.buglabs.xbee.protocol.XBeeProtocol;
+import com.rapplogic.xbee.api.XBee;
+
+public interface XBeeController {
+ public void addListener(XBeeProtocol proto);
+ public boolean removeListener(int[] addr);
+ public XBee getXBee();
+}
Oops, something went wrong.

0 comments on commit 4db20c1

Please sign in to comment.