Skip to content

Commit

Permalink
updated demo for new udev devnode
Browse files Browse the repository at this point in the history
  • Loading branch information
theterg committed Sep 28, 2011
1 parent 5bc453b commit 9faa007
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
25 changes: 7 additions & 18 deletions RemoteMonDemoAPI/remotemondemoapi/RemoteMonDemoAPIApplication.java
Expand Up @@ -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.
*
Expand All @@ -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")));
Expand All @@ -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); }

}
2 changes: 1 addition & 1 deletion com.buglabs.xbee/com/buglabs/xbee/XBeeMonitor.java
Expand Up @@ -42,7 +42,7 @@ public class XBeeMonitor implements ManagedRunnable, Runnable, PacketListener, X
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;
Expand Down

0 comments on commit 9faa007

Please sign in to comment.