Suga koubou / Mbed 2 deprecated XBee_sample

Dependencies:   mbed XBee

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "XBee.h"
00003 
00004 DigitalOut myled(LED1);
00005 XBee xbee(p13, p14);
00006 XBeeAddress64 remoteAddress = XBeeAddress64(0x0013A200, 0x40319F25);
00007 
00008 int main() {
00009     uint8_t Cmd[] = {'D', '4'};
00010     uint8_t Low[] = {0x04};
00011     uint8_t High[] = {0x05};
00012     RemoteAtCommandRequest remoteAtRequest;
00013 
00014     wait(1);
00015     xbee.begin(9800);
00016 
00017     remoteAtRequest = RemoteAtCommandRequest(remoteAddress, Cmd, Low, sizeof(Low));
00018     remoteAtRequest.setApplyChanges(true);
00019 
00020     while(1) {
00021         myled = 1;
00022         remoteAtRequest.setCommandValue(Low);
00023         remoteAtRequest.setCommandValueLength(sizeof(Low));
00024         xbee.send(remoteAtRequest);
00025         myled = 0;
00026         wait(1);
00027 
00028         myled = 1;
00029         remoteAtRequest.setCommandValue(High);
00030         remoteAtRequest.setCommandValueLength(sizeof(High));
00031         xbee.send(remoteAtRequest);
00032         myled = 0;
00033         wait(1);
00034     }
00035 }