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:
Sat Aug 02 16:41:14 2014 +0000
Revision:
55:610aa4a2ed3b
Parent:
52:0950b05d5270
Child:
56:7fe74b03e6b1
Add support for "Restore Defaults" AT command.; Support in XbeeDeviceRemoteAt for re-association with a different XBee.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
johnb 8:1b48b619d7f6 1 /**
johnb 8:1b48b619d7f6 2 @file
johnb 8:1b48b619d7f6 3 @brief Class to abstract AT commands send to the XBee API
johnb 8:1b48b619d7f6 4
johnb 8:1b48b619d7f6 5 AT commands have the payload:
johnb 8:1b48b619d7f6 6
johnb 8:1b48b619d7f6 7 Byte 1 : Frame ID
johnb 8:1b48b619d7f6 8 Byte 2 & 3 : AT command
johnb 8:1b48b619d7f6 9 Byte 4-n : Parameter Value
johnb 8:1b48b619d7f6 10
johnb 8:1b48b619d7f6 11 @author John Bailey
johnb 8:1b48b619d7f6 12
johnb 8:1b48b619d7f6 13 @copyright Copyright 2014 John Bailey
johnb 8:1b48b619d7f6 14
johnb 8:1b48b619d7f6 15 @section LICENSE
johnb 8:1b48b619d7f6 16
johnb 8:1b48b619d7f6 17 Licensed under the Apache License, Version 2.0 (the "License");
johnb 8:1b48b619d7f6 18 you may not use this file except in compliance with the License.
johnb 8:1b48b619d7f6 19 You may obtain a copy of the License at
johnb 8:1b48b619d7f6 20
johnb 8:1b48b619d7f6 21 http://www.apache.org/licenses/LICENSE-2.0
johnb 8:1b48b619d7f6 22
johnb 8:1b48b619d7f6 23 Unless required by applicable law or agreed to in writing, software
johnb 8:1b48b619d7f6 24 distributed under the License is distributed on an "AS IS" BASIS,
johnb 8:1b48b619d7f6 25 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
johnb 8:1b48b619d7f6 26 See the License for the specific language governing permissions and
johnb 8:1b48b619d7f6 27 limitations under the License.
johnb 8:1b48b619d7f6 28
johnb 8:1b48b619d7f6 29 */
johnb 8:1b48b619d7f6 30
johnb 8:1b48b619d7f6 31 #if !defined XBEEAPICMDAT_HPP
johnb 8:1b48b619d7f6 32 #define XBEEAPICMDAT_HPP
johnb 8:1b48b619d7f6 33
johnb 8:1b48b619d7f6 34 #include "XBeeApiFrame.hpp"
johnb 8:1b48b619d7f6 35 #include "XBeeDevice.hpp"
johnb 8:1b48b619d7f6 36
johnb 8:1b48b619d7f6 37 #include <stdint.h>
johnb 8:1b48b619d7f6 38
johnb 26:f5df80e990f4 39 #define XBEE_API_CMD_SET_HEADER_LEN 3U
johnb 50:f76b7e7959a2 40 #define XBEE_API_CMD_REQ_HEADER_LEN 3U
johnb 50:f76b7e7959a2 41
johnb 50:f76b7e7959a2 42 #define XBEE_API_DIO_CHANNEL_COUNT 8U
johnb 52:0950b05d5270 43 #define XBEE_API_ADC_CHANNEL_COUNT 6U
johnb 26:f5df80e990f4 44
johnb 26:f5df80e990f4 45 /** Class to access the configuration interface of the XBee.
johnb 26:f5df80e990f4 46 Requests to the XBee are non-blocking meaning that code
johnb 26:f5df80e990f4 47 which utilises this class must deal with the fact that
johnb 26:f5df80e990f4 48 there will be a delay between requesting the data from
johnb 26:f5df80e990f4 49 the XBee and the data being available via the API. See
johnb 26:f5df80e990f4 50 XBeeApiCmdAtBlocking for a blocking version.
johnb 26:f5df80e990f4 51
johnb 26:f5df80e990f4 52 Parameters from the XBee are cached in the object so
johnb 26:f5df80e990f4 53 subsequent requests do not need have the overhead of
johnb 55:610aa4a2ed3b 54 communication with the XBee
johnb 55:610aa4a2ed3b 55
johnb 55:610aa4a2ed3b 56 The following table cross-references between the AT commands
johnb 55:610aa4a2ed3b 57 and the method(s) associated with them.
johnb 55:610aa4a2ed3b 58
johnb 55:610aa4a2ed3b 59 AT Command | Method(s)
johnb 55:610aa4a2ed3b 60 -----------|-----------------------------------------------
johnb 55:610aa4a2ed3b 61 WR | requestWriteSettings
johnb 55:610aa4a2ed3b 62 RE | requestRestoreDefaults
johnb 55:610aa4a2ed3b 63 FR | requestReset
johnb 55:610aa4a2ed3b 64 CH | requestChannel, setChannel, getChannel
johnb 55:610aa4a2ed3b 65 ID | requestPanId, setPanId, getPanId
johnb 55:610aa4a2ed3b 66 DH | requestDestinationAddress, requestDestinationAddressHigh, setDestinationAddressHigh, getDestinationAddressHigh
johnb 55:610aa4a2ed3b 67 DL | requestDestinationAddress, requestDestinationAddressLow, setDestinationAddressLow, getDestinationAddressLow
johnb 55:610aa4a2ed3b 68 MY | requestSourceAddress, getSourceAddress, setSourceAddress
johnb 55:610aa4a2ed3b 69 SH | requestSerialNumber, requestSerialNumberHigh, getSerialNumber
johnb 55:610aa4a2ed3b 70 SL | requestSerialNumber, requestSerialNumberLow, getSerialNumber
johnb 55:610aa4a2ed3b 71 RR |
johnb 55:610aa4a2ed3b 72 RN |
johnb 55:610aa4a2ed3b 73 MM | requestMacMode, setMacMode, getMacMode
johnb 55:610aa4a2ed3b 74 NI |
johnb 55:610aa4a2ed3b 75 ND |
johnb 55:610aa4a2ed3b 76 NT |
johnb 55:610aa4a2ed3b 77 NO |
johnb 55:610aa4a2ed3b 78 DN |
johnb 55:610aa4a2ed3b 79 CE | requestCoordinatorEnabled, setCoordinatorEnabled, getCoordinatorEnabled
johnb 55:610aa4a2ed3b 80 SC |
johnb 55:610aa4a2ed3b 81 SD |
johnb 55:610aa4a2ed3b 82 A1 |
johnb 55:610aa4a2ed3b 83 A2 |
johnb 55:610aa4a2ed3b 84 AI |
johnb 55:610aa4a2ed3b 85 DA |
johnb 55:610aa4a2ed3b 86 FP |
johnb 55:610aa4a2ed3b 87 AS |
johnb 55:610aa4a2ed3b 88 ED |
johnb 55:610aa4a2ed3b 89 EE |
johnb 55:610aa4a2ed3b 90 KY |
johnb 55:610aa4a2ed3b 91 PL |
johnb 55:610aa4a2ed3b 92 CA |
johnb 55:610aa4a2ed3b 93 SM |
johnb 55:610aa4a2ed3b 94 SO |
johnb 55:610aa4a2ed3b 95 ST |
johnb 55:610aa4a2ed3b 96 SP |
johnb 55:610aa4a2ed3b 97 DP |
johnb 55:610aa4a2ed3b 98 BD |
johnb 55:610aa4a2ed3b 99 RO |
johnb 55:610aa4a2ed3b 100 AP |
johnb 55:610aa4a2ed3b 101 NB |
johnb 55:610aa4a2ed3b 102 PR |
johnb 55:610aa4a2ed3b 103 D8 | requestDioConfig, setDioConfig, getDioConfig
johnb 55:610aa4a2ed3b 104 D7 | requestDioConfig, setDioConfig, getDioConfig
johnb 55:610aa4a2ed3b 105 D6 | requestDioConfig, setDioConfig, getDioConfig
johnb 55:610aa4a2ed3b 106 D5 | requestDioConfig, setDioConfig, getDioConfig
johnb 55:610aa4a2ed3b 107 D4 | requestDioConfig, setDioConfig, getDioConfig
johnb 55:610aa4a2ed3b 108 D3 | requestDioConfig, setDioConfig, getDioConfig
johnb 55:610aa4a2ed3b 109 D2 | requestDioConfig, setDioConfig, getDioConfig
johnb 55:610aa4a2ed3b 110 D1 | requestDioConfig, setDioConfig, getDioConfig
johnb 55:610aa4a2ed3b 111 D0 | requestDioConfig, setDioConfig, getDioConfig
johnb 55:610aa4a2ed3b 112 IU |
johnb 55:610aa4a2ed3b 113 IT |
johnb 55:610aa4a2ed3b 114 IS | requestForceSample
johnb 55:610aa4a2ed3b 115 IO |
johnb 55:610aa4a2ed3b 116 IC | requestDioChangeDetectMask, setDioChangeDetectMask, getDioChangeDetectMask
johnb 55:610aa4a2ed3b 117 IR | requestSampleRate, setSampleRate, getSampleRate
johnb 55:610aa4a2ed3b 118 IA |
johnb 55:610aa4a2ed3b 119 T7 |
johnb 55:610aa4a2ed3b 120 T6 |
johnb 55:610aa4a2ed3b 121 T5 |
johnb 55:610aa4a2ed3b 122 T4 |
johnb 55:610aa4a2ed3b 123 T3 |
johnb 55:610aa4a2ed3b 124 T2 |
johnb 55:610aa4a2ed3b 125 T1 |
johnb 55:610aa4a2ed3b 126 T0 |
johnb 55:610aa4a2ed3b 127 P0 |
johnb 55:610aa4a2ed3b 128 P1 |
johnb 55:610aa4a2ed3b 129 M0 |
johnb 55:610aa4a2ed3b 130 M1 |
johnb 55:610aa4a2ed3b 131 PT |
johnb 55:610aa4a2ed3b 132 RP |
johnb 55:610aa4a2ed3b 133 VR | requestFirmwareVersion, getFirmwareVersion
johnb 55:610aa4a2ed3b 134 VL |
johnb 55:610aa4a2ed3b 135 HV | requestHardwareVersion, getHardwareVersion
johnb 55:610aa4a2ed3b 136 EC |
johnb 55:610aa4a2ed3b 137 EA |
johnb 55:610aa4a2ed3b 138 ED |
johnb 55:610aa4a2ed3b 139 CT |
johnb 55:610aa4a2ed3b 140 CN |
johnb 55:610aa4a2ed3b 141 AC | requestApplyChanges
johnb 55:610aa4a2ed3b 142 GT |
johnb 55:610aa4a2ed3b 143 CC |
johnb 55:610aa4a2ed3b 144 */
johnb 8:1b48b619d7f6 145 class XBeeApiCmdAt : public XBeeApiFrameDecoder
johnb 8:1b48b619d7f6 146 {
johnb 13:302e7c1ea0b3 147 public:
johnb 26:f5df80e990f4 148 /** Type to represent the ID of a PAN (Personal Area Network) */
johnb 26:f5df80e990f4 149 typedef uint16_t panId_t;
johnb 26:f5df80e990f4 150 /** Type to represent a wireless channel number */
johnb 26:f5df80e990f4 151 typedef uint8_t channel_t;
johnb 32:af4e495afd62 152 /** Type to represent the different MAC modes supported by the XBee */
johnb 32:af4e495afd62 153 typedef enum {
johnb 32:af4e495afd62 154 XBEE_API_MAC_MODE_DIGI_ACK = 0,
johnb 32:af4e495afd62 155 XBEE_API_MAC_MODE_802_15_4_NO_ACK = 1,
johnb 32:af4e495afd62 156 XBEE_API_MAC_MODE_802_15_4_ACK = 2,
johnb 32:af4e495afd62 157 XBEE_API_MAC_MODE_DIGI_NO_ACK = 3,
johnb 32:af4e495afd62 158 } XBeeApiMACMode_e;
johnb 13:302e7c1ea0b3 159
johnb 55:610aa4a2ed3b 160 /** Type to represent the various different configuration options
johnb 55:610aa4a2ed3b 161 for the I/O pins. Note that not all I/O pins will support all
johnb 55:610aa4a2ed3b 162 options */
johnb 50:f76b7e7959a2 163 typedef enum
johnb 50:f76b7e7959a2 164 {
johnb 50:f76b7e7959a2 165 XBEE_API_DIO_DISABLED = 0,
johnb 50:f76b7e7959a2 166 XBEE_API_DIO_SPECIAL = 1,
johnb 51:a7d0d2ef9261 167 XBEE_API_DIO_ADC = 2,
johnb 50:f76b7e7959a2 168 XBEE_API_DIO_INPUT = 3,
johnb 50:f76b7e7959a2 169 XBEE_API_DIO_OUT_LOW = 4,
johnb 50:f76b7e7959a2 170 XBEE_API_DIO_OUT_HIGH = 5,
johnb 50:f76b7e7959a2 171 XBEE_API_DIO_RS485_TX_LOW = 6,
johnb 50:f76b7e7959a2 172 XBEE_API_DIO_RS485_TX_HIGH = 7
johnb 50:f76b7e7959a2 173 } XBeeApiDioConfig_e;
johnb 50:f76b7e7959a2 174
johnb 8:1b48b619d7f6 175 protected:
johnb 26:f5df80e990f4 176 /** Indicates whether or not m_hwVer contains data retrieved from the XBee */
johnb 31:c144106e55b5 177 bool m_have_hwVer;
johnb 26:f5df80e990f4 178 /** Indicates whether or not m_fwVer contains data retrieved from the XBee */
johnb 31:c144106e55b5 179 bool m_have_fwVer;
johnb 26:f5df80e990f4 180 /** Indicates whether or not m_chan contains data retrieved from the XBee */
johnb 31:c144106e55b5 181 bool m_have_chan;
johnb 26:f5df80e990f4 182 /** Indicates whether or not m_PANId contains data retrieved from the XBee */
johnb 31:c144106e55b5 183 bool m_have_PANId;
johnb 26:f5df80e990f4 184 /** Indicates whether or not m_EDA contains data retrieved from the XBee */
johnb 31:c144106e55b5 185 bool m_have_EDA;
johnb 26:f5df80e990f4 186 /** Indicates whether or not m_CE contains data retrieved from the XBee */
johnb 31:c144106e55b5 187 bool m_have_CE;
johnb 31:c144106e55b5 188 bool m_have_sourceAddress;
johnb 32:af4e495afd62 189 bool m_have_snLow;
johnb 32:af4e495afd62 190 bool m_have_snHigh;
johnb 32:af4e495afd62 191 bool m_have_retries;
johnb 32:af4e495afd62 192 bool m_have_randomDelaySlots;
johnb 32:af4e495afd62 193 bool m_have_macMode;
johnb 50:f76b7e7959a2 194 bool m_have_d[ XBEE_API_DIO_CHANNEL_COUNT ];
johnb 51:a7d0d2ef9261 195 bool m_have_dioChangeDetectMask;
johnb 51:a7d0d2ef9261 196 bool m_have_dioLevels;
johnb 51:a7d0d2ef9261 197 bool m_have_sampleRate;
johnb 51:a7d0d2ef9261 198 bool m_have_destHigh;
johnb 51:a7d0d2ef9261 199 bool m_have_destLow;
johnb 51:a7d0d2ef9261 200
johnb 13:302e7c1ea0b3 201
johnb 8:1b48b619d7f6 202 uint16_t m_hwVer;
johnb 8:1b48b619d7f6 203 uint16_t m_fwVer;
johnb 13:302e7c1ea0b3 204 channel_t m_chan;
johnb 13:302e7c1ea0b3 205 channel_t m_chanPend;
johnb 13:302e7c1ea0b3 206 panId_t m_PANId;
johnb 13:302e7c1ea0b3 207 panId_t m_PANIdPend;
johnb 13:302e7c1ea0b3 208 bool m_EDA;
johnb 13:302e7c1ea0b3 209 bool m_EDAPend;
johnb 13:302e7c1ea0b3 210 bool m_CE;
johnb 13:302e7c1ea0b3 211 bool m_CEPend;
johnb 31:c144106e55b5 212 uint16_t m_sourceAddress;
johnb 31:c144106e55b5 213 uint16_t m_sourceAddressPend;
johnb 32:af4e495afd62 214 uint32_t m_snLow;
johnb 32:af4e495afd62 215 uint32_t m_snHigh;
johnb 32:af4e495afd62 216 uint8_t m_retries;
johnb 32:af4e495afd62 217 uint8_t m_retriesPend;
johnb 32:af4e495afd62 218 uint8_t m_randomDelaySlots;
johnb 32:af4e495afd62 219 uint8_t m_randomDelaySlotsPend;
johnb 50:f76b7e7959a2 220 XBeeApiMACMode_e m_macMode;
johnb 50:f76b7e7959a2 221 XBeeApiMACMode_e m_macModePend;
johnb 50:f76b7e7959a2 222 XBeeApiDioConfig_e m_d[ XBEE_API_DIO_CHANNEL_COUNT ];
johnb 50:f76b7e7959a2 223 XBeeApiDioConfig_e m_dPend[ XBEE_API_DIO_CHANNEL_COUNT ];
johnb 51:a7d0d2ef9261 224 uint8_t m_dioChangeDetectMask;
johnb 51:a7d0d2ef9261 225 uint8_t m_dioChangeDetectMaskPend;
johnb 51:a7d0d2ef9261 226 uint8_t m_dioLevels;
johnb 51:a7d0d2ef9261 227 uint8_t m_dioLevelsPend;
johnb 51:a7d0d2ef9261 228 uint16_t m_sampleRate;
johnb 51:a7d0d2ef9261 229 uint16_t m_sampleRatePend;
johnb 51:a7d0d2ef9261 230 uint32_t m_destHigh;
johnb 51:a7d0d2ef9261 231 uint32_t m_destHighPend;
johnb 51:a7d0d2ef9261 232 uint32_t m_destLow;
johnb 51:a7d0d2ef9261 233 uint32_t m_destLowPend;
johnb 51:a7d0d2ef9261 234 uint32_t m_writeCount;
johnb 51:a7d0d2ef9261 235 uint32_t m_applyCount;
johnb 51:a7d0d2ef9261 236 uint32_t m_resetCount;
johnb 51:a7d0d2ef9261 237 uint32_t m_sampleCount;
johnb 55:610aa4a2ed3b 238 uint32_t m_restoreCount;
johnb 52:0950b05d5270 239
johnb 52:0950b05d5270 240 time_t m_ioDigitalUpdatedTime[ XBEE_API_DIO_CHANNEL_COUNT ];
johnb 52:0950b05d5270 241 bool m_ioDigitalState[ XBEE_API_DIO_CHANNEL_COUNT ];
johnb 52:0950b05d5270 242 time_t m_ioAnalogueUpdatedTime[ XBEE_API_ADC_CHANNEL_COUNT ];
johnb 52:0950b05d5270 243 uint16_t m_ioAnalogueVal[ XBEE_API_ADC_CHANNEL_COUNT ];
johnb 52:0950b05d5270 244
johnb 8:1b48b619d7f6 245
johnb 50:f76b7e7959a2 246 virtual void SendCmd_uint8_t( const uint8_t p_frameId,
johnb 50:f76b7e7959a2 247 const uint8_t* const p_data,
johnb 50:f76b7e7959a2 248 const uint8_t& p_val );
johnb 50:f76b7e7959a2 249 virtual void SendCmd_uint16_t( const uint8_t p_frameId,
johnb 50:f76b7e7959a2 250 const uint8_t* const p_data,
johnb 50:f76b7e7959a2 251 const uint16_t& p_val );
johnb 51:a7d0d2ef9261 252 virtual void SendCmd_uint32_t( const uint8_t p_frameId,
johnb 51:a7d0d2ef9261 253 const uint8_t* const p_data,
johnb 51:a7d0d2ef9261 254 const uint32_t& p_val );
johnb 50:f76b7e7959a2 255 virtual void SendReq( const uint8_t p_frameId,
johnb 50:f76b7e7959a2 256 const uint8_t* p_data );
johnb 13:302e7c1ea0b3 257
johnb 50:f76b7e7959a2 258 virtual size_t getResponseStatusPos( void ) const;
johnb 50:f76b7e7959a2 259
johnb 50:f76b7e7959a2 260
johnb 50:f76b7e7959a2 261 /* Implement XBeeApiCmdDecoder interface */
johnb 50:f76b7e7959a2 262 virtual bool decodeCallback( const uint8_t* const p_data, size_t p_len );
johnb 50:f76b7e7959a2 263
johnb 50:f76b7e7959a2 264 virtual bool processResponseFrame( const uint8_t* const p_data, size_t p_len );
johnb 50:f76b7e7959a2 265
johnb 52:0950b05d5270 266 virtual bool processIOFrame( const uint8_t* const p_data, size_t p_len, const size_t p_start );
johnb 26:f5df80e990f4 267
johnb 55:610aa4a2ed3b 268 void resetCachedData( void );
johnb 55:610aa4a2ed3b 269
johnb 8:1b48b619d7f6 270 public:
johnb 13:302e7c1ea0b3 271
johnb 29:c6d037cceb02 272 /** Constructor
johnb 29:c6d037cceb02 273
johnb 29:c6d037cceb02 274 \param p_device XBee device with which this object should be associated */
johnb 29:c6d037cceb02 275 XBeeApiCmdAt( XBeeDevice* const p_device = NULL );
johnb 26:f5df80e990f4 276
johnb 26:f5df80e990f4 277 /** Destructor */
johnb 26:f5df80e990f4 278 virtual ~XBeeApiCmdAt( void ) {};
johnb 8:1b48b619d7f6 279
johnb 52:0950b05d5270 280 time_t getDigitalState( const uint8_t p_chanNo, bool& p_state );
johnb 52:0950b05d5270 281 time_t getAnalogueValue( const uint8_t p_chanNo, uint16_t& p_val );
johnb 52:0950b05d5270 282
johnb 26:f5df80e990f4 283 /** Request the hardware version identifier from the XBee.
johnb 26:f5df80e990f4 284 As the data is retrieved asynchronously to this call,
johnb 26:f5df80e990f4 285 once the response is received it can be accessed via
johnb 26:f5df80e990f4 286 getHardwareVersion() */
johnb 26:f5df80e990f4 287 bool requestHardwareVersion( void );
johnb 26:f5df80e990f4 288 bool requestFirmwareVersion( void );
johnb 26:f5df80e990f4 289 bool requestChannel( void );
johnb 26:f5df80e990f4 290 bool requestCoordinatorEnabled( void );
johnb 26:f5df80e990f4 291 bool requestEndDeviceAssociationEnabled( void );
johnb 26:f5df80e990f4 292 bool requestPanId( void );
johnb 31:c144106e55b5 293 bool requestSourceAddress( void );
johnb 32:af4e495afd62 294 bool requestSerialNumber( void );
johnb 50:f76b7e7959a2 295 bool requestSerialNumberHigh( void );
johnb 50:f76b7e7959a2 296 bool requestSerialNumberLow( void );
johnb 50:f76b7e7959a2 297 bool requestDioConfig( const uint8_t p_chanNo );
johnb 51:a7d0d2ef9261 298 bool requestDioChangeDetectMask( void );
johnb 51:a7d0d2ef9261 299 bool requestSampleRate( void );
johnb 50:f76b7e7959a2 300
johnb 32:af4e495afd62 301 /** Request the number of retries the XBee is configured to make.
johnb 32:af4e495afd62 302 Note that the 802.15.4 MAC already allows 3 retries, so this parameter
johnb 32:af4e495afd62 303 specifies an additional multiple of 3 retries
johnb 32:af4e495afd62 304 As the data is retrieved asynchronously to this call,
johnb 32:af4e495afd62 305 once the response is received it can be accessed via
johnb 32:af4e495afd62 306 getRetries()
johnb 32:af4e495afd62 307 */
johnb 32:af4e495afd62 308 bool requestRetries( void );
johnb 32:af4e495afd62 309
johnb 32:af4e495afd62 310 /** Request the minimum value of the back-off exponent in the CSMA-CA algorithm
johnb 32:af4e495afd62 311 used in collision avoidance.
johnb 32:af4e495afd62 312 */
johnb 32:af4e495afd62 313 bool requestRandomDelaySlots( void );
johnb 32:af4e495afd62 314
johnb 32:af4e495afd62 315 bool requestMacMode( void );
johnb 51:a7d0d2ef9261 316 bool requestDestinationAddress( void );
johnb 51:a7d0d2ef9261 317 bool requestDestinationAddressHigh( void );
johnb 51:a7d0d2ef9261 318 bool requestDestinationAddressLow( void );
johnb 51:a7d0d2ef9261 319
johnb 51:a7d0d2ef9261 320 bool requestWriteSettings( void );
johnb 51:a7d0d2ef9261 321 bool requestApplyChanges( void );
johnb 51:a7d0d2ef9261 322 bool requestReset( void );
johnb 51:a7d0d2ef9261 323 bool requestForceSample( void );
johnb 55:610aa4a2ed3b 324 bool requestRestoreDefaults( void );
johnb 8:1b48b619d7f6 325
johnb 26:f5df80e990f4 326 /** Read the XBee's hardware version identifier.
johnb 26:f5df80e990f4 327
johnb 26:f5df80e990f4 328 This method does not initiate any communication with the
johnb 26:f5df80e990f4 329 XBee - the identifier must previously have been requested
johnb 26:f5df80e990f4 330 via requestHardwareVersion(). The method is non-blocking. */
johnb 26:f5df80e990f4 331 virtual bool getHardwareVersion( uint16_t* const p_ver );
johnb 26:f5df80e990f4 332
johnb 26:f5df80e990f4 333 /** Read the XBee's firmware version identifier.
johnb 26:f5df80e990f4 334
johnb 26:f5df80e990f4 335 This method does not initiate any communication with the
johnb 26:f5df80e990f4 336 XBee - the identifier must previously have been requested
johnb 26:f5df80e990f4 337 via requestFirmwareVersion(). The method is non-blocking. */
johnb 26:f5df80e990f4 338 virtual bool getFirmwareVersion( uint16_t* const p_ver );
johnb 32:af4e495afd62 339
johnb 32:af4e495afd62 340 virtual bool getSerialNumber( uint64_t* const p_sn );
johnb 13:302e7c1ea0b3 341
johnb 32:af4e495afd62 342 virtual bool getChannel( uint8_t* const p_chan );
johnb 32:af4e495afd62 343 virtual bool setChannel( uint8_t const p_chan );
johnb 8:1b48b619d7f6 344
johnb 32:af4e495afd62 345 virtual bool getCoordinatorEnabled( bool* const p_en );
johnb 32:af4e495afd62 346 virtual bool setCoordinatorEnabled( const bool p_en );
johnb 32:af4e495afd62 347
johnb 32:af4e495afd62 348 virtual bool getEndDeviceAssociationEnabled( bool* const p_en );
johnb 32:af4e495afd62 349 virtual bool setEndDeviceAssociationEnabled( const bool p_en );
johnb 13:302e7c1ea0b3 350
johnb 32:af4e495afd62 351 virtual bool getPanId( panId_t* const p_id );
johnb 32:af4e495afd62 352 virtual bool setPanId( const panId_t p_id );
johnb 32:af4e495afd62 353
johnb 32:af4e495afd62 354 virtual bool getSourceAddress( uint16_t* const p_addr );
johnb 32:af4e495afd62 355 virtual bool setSourceAddress( const uint16_t p_addr );
johnb 31:c144106e55b5 356
johnb 32:af4e495afd62 357 virtual bool getRetries( uint8_t* const p_addr );
johnb 32:af4e495afd62 358 virtual bool setRetries( const uint8_t p_addr );
johnb 31:c144106e55b5 359
johnb 32:af4e495afd62 360 virtual bool getRandomDelaySlots( uint8_t* const p_addr );
johnb 32:af4e495afd62 361 virtual bool setRandomDelaySlots( const uint8_t p_addr );
johnb 32:af4e495afd62 362
johnb 32:af4e495afd62 363 virtual bool getMacMode( XBeeApiMACMode_e* const p_mode );
johnb 50:f76b7e7959a2 364 virtual bool setMacMode( const XBeeApiMACMode_e p_mode );
johnb 50:f76b7e7959a2 365
johnb 50:f76b7e7959a2 366 virtual bool getDioConfig( const uint8_t p_chanNo, XBeeApiDioConfig_e* const p_conf );
johnb 50:f76b7e7959a2 367 virtual bool setDioConfig( const uint8_t p_chanNo, const XBeeApiDioConfig_e p_conf );
johnb 51:a7d0d2ef9261 368
johnb 51:a7d0d2ef9261 369 virtual bool getDioChangeDetectMask( uint8_t* const p_mask );
johnb 51:a7d0d2ef9261 370 virtual bool setDioChangeDetectMask( const uint8_t p_mask );
johnb 26:f5df80e990f4 371
johnb 51:a7d0d2ef9261 372 /** Note that this method will only return a value in the case that the levels have
johnb 51:a7d0d2ef9261 373 been previously set via the setDioLevels method and that the XBee has
johnb 51:a7d0d2ef9261 374 returned a successful response. There is no ability to simply read what the
johnb 51:a7d0d2ef9261 375 current digital outputs are set to */
johnb 51:a7d0d2ef9261 376 virtual bool getDioLevels( uint8_t* const p_mask );
johnb 51:a7d0d2ef9261 377 virtual bool setDioLevels( const uint8_t p_mask );
johnb 8:1b48b619d7f6 378
johnb 51:a7d0d2ef9261 379 /* TODO: Add protection to prevent p_interval being too small - see data sheet */
johnb 51:a7d0d2ef9261 380 virtual bool getSampleRate( uint16_t* const p_interval );
johnb 51:a7d0d2ef9261 381 virtual bool setSampleRate( const uint16_t p_interval );
johnb 51:a7d0d2ef9261 382
johnb 51:a7d0d2ef9261 383 virtual bool getDestinationAddress( uint64_t* const p_address );
johnb 51:a7d0d2ef9261 384 virtual bool setDestinationAddress( const uint64_t p_address );
johnb 13:302e7c1ea0b3 385
johnb 51:a7d0d2ef9261 386 virtual bool getDestinationAddressHigh( uint32_t* const p_address );
johnb 51:a7d0d2ef9261 387 virtual bool setDestinationAddressHigh( const uint32_t p_address );
johnb 31:c144106e55b5 388
johnb 51:a7d0d2ef9261 389 virtual bool getDestinationAddressLow( uint32_t* const p_address );
johnb 51:a7d0d2ef9261 390 virtual bool setDestinationAddressLow( const uint32_t p_address );
johnb 32:af4e495afd62 391
johnb 8:1b48b619d7f6 392 };
johnb 8:1b48b619d7f6 393
johnb 8:1b48b619d7f6 394 #endif