XBee-mbed sample

Dependencies:   mbed XBee

main.cpp

Committer:
okini3939
Date:
2010-11-22
Revision:
0:12a6db2d1600
Child:
1:f9ececd7aa01

File content as of revision 0:12a6db2d1600:

#include "mbed.h"
#include "XBee.h"

DigitalOut myled(LED1);
XBee xbee(p13, p14);
XBeeAddress64 remoteAddress = XBeeAddress64(0x0013A200, 0x40319F25);

int main() {
    uint8_t p2Cmd[] = {'D', '4'};
    uint8_t p2Low[] = {0x04};
    uint8_t p2High[] = {0x05};
    RemoteAtCommandRequest remoteAtRequest;

    wait(1);
    xbee.begin(9800);

    remoteAtRequest = RemoteAtCommandRequest(remoteAddress, p2Cmd, p2Low, sizeof(p2Low));
    remoteAtRequest.setApplyChanges(true); // I/Oó‘Ԃ𑦔½‰f‚³‚¹‚é

    while(1) {
        myled = 1;
        remoteAtRequest.setCommandValue(p2Low);
        remoteAtRequest.setCommandValueLength(sizeof(p2Low));
        xbee.send(remoteAtRequest);
        myled = 0;
        wait(1);

        myled = 1;
        remoteAtRequest.setCommandValue(p2High);
        remoteAtRequest.setCommandValueLength(sizeof(p2High));
        xbee.send(remoteAtRequest);
        myled = 0;
        wait(1);
    }
}