Simple example of how to use XBeeApi - set up the XBee, configure P2P networking then transmit a frame.

Dependencies:   XBeeApi mbed

Dependents:   XBeeApiBroadcastExample

See also the the API page

Files at this revision

API Documentation at this revision

Comitter:
johnb
Date:
Sun Jul 06 21:01:14 2014 +0000
Parent:
3:8fea787c2199
Commit message:
Updated to use constructor rather than method calls to set up TX frame

Changed in this revision

XBeeApi.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/XBeeApi.lib	Fri Mar 28 22:31:04 2014 +0000
+++ b/XBeeApi.lib	Sun Jul 06 21:01:14 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/johnb/code/XBeeApi/#cc7e8d1e35dd
+http://mbed.org/users/johnb/code/XBeeApi/#85a66d56e176
--- a/main.cpp	Fri Mar 28 22:31:04 2014 +0000
+++ b/main.cpp	Sun Jul 06 21:01:14 2014 +0000
@@ -58,7 +58,7 @@
     XBeeDevice::XBeeDeviceReturn_t status;
 
     /* This is the frame we're going to transmit */
-    XBeeApiTxFrame frame( &xbeeDevice );
+    XBeeApiTxFrame frame( &xbeeDevice, tx_data, sizeof( tx_data ), frameDestinationAddress );
         
     /* Get API mode 2 set up - this is a pre-requisit to using other XBeeApi functions.
        This step may not be needed in the case that the XBee has already been configured
@@ -72,10 +72,6 @@
         /* Set up a peer-to-peer network using the specified PAN and channel */
         xbeeSetNetworkTypeP2P( &atIf, myPANId, myChannelId );
 
-        /* Set the data pointer & destination address in the transmit frame */
-        frame.setDataPtr( tx_data, sizeof( tx_data ) );
-        frame.setDestAddr( frameDestinationAddress );
-        
         xbeeDevice.SendFrame( &frame );    
     }
 }
\ No newline at end of file