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.
Utility/XBeeApiCmdAtBlocking.cpp@56:7fe74b03e6b1, 2014-08-08 (annotated)
- Committer:
- johnb
- Date:
- Fri Aug 08 11:59:52 2014 +0000
- Revision:
- 56:7fe74b03e6b1
- Parent:
- 51:a7d0d2ef9261
Add support for setting up encrypted communications; Re-jig XBeeApiCmdAt virtual functions to make inheritance by XBeeDeviceRemoteAt cleaner.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
johnb | 51:a7d0d2ef9261 | 1 | /** |
johnb | 51:a7d0d2ef9261 | 2 | |
johnb | 51:a7d0d2ef9261 | 3 | Copyright 2014 John Bailey |
johnb | 51:a7d0d2ef9261 | 4 | |
johnb | 51:a7d0d2ef9261 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
johnb | 51:a7d0d2ef9261 | 6 | you may not use this file except in compliance with the License. |
johnb | 51:a7d0d2ef9261 | 7 | You may obtain a copy of the License at |
johnb | 51:a7d0d2ef9261 | 8 | |
johnb | 51:a7d0d2ef9261 | 9 | http://www.apache.org/licenses/LICENSE-2.0 |
johnb | 51:a7d0d2ef9261 | 10 | |
johnb | 51:a7d0d2ef9261 | 11 | Unless required by applicable law or agreed to in writing, software |
johnb | 51:a7d0d2ef9261 | 12 | distributed under the License is distributed on an "AS IS" BASIS, |
johnb | 51:a7d0d2ef9261 | 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
johnb | 51:a7d0d2ef9261 | 14 | See the License for the specific language governing permissions and |
johnb | 51:a7d0d2ef9261 | 15 | limitations under the License. |
johnb | 51:a7d0d2ef9261 | 16 | |
johnb | 51:a7d0d2ef9261 | 17 | */ |
johnb | 51:a7d0d2ef9261 | 18 | |
johnb | 51:a7d0d2ef9261 | 19 | #include "XBeeApiCmdAtBlocking.hpp" |
johnb | 51:a7d0d2ef9261 | 20 | |
johnb | 51:a7d0d2ef9261 | 21 | XBeeApiCmdAtBlocking::XBeeApiCmdAtBlocking( XBeeDevice* const p_device, const uint16_t p_timeout, const uint16_t p_slice ) : |
johnb | 51:a7d0d2ef9261 | 22 | XBeeApiCmdAt( p_device ), |
johnb | 51:a7d0d2ef9261 | 23 | m_timeout( p_timeout ), |
johnb | 51:a7d0d2ef9261 | 24 | m_slice( p_slice ) |
johnb | 51:a7d0d2ef9261 | 25 | { |
johnb | 51:a7d0d2ef9261 | 26 | } |
johnb | 51:a7d0d2ef9261 | 27 | |
johnb | 51:a7d0d2ef9261 | 28 | /** |
johnb | 51:a7d0d2ef9261 | 29 | Macro to wrap around the "requestXXX" & "getXXX" methods and implement a blocking call. |
johnb | 51:a7d0d2ef9261 | 30 | This macro is used as the basis for getXXX functions in XBeeApiCmdAtBlocking. |
johnb | 51:a7d0d2ef9261 | 31 | |
johnb | 51:a7d0d2ef9261 | 32 | Originally looked to achieve this using a template function passing method pointers, however |
johnb | 51:a7d0d2ef9261 | 33 | there's no way to get a method pointer to the parent class implementation as opposed to the |
johnb | 51:a7d0d2ef9261 | 34 | implementation in this class, meaning that the result was a recursive method call. The joys of |
johnb | 51:a7d0d2ef9261 | 35 | polymorphism. |
johnb | 51:a7d0d2ef9261 | 36 | |
johnb | 51:a7d0d2ef9261 | 37 | e.g. We pass a pointer to method getHardwareVersion(). The function receiving the pointer |
johnb | 51:a7d0d2ef9261 | 38 | uses it to make a function call. The actual function that's called is (correctly) |
johnb | 51:a7d0d2ef9261 | 39 | the one implemented in this class, however what we actually wanted in this case |
johnb | 51:a7d0d2ef9261 | 40 | was to call the implementation in the base class. Using static_cast<> doesn't have |
johnb | 51:a7d0d2ef9261 | 41 | any effect and taking the address of XBeeApiCmdAt::getHardwareVersion ends up with |
johnb | 51:a7d0d2ef9261 | 42 | XBeeApiCmdAtBlocking::getHardwareVersion being called due to polymorphism. */ |
johnb | 51:a7d0d2ef9261 | 43 | #define BLOCKING_GET( _REQ_FN, _GET_FN, _VAR ) \ |
johnb | 51:a7d0d2ef9261 | 44 | bool ret_val = false; \ |
johnb | 51:a7d0d2ef9261 | 45 | \ |
johnb | 51:a7d0d2ef9261 | 46 | if( _GET_FN( _VAR ) )\ |
johnb | 51:a7d0d2ef9261 | 47 | {\ |
johnb | 51:a7d0d2ef9261 | 48 | ret_val = true;\ |
johnb | 51:a7d0d2ef9261 | 49 | } \ |
johnb | 51:a7d0d2ef9261 | 50 | else if( _REQ_FN() )\ |
johnb | 51:a7d0d2ef9261 | 51 | {\ |
johnb | 51:a7d0d2ef9261 | 52 | uint16_t counter = m_timeout; \ |
johnb | 51:a7d0d2ef9261 | 53 | bool cont;\ |
johnb | 51:a7d0d2ef9261 | 54 | \ |
johnb | 51:a7d0d2ef9261 | 55 | do{\ |
johnb | 51:a7d0d2ef9261 | 56 | cont = false; \ |
johnb | 51:a7d0d2ef9261 | 57 | wait_ms( m_slice );\ |
johnb | 51:a7d0d2ef9261 | 58 | if( _GET_FN( _VAR ) )\ |
johnb | 51:a7d0d2ef9261 | 59 | {\ |
johnb | 51:a7d0d2ef9261 | 60 | ret_val = true;\ |
johnb | 51:a7d0d2ef9261 | 61 | }\ |
johnb | 51:a7d0d2ef9261 | 62 | else if( counter > m_slice ) {\ |
johnb | 51:a7d0d2ef9261 | 63 | counter -= m_slice; \ |
johnb | 51:a7d0d2ef9261 | 64 | cont = true;\ |
johnb | 51:a7d0d2ef9261 | 65 | } \ |
johnb | 51:a7d0d2ef9261 | 66 | } while( cont );\ |
johnb | 51:a7d0d2ef9261 | 67 | }\ |
johnb | 51:a7d0d2ef9261 | 68 | \ |
johnb | 51:a7d0d2ef9261 | 69 | return( ret_val ); |
johnb | 51:a7d0d2ef9261 | 70 | |
johnb | 51:a7d0d2ef9261 | 71 | /** |
johnb | 51:a7d0d2ef9261 | 72 | Macro to wrap around the "setXXX" & "getXXX" methods and implement a blocking call. |
johnb | 51:a7d0d2ef9261 | 73 | This macro is used as the basis for setXXX functions in XBeeApiCmdAtBlocking. |
johnb | 51:a7d0d2ef9261 | 74 | */ |
johnb | 51:a7d0d2ef9261 | 75 | #define BLOCKING_SET( _SET_FN, _GET_FN, _VAR, _TYPE ) \ |
johnb | 51:a7d0d2ef9261 | 76 | bool ret_val = false; \ |
johnb | 51:a7d0d2ef9261 | 77 | uint16_t counter = m_timeout; \ |
johnb | 51:a7d0d2ef9261 | 78 | _TYPE readback; \ |
johnb | 51:a7d0d2ef9261 | 79 | \ |
johnb | 51:a7d0d2ef9261 | 80 | if( _SET_FN( _VAR ) )\ |
johnb | 51:a7d0d2ef9261 | 81 | {\ |
johnb | 51:a7d0d2ef9261 | 82 | bool cont;\ |
johnb | 51:a7d0d2ef9261 | 83 | \ |
johnb | 51:a7d0d2ef9261 | 84 | do{\ |
johnb | 51:a7d0d2ef9261 | 85 | cont = false;\ |
johnb | 51:a7d0d2ef9261 | 86 | wait_ms( m_slice );\ |
johnb | 51:a7d0d2ef9261 | 87 | if( _GET_FN( &readback ) &&\ |
johnb | 51:a7d0d2ef9261 | 88 | ( readback == _VAR ))\ |
johnb | 51:a7d0d2ef9261 | 89 | {\ |
johnb | 51:a7d0d2ef9261 | 90 | ret_val = true;\ |
johnb | 51:a7d0d2ef9261 | 91 | }\ |
johnb | 51:a7d0d2ef9261 | 92 | else if( counter > m_slice ) {\ |
johnb | 51:a7d0d2ef9261 | 93 | counter -= m_slice; \ |
johnb | 51:a7d0d2ef9261 | 94 | cont = true;\ |
johnb | 51:a7d0d2ef9261 | 95 | } \ |
johnb | 51:a7d0d2ef9261 | 96 | } while( cont );\ |
johnb | 51:a7d0d2ef9261 | 97 | }\ |
johnb | 51:a7d0d2ef9261 | 98 | \ |
johnb | 51:a7d0d2ef9261 | 99 | return( ret_val ); |
johnb | 51:a7d0d2ef9261 | 100 | |
johnb | 51:a7d0d2ef9261 | 101 | |
johnb | 51:a7d0d2ef9261 | 102 | bool XBeeApiCmdAtBlocking::getHardwareVersion( uint16_t* const p_ver ) |
johnb | 51:a7d0d2ef9261 | 103 | { |
johnb | 51:a7d0d2ef9261 | 104 | BLOCKING_GET( XBeeApiCmdAt::requestHardwareVersion, |
johnb | 51:a7d0d2ef9261 | 105 | XBeeApiCmdAt::getHardwareVersion, |
johnb | 51:a7d0d2ef9261 | 106 | p_ver ); |
johnb | 51:a7d0d2ef9261 | 107 | } |
johnb | 51:a7d0d2ef9261 | 108 | |
johnb | 51:a7d0d2ef9261 | 109 | bool XBeeApiCmdAtBlocking::getFirmwareVersion( uint16_t* const p_ver ) |
johnb | 51:a7d0d2ef9261 | 110 | { |
johnb | 51:a7d0d2ef9261 | 111 | BLOCKING_GET( XBeeApiCmdAt::requestFirmwareVersion, |
johnb | 51:a7d0d2ef9261 | 112 | XBeeApiCmdAt::getFirmwareVersion, |
johnb | 51:a7d0d2ef9261 | 113 | p_ver ); |
johnb | 51:a7d0d2ef9261 | 114 | } |
johnb | 51:a7d0d2ef9261 | 115 | |
johnb | 51:a7d0d2ef9261 | 116 | bool XBeeApiCmdAtBlocking::getSerialNumber( uint64_t* const p_sn ) |
johnb | 51:a7d0d2ef9261 | 117 | { |
johnb | 51:a7d0d2ef9261 | 118 | BLOCKING_GET( XBeeApiCmdAt::requestSerialNumber, |
johnb | 51:a7d0d2ef9261 | 119 | XBeeApiCmdAt::getSerialNumber, |
johnb | 51:a7d0d2ef9261 | 120 | p_sn ); |
johnb | 51:a7d0d2ef9261 | 121 | } |
johnb | 51:a7d0d2ef9261 | 122 | |
johnb | 51:a7d0d2ef9261 | 123 | bool XBeeApiCmdAtBlocking::getChannel( uint8_t* const p_chan ) |
johnb | 51:a7d0d2ef9261 | 124 | { |
johnb | 51:a7d0d2ef9261 | 125 | BLOCKING_GET( XBeeApiCmdAt::requestChannel, |
johnb | 51:a7d0d2ef9261 | 126 | XBeeApiCmdAt::getChannel, |
johnb | 51:a7d0d2ef9261 | 127 | p_chan ); |
johnb | 51:a7d0d2ef9261 | 128 | } |
johnb | 51:a7d0d2ef9261 | 129 | |
johnb | 51:a7d0d2ef9261 | 130 | bool XBeeApiCmdAtBlocking::setChannel( uint8_t const p_chan ) |
johnb | 51:a7d0d2ef9261 | 131 | { |
johnb | 51:a7d0d2ef9261 | 132 | BLOCKING_SET( XBeeApiCmdAt::setChannel, |
johnb | 51:a7d0d2ef9261 | 133 | XBeeApiCmdAt::getChannel, |
johnb | 51:a7d0d2ef9261 | 134 | p_chan, |
johnb | 51:a7d0d2ef9261 | 135 | uint8_t ); |
johnb | 51:a7d0d2ef9261 | 136 | } |
johnb | 51:a7d0d2ef9261 | 137 | |
johnb | 51:a7d0d2ef9261 | 138 | bool XBeeApiCmdAtBlocking::getCoordinatorEnabled( bool* const p_en ) |
johnb | 51:a7d0d2ef9261 | 139 | { |
johnb | 51:a7d0d2ef9261 | 140 | BLOCKING_GET( XBeeApiCmdAt::requestCoordinatorEnabled, |
johnb | 51:a7d0d2ef9261 | 141 | XBeeApiCmdAt::getCoordinatorEnabled, |
johnb | 51:a7d0d2ef9261 | 142 | p_en ); |
johnb | 51:a7d0d2ef9261 | 143 | } |
johnb | 51:a7d0d2ef9261 | 144 | |
johnb | 51:a7d0d2ef9261 | 145 | bool XBeeApiCmdAtBlocking::setCoordinatorEnabled( const bool p_en ) |
johnb | 51:a7d0d2ef9261 | 146 | { |
johnb | 51:a7d0d2ef9261 | 147 | BLOCKING_SET( XBeeApiCmdAt::setCoordinatorEnabled, |
johnb | 51:a7d0d2ef9261 | 148 | XBeeApiCmdAt::getCoordinatorEnabled, |
johnb | 51:a7d0d2ef9261 | 149 | p_en, |
johnb | 51:a7d0d2ef9261 | 150 | bool ); |
johnb | 51:a7d0d2ef9261 | 151 | } |
johnb | 51:a7d0d2ef9261 | 152 | |
johnb | 51:a7d0d2ef9261 | 153 | bool XBeeApiCmdAtBlocking::getEndDeviceAssociationEnabled( bool* const p_en ) |
johnb | 51:a7d0d2ef9261 | 154 | { |
johnb | 51:a7d0d2ef9261 | 155 | BLOCKING_GET( XBeeApiCmdAt::requestEndDeviceAssociationEnabled, |
johnb | 51:a7d0d2ef9261 | 156 | XBeeApiCmdAt::getEndDeviceAssociationEnabled, |
johnb | 51:a7d0d2ef9261 | 157 | p_en ); |
johnb | 51:a7d0d2ef9261 | 158 | } |
johnb | 51:a7d0d2ef9261 | 159 | |
johnb | 51:a7d0d2ef9261 | 160 | bool XBeeApiCmdAtBlocking::setEndDeviceAssociationEnabled( const bool p_en ) |
johnb | 51:a7d0d2ef9261 | 161 | { |
johnb | 51:a7d0d2ef9261 | 162 | BLOCKING_SET( XBeeApiCmdAt::setEndDeviceAssociationEnabled, |
johnb | 51:a7d0d2ef9261 | 163 | XBeeApiCmdAt::getEndDeviceAssociationEnabled, |
johnb | 51:a7d0d2ef9261 | 164 | p_en, |
johnb | 51:a7d0d2ef9261 | 165 | bool ); |
johnb | 51:a7d0d2ef9261 | 166 | } |
johnb | 51:a7d0d2ef9261 | 167 | |
johnb | 51:a7d0d2ef9261 | 168 | bool XBeeApiCmdAtBlocking::getPanId( panId_t* const p_chan ) |
johnb | 51:a7d0d2ef9261 | 169 | { |
johnb | 51:a7d0d2ef9261 | 170 | BLOCKING_GET( XBeeApiCmdAt::requestPanId, |
johnb | 51:a7d0d2ef9261 | 171 | XBeeApiCmdAt::getPanId, |
johnb | 51:a7d0d2ef9261 | 172 | p_chan ); |
johnb | 51:a7d0d2ef9261 | 173 | } |
johnb | 51:a7d0d2ef9261 | 174 | |
johnb | 51:a7d0d2ef9261 | 175 | bool XBeeApiCmdAtBlocking::setPanId( const panId_t p_chan ) |
johnb | 51:a7d0d2ef9261 | 176 | { |
johnb | 51:a7d0d2ef9261 | 177 | BLOCKING_SET( XBeeApiCmdAt::setPanId, |
johnb | 51:a7d0d2ef9261 | 178 | XBeeApiCmdAt::getPanId, |
johnb | 51:a7d0d2ef9261 | 179 | p_chan, |
johnb | 51:a7d0d2ef9261 | 180 | panId_t ); |
johnb | 51:a7d0d2ef9261 | 181 | } |
johnb | 51:a7d0d2ef9261 | 182 | |
johnb | 51:a7d0d2ef9261 | 183 | bool XBeeApiCmdAtBlocking::getSourceAddress( uint16_t* const p_addr ) |
johnb | 51:a7d0d2ef9261 | 184 | { |
johnb | 51:a7d0d2ef9261 | 185 | BLOCKING_GET( XBeeApiCmdAt::requestSourceAddress, |
johnb | 51:a7d0d2ef9261 | 186 | XBeeApiCmdAt::getSourceAddress, |
johnb | 51:a7d0d2ef9261 | 187 | p_addr ); |
johnb | 51:a7d0d2ef9261 | 188 | } |
johnb | 51:a7d0d2ef9261 | 189 | |
johnb | 51:a7d0d2ef9261 | 190 | bool XBeeApiCmdAtBlocking::setSourceAddress( const uint16_t p_addr ) |
johnb | 51:a7d0d2ef9261 | 191 | { |
johnb | 51:a7d0d2ef9261 | 192 | BLOCKING_SET( XBeeApiCmdAt::setSourceAddress, |
johnb | 51:a7d0d2ef9261 | 193 | XBeeApiCmdAt::getSourceAddress, |
johnb | 51:a7d0d2ef9261 | 194 | p_addr, |
johnb | 51:a7d0d2ef9261 | 195 | uint16_t ); |
johnb | 51:a7d0d2ef9261 | 196 | } |
johnb | 51:a7d0d2ef9261 | 197 | |
johnb | 51:a7d0d2ef9261 | 198 | bool XBeeApiCmdAtBlocking::getRetries( uint8_t* const p_addr ) |
johnb | 51:a7d0d2ef9261 | 199 | { |
johnb | 51:a7d0d2ef9261 | 200 | BLOCKING_GET( XBeeApiCmdAt::requestRetries, |
johnb | 51:a7d0d2ef9261 | 201 | XBeeApiCmdAt::getRetries, |
johnb | 51:a7d0d2ef9261 | 202 | p_addr ); |
johnb | 51:a7d0d2ef9261 | 203 | } |
johnb | 51:a7d0d2ef9261 | 204 | |
johnb | 51:a7d0d2ef9261 | 205 | bool XBeeApiCmdAtBlocking::setRetries( const uint8_t p_addr ) |
johnb | 51:a7d0d2ef9261 | 206 | { |
johnb | 51:a7d0d2ef9261 | 207 | BLOCKING_SET( XBeeApiCmdAt::setRetries, |
johnb | 51:a7d0d2ef9261 | 208 | XBeeApiCmdAt::getRetries, |
johnb | 51:a7d0d2ef9261 | 209 | p_addr, |
johnb | 51:a7d0d2ef9261 | 210 | uint8_t ); |
johnb | 51:a7d0d2ef9261 | 211 | } |
johnb | 51:a7d0d2ef9261 | 212 | |
johnb | 51:a7d0d2ef9261 | 213 | bool XBeeApiCmdAtBlocking::getRandomDelaySlots( uint8_t* const p_addr ) |
johnb | 51:a7d0d2ef9261 | 214 | { |
johnb | 51:a7d0d2ef9261 | 215 | BLOCKING_GET( XBeeApiCmdAt::requestRandomDelaySlots, |
johnb | 51:a7d0d2ef9261 | 216 | XBeeApiCmdAt::getRandomDelaySlots, |
johnb | 51:a7d0d2ef9261 | 217 | p_addr ); |
johnb | 51:a7d0d2ef9261 | 218 | } |
johnb | 51:a7d0d2ef9261 | 219 | |
johnb | 51:a7d0d2ef9261 | 220 | bool XBeeApiCmdAtBlocking::setRandomDelaySlots( const uint8_t p_addr ) |
johnb | 51:a7d0d2ef9261 | 221 | { |
johnb | 51:a7d0d2ef9261 | 222 | BLOCKING_SET( XBeeApiCmdAt::setRandomDelaySlots, |
johnb | 51:a7d0d2ef9261 | 223 | XBeeApiCmdAt::getRandomDelaySlots, |
johnb | 51:a7d0d2ef9261 | 224 | p_addr, |
johnb | 51:a7d0d2ef9261 | 225 | uint8_t ); |
johnb | 51:a7d0d2ef9261 | 226 | } |
johnb | 51:a7d0d2ef9261 | 227 | |
johnb | 51:a7d0d2ef9261 | 228 | bool XBeeApiCmdAtBlocking::getMacMode( XBeeApiMACMode_e* const p_mode ) |
johnb | 51:a7d0d2ef9261 | 229 | { |
johnb | 51:a7d0d2ef9261 | 230 | BLOCKING_GET( XBeeApiCmdAt::requestMacMode, |
johnb | 51:a7d0d2ef9261 | 231 | XBeeApiCmdAt::getMacMode, |
johnb | 51:a7d0d2ef9261 | 232 | p_mode ); |
johnb | 51:a7d0d2ef9261 | 233 | } |
johnb | 51:a7d0d2ef9261 | 234 | |
johnb | 51:a7d0d2ef9261 | 235 | bool XBeeApiCmdAtBlocking::setMacMode( const XBeeApiMACMode_e p_mode ) |
johnb | 51:a7d0d2ef9261 | 236 | { |
johnb | 51:a7d0d2ef9261 | 237 | BLOCKING_SET( XBeeApiCmdAt::setMacMode, |
johnb | 51:a7d0d2ef9261 | 238 | XBeeApiCmdAt::getMacMode, |
johnb | 51:a7d0d2ef9261 | 239 | p_mode, |
johnb | 51:a7d0d2ef9261 | 240 | XBeeApiMACMode_e ); |
johnb | 51:a7d0d2ef9261 | 241 | } |
johnb | 51:a7d0d2ef9261 | 242 | |
johnb | 51:a7d0d2ef9261 | 243 | bool XBeeApiCmdAtBlocking::getDioConfig( const uint8_t p_chanNo, XBeeApiDioConfig_e* const p_conf ) |
johnb | 51:a7d0d2ef9261 | 244 | { |
johnb | 51:a7d0d2ef9261 | 245 | /* TODO */ |
johnb | 51:a7d0d2ef9261 | 246 | return false; |
johnb | 51:a7d0d2ef9261 | 247 | } |
johnb | 51:a7d0d2ef9261 | 248 | |
johnb | 51:a7d0d2ef9261 | 249 | bool XBeeApiCmdAtBlocking::setDioConfig( const uint8_t p_chanNo, const XBeeApiDioConfig_e p_conf ) |
johnb | 51:a7d0d2ef9261 | 250 | { |
johnb | 51:a7d0d2ef9261 | 251 | /* TODO */ |
johnb | 51:a7d0d2ef9261 | 252 | return false; |
johnb | 51:a7d0d2ef9261 | 253 | } |
johnb | 51:a7d0d2ef9261 | 254 | |
johnb | 51:a7d0d2ef9261 | 255 | bool XBeeApiCmdAtBlocking::getDioChangeDetectMask( uint8_t* const p_mask ) |
johnb | 51:a7d0d2ef9261 | 256 | { |
johnb | 51:a7d0d2ef9261 | 257 | BLOCKING_GET( XBeeApiCmdAt::requestDioChangeDetectMask, |
johnb | 51:a7d0d2ef9261 | 258 | XBeeApiCmdAt::getDioChangeDetectMask, |
johnb | 51:a7d0d2ef9261 | 259 | p_mask ); |
johnb | 51:a7d0d2ef9261 | 260 | } |
johnb | 51:a7d0d2ef9261 | 261 | |
johnb | 51:a7d0d2ef9261 | 262 | bool XBeeApiCmdAtBlocking::setDioChangeDetectMask( const uint8_t p_mask ) |
johnb | 51:a7d0d2ef9261 | 263 | { |
johnb | 51:a7d0d2ef9261 | 264 | BLOCKING_SET( XBeeApiCmdAt::setDioChangeDetectMask, |
johnb | 51:a7d0d2ef9261 | 265 | XBeeApiCmdAt::getDioChangeDetectMask, |
johnb | 51:a7d0d2ef9261 | 266 | p_mask, |
johnb | 51:a7d0d2ef9261 | 267 | uint8_t ); |
johnb | 51:a7d0d2ef9261 | 268 | } |
johnb | 51:a7d0d2ef9261 | 269 | |
johnb | 51:a7d0d2ef9261 | 270 | bool XBeeApiCmdAtBlocking::getDioLevels( uint8_t* const p_mask ) |
johnb | 51:a7d0d2ef9261 | 271 | { |
johnb | 51:a7d0d2ef9261 | 272 | /* TODO */ |
johnb | 51:a7d0d2ef9261 | 273 | return false; |
johnb | 51:a7d0d2ef9261 | 274 | } |
johnb | 51:a7d0d2ef9261 | 275 | |
johnb | 51:a7d0d2ef9261 | 276 | bool XBeeApiCmdAtBlocking::setDioLevels( const uint8_t p_mask ) |
johnb | 51:a7d0d2ef9261 | 277 | { |
johnb | 51:a7d0d2ef9261 | 278 | BLOCKING_SET( XBeeApiCmdAt::setDioLevels, |
johnb | 51:a7d0d2ef9261 | 279 | XBeeApiCmdAt::getDioLevels, |
johnb | 51:a7d0d2ef9261 | 280 | p_mask, |
johnb | 51:a7d0d2ef9261 | 281 | uint8_t ); |
johnb | 51:a7d0d2ef9261 | 282 | } |
johnb | 51:a7d0d2ef9261 | 283 | |
johnb | 51:a7d0d2ef9261 | 284 | bool XBeeApiCmdAtBlocking::getSampleRate( uint16_t* const p_interval ) |
johnb | 51:a7d0d2ef9261 | 285 | { |
johnb | 51:a7d0d2ef9261 | 286 | BLOCKING_GET( XBeeApiCmdAt::requestSampleRate, |
johnb | 51:a7d0d2ef9261 | 287 | XBeeApiCmdAt::getSampleRate, |
johnb | 51:a7d0d2ef9261 | 288 | p_interval ); |
johnb | 51:a7d0d2ef9261 | 289 | } |
johnb | 51:a7d0d2ef9261 | 290 | |
johnb | 51:a7d0d2ef9261 | 291 | bool XBeeApiCmdAtBlocking::setSampleRate( const uint16_t p_interval ) |
johnb | 51:a7d0d2ef9261 | 292 | { |
johnb | 51:a7d0d2ef9261 | 293 | BLOCKING_SET( XBeeApiCmdAt::setSampleRate, |
johnb | 51:a7d0d2ef9261 | 294 | XBeeApiCmdAt::getSampleRate, |
johnb | 51:a7d0d2ef9261 | 295 | p_interval, |
johnb | 51:a7d0d2ef9261 | 296 | uint16_t ); |
johnb | 51:a7d0d2ef9261 | 297 | } |
johnb | 51:a7d0d2ef9261 | 298 | |
johnb | 51:a7d0d2ef9261 | 299 | bool XBeeApiCmdAtBlocking::getDestinationAddress( uint64_t* const p_address ) |
johnb | 51:a7d0d2ef9261 | 300 | { |
johnb | 51:a7d0d2ef9261 | 301 | BLOCKING_GET( XBeeApiCmdAt::requestDestinationAddress, |
johnb | 51:a7d0d2ef9261 | 302 | XBeeApiCmdAt::getDestinationAddress, |
johnb | 51:a7d0d2ef9261 | 303 | p_address ); |
johnb | 51:a7d0d2ef9261 | 304 | } |
johnb | 51:a7d0d2ef9261 | 305 | |
johnb | 51:a7d0d2ef9261 | 306 | bool XBeeApiCmdAtBlocking::setDestinationAddress( const uint64_t p_address ) |
johnb | 51:a7d0d2ef9261 | 307 | { |
johnb | 51:a7d0d2ef9261 | 308 | BLOCKING_SET( XBeeApiCmdAt::setDestinationAddress, |
johnb | 51:a7d0d2ef9261 | 309 | XBeeApiCmdAt::getDestinationAddress, |
johnb | 51:a7d0d2ef9261 | 310 | p_address, |
johnb | 51:a7d0d2ef9261 | 311 | uint64_t ); |
johnb | 51:a7d0d2ef9261 | 312 | } |
johnb | 51:a7d0d2ef9261 | 313 | |
johnb | 51:a7d0d2ef9261 | 314 | bool XBeeApiCmdAtBlocking::getDestinationAddressHigh( uint32_t* const p_address ) |
johnb | 51:a7d0d2ef9261 | 315 | { |
johnb | 51:a7d0d2ef9261 | 316 | BLOCKING_GET( XBeeApiCmdAt::requestDestinationAddressHigh, |
johnb | 51:a7d0d2ef9261 | 317 | XBeeApiCmdAt::getDestinationAddressHigh, |
johnb | 51:a7d0d2ef9261 | 318 | p_address ); |
johnb | 51:a7d0d2ef9261 | 319 | } |
johnb | 51:a7d0d2ef9261 | 320 | |
johnb | 51:a7d0d2ef9261 | 321 | bool XBeeApiCmdAtBlocking::setDestinationAddressHigh( const uint32_t p_address ) |
johnb | 51:a7d0d2ef9261 | 322 | { |
johnb | 51:a7d0d2ef9261 | 323 | BLOCKING_SET( XBeeApiCmdAt::setDestinationAddressHigh, |
johnb | 51:a7d0d2ef9261 | 324 | XBeeApiCmdAt::getDestinationAddressHigh, |
johnb | 51:a7d0d2ef9261 | 325 | p_address, |
johnb | 51:a7d0d2ef9261 | 326 | uint32_t ); |
johnb | 51:a7d0d2ef9261 | 327 | } |
johnb | 51:a7d0d2ef9261 | 328 | |
johnb | 51:a7d0d2ef9261 | 329 | bool XBeeApiCmdAtBlocking::getDestinationAddressLow( uint32_t* const p_address ) |
johnb | 51:a7d0d2ef9261 | 330 | { |
johnb | 51:a7d0d2ef9261 | 331 | BLOCKING_GET( XBeeApiCmdAt::requestDestinationAddressLow, |
johnb | 51:a7d0d2ef9261 | 332 | XBeeApiCmdAt::getDestinationAddressLow, |
johnb | 51:a7d0d2ef9261 | 333 | p_address ); |
johnb | 51:a7d0d2ef9261 | 334 | } |
johnb | 51:a7d0d2ef9261 | 335 | |
johnb | 51:a7d0d2ef9261 | 336 | bool XBeeApiCmdAtBlocking::setDestinationAddressLow( const uint32_t p_address ) |
johnb | 51:a7d0d2ef9261 | 337 | { |
johnb | 51:a7d0d2ef9261 | 338 | BLOCKING_SET( XBeeApiCmdAt::setDestinationAddressLow, |
johnb | 51:a7d0d2ef9261 | 339 | XBeeApiCmdAt::getDestinationAddressLow, |
johnb | 51:a7d0d2ef9261 | 340 | p_address, |
johnb | 51:a7d0d2ef9261 | 341 | uint32_t ); |
johnb | 56:7fe74b03e6b1 | 342 | } |
johnb | 56:7fe74b03e6b1 | 343 | |
johnb | 56:7fe74b03e6b1 | 344 | bool XBeeApiCmdAtBlocking::setEncryptionKey( const uint8_t* p_key ) |
johnb | 56:7fe74b03e6b1 | 345 | { |
johnb | 56:7fe74b03e6b1 | 346 | bool ret_val = false; |
johnb | 56:7fe74b03e6b1 | 347 | uint16_t counter = m_timeout; |
johnb | 56:7fe74b03e6b1 | 348 | |
johnb | 56:7fe74b03e6b1 | 349 | if( XBeeApiCmdAt::setEncryptionKey( p_key ) )\ |
johnb | 56:7fe74b03e6b1 | 350 | { |
johnb | 56:7fe74b03e6b1 | 351 | bool cont; |
johnb | 56:7fe74b03e6b1 | 352 | |
johnb | 56:7fe74b03e6b1 | 353 | do{ |
johnb | 56:7fe74b03e6b1 | 354 | cont = false; |
johnb | 56:7fe74b03e6b1 | 355 | wait_ms( m_slice ); |
johnb | 56:7fe74b03e6b1 | 356 | if( XBeeApiCmdAt::getEncryptionKeySet() ) |
johnb | 56:7fe74b03e6b1 | 357 | { |
johnb | 56:7fe74b03e6b1 | 358 | ret_val = true; |
johnb | 56:7fe74b03e6b1 | 359 | } |
johnb | 56:7fe74b03e6b1 | 360 | else if( counter > m_slice ) { |
johnb | 56:7fe74b03e6b1 | 361 | counter -= m_slice; |
johnb | 56:7fe74b03e6b1 | 362 | cont = true; |
johnb | 56:7fe74b03e6b1 | 363 | } |
johnb | 56:7fe74b03e6b1 | 364 | } while( cont ); |
johnb | 56:7fe74b03e6b1 | 365 | } |
johnb | 56:7fe74b03e6b1 | 366 | |
johnb | 56:7fe74b03e6b1 | 367 | return( ret_val ); |
johnb | 56:7fe74b03e6b1 | 368 | } |
johnb | 56:7fe74b03e6b1 | 369 | |
johnb | 56:7fe74b03e6b1 | 370 | bool XBeeApiCmdAtBlocking::getEncryptionEnabled( bool* const p_enabled ) |
johnb | 56:7fe74b03e6b1 | 371 | { |
johnb | 56:7fe74b03e6b1 | 372 | BLOCKING_GET( XBeeApiCmdAt::requestEncryptionEnabled, |
johnb | 56:7fe74b03e6b1 | 373 | XBeeApiCmdAt::getEncryptionEnabled, |
johnb | 56:7fe74b03e6b1 | 374 | p_enabled ); |
johnb | 56:7fe74b03e6b1 | 375 | } |
johnb | 56:7fe74b03e6b1 | 376 | |
johnb | 56:7fe74b03e6b1 | 377 | bool XBeeApiCmdAtBlocking::setEncryptionEnabled( const bool p_enabled ) |
johnb | 56:7fe74b03e6b1 | 378 | { |
johnb | 56:7fe74b03e6b1 | 379 | BLOCKING_SET( XBeeApiCmdAt::setEncryptionEnabled, |
johnb | 56:7fe74b03e6b1 | 380 | XBeeApiCmdAt::getEncryptionEnabled, |
johnb | 56:7fe74b03e6b1 | 381 | p_enabled, |
johnb | 56:7fe74b03e6b1 | 382 | bool ); |
johnb | 56:7fe74b03e6b1 | 383 | } |