Hiroshi Yamaguchi / Mbed 2 deprecated XBeeExamples

Dependencies:   mbed XBee mbed-rtos

Committer:
yamaguch
Date:
Wed Nov 09 07:33:40 2011 +0000
Revision:
0:34e0352d7396
Child:
5:d01cf03058f6
initial creation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yamaguch 0:34e0352d7396 1 #include "XBee.h"
yamaguch 0:34e0352d7396 2
yamaguch 0:34e0352d7396 3 void xbeeio5() {
yamaguch 0:34e0352d7396 4 Serial ser(p9, p10);
yamaguch 0:34e0352d7396 5 ser.baud(115200);
yamaguch 0:34e0352d7396 6 XBee xbee(ser);
yamaguch 0:34e0352d7396 7 xbee.init();
yamaguch 0:34e0352d7396 8
yamaguch 0:34e0352d7396 9 unsigned long long destination = 0x0013A20040666193;
yamaguch 0:34e0352d7396 10 printf("Destination (0x0013A200XXXXXXXX) => ");
yamaguch 0:34e0352d7396 11 scanf("%llx", &destination);
yamaguch 0:34e0352d7396 12 printf("xbee.setDestination(0x%0llX)\n", destination);
yamaguch 0:34e0352d7396 13 xbee.setDestination(destination);
yamaguch 0:34e0352d7396 14
yamaguch 0:34e0352d7396 15 char param[] = {2}; // analog input
yamaguch 0:34e0352d7396 16 xbee.sendRemoteCommand("D1", param, 1);
yamaguch 0:34e0352d7396 17 while (xbee.receive()); // clear receive buffer
yamaguch 0:34e0352d7396 18
yamaguch 0:34e0352d7396 19 for (int i = 0; i < 60; i++) {
yamaguch 0:34e0352d7396 20 xbee.sendRemoteCommand("IS");
yamaguch 0:34e0352d7396 21 if (xbee.receive() == XBee::RemoteCommandResponse) {
yamaguch 0:34e0352d7396 22 char data[16];
yamaguch 0:34e0352d7396 23 xbee.scan(XBee::CommandData, data, sizeof(data));
yamaguch 0:34e0352d7396 24 IOSample sample(data);
yamaguch 0:34e0352d7396 25 printf("AD1 = %3.2fV\n", 3.3 * sample.ad[1] / 1023);
yamaguch 0:34e0352d7396 26 }
yamaguch 0:34e0352d7396 27 wait(1);
yamaguch 0:34e0352d7396 28 }
yamaguch 0:34e0352d7396 29
yamaguch 0:34e0352d7396 30 printf("done.\n");
yamaguch 0:34e0352d7396 31 }