Browse files

updated demo for new udev devnode

  • Loading branch information...
1 parent 5bc453b commit 9faa0076493f884412d0e654e867377a5b08bf8d @theterg theterg committed Sep 28, 2011
View
25 RemoteMonDemoAPI/remotemondemoapi/RemoteMonDemoAPIApplication.java
@@ -3,18 +3,14 @@
import java.util.Arrays;
import java.util.Map;
+import org.osgi.service.log.LogService;
+
+import com.buglabs.application.ServiceTrackerHelper.ManagedRunnable;
import com.buglabs.xbee.XBeeCallback;
import com.buglabs.xbee.XBeeController;
import com.buglabs.xbee.protocol.MaxbotixRangefinder;
import com.buglabs.xbee.protocol.PIRMotion;
-import com.buglabs.xbee.protocol.SerialDevice;
import com.buglabs.xbee.protocol.SparkfunWeatherboard;
-import com.buglabs.xbee.protocol.XBeeProtocol;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.service.log.LogService;
-
-import com.buglabs.application.ServiceTrackerHelper.ManagedRunnable;
/**
* This class represents the running application when all service dependencies are fulfilled.
*
@@ -26,30 +22,23 @@
* finer grained service binding logic, see ServiceTrackerHelper.openServiceTracker(BundleContext context, String[] services, Filter filter, ServiceTrackerCustomizer customizer)
*/
public class RemoteMonDemoAPIApplication implements ManagedRunnable, XBeeCallback {
- final int[] WEATHER_ADDRESS = {0x00, 0x03};
- final int[] MOTION_ADDRESS = {0x00, 0x02};
- final int[] RANGE_ADDRESS = {0x00, 0x01};
-
private XBeeController xbc;
private LogService ls;
- private SparkfunWeatherboard weather;
- private MaxbotixRangefinder range;
- private PIRMotion motion;
@Override
public void dataRecieved(Map<String, Object> data) {
- if ((Class)data.get("class") == SparkfunWeatherboard.class){
+ if ((Class<?>)data.get("class") == SparkfunWeatherboard.class){
ilog("Weather data from "+Integer.toHexString(((int[])data.get("address"))[1]));
ilog("Temperature: "+data.get("Temperature"));
ilog("Humidity: "+data.get("Humidity"));
ilog("Dewpoint: "+data.get("Dewpoint"));
ilog("Pressure: "+data.get("Pressure"));
ilog("Light: "+data.get("Light"));
- } else if ((Class)data.get("class") == MaxbotixRangefinder.class){
+ } else if ((Class<?>)data.get("class") == MaxbotixRangefinder.class){
String range = (String) data.get("Range");
ilog("Range from "+Integer.toHexString(((int[])data.get("address"))[1])
+": "+range);
- } else if ((Class)data.get("class") == PIRMotion.class){
+ } else if ((Class<?>)data.get("class") == PIRMotion.class){
ilog("Motion detected from "+Integer.toHexString(((int[])data.get("address"))[1]));
} else {
ilog("Unknown data: "+Arrays.toString((int[])data.get("raw")));
@@ -74,6 +63,6 @@ public void shutdown() {
ilog("Stop");
}
- void ilog(String message){ ls.log(ls.LOG_INFO, "["+this.getClass().getSimpleName()+"] "+message); }
+ void ilog(String message){ ls.log(LogService.LOG_INFO, "["+this.getClass().getSimpleName()+"] "+message); }
}
View
2 com.buglabs.xbee/com/buglabs/xbee/XBeeMonitor.java
@@ -42,7 +42,7 @@
private Thread t;
private LogService ls;
private boolean running = true;
- private String devnode = "/dev/ttyUSB0";
+ private String devnode = "/dev/ttyXbee0";
private int baud = 9600;
private Map<XBeeAddress, XBeeProtocol> protocols;
private Set<Class> expectedProtocols;

0 comments on commit 9faa007

Please sign in to comment.