Skip to content
Browse files

Basic RM XBee application complete - 3 sensors with hardcoded address…

…es will print data to the log
  • Loading branch information...
1 parent 60bd00f commit f44d0efeb5a037603daf3e078479c54fef120557 @theterg theterg committed Sep 23, 2011
View
BIN XBeeAPITest/xbeeapitest/XBeeAPITestApplication$PacketParser.class
Binary file not shown.
View
BIN XBeeAPITest/xbeeapitest/XBeeAPITestApplication.class
Binary file not shown.
View
11 XBeeAPITest/xbeeapitest/XBeeAPITestApplication.java
@@ -67,11 +67,15 @@ public void processResponse(XBeeResponse res) {
if (res.getApiId() == ApiId.RX_16_RESPONSE){
RxResponse pkt = (RxResponse) res;
String data = ByteUtils.toString(pkt.getData());
+ data = data.replaceAll("\n", "");
+ data = data.replaceAll("\r", "");
//dlog("Incoming data "+pkt.getSourceAddress().getAddress()[1]+": "+data);
if (pkt.getSourceAddress().getAddress()[1] == 1){
//Data from the Sonar mote
- if (data.charAt(0) == 'R'){
- ilog("Range: "+data.substring(1)+"(cm)");
+ if (data.charAt(0) == 'R'){
+ //Remove out-of-range-samples
+ if (!data.contains("765"))
+ ilog("Range: "+data.substring(1)+" (cm)");
} else {
dlog("Sonar data: "+data);
}
@@ -106,7 +110,8 @@ public void processResponse(XBeeResponse res) {
//If incoming data is an IO packet
//Assume this was from a Motion module
RxResponseIoSample pkt = (RxResponseIoSample) res;
- ilog("Motion detected: "+ByteUtils.toBase16(pkt.getSamples()[0].getDioMsb())+","+ByteUtils.toBase16(pkt.getSamples()[0].getDioLsb()));
+ //ilog("Motion detected!: "+ByteUtils.toBase16(pkt.getSamples()[0].getDioMsb())+","+ByteUtils.toBase16(pkt.getSamples()[0].getDioLsb()));
+ ilog("Motion detected!");
}
}

0 comments on commit f44d0ef

Please sign in to comment.
Something went wrong with that request. Please try again.