Test / example for the XBeeApi library

Dependencies:   XBeeApi mbed

Example program employing the XBeeApi library to configure and communicate with an XBee. See the notebook page here

Committer:
johnb
Date:
Sat Jan 18 19:44:28 2014 +0000
Revision:
0:132f26d3350b
Child:
1:3de4723efe9e
Work-in-progress commit : Updates based in progress in XBeeApi library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
johnb 0:132f26d3350b 1 #include "mbed.h"
johnb 0:132f26d3350b 2 #include "XBeeApi.hpp"
johnb 0:132f26d3350b 3 #include "XBeeDevice.hpp"
johnb 0:132f26d3350b 4 #include "XBeeApiCmdAt.hpp"
johnb 0:132f26d3350b 5
johnb 0:132f26d3350b 6 Serial pc(USBTX, USBRX); // tx, rx
johnb 0:132f26d3350b 7
johnb 0:132f26d3350b 8 XBeeDevice xbeeDevice( PTA2, PTA1, NC, NC ); // tx, rx
johnb 0:132f26d3350b 9
johnb 0:132f26d3350b 10 XBeeApi xbeeApi(xbeeDevice);
johnb 0:132f26d3350b 11
johnb 0:132f26d3350b 12
johnb 0:132f26d3350b 13 uint8_t foo = 0;
johnb 0:132f26d3350b 14
johnb 0:132f26d3350b 15 int main() {
johnb 0:132f26d3350b 16 XBeeApiCmdAt cmd;
johnb 0:132f26d3350b 17 XBeeDevice::XBeeDeviceReturn_t status;
johnb 0:132f26d3350b 18
johnb 0:132f26d3350b 19 /* Get API mode 2 set up */
johnb 0:132f26d3350b 20 status = xbeeDevice.setUpApi();
johnb 0:132f26d3350b 21
johnb 0:132f26d3350b 22 if( status != XBeeDevice::XBEEDEVICE_OK )
johnb 0:132f26d3350b 23 {
johnb 0:132f26d3350b 24 pc.printf("\r\n[%4d]: XBeeStatus: %d\r\n",__LINE__,status);
johnb 0:132f26d3350b 25 }
johnb 0:132f26d3350b 26 else
johnb 0:132f26d3350b 27 {
johnb 0:132f26d3350b 28 /* If we got the API set up should be OK to send an API command */
johnb 0:132f26d3350b 29 xbeeDevice.SendCmd( &cmd );
johnb 0:132f26d3350b 30 }
johnb 0:132f26d3350b 31
johnb 0:132f26d3350b 32 while( 1 ) {
johnb 0:132f26d3350b 33 wait(1);
johnb 0:132f26d3350b 34 xbeeDevice.dumpRxBuffer( &pc, true );
johnb 0:132f26d3350b 35 }
johnb 0:132f26d3350b 36 pc.printf("\r\n[%4d]: Done\r\n",__LINE__);
johnb 0:132f26d3350b 37 }