Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: XBeeApiBroadcastExample
Diff: main.cpp
- Revision:
- 0:99422855f301
- Child:
- 1:953e5affd67a
diff -r 000000000000 -r 99422855f301 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Mar 25 18:39:34 2014 +0000
@@ -0,0 +1,62 @@
+/**
+ @file
+ @brief Example of using the XBeeApi library to broadcast a message
+ This example has a minimum of error checking in order
+ to keep the code compact
+
+ @author John Bailey
+
+ @copyright Copyright 2014 John Bailey
+
+ @section LICENSE
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+*/
+
+#include "mbed.h"
+#include "xbeeapi.hpp"
+
+uint8_t tx_data[] = { 'H', 'E', 'L', 'L', 'O' };
+
+/* TODO: You may need to change these based on the device/connections that you're using */
+XBeeDevice xbeeDevice( PTA2, PTA1, NC, NC );
+
+int main() {
+ /* This example will use the blocking API for simplicity */
+ XBeeApiCmdAtBlocking atIf( &xbeeDevice );
+
+ XBeeDevice::XBeeDeviceReturn_t status;
+
+ /* This is the frame we're going to transmit */
+ XBeeApiTxFrameEx frame( &xbeeDevice );
+
+ /* 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
+ to use Mode 2 and the setting has been stored in NV */
+ status = xbeeDevice.setUpApi();
+
+ if( status != XBeeDevice::XBEEDEVICE_OK )
+ {
+ /* Set the 16-bit source address of this XBee */
+ atIf.setSourceAddress( 0x1234 );
+ /* Set up a peer-to-peer network using the specified PAN and channel */
+ xbeeSetNetworkTypeP2P( &atIf, 1000, 14 );
+
+ /* Set the data pointer & destination address in the transmit frame */
+ frame.setDataPtr( tx_data, sizeof( tx_data ) );
+ frame.setDestAddr( 0x01 );
+
+ xbeeDevice.SendFrame( &frame );
+ }
+}
\ No newline at end of file