API for communicating with XBee devices.

Dependencies:   CircularBuffer FixedLengthList

Dependents:   XBeeApiTest XBeeApiSimpleATCmdsExample XBeeApiBroadcastExample XBeeApiBroadcastExampleRTOS ... more

Overview

XBeeApi is intended to be a library for providing a high-level API interface to the XBee - for example getChannel() and setChannel(2) methods rather than needing to send( "ATCH" ) and send( "ATCH 2" ) - and then de-code the responses.

See the notebook page here for a description of how the API works & some details on the various classes.

Features:

  • Support for transmission & reception of data packets
  • Support for reading & changing settings
  • Support for "Remote AT" interface to access settings & I/O channels on remote XBees
  • XBeeApi should work if you're using mbed-rtos, though it is not currently threadsafe. Take a look at the XBeeApiBroadcastExampleRTOS example if you're including mbed-rtos.

Example Programs

There are also example programs available:

Transmit

Import programXBeeApiSimpleBroadcastExample

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

Import programXBeeApiBroadcastExample

Example for XBeeAPI; a little more involved than XBeeApiSimpleBroadcastExample with report on failure to set up the XBee and on the transmit status of the message.

Import programXBeeApiBroadcastExampleRTOS

Example of using the XBeeApi library to broadcast a message, based on XBeeApiBroadcastExample. This example shows how to use the library when using mbed-rtos. Before compiling you must open "XbeeApi\Config\XBeeApiCfg.hpp" and change the '#if 0' to '#if 1' on the line above the comment reading "Use RTOS features to make XBeeApi threadsafe"

Settings/Status

Import programXBeeApiSimpleATCmdsExample

Simple example of using XBeeApi to send AT-style commands to the XBee

Import programXBeeApiRemoteATCmdsExample

Example of using the XBeeApi library to send AT commands to remote XBee devices in order to read/write settings

Receive

Import programXBeeApiSimpleReceiveExample

Simple example of using XBeeApi to receive data packets via wireless

Import programXBeeApiReceiveCallbackExample

Example of using the XBeeApi library to receive a message via a callback method

Import programXBeeApiReceiveCallbackExampleRTOS

Example of using the XBeeApi library to receive a message via a callback method. This example shows how to use the library when using mbed-rtos. See the comment at the top of main.cpp

Remote I/O

Import programXBeeApiRemoteIOExample

Example of using the XBeeApi library to read inputs on a remote XBee

If you have 2 mbed connected XBees available then you can use XBeeApiSimpleReceiveExample and XBeeApiSimpleBroadcastExample as a pair.

Note that this is still a work in progress! XBeeApiTodoList tracks some of the functionality still to be added.

Committer:
johnb
Date:
Sun Jul 13 15:47:40 2014 +0000
Revision:
50:f76b7e7959a2
Child:
51:a7d0d2ef9261
Add support for Remote AT commands

Who changed what in which revision?

UserRevisionLine numberNew contents of line
johnb 50:f76b7e7959a2 1 /**
johnb 50:f76b7e7959a2 2 @file
johnb 50:f76b7e7959a2 3 @brief Class to provide an abstract representation of a remote
johnb 50:f76b7e7959a2 4 XBee device's AT command interface
johnb 50:f76b7e7959a2 5
johnb 50:f76b7e7959a2 6 @author John Bailey
johnb 50:f76b7e7959a2 7
johnb 50:f76b7e7959a2 8 @copyright Copyright 2014 John Bailey
johnb 50:f76b7e7959a2 9
johnb 50:f76b7e7959a2 10 @section LICENSE
johnb 50:f76b7e7959a2 11
johnb 50:f76b7e7959a2 12 Licensed under the Apache License, Version 2.0 (the "License");
johnb 50:f76b7e7959a2 13 you may not use this file except in compliance with the License.
johnb 50:f76b7e7959a2 14 You may obtain a copy of the License at
johnb 50:f76b7e7959a2 15
johnb 50:f76b7e7959a2 16 http://www.apache.org/licenses/LICENSE-2.0
johnb 50:f76b7e7959a2 17
johnb 50:f76b7e7959a2 18 Unless required by applicable law or agreed to in writing, software
johnb 50:f76b7e7959a2 19 distributed under the License is distributed on an "AS IS" BASIS,
johnb 50:f76b7e7959a2 20 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
johnb 50:f76b7e7959a2 21 See the License for the specific language governing permissions and
johnb 50:f76b7e7959a2 22 limitations under the License.
johnb 50:f76b7e7959a2 23
johnb 50:f76b7e7959a2 24 */
johnb 50:f76b7e7959a2 25
johnb 50:f76b7e7959a2 26 #if !defined XBEEDEVICEREMOTEAT_HPP
johnb 50:f76b7e7959a2 27 #define XBEEDEVICEREMOTEAT_HPP
johnb 50:f76b7e7959a2 28
johnb 50:f76b7e7959a2 29 #include "XBeeApiCfg.hpp"
johnb 50:f76b7e7959a2 30 #include "XBeeApiFrame.hpp"
johnb 50:f76b7e7959a2 31 #include "XBeeApiCmdAt.hpp"
johnb 50:f76b7e7959a2 32
johnb 50:f76b7e7959a2 33 /** */
johnb 50:f76b7e7959a2 34 class XBeeDeviceRemoteAt : public XBeeApiCmdAt
johnb 50:f76b7e7959a2 35 {
johnb 50:f76b7e7959a2 36 protected:
johnb 50:f76b7e7959a2 37 /** Called by XBeeDevice in order to offer frame data to the object for
johnb 50:f76b7e7959a2 38 decoding
johnb 50:f76b7e7959a2 39
johnb 50:f76b7e7959a2 40 \param p_data Pointer to the content of the received data
johnb 50:f76b7e7959a2 41 \param p_len Length of the data pointed to by p_data
johnb 50:f76b7e7959a2 42 */
johnb 50:f76b7e7959a2 43 virtual bool decodeCallback( const uint8_t* const p_data, size_t p_len );
johnb 50:f76b7e7959a2 44
johnb 50:f76b7e7959a2 45 virtual void SendCmd_uint8_t( const uint8_t p_frameId,
johnb 50:f76b7e7959a2 46 const uint8_t* const p_data,
johnb 50:f76b7e7959a2 47 const uint8_t& p_val );
johnb 50:f76b7e7959a2 48 virtual void SendCmd_uint16_t( const uint8_t p_frameId,
johnb 50:f76b7e7959a2 49 const uint8_t* const p_data,
johnb 50:f76b7e7959a2 50 const uint16_t& p_val );
johnb 50:f76b7e7959a2 51 virtual void SendReq( const uint8_t p_frameId,
johnb 50:f76b7e7959a2 52 const uint8_t* p_data );
johnb 50:f76b7e7959a2 53
johnb 50:f76b7e7959a2 54 virtual size_t getResponseStatusPos( void ) const;
johnb 50:f76b7e7959a2 55
johnb 50:f76b7e7959a2 56 uint16_t m_addr16Bit;
johnb 50:f76b7e7959a2 57 uint64_t m_addr64Bit;
johnb 50:f76b7e7959a2 58
johnb 50:f76b7e7959a2 59 public:
johnb 50:f76b7e7959a2 60 /** Constructor */
johnb 50:f76b7e7959a2 61 XBeeDeviceRemoteAt( XBeeDevice* p_device,
johnb 50:f76b7e7959a2 62 const uint16_t& p_addr16Bit,
johnb 50:f76b7e7959a2 63 const uint64_t& p_addr64Bit );
johnb 50:f76b7e7959a2 64
johnb 50:f76b7e7959a2 65 /** Destructor */
johnb 50:f76b7e7959a2 66 virtual ~XBeeDeviceRemoteAt( void );
johnb 50:f76b7e7959a2 67 };
johnb 50:f76b7e7959a2 68
johnb 50:f76b7e7959a2 69 #endif