xbee_lib from Tristan Hughes with some changes by zac dannelly

Dependents:   potSend potGet serialRangeGet

Fork of xbee_lib by Tristan Hughes

Revision:
3:682615a0717e
Parent:
2:cb627ea9b817
Child:
4:ede20c047d8b
--- a/xbee.cpp	Wed Aug 29 13:27:02 2012 +0000
+++ b/xbee.cpp	Wed Aug 29 14:04:27 2012 +0000
@@ -1,10 +1,11 @@
 #include "xbee.h"
 
 
-xbee::xbee(PinName tx, PinName rx)
+xbee::xbee(PinName tx, PinName rx, PinName reset)
 {
     _tx = tx;
     _rx = rx;
+    _reset = reset;
 }
 
 xbee::~xbee()
@@ -49,14 +50,14 @@
     return 1;
 }
 
-int xbee::SetKey(char* key)
+int xbee::SetKey(int* key)
 {
     Serial DATA(_tx,_rx);
     DATA.printf("ATEE 1 \r");
 
     DATA.scanf ("%*s");
     wait_ms(1);
-    DATA.printf("ATKY %s \r",key);
+    DATA.printf("ATKY %x \r",key);
     DATA.scanf ("%*s");
     return 1;
 }
@@ -96,7 +97,8 @@
     while(numchar!=count) {
         if(DATA.readable()) {
             *data_buf = DATA.getc();
-            data_buf+=1; count++;
+            data_buf+=1;
+            count++;
         }
 
     }
@@ -110,3 +112,14 @@
     DATA.scanf ("%*s");
     return 1;
 }
+
+void xbee::Reset()
+{
+    DigitalOut rssi(_reset);
+    rssi = 0;
+    wait_ms(10);
+    rssi = 1;
+    wait_ms(1);
+}
+
+