Hiroshi Yamaguchi / Mbed 2 deprecated XBeeExamples

Dependencies:   mbed XBee mbed-rtos

Revision:
5:d01cf03058f6
Parent:
0:34e0352d7396
Child:
6:d456c203adb6
--- a/xbeeio5.cpp	Mon Nov 28 01:59:03 2011 +0000
+++ b/xbeeio5.cpp	Thu Apr 12 10:21:11 2012 +0000
@@ -1,26 +1,24 @@
 #include "XBee.h"
 
 void xbeeio5() {
-    Serial ser(p9, p10);
-    ser.baud(115200);
-    XBee xbee(ser);
+    XBee xbee(p9, p10);
+    xbee.baud(115200);
     xbee.init();
 
-    unsigned long long destination = 0x0013A20040666193;
-    printf("Destination (0x0013A200XXXXXXXX) => ");
-    scanf("%llx", &destination);
-    printf("xbee.setDestination(0x%0llX)\n", destination);
-    xbee.setDestination(destination);
+    xbee.setDestination(XBeeAddress64(0x0013A200, 0x40666193));
+
+    xbee.sendRemoteCommand("D1", 2);
 
-    char param[] = {2}; // analog input
-    xbee.sendRemoteCommand("D1", param, 1);
-    while (xbee.receive()); // clear receive buffer
+    // clear receive buffer
+    while (xbee.receive())
+        ;
 
     for (int i = 0; i < 60; i++) {
         xbee.sendRemoteCommand("IS");
         if (xbee.receive() == XBee::RemoteCommandResponse) {
-            char data[16];
-            xbee.scan(XBee::CommandData, data, sizeof(data));
+            XBeeCommandData data(16);
+            xbee.scan(data);
+            
             IOSample sample(data);
             printf("AD1 = %3.2fV\n", 3.3 * sample.ad[1] / 1023);
         }