Hiroshi Yamaguchi / Mbed 2 deprecated XBeeExamples

Dependencies:   mbed XBee mbed-rtos

xbeeio5.cpp

Committer:
yamaguch
Date:
2012-04-12
Revision:
5:d01cf03058f6
Parent:
0:34e0352d7396
Child:
6:d456c203adb6

File content as of revision 5:d01cf03058f6:

#include "XBee.h"

void xbeeio5() {
    XBee xbee(p9, p10);
    xbee.baud(115200);
    xbee.init();

    xbee.setDestination(XBeeAddress64(0x0013A200, 0x40666193));

    xbee.sendRemoteCommand("D1", 2);

    // clear receive buffer
    while (xbee.receive())
        ;

    for (int i = 0; i < 60; i++) {
        xbee.sendRemoteCommand("IS");
        if (xbee.receive() == XBee::RemoteCommandResponse) {
            XBeeCommandData data(16);
            xbee.scan(data);
            
            IOSample sample(data);
            printf("AD1 = %3.2fV\n", 3.3 * sample.ad[1] / 1023);
        }
        wait(1);
    }

    printf("done.\n");
}