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.
Dependencies: CircularBuffer FixedLengthList
Dependents: XBeeApiTest XBeeApiSimpleATCmdsExample XBeeApiBroadcastExample XBeeApiBroadcastExampleRTOS ... more
Utility/XBeeApiCmdAt.hpp@56:7fe74b03e6b1, 2014-08-08 (annotated)
- Committer:
- johnb
- Date:
- Fri Aug 08 11:59:52 2014 +0000
- Revision:
- 56:7fe74b03e6b1
- Parent:
- 55:610aa4a2ed3b
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 | 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 | 56:7fe74b03e6b1 | 89 | EE | requestEncryptionEnabled, setEncryptionEnabled, getEncryptionEnabled |
| johnb | 56:7fe74b03e6b1 | 90 | KY | setEncryptionKey, getEncryptionKeySet |
| 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 | 56:7fe74b03e6b1 | 200 | bool m_have_encryptionEnabled; |
| johnb | 56:7fe74b03e6b1 | 201 | bool m_keySet; |
| johnb | 51:a7d0d2ef9261 | 202 | |
| johnb | 13:302e7c1ea0b3 | 203 | |
| johnb | 8:1b48b619d7f6 | 204 | uint16_t m_hwVer; |
| johnb | 8:1b48b619d7f6 | 205 | uint16_t m_fwVer; |
| johnb | 13:302e7c1ea0b3 | 206 | channel_t m_chan; |
| johnb | 13:302e7c1ea0b3 | 207 | channel_t m_chanPend; |
| johnb | 13:302e7c1ea0b3 | 208 | panId_t m_PANId; |
| johnb | 13:302e7c1ea0b3 | 209 | panId_t m_PANIdPend; |
| johnb | 13:302e7c1ea0b3 | 210 | bool m_EDA; |
| johnb | 13:302e7c1ea0b3 | 211 | bool m_EDAPend; |
| johnb | 13:302e7c1ea0b3 | 212 | bool m_CE; |
| johnb | 13:302e7c1ea0b3 | 213 | bool m_CEPend; |
| johnb | 31:c144106e55b5 | 214 | uint16_t m_sourceAddress; |
| johnb | 31:c144106e55b5 | 215 | uint16_t m_sourceAddressPend; |
| johnb | 32:af4e495afd62 | 216 | uint32_t m_snLow; |
| johnb | 32:af4e495afd62 | 217 | uint32_t m_snHigh; |
| johnb | 32:af4e495afd62 | 218 | uint8_t m_retries; |
| johnb | 32:af4e495afd62 | 219 | uint8_t m_retriesPend; |
| johnb | 32:af4e495afd62 | 220 | uint8_t m_randomDelaySlots; |
| johnb | 32:af4e495afd62 | 221 | uint8_t m_randomDelaySlotsPend; |
| johnb | 50:f76b7e7959a2 | 222 | XBeeApiMACMode_e m_macMode; |
| johnb | 50:f76b7e7959a2 | 223 | XBeeApiMACMode_e m_macModePend; |
| johnb | 50:f76b7e7959a2 | 224 | XBeeApiDioConfig_e m_d[ XBEE_API_DIO_CHANNEL_COUNT ]; |
| johnb | 50:f76b7e7959a2 | 225 | XBeeApiDioConfig_e m_dPend[ XBEE_API_DIO_CHANNEL_COUNT ]; |
| johnb | 51:a7d0d2ef9261 | 226 | uint8_t m_dioChangeDetectMask; |
| johnb | 51:a7d0d2ef9261 | 227 | uint8_t m_dioChangeDetectMaskPend; |
| johnb | 51:a7d0d2ef9261 | 228 | uint8_t m_dioLevels; |
| johnb | 51:a7d0d2ef9261 | 229 | uint8_t m_dioLevelsPend; |
| johnb | 51:a7d0d2ef9261 | 230 | uint16_t m_sampleRate; |
| johnb | 51:a7d0d2ef9261 | 231 | uint16_t m_sampleRatePend; |
| johnb | 51:a7d0d2ef9261 | 232 | uint32_t m_destHigh; |
| johnb | 51:a7d0d2ef9261 | 233 | uint32_t m_destHighPend; |
| johnb | 51:a7d0d2ef9261 | 234 | uint32_t m_destLow; |
| johnb | 51:a7d0d2ef9261 | 235 | uint32_t m_destLowPend; |
| johnb | 51:a7d0d2ef9261 | 236 | uint32_t m_writeCount; |
| johnb | 51:a7d0d2ef9261 | 237 | uint32_t m_applyCount; |
| johnb | 51:a7d0d2ef9261 | 238 | uint32_t m_resetCount; |
| johnb | 51:a7d0d2ef9261 | 239 | uint32_t m_sampleCount; |
| johnb | 55:610aa4a2ed3b | 240 | uint32_t m_restoreCount; |
| johnb | 56:7fe74b03e6b1 | 241 | bool m_encryptionEnabled; |
| johnb | 56:7fe74b03e6b1 | 242 | bool m_encryptionEnabledPend; |
| johnb | 52:0950b05d5270 | 243 | |
| johnb | 52:0950b05d5270 | 244 | time_t m_ioDigitalUpdatedTime[ XBEE_API_DIO_CHANNEL_COUNT ]; |
| johnb | 52:0950b05d5270 | 245 | bool m_ioDigitalState[ XBEE_API_DIO_CHANNEL_COUNT ]; |
| johnb | 52:0950b05d5270 | 246 | time_t m_ioAnalogueUpdatedTime[ XBEE_API_ADC_CHANNEL_COUNT ]; |
| johnb | 52:0950b05d5270 | 247 | uint16_t m_ioAnalogueVal[ XBEE_API_ADC_CHANNEL_COUNT ]; |
| johnb | 52:0950b05d5270 | 248 | |
| johnb | 8:1b48b619d7f6 | 249 | |
| johnb | 56:7fe74b03e6b1 | 250 | void SendCmd_uint8_t( const uint8_t p_frameId, |
| johnb | 56:7fe74b03e6b1 | 251 | const uint8_t* const p_data, |
| johnb | 56:7fe74b03e6b1 | 252 | const uint8_t& p_val ); |
| johnb | 56:7fe74b03e6b1 | 253 | void SendCmd_uint8_t( const uint8_t p_frameId, |
| johnb | 56:7fe74b03e6b1 | 254 | const uint8_t* const p_data, |
| johnb | 56:7fe74b03e6b1 | 255 | const uint8_t* p_val ); |
| johnb | 56:7fe74b03e6b1 | 256 | void SendCmd_uint16_t( const uint8_t p_frameId, |
| johnb | 56:7fe74b03e6b1 | 257 | const uint8_t* const p_data, |
| johnb | 56:7fe74b03e6b1 | 258 | const uint16_t& p_val ); |
| johnb | 56:7fe74b03e6b1 | 259 | void SendCmd_uint32_t( const uint8_t p_frameId, |
| johnb | 56:7fe74b03e6b1 | 260 | const uint8_t* const p_data, |
| johnb | 56:7fe74b03e6b1 | 261 | const uint32_t& p_val ); |
| johnb | 56:7fe74b03e6b1 | 262 | |
| johnb | 56:7fe74b03e6b1 | 263 | virtual void SendCmd( const uint8_t p_frameId, |
| johnb | 56:7fe74b03e6b1 | 264 | const uint8_t* const p_data, |
| johnb | 56:7fe74b03e6b1 | 265 | const uint8_t* const p_val, |
| johnb | 56:7fe74b03e6b1 | 266 | const uint8_t p_len ); |
| johnb | 56:7fe74b03e6b1 | 267 | |
| johnb | 50:f76b7e7959a2 | 268 | virtual size_t getResponseStatusPos( void ) const; |
| johnb | 50:f76b7e7959a2 | 269 | |
| johnb | 50:f76b7e7959a2 | 270 | |
| johnb | 50:f76b7e7959a2 | 271 | /* Implement XBeeApiCmdDecoder interface */ |
| johnb | 50:f76b7e7959a2 | 272 | virtual bool decodeCallback( const uint8_t* const p_data, size_t p_len ); |
| johnb | 50:f76b7e7959a2 | 273 | |
| johnb | 50:f76b7e7959a2 | 274 | virtual bool processResponseFrame( const uint8_t* const p_data, size_t p_len ); |
| johnb | 50:f76b7e7959a2 | 275 | |
| johnb | 52:0950b05d5270 | 276 | virtual bool processIOFrame( const uint8_t* const p_data, size_t p_len, const size_t p_start ); |
| johnb | 26:f5df80e990f4 | 277 | |
| johnb | 55:610aa4a2ed3b | 278 | void resetCachedData( void ); |
| johnb | 55:610aa4a2ed3b | 279 | |
| johnb | 8:1b48b619d7f6 | 280 | public: |
| johnb | 13:302e7c1ea0b3 | 281 | |
| johnb | 29:c6d037cceb02 | 282 | /** Constructor |
| johnb | 29:c6d037cceb02 | 283 | |
| johnb | 29:c6d037cceb02 | 284 | \param p_device XBee device with which this object should be associated */ |
| johnb | 29:c6d037cceb02 | 285 | XBeeApiCmdAt( XBeeDevice* const p_device = NULL ); |
| johnb | 26:f5df80e990f4 | 286 | |
| johnb | 26:f5df80e990f4 | 287 | /** Destructor */ |
| johnb | 26:f5df80e990f4 | 288 | virtual ~XBeeApiCmdAt( void ) {}; |
| johnb | 8:1b48b619d7f6 | 289 | |
| johnb | 52:0950b05d5270 | 290 | time_t getDigitalState( const uint8_t p_chanNo, bool& p_state ); |
| johnb | 52:0950b05d5270 | 291 | time_t getAnalogueValue( const uint8_t p_chanNo, uint16_t& p_val ); |
| johnb | 52:0950b05d5270 | 292 | |
| johnb | 26:f5df80e990f4 | 293 | /** Request the hardware version identifier from the XBee. |
| johnb | 26:f5df80e990f4 | 294 | As the data is retrieved asynchronously to this call, |
| johnb | 26:f5df80e990f4 | 295 | once the response is received it can be accessed via |
| johnb | 26:f5df80e990f4 | 296 | getHardwareVersion() */ |
| johnb | 26:f5df80e990f4 | 297 | bool requestHardwareVersion( void ); |
| johnb | 26:f5df80e990f4 | 298 | bool requestFirmwareVersion( void ); |
| johnb | 26:f5df80e990f4 | 299 | bool requestChannel( void ); |
| johnb | 26:f5df80e990f4 | 300 | bool requestCoordinatorEnabled( void ); |
| johnb | 26:f5df80e990f4 | 301 | bool requestEndDeviceAssociationEnabled( void ); |
| johnb | 26:f5df80e990f4 | 302 | bool requestPanId( void ); |
| johnb | 31:c144106e55b5 | 303 | bool requestSourceAddress( void ); |
| johnb | 32:af4e495afd62 | 304 | bool requestSerialNumber( void ); |
| johnb | 50:f76b7e7959a2 | 305 | bool requestSerialNumberHigh( void ); |
| johnb | 50:f76b7e7959a2 | 306 | bool requestSerialNumberLow( void ); |
| johnb | 50:f76b7e7959a2 | 307 | bool requestDioConfig( const uint8_t p_chanNo ); |
| johnb | 51:a7d0d2ef9261 | 308 | bool requestDioChangeDetectMask( void ); |
| johnb | 51:a7d0d2ef9261 | 309 | bool requestSampleRate( void ); |
| johnb | 50:f76b7e7959a2 | 310 | |
| johnb | 32:af4e495afd62 | 311 | /** Request the number of retries the XBee is configured to make. |
| johnb | 32:af4e495afd62 | 312 | Note that the 802.15.4 MAC already allows 3 retries, so this parameter |
| johnb | 32:af4e495afd62 | 313 | specifies an additional multiple of 3 retries |
| johnb | 32:af4e495afd62 | 314 | As the data is retrieved asynchronously to this call, |
| johnb | 32:af4e495afd62 | 315 | once the response is received it can be accessed via |
| johnb | 32:af4e495afd62 | 316 | getRetries() |
| johnb | 32:af4e495afd62 | 317 | */ |
| johnb | 32:af4e495afd62 | 318 | bool requestRetries( void ); |
| johnb | 32:af4e495afd62 | 319 | |
| johnb | 32:af4e495afd62 | 320 | /** Request the minimum value of the back-off exponent in the CSMA-CA algorithm |
| johnb | 32:af4e495afd62 | 321 | used in collision avoidance. |
| johnb | 32:af4e495afd62 | 322 | */ |
| johnb | 32:af4e495afd62 | 323 | bool requestRandomDelaySlots( void ); |
| johnb | 32:af4e495afd62 | 324 | |
| johnb | 32:af4e495afd62 | 325 | bool requestMacMode( void ); |
| johnb | 51:a7d0d2ef9261 | 326 | bool requestDestinationAddress( void ); |
| johnb | 51:a7d0d2ef9261 | 327 | bool requestDestinationAddressHigh( void ); |
| johnb | 51:a7d0d2ef9261 | 328 | bool requestDestinationAddressLow( void ); |
| johnb | 51:a7d0d2ef9261 | 329 | |
| johnb | 51:a7d0d2ef9261 | 330 | bool requestWriteSettings( void ); |
| johnb | 51:a7d0d2ef9261 | 331 | bool requestApplyChanges( void ); |
| johnb | 51:a7d0d2ef9261 | 332 | bool requestReset( void ); |
| johnb | 51:a7d0d2ef9261 | 333 | bool requestForceSample( void ); |
| johnb | 55:610aa4a2ed3b | 334 | bool requestRestoreDefaults( void ); |
| johnb | 56:7fe74b03e6b1 | 335 | bool requestEncryptionEnabled( void ); |
| johnb | 8:1b48b619d7f6 | 336 | |
| johnb | 26:f5df80e990f4 | 337 | /** Read the XBee's hardware version identifier. |
| johnb | 26:f5df80e990f4 | 338 | |
| johnb | 26:f5df80e990f4 | 339 | This method does not initiate any communication with the |
| johnb | 26:f5df80e990f4 | 340 | XBee - the identifier must previously have been requested |
| johnb | 26:f5df80e990f4 | 341 | via requestHardwareVersion(). The method is non-blocking. */ |
| johnb | 26:f5df80e990f4 | 342 | virtual bool getHardwareVersion( uint16_t* const p_ver ); |
| johnb | 26:f5df80e990f4 | 343 | |
| johnb | 26:f5df80e990f4 | 344 | /** Read the XBee's firmware version identifier. |
| johnb | 26:f5df80e990f4 | 345 | |
| johnb | 26:f5df80e990f4 | 346 | This method does not initiate any communication with the |
| johnb | 26:f5df80e990f4 | 347 | XBee - the identifier must previously have been requested |
| johnb | 26:f5df80e990f4 | 348 | via requestFirmwareVersion(). The method is non-blocking. */ |
| johnb | 26:f5df80e990f4 | 349 | virtual bool getFirmwareVersion( uint16_t* const p_ver ); |
| johnb | 32:af4e495afd62 | 350 | |
| johnb | 32:af4e495afd62 | 351 | virtual bool getSerialNumber( uint64_t* const p_sn ); |
| johnb | 13:302e7c1ea0b3 | 352 | |
| johnb | 32:af4e495afd62 | 353 | virtual bool getChannel( uint8_t* const p_chan ); |
| johnb | 32:af4e495afd62 | 354 | virtual bool setChannel( uint8_t const p_chan ); |
| johnb | 8:1b48b619d7f6 | 355 | |
| johnb | 32:af4e495afd62 | 356 | virtual bool getCoordinatorEnabled( bool* const p_en ); |
| johnb | 32:af4e495afd62 | 357 | virtual bool setCoordinatorEnabled( const bool p_en ); |
| johnb | 32:af4e495afd62 | 358 | |
| johnb | 32:af4e495afd62 | 359 | virtual bool getEndDeviceAssociationEnabled( bool* const p_en ); |
| johnb | 32:af4e495afd62 | 360 | virtual bool setEndDeviceAssociationEnabled( const bool p_en ); |
| johnb | 13:302e7c1ea0b3 | 361 | |
| johnb | 32:af4e495afd62 | 362 | virtual bool getPanId( panId_t* const p_id ); |
| johnb | 32:af4e495afd62 | 363 | virtual bool setPanId( const panId_t p_id ); |
| johnb | 32:af4e495afd62 | 364 | |
| johnb | 32:af4e495afd62 | 365 | virtual bool getSourceAddress( uint16_t* const p_addr ); |
| johnb | 32:af4e495afd62 | 366 | virtual bool setSourceAddress( const uint16_t p_addr ); |
| johnb | 31:c144106e55b5 | 367 | |
| johnb | 32:af4e495afd62 | 368 | virtual bool getRetries( uint8_t* const p_addr ); |
| johnb | 32:af4e495afd62 | 369 | virtual bool setRetries( const uint8_t p_addr ); |
| johnb | 31:c144106e55b5 | 370 | |
| johnb | 32:af4e495afd62 | 371 | virtual bool getRandomDelaySlots( uint8_t* const p_addr ); |
| johnb | 32:af4e495afd62 | 372 | virtual bool setRandomDelaySlots( const uint8_t p_addr ); |
| johnb | 32:af4e495afd62 | 373 | |
| johnb | 32:af4e495afd62 | 374 | virtual bool getMacMode( XBeeApiMACMode_e* const p_mode ); |
| johnb | 50:f76b7e7959a2 | 375 | virtual bool setMacMode( const XBeeApiMACMode_e p_mode ); |
| johnb | 50:f76b7e7959a2 | 376 | |
| johnb | 50:f76b7e7959a2 | 377 | virtual bool getDioConfig( const uint8_t p_chanNo, XBeeApiDioConfig_e* const p_conf ); |
| johnb | 50:f76b7e7959a2 | 378 | virtual bool setDioConfig( const uint8_t p_chanNo, const XBeeApiDioConfig_e p_conf ); |
| johnb | 51:a7d0d2ef9261 | 379 | |
| johnb | 51:a7d0d2ef9261 | 380 | virtual bool getDioChangeDetectMask( uint8_t* const p_mask ); |
| johnb | 51:a7d0d2ef9261 | 381 | virtual bool setDioChangeDetectMask( const uint8_t p_mask ); |
| johnb | 26:f5df80e990f4 | 382 | |
| johnb | 51:a7d0d2ef9261 | 383 | /** Note that this method will only return a value in the case that the levels have |
| johnb | 51:a7d0d2ef9261 | 384 | been previously set via the setDioLevels method and that the XBee has |
| johnb | 51:a7d0d2ef9261 | 385 | returned a successful response. There is no ability to simply read what the |
| johnb | 51:a7d0d2ef9261 | 386 | current digital outputs are set to */ |
| johnb | 51:a7d0d2ef9261 | 387 | virtual bool getDioLevels( uint8_t* const p_mask ); |
| johnb | 51:a7d0d2ef9261 | 388 | virtual bool setDioLevels( const uint8_t p_mask ); |
| johnb | 8:1b48b619d7f6 | 389 | |
| johnb | 51:a7d0d2ef9261 | 390 | /* TODO: Add protection to prevent p_interval being too small - see data sheet */ |
| johnb | 51:a7d0d2ef9261 | 391 | virtual bool getSampleRate( uint16_t* const p_interval ); |
| johnb | 51:a7d0d2ef9261 | 392 | virtual bool setSampleRate( const uint16_t p_interval ); |
| johnb | 51:a7d0d2ef9261 | 393 | |
| johnb | 51:a7d0d2ef9261 | 394 | virtual bool getDestinationAddress( uint64_t* const p_address ); |
| johnb | 51:a7d0d2ef9261 | 395 | virtual bool setDestinationAddress( const uint64_t p_address ); |
| johnb | 13:302e7c1ea0b3 | 396 | |
| johnb | 51:a7d0d2ef9261 | 397 | virtual bool getDestinationAddressHigh( uint32_t* const p_address ); |
| johnb | 51:a7d0d2ef9261 | 398 | virtual bool setDestinationAddressHigh( const uint32_t p_address ); |
| johnb | 31:c144106e55b5 | 399 | |
| johnb | 51:a7d0d2ef9261 | 400 | virtual bool getDestinationAddressLow( uint32_t* const p_address ); |
| johnb | 51:a7d0d2ef9261 | 401 | virtual bool setDestinationAddressLow( const uint32_t p_address ); |
| johnb | 32:af4e495afd62 | 402 | |
| johnb | 56:7fe74b03e6b1 | 403 | /** Set the encryption key used by the XBee. This key will only |
| johnb | 56:7fe74b03e6b1 | 404 | be used if encryption is enabled (see setEncryptionEnable ). |
| johnb | 56:7fe74b03e6b1 | 405 | Once set the key cannot be read back. |
| johnb | 56:7fe74b03e6b1 | 406 | |
| johnb | 56:7fe74b03e6b1 | 407 | \param p_key Pointer to a 16-byte array, with the first array |
| johnb | 56:7fe74b03e6b1 | 408 | entry containing the most significant 8 bits of the |
| johnb | 56:7fe74b03e6b1 | 409 | 128-bit key |
| johnb | 56:7fe74b03e6b1 | 410 | */ |
| johnb | 56:7fe74b03e6b1 | 411 | virtual bool setEncryptionKey( const uint8_t* p_key ); |
| johnb | 56:7fe74b03e6b1 | 412 | |
| johnb | 56:7fe74b03e6b1 | 413 | /** Determine whether or not a call to setEncryptionKey has successfully |
| johnb | 56:7fe74b03e6b1 | 414 | set the key in the XBee. Note that this will not query the key stored |
| johnb | 56:7fe74b03e6b1 | 415 | in the XBee and will only evern return true if a call to setEncryptionKey |
| johnb | 56:7fe74b03e6b1 | 416 | was made |
| johnb | 56:7fe74b03e6b1 | 417 | |
| johnb | 56:7fe74b03e6b1 | 418 | \returns true in the case that the XBee has responded to confirm that |
| johnb | 56:7fe74b03e6b1 | 419 | a call to setEncryptionKey was successful |
| johnb | 56:7fe74b03e6b1 | 420 | */ |
| johnb | 56:7fe74b03e6b1 | 421 | virtual bool getEncryptionKeySet( void ); |
| johnb | 56:7fe74b03e6b1 | 422 | |
| johnb | 56:7fe74b03e6b1 | 423 | virtual bool getEncryptionEnabled( bool* const p_enabled ); |
| johnb | 56:7fe74b03e6b1 | 424 | virtual bool setEncryptionEnabled( const bool p_enabled ); |
| johnb | 8:1b48b619d7f6 | 425 | }; |
| johnb | 8:1b48b619d7f6 | 426 | |
| johnb | 56:7fe74b03e6b1 | 427 | #define XBEE_CMD_MAX_PARAM_LENGTH (16U) |
| johnb | 56:7fe74b03e6b1 | 428 | |
| johnb | 8:1b48b619d7f6 | 429 | #endif |