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:
53:7b65422d7a32
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
johnb 8:1b48b619d7f6 3 Copyright 2014 John Bailey
johnb 13:302e7c1ea0b3 4
johnb 8:1b48b619d7f6 5 Licensed under the Apache License, Version 2.0 (the "License");
johnb 8:1b48b619d7f6 6 you may not use this file except in compliance with the License.
johnb 8:1b48b619d7f6 7 You may obtain a copy of the License at
johnb 8:1b48b619d7f6 8
johnb 8:1b48b619d7f6 9 http://www.apache.org/licenses/LICENSE-2.0
johnb 8:1b48b619d7f6 10
johnb 8:1b48b619d7f6 11 Unless required by applicable law or agreed to in writing, software
johnb 8:1b48b619d7f6 12 distributed under the License is distributed on an "AS IS" BASIS,
johnb 8:1b48b619d7f6 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
johnb 8:1b48b619d7f6 14 See the License for the specific language governing permissions and
johnb 8:1b48b619d7f6 15 limitations under the License.
johnb 8:1b48b619d7f6 16
johnb 8:1b48b619d7f6 17 */
johnb 8:1b48b619d7f6 18
johnb 8:1b48b619d7f6 19 #include "XBeeApiCmdAt.hpp"
johnb 8:1b48b619d7f6 20
johnb 8:1b48b619d7f6 21 /* Set of Frame ID codes for the various commands (see XBEE_CMD_POSN_FRAME_ID) */
johnb 8:1b48b619d7f6 22
johnb 13:302e7c1ea0b3 23 #define CMD_RESPONSE_GET_VR '1'
johnb 13:302e7c1ea0b3 24 #define CMD_RESPONSE_GET_HV '2'
johnb 13:302e7c1ea0b3 25 #define CMD_RESPONSE_GET_CH '3'
johnb 13:302e7c1ea0b3 26 #define CMD_RESPONSE_SET_CH '4'
johnb 13:302e7c1ea0b3 27 #define CMD_RESPONSE_SET_CE '5'
johnb 13:302e7c1ea0b3 28 #define CMD_RESPONSE_GET_CE '6'
johnb 13:302e7c1ea0b3 29 #define CMD_RESPONSE_SET_EDA '7'
johnb 13:302e7c1ea0b3 30 #define CMD_RESPONSE_GET_EDA '8'
johnb 13:302e7c1ea0b3 31 #define CMD_RESPONSE_SET_PID '9'
johnb 13:302e7c1ea0b3 32 #define CMD_RESPONSE_GET_PID '0'
johnb 31:c144106e55b5 33 #define CMD_RESPONSE_SET_MY 'a'
johnb 31:c144106e55b5 34 #define CMD_RESPONSE_GET_MY 'b'
johnb 32:af4e495afd62 35 #define CMD_RESPONSE_GET_SH 'c'
johnb 32:af4e495afd62 36 #define CMD_RESPONSE_GET_SL 'd'
johnb 32:af4e495afd62 37 #define CMD_RESPONSE_SET_RR 'e'
johnb 32:af4e495afd62 38 #define CMD_RESPONSE_GET_RR 'f'
johnb 32:af4e495afd62 39 #define CMD_RESPONSE_SET_RN 'g'
johnb 32:af4e495afd62 40 #define CMD_RESPONSE_GET_RN 'h'
johnb 32:af4e495afd62 41 #define CMD_RESPONSE_SET_MM 'i'
johnb 32:af4e495afd62 42 #define CMD_RESPONSE_GET_MM 'j'
johnb 50:f76b7e7959a2 43 #define CMD_RESPONSE_GET_D0 'k'
johnb 50:f76b7e7959a2 44 #define CMD_RESPONSE_GET_D1 'l'
johnb 50:f76b7e7959a2 45 #define CMD_RESPONSE_GET_D2 'm'
johnb 50:f76b7e7959a2 46 #define CMD_RESPONSE_GET_D3 'n'
johnb 50:f76b7e7959a2 47 #define CMD_RESPONSE_GET_D4 'o'
johnb 50:f76b7e7959a2 48 #define CMD_RESPONSE_GET_D5 'p'
johnb 50:f76b7e7959a2 49 #define CMD_RESPONSE_GET_D6 'q'
johnb 50:f76b7e7959a2 50 #define CMD_RESPONSE_GET_D7 'r'
johnb 51:a7d0d2ef9261 51 #define CMD_RESPONSE_SET_D0 's'
johnb 51:a7d0d2ef9261 52 #define CMD_RESPONSE_SET_D1 't'
johnb 51:a7d0d2ef9261 53 #define CMD_RESPONSE_SET_D2 'u'
johnb 51:a7d0d2ef9261 54 #define CMD_RESPONSE_SET_D3 'v'
johnb 51:a7d0d2ef9261 55 #define CMD_RESPONSE_SET_D4 'w'
johnb 51:a7d0d2ef9261 56 #define CMD_RESPONSE_SET_D5 'x'
johnb 51:a7d0d2ef9261 57 #define CMD_RESPONSE_SET_D6 'y'
johnb 51:a7d0d2ef9261 58 #define CMD_RESPONSE_SET_D7 'z'
johnb 51:a7d0d2ef9261 59 #define CMD_RESPONSE_SET_IC 'A'
johnb 51:a7d0d2ef9261 60 #define CMD_RESPONSE_GET_IC 'B'
johnb 51:a7d0d2ef9261 61 #define CMD_RESPONSE_SET_IO 'C'
johnb 51:a7d0d2ef9261 62 #define CMD_RESPONSE_SET_IR 'D'
johnb 51:a7d0d2ef9261 63 #define CMD_RESPONSE_GET_IR 'E'
johnb 51:a7d0d2ef9261 64 #define CMD_RESPONSE_SET_DH 'F'
johnb 51:a7d0d2ef9261 65 #define CMD_RESPONSE_GET_DH 'G'
johnb 51:a7d0d2ef9261 66 #define CMD_RESPONSE_SET_DL 'H'
johnb 51:a7d0d2ef9261 67 #define CMD_RESPONSE_GET_DL 'I'
johnb 51:a7d0d2ef9261 68 #define CMD_RESPONSE_SET_WR 'J'
johnb 51:a7d0d2ef9261 69 #define CMD_RESPONSE_SET_AC 'K'
johnb 51:a7d0d2ef9261 70 #define CMD_RESPONSE_SET_FR 'L'
johnb 51:a7d0d2ef9261 71 #define CMD_RESPONSE_SET_IS 'M'
johnb 55:610aa4a2ed3b 72 #define CMD_RESPONSE_SET_RE 'N'
johnb 13:302e7c1ea0b3 73
johnb 30:9532b01a1ae1 74 /** Lowest channel supported by the XBee S1 */
johnb 30:9532b01a1ae1 75 #define XBEE_CHAN_MIN 0x0b
johnb 30:9532b01a1ae1 76 /** Highest channel supported by the XBee S1 */
johnb 30:9532b01a1ae1 77 #define XBEE_CHAN_MAX 0x1a
johnb 13:302e7c1ea0b3 78
johnb 30:9532b01a1ae1 79 /** Lowest channel supported by the XBee S1 Pro */
johnb 30:9532b01a1ae1 80 #define XBEE_PRO_CHAN_MIN 0x0c
johnb 30:9532b01a1ae1 81 /** Highest channel supported by the XBee S1 Pro */
johnb 30:9532b01a1ae1 82 #define XBEE_PRO_CHAN_MAX 0x17
johnb 8:1b48b619d7f6 83
johnb 8:1b48b619d7f6 84 /* Content for the various commands - value of 0 indicates a value to be populated (i.e. variable) */
johnb 8:1b48b619d7f6 85
johnb 50:f76b7e7959a2 86 static const uint8_t cmd_vr[] = { 'V', 'R' };
johnb 50:f76b7e7959a2 87 static const uint8_t cmd_vr_get_fid = CMD_RESPONSE_GET_VR;
johnb 50:f76b7e7959a2 88
johnb 50:f76b7e7959a2 89 static const uint8_t cmd_hv[] = { 'H', 'V' };
johnb 50:f76b7e7959a2 90 static const uint8_t cmd_hv_get_fid = CMD_RESPONSE_GET_HV;
johnb 50:f76b7e7959a2 91
johnb 50:f76b7e7959a2 92 static const uint8_t cmd_sh[] = { 'S', 'H' };
johnb 50:f76b7e7959a2 93 static const uint8_t cmd_sh_get_fid = CMD_RESPONSE_GET_SH;
johnb 50:f76b7e7959a2 94
johnb 50:f76b7e7959a2 95 static const uint8_t cmd_sl[] = { 'S', 'L' };
johnb 50:f76b7e7959a2 96 static const uint8_t cmd_sl_get_fid = CMD_RESPONSE_GET_SL;
johnb 13:302e7c1ea0b3 97
johnb 50:f76b7e7959a2 98 static const uint8_t cmd_ch[] = { 'C', 'H' };
johnb 50:f76b7e7959a2 99 static const uint8_t cmd_ch_get_fid = CMD_RESPONSE_GET_CH;
johnb 50:f76b7e7959a2 100 static const uint8_t cmd_ch_set[] = { 'C', 'H', 0 };
johnb 50:f76b7e7959a2 101 static const uint8_t cmd_ch_set_fid = CMD_RESPONSE_SET_CH;
johnb 50:f76b7e7959a2 102
johnb 50:f76b7e7959a2 103 static const uint8_t cmd_ce[] = { 'C', 'E' };
johnb 50:f76b7e7959a2 104 static const uint8_t cmd_ce_get_fid = CMD_RESPONSE_GET_CE;
johnb 50:f76b7e7959a2 105 static const uint8_t cmd_ce_set[] = { 'C', 'E', 0 };
johnb 50:f76b7e7959a2 106 static const uint8_t cmd_ce_set_fid = CMD_RESPONSE_SET_CE;
johnb 13:302e7c1ea0b3 107
johnb 50:f76b7e7959a2 108 static const uint8_t cmd_eda[] = { 'A', '1' };
johnb 50:f76b7e7959a2 109 static const uint8_t cmd_eda_get_fid = CMD_RESPONSE_GET_EDA;
johnb 50:f76b7e7959a2 110 static const uint8_t cmd_eda_set[] = { 'A', '1', 0 };
johnb 50:f76b7e7959a2 111 static const uint8_t cmd_eda_set_fid = CMD_RESPONSE_SET_EDA;
johnb 32:af4e495afd62 112
johnb 50:f76b7e7959a2 113 static const uint8_t cmd_pid[] = { 'I', 'D' };
johnb 50:f76b7e7959a2 114 static const uint8_t cmd_pid_get_fid = CMD_RESPONSE_GET_PID;
johnb 50:f76b7e7959a2 115 static const uint8_t cmd_pid_set[] = { 'I', 'D', 0, 0 };
johnb 50:f76b7e7959a2 116 static const uint8_t cmd_pid_set_fid = CMD_RESPONSE_SET_PID;
johnb 13:302e7c1ea0b3 117
johnb 50:f76b7e7959a2 118 static const uint8_t cmd_my[] = { 'M', 'Y' };
johnb 50:f76b7e7959a2 119 static const uint8_t cmd_my_get_fid = CMD_RESPONSE_GET_MY;
johnb 50:f76b7e7959a2 120 static const uint8_t cmd_my_set[] = { 'M', 'Y', 0, 0 };
johnb 50:f76b7e7959a2 121 static const uint8_t cmd_my_set_fid = CMD_RESPONSE_SET_MY;
johnb 32:af4e495afd62 122
johnb 50:f76b7e7959a2 123 static const uint8_t cmd_rr[] = { 'R', 'R' };
johnb 50:f76b7e7959a2 124 static const uint8_t cmd_rr_get_fid = CMD_RESPONSE_GET_RR;
johnb 50:f76b7e7959a2 125 static const uint8_t cmd_rr_set[] = { 'R', 'R', 0 };
johnb 50:f76b7e7959a2 126 static const uint8_t cmd_rr_set_fid = CMD_RESPONSE_SET_RR;
johnb 50:f76b7e7959a2 127
johnb 50:f76b7e7959a2 128 static const uint8_t cmd_rn[] = { 'R', 'N' };
johnb 50:f76b7e7959a2 129 static const uint8_t cmd_rn_get_fid = CMD_RESPONSE_GET_RN;
johnb 50:f76b7e7959a2 130 static const uint8_t cmd_rn_set[] = { 'R', 'N', 0 };
johnb 50:f76b7e7959a2 131 static const uint8_t cmd_rn_set_fid = CMD_RESPONSE_SET_RN;
johnb 13:302e7c1ea0b3 132
johnb 50:f76b7e7959a2 133 static const uint8_t cmd_mm[] = { 'M', 'M' };
johnb 50:f76b7e7959a2 134 static const uint8_t cmd_mm_get_fid = CMD_RESPONSE_GET_MM;
johnb 50:f76b7e7959a2 135 static const uint8_t cmd_mm_set[] = { 'M', 'M', 0 };
johnb 50:f76b7e7959a2 136 static const uint8_t cmd_mm_set_fid = CMD_RESPONSE_SET_MM;
johnb 8:1b48b619d7f6 137
johnb 51:a7d0d2ef9261 138 static const uint8_t cmd_ic[] = { 'I', 'C' };
johnb 51:a7d0d2ef9261 139 static const uint8_t cmd_ic_get_fid = CMD_RESPONSE_GET_IC;
johnb 51:a7d0d2ef9261 140 static const uint8_t cmd_ic_set[] = { 'I', 'C', 0 };
johnb 51:a7d0d2ef9261 141 static const uint8_t cmd_ic_set_fid = CMD_RESPONSE_SET_IC;
johnb 51:a7d0d2ef9261 142
johnb 51:a7d0d2ef9261 143 static const uint8_t cmd_io_set[] = { 'I', 'O', 0 };
johnb 51:a7d0d2ef9261 144 static const uint8_t cmd_io_set_fid = CMD_RESPONSE_SET_IO;
johnb 51:a7d0d2ef9261 145
johnb 51:a7d0d2ef9261 146 static const uint8_t cmd_ir[] = { 'I', 'R' };
johnb 51:a7d0d2ef9261 147 static const uint8_t cmd_ir_get_fid = CMD_RESPONSE_GET_IR;
johnb 51:a7d0d2ef9261 148 static const uint8_t cmd_ir_set[] = { 'I', 'R', 0, 0 };
johnb 51:a7d0d2ef9261 149 static const uint8_t cmd_ir_set_fid = CMD_RESPONSE_SET_IR;
johnb 51:a7d0d2ef9261 150
johnb 51:a7d0d2ef9261 151 static const uint8_t cmd_dh[] = { 'D', 'H' };
johnb 51:a7d0d2ef9261 152 static const uint8_t cmd_dh_get_fid = CMD_RESPONSE_GET_DH;
johnb 51:a7d0d2ef9261 153 static const uint8_t cmd_dh_set[] = { 'D', 'H', 0, 0, 0, 0 };
johnb 51:a7d0d2ef9261 154 static const uint8_t cmd_dh_set_fid = CMD_RESPONSE_SET_DH;
johnb 51:a7d0d2ef9261 155
johnb 51:a7d0d2ef9261 156 static const uint8_t cmd_dl[] = { 'D', 'L' };
johnb 51:a7d0d2ef9261 157 static const uint8_t cmd_dl_get_fid = CMD_RESPONSE_GET_DL;
johnb 51:a7d0d2ef9261 158 static const uint8_t cmd_dl_set[] = { 'D', 'L', 0, 0, 0, 0 };
johnb 51:a7d0d2ef9261 159 static const uint8_t cmd_dl_set_fid = CMD_RESPONSE_SET_DL;
johnb 51:a7d0d2ef9261 160
johnb 51:a7d0d2ef9261 161 static const uint8_t cmd_wr[] = { 'W', 'R' };
johnb 51:a7d0d2ef9261 162 static const uint8_t cmd_wr_set_fid = CMD_RESPONSE_SET_WR;
johnb 51:a7d0d2ef9261 163
johnb 51:a7d0d2ef9261 164 static const uint8_t cmd_ac[] = { 'A', 'C' };
johnb 51:a7d0d2ef9261 165 static const uint8_t cmd_ac_set_fid = CMD_RESPONSE_SET_AC;
johnb 51:a7d0d2ef9261 166
johnb 51:a7d0d2ef9261 167 static const uint8_t cmd_fr[] = { 'F', 'R' };
johnb 51:a7d0d2ef9261 168 static const uint8_t cmd_fr_set_fid = CMD_RESPONSE_SET_FR;
johnb 51:a7d0d2ef9261 169
johnb 51:a7d0d2ef9261 170 static const uint8_t cmd_is[] = { 'I', 'S' };
johnb 51:a7d0d2ef9261 171 static const uint8_t cmd_is_set_fid = CMD_RESPONSE_SET_IS;
johnb 51:a7d0d2ef9261 172
johnb 55:610aa4a2ed3b 173 static const uint8_t cmd_re[] = { 'R', 'E' };
johnb 55:610aa4a2ed3b 174 static const uint8_t cmd_re_set_fid = CMD_RESPONSE_SET_RE;
johnb 55:610aa4a2ed3b 175
johnb 55:610aa4a2ed3b 176
johnb 50:f76b7e7959a2 177 static const uint8_t cmd_d[ XBEE_API_DIO_CHANNEL_COUNT ][2] = {{ 'D', '0' },
johnb 50:f76b7e7959a2 178 { 'D', '1' },
johnb 50:f76b7e7959a2 179 { 'D', '2' },
johnb 50:f76b7e7959a2 180 { 'D', '3' },
johnb 50:f76b7e7959a2 181 { 'D', '4' },
johnb 50:f76b7e7959a2 182 { 'D', '5' },
johnb 50:f76b7e7959a2 183 { 'D', '6' },
johnb 50:f76b7e7959a2 184 { 'D', '7' }};
johnb 50:f76b7e7959a2 185 static const uint8_t cmd_d_get_fid[ XBEE_API_DIO_CHANNEL_COUNT ] = { CMD_RESPONSE_GET_D0,
johnb 50:f76b7e7959a2 186 CMD_RESPONSE_GET_D1,
johnb 50:f76b7e7959a2 187 CMD_RESPONSE_GET_D2,
johnb 50:f76b7e7959a2 188 CMD_RESPONSE_GET_D3,
johnb 50:f76b7e7959a2 189 CMD_RESPONSE_GET_D4,
johnb 50:f76b7e7959a2 190 CMD_RESPONSE_GET_D5,
johnb 50:f76b7e7959a2 191 CMD_RESPONSE_GET_D6,
johnb 50:f76b7e7959a2 192 CMD_RESPONSE_GET_D7 };
johnb 31:c144106e55b5 193
johnb 53:7b65422d7a32 194 #define XBEE_CMD_POSN_FRAME_ID (XBEE_CMD_POSN_ID_SPECIFIC_DATA)
johnb 53:7b65422d7a32 195 #define XBEE_CMD_POSN_STATUS (7U)
johnb 8:1b48b619d7f6 196 #define XBEE_CMD_POSN_PARAM_START (8U)
johnb 8:1b48b619d7f6 197
johnb 13:302e7c1ea0b3 198 #define XBEE_CMD_RESPONS_HAS_DATA( _p_len ) ((_p_len > ( XBEE_CMD_POSN_PARAM_START + 1 ))
johnb 13:302e7c1ea0b3 199
johnb 50:f76b7e7959a2 200 /** Template class to create an XBeeApiFrame which can be used to change
johnb 50:f76b7e7959a2 201 the value of one of the XBee parameters. This class is used by the
johnb 50:f76b7e7959a2 202 setXXX methods in XBeeApiCmdAt */
johnb 50:f76b7e7959a2 203 template< typename T >
johnb 50:f76b7e7959a2 204 class XBeeApiCmdAtSet : public XBeeApiFrame {
johnb 50:f76b7e7959a2 205 uint8_t m_buffer[ XBEE_API_CMD_SET_HEADER_LEN + sizeof( T ) ];
johnb 50:f76b7e7959a2 206 public:
johnb 50:f76b7e7959a2 207 /** Constructor
johnb 50:f76b7e7959a2 208
johnb 50:f76b7e7959a2 209 \param p_data Pointer to a buffer of length 2 bytes identifying
johnb 50:f76b7e7959a2 210 the command, e.g. 'V', 'R' would set up a version
johnb 50:f76b7e7959a2 211 request
johnb 50:f76b7e7959a2 212 \param p_val New value for the parameter
johnb 50:f76b7e7959a2 213 */
johnb 50:f76b7e7959a2 214 XBeeApiCmdAtSet( const uint8_t p_frameId,
johnb 50:f76b7e7959a2 215 const uint8_t* const p_data,
johnb 50:f76b7e7959a2 216 const T p_val );
johnb 50:f76b7e7959a2 217 /** Destructor */
johnb 50:f76b7e7959a2 218 virtual ~XBeeApiCmdAtSet();
johnb 50:f76b7e7959a2 219 };
johnb 50:f76b7e7959a2 220
johnb 50:f76b7e7959a2 221 class XBeeApiCmdAtReq : public XBeeApiFrame {
johnb 50:f76b7e7959a2 222 uint8_t m_buffer[ XBEE_API_CMD_REQ_HEADER_LEN ];
johnb 50:f76b7e7959a2 223 public:
johnb 50:f76b7e7959a2 224 /** Constructor
johnb 50:f76b7e7959a2 225
johnb 50:f76b7e7959a2 226 \param p_data Pointer to a buffer of length 2 bytes identifying
johnb 50:f76b7e7959a2 227 the command, e.g. 'V', 'R' would set up a version
johnb 50:f76b7e7959a2 228 request
johnb 50:f76b7e7959a2 229 \param p_val New value for the parameter
johnb 50:f76b7e7959a2 230 */
johnb 50:f76b7e7959a2 231 XBeeApiCmdAtReq( const uint8_t p_frameId,
johnb 50:f76b7e7959a2 232 const uint8_t* const p_data );
johnb 50:f76b7e7959a2 233 /** Destructor */
johnb 50:f76b7e7959a2 234 virtual ~XBeeApiCmdAtReq();
johnb 50:f76b7e7959a2 235 };
johnb 50:f76b7e7959a2 236
johnb 55:610aa4a2ed3b 237 void XBeeApiCmdAt::resetCachedData( void )
johnb 8:1b48b619d7f6 238 {
johnb 52:0950b05d5270 239 uint8_t i;
johnb 55:610aa4a2ed3b 240
johnb 55:610aa4a2ed3b 241 m_have_hwVer = false;
johnb 55:610aa4a2ed3b 242 m_have_fwVer = false;
johnb 55:610aa4a2ed3b 243 m_have_chan = false;
johnb 55:610aa4a2ed3b 244 m_have_PANId = false;
johnb 55:610aa4a2ed3b 245 m_have_EDA = false;
johnb 55:610aa4a2ed3b 246 m_have_CE = false;
johnb 55:610aa4a2ed3b 247 m_have_sourceAddress = false;
johnb 55:610aa4a2ed3b 248 m_have_retries = false;
johnb 55:610aa4a2ed3b 249 m_have_randomDelaySlots = false;
johnb 55:610aa4a2ed3b 250 m_have_macMode = false;
johnb 55:610aa4a2ed3b 251 m_have_dioChangeDetectMask = false;
johnb 55:610aa4a2ed3b 252 m_have_dioLevels = false;
johnb 55:610aa4a2ed3b 253 m_have_sampleRate = false;
johnb 55:610aa4a2ed3b 254 m_have_destHigh = false;
johnb 55:610aa4a2ed3b 255 m_have_destLow = false;
johnb 55:610aa4a2ed3b 256 m_writeCount = 0;
johnb 55:610aa4a2ed3b 257 m_applyCount = 0;
johnb 55:610aa4a2ed3b 258 m_resetCount = 0;
johnb 55:610aa4a2ed3b 259 m_sampleCount = 0;
johnb 55:610aa4a2ed3b 260 m_restoreCount = 0;
johnb 55:610aa4a2ed3b 261
johnb 55:610aa4a2ed3b 262 /* We DO NOT reset m_have_snLow and m_have_snHigh here as
johnb 55:610aa4a2ed3b 263 these are reset only in the custructor - we assume that if
johnb 55:610aa4a2ed3b 264 we've received them then they can't change
johnb 55:610aa4a2ed3b 265 TODO: Could be wrong - what about if we're re-using remote XBee? */
johnb 55:610aa4a2ed3b 266
johnb 52:0950b05d5270 267 for( i = 0;
johnb 51:a7d0d2ef9261 268 i < XBEE_API_DIO_CHANNEL_COUNT;
johnb 51:a7d0d2ef9261 269 i++ )
johnb 51:a7d0d2ef9261 270 {
johnb 51:a7d0d2ef9261 271 m_have_d[ i ] = false;
johnb 52:0950b05d5270 272 m_ioDigitalUpdatedTime[ i ] = 0;
johnb 52:0950b05d5270 273 }
johnb 52:0950b05d5270 274 for( i = 0;
johnb 52:0950b05d5270 275 i < XBEE_API_ADC_CHANNEL_COUNT;
johnb 52:0950b05d5270 276 i++ )
johnb 52:0950b05d5270 277 {
johnb 52:0950b05d5270 278 m_ioAnalogueUpdatedTime[ i ] = 0;
johnb 51:a7d0d2ef9261 279 }
johnb 8:1b48b619d7f6 280 }
johnb 8:1b48b619d7f6 281
johnb 55:610aa4a2ed3b 282
johnb 55:610aa4a2ed3b 283 XBeeApiCmdAt::XBeeApiCmdAt( XBeeDevice* const p_device ) : XBeeApiFrameDecoder( p_device ) ,
johnb 55:610aa4a2ed3b 284 m_have_snLow ( false ),
johnb 55:610aa4a2ed3b 285 m_have_snHigh ( false )
johnb 55:610aa4a2ed3b 286 {
johnb 55:610aa4a2ed3b 287 resetCachedData();
johnb 55:610aa4a2ed3b 288 }
johnb 55:610aa4a2ed3b 289
johnb 51:a7d0d2ef9261 290 #define RESPONSE_OK( _data ) (_data[ statusPosn ] == 0)
johnb 51:a7d0d2ef9261 291
johnb 51:a7d0d2ef9261 292 #define PROCESS_SET_RESPONSE( _type, _var ) \
johnb 51:a7d0d2ef9261 293 case CMD_RESPONSE_SET_ ## _type: \
johnb 51:a7d0d2ef9261 294 if( RESPONSE_OK( p_data )) \
johnb 51:a7d0d2ef9261 295 { \
johnb 51:a7d0d2ef9261 296 m_ ## _var = m_ ## _var ## Pend; \
johnb 51:a7d0d2ef9261 297 m_have_ ## _var = true; \
johnb 51:a7d0d2ef9261 298 } \
johnb 51:a7d0d2ef9261 299 else \
johnb 51:a7d0d2ef9261 300 { \
johnb 51:a7d0d2ef9261 301 /* TODO */ \
johnb 51:a7d0d2ef9261 302 } \
johnb 51:a7d0d2ef9261 303 ret_val = true; \
johnb 51:a7d0d2ef9261 304 break;
johnb 51:a7d0d2ef9261 305
johnb 51:a7d0d2ef9261 306 #define PROCESS_SET_GET_RESPONSE_GENERIC( _type, _var, _src, _t, _sfx ) \
johnb 32:af4e495afd62 307 case CMD_RESPONSE_SET_ ## _type: \
johnb 32:af4e495afd62 308 case CMD_RESPONSE_GET_ ## _type: \
johnb 51:a7d0d2ef9261 309 if( RESPONSE_OK( p_data )) \
johnb 32:af4e495afd62 310 { \
johnb 50:f76b7e7959a2 311 if( CMD_RESPONSE_GET_ ## _type == p_data[ XBEE_CMD_POSN_FRAME_ID ] ) \
johnb 32:af4e495afd62 312 { \
johnb 51:a7d0d2ef9261 313 m_ ##_var ##_sfx = (_t) (_src); \
johnb 32:af4e495afd62 314 } \
johnb 32:af4e495afd62 315 else \
johnb 32:af4e495afd62 316 { \
johnb 51:a7d0d2ef9261 317 m_ ##_var ##_sfx = m_ ## _var ## Pend ## _sfx; \
johnb 32:af4e495afd62 318 } \
johnb 51:a7d0d2ef9261 319 m_have_ ##_var ##_sfx = true; \
johnb 32:af4e495afd62 320 } \
johnb 32:af4e495afd62 321 else \
johnb 32:af4e495afd62 322 { \
johnb 32:af4e495afd62 323 /* TODO */ \
johnb 32:af4e495afd62 324 } \
johnb 32:af4e495afd62 325 ret_val = true; \
johnb 32:af4e495afd62 326 break;
johnb 32:af4e495afd62 327
johnb 32:af4e495afd62 328 #define PROCESS_GET_RESPONSE_GENERIC( _type, _var, _src ) \
johnb 32:af4e495afd62 329 case CMD_RESPONSE_GET_ ## _type: \
johnb 51:a7d0d2ef9261 330 if( RESPONSE_OK( p_data )) \
johnb 32:af4e495afd62 331 { \
johnb 32:af4e495afd62 332 m_ ##_var = _src; \
johnb 32:af4e495afd62 333 m_have_ ## _var = true; \
johnb 32:af4e495afd62 334 } \
johnb 32:af4e495afd62 335 else \
johnb 32:af4e495afd62 336 { \
johnb 32:af4e495afd62 337 /* TODO */ \
johnb 32:af4e495afd62 338 } \
johnb 32:af4e495afd62 339 ret_val = true; \
johnb 32:af4e495afd62 340 break;
johnb 32:af4e495afd62 341
johnb 51:a7d0d2ef9261 342 #define PROCESS_SET_GET_RESPONSE_8BIT_WITHCAST( _type, _var, _t, _sfx ) PROCESS_SET_GET_RESPONSE_GENERIC( _type, _var, p_data[ dataPosn ], _t, _sfx )
johnb 51:a7d0d2ef9261 343 #define PROCESS_SET_GET_RESPONSE_8BIT( _type, _var ) PROCESS_SET_GET_RESPONSE_GENERIC( _type, _var, p_data[ dataPosn ], uint8_t, )
johnb 51:a7d0d2ef9261 344 #define PROCESS_SET_GET_RESPONSE_16BIT( _type, _var ) PROCESS_SET_GET_RESPONSE_GENERIC( _type, _var, ((uint16_t)p_data[ dataPosn ] << 8) | p_data[ dataPosn + 1 ], uint16_t, )
johnb 51:a7d0d2ef9261 345 #define PROCESS_SET_GET_RESPONSE_32BIT( _type, _var ) PROCESS_SET_GET_RESPONSE_GENERIC( _type, _var, ((uint32_t)p_data[ dataPosn ] << 24) |\
johnb 51:a7d0d2ef9261 346 ((uint32_t)p_data[ dataPosn + 1 ] << 16) |\
johnb 51:a7d0d2ef9261 347 ((uint32_t)p_data[ dataPosn + 2 ] << 8) |\
johnb 51:a7d0d2ef9261 348 ((uint32_t)p_data[ dataPosn + 3 ]), uint32_t, )
johnb 50:f76b7e7959a2 349
johnb 50:f76b7e7959a2 350 #define PROCESS_GET_RESPONSE_16BIT( _type, _var ) PROCESS_GET_RESPONSE_GENERIC( _type, _var, ((uint16_t)p_data[ dataPosn ] << 8) | p_data[ dataPosn + 1 ] )
johnb 50:f76b7e7959a2 351 #define PROCESS_GET_RESPONSE_32BIT( _type, _var ) PROCESS_GET_RESPONSE_GENERIC( _type, _var, ((uint32_t)p_data[ dataPosn ] << 24) |\
johnb 50:f76b7e7959a2 352 ((uint32_t)p_data[ dataPosn + 1 ] << 16) |\
johnb 50:f76b7e7959a2 353 ((uint32_t)p_data[ dataPosn + 2 ] << 8) |\
johnb 50:f76b7e7959a2 354 ((uint32_t)p_data[ dataPosn + 3 ]))
johnb 50:f76b7e7959a2 355
johnb 50:f76b7e7959a2 356 size_t XBeeApiCmdAt::getResponseStatusPos( void ) const
johnb 50:f76b7e7959a2 357 {
johnb 50:f76b7e7959a2 358 return XBEE_CMD_POSN_STATUS;
johnb 50:f76b7e7959a2 359 }
johnb 32:af4e495afd62 360
johnb 50:f76b7e7959a2 361 bool XBeeApiCmdAt::processResponseFrame( const uint8_t* const p_data, size_t p_len )
johnb 50:f76b7e7959a2 362 {
johnb 50:f76b7e7959a2 363 bool ret_val = false;
johnb 50:f76b7e7959a2 364 size_t statusPosn = getResponseStatusPos();
johnb 50:f76b7e7959a2 365 size_t dataPosn = statusPosn + 1;
johnb 50:f76b7e7959a2 366
johnb 50:f76b7e7959a2 367 switch( p_data[ XBEE_CMD_POSN_FRAME_ID ] )
johnb 50:f76b7e7959a2 368 {
johnb 51:a7d0d2ef9261 369 case CMD_RESPONSE_SET_WR:
johnb 51:a7d0d2ef9261 370 if( RESPONSE_OK( p_data ))
johnb 51:a7d0d2ef9261 371 {
johnb 51:a7d0d2ef9261 372 m_writeCount++;
johnb 51:a7d0d2ef9261 373 }
johnb 51:a7d0d2ef9261 374 ret_val = true;
johnb 51:a7d0d2ef9261 375 break;
johnb 51:a7d0d2ef9261 376 case CMD_RESPONSE_SET_AC:
johnb 51:a7d0d2ef9261 377 if( RESPONSE_OK( p_data ))
johnb 51:a7d0d2ef9261 378 {
johnb 51:a7d0d2ef9261 379 m_applyCount++;
johnb 51:a7d0d2ef9261 380 }
johnb 51:a7d0d2ef9261 381 ret_val = true;
johnb 51:a7d0d2ef9261 382 break;
johnb 51:a7d0d2ef9261 383 case CMD_RESPONSE_SET_FR:
johnb 51:a7d0d2ef9261 384 if( RESPONSE_OK( p_data ))
johnb 51:a7d0d2ef9261 385 {
johnb 51:a7d0d2ef9261 386 m_resetCount++;
johnb 51:a7d0d2ef9261 387 }
johnb 51:a7d0d2ef9261 388 ret_val = true;
johnb 51:a7d0d2ef9261 389 break;
johnb 51:a7d0d2ef9261 390 case CMD_RESPONSE_SET_IS:
johnb 51:a7d0d2ef9261 391 if( RESPONSE_OK( p_data ))
johnb 51:a7d0d2ef9261 392 {
johnb 51:a7d0d2ef9261 393 m_sampleCount++;
johnb 51:a7d0d2ef9261 394 }
johnb 51:a7d0d2ef9261 395 ret_val = true;
johnb 51:a7d0d2ef9261 396 break;
johnb 55:610aa4a2ed3b 397 case CMD_RESPONSE_SET_RE:
johnb 55:610aa4a2ed3b 398 if( RESPONSE_OK( p_data ))
johnb 55:610aa4a2ed3b 399 {
johnb 55:610aa4a2ed3b 400 /* If all settings have been reset, clear out any cached
johnb 55:610aa4a2ed3b 401 data members in this class */
johnb 55:610aa4a2ed3b 402 resetCachedData();
johnb 55:610aa4a2ed3b 403 m_restoreCount++;
johnb 55:610aa4a2ed3b 404 }
johnb 55:610aa4a2ed3b 405 ret_val = true;
johnb 55:610aa4a2ed3b 406 break;
johnb 50:f76b7e7959a2 407 PROCESS_GET_RESPONSE_16BIT( HV, hwVer )
johnb 50:f76b7e7959a2 408 PROCESS_GET_RESPONSE_16BIT( VR, fwVer )
johnb 50:f76b7e7959a2 409
johnb 50:f76b7e7959a2 410 PROCESS_SET_GET_RESPONSE_8BIT( CH, chan )
johnb 50:f76b7e7959a2 411 PROCESS_SET_GET_RESPONSE_8BIT( CE, CE )
johnb 50:f76b7e7959a2 412 PROCESS_SET_GET_RESPONSE_16BIT( PID, PANId )
johnb 50:f76b7e7959a2 413 PROCESS_SET_GET_RESPONSE_8BIT( EDA, EDA )
johnb 50:f76b7e7959a2 414 PROCESS_SET_GET_RESPONSE_8BIT( RR, retries )
johnb 50:f76b7e7959a2 415 PROCESS_SET_GET_RESPONSE_16BIT( MY, sourceAddress )
johnb 50:f76b7e7959a2 416 PROCESS_GET_RESPONSE_32BIT( SH, snHigh )
johnb 50:f76b7e7959a2 417 PROCESS_GET_RESPONSE_32BIT( SL, snLow )
johnb 51:a7d0d2ef9261 418 PROCESS_SET_GET_RESPONSE_32BIT( DH, destHigh )
johnb 51:a7d0d2ef9261 419 PROCESS_SET_GET_RESPONSE_32BIT( DL, destLow )
johnb 50:f76b7e7959a2 420 PROCESS_SET_GET_RESPONSE_8BIT( RN, randomDelaySlots )
johnb 51:a7d0d2ef9261 421 PROCESS_SET_GET_RESPONSE_8BIT_WITHCAST( MM, macMode, XBeeApiMACMode_e, )
johnb 50:f76b7e7959a2 422 /* TODO: Add D0, D1, D2 response handling */
johnb 51:a7d0d2ef9261 423 PROCESS_SET_GET_RESPONSE_8BIT_WITHCAST( D0, d, XBeeApiDioConfig_e, [0] )
johnb 51:a7d0d2ef9261 424 PROCESS_SET_GET_RESPONSE_8BIT( IC, dioChangeDetectMask )
johnb 51:a7d0d2ef9261 425 PROCESS_SET_RESPONSE( IO, dioLevels )
johnb 51:a7d0d2ef9261 426 PROCESS_SET_GET_RESPONSE_16BIT( IR, sampleRate )
johnb 50:f76b7e7959a2 427 }
johnb 32:af4e495afd62 428
johnb 50:f76b7e7959a2 429 return ret_val;
johnb 50:f76b7e7959a2 430 }
johnb 32:af4e495afd62 431
johnb 52:0950b05d5270 432 #define DIO_CHANNEL_MASK (0x01FFU)
johnb 52:0950b05d5270 433 #define ADC_CHANNEL_MASK (0x7E00U)
johnb 52:0950b05d5270 434
johnb 52:0950b05d5270 435 bool XBeeApiCmdAt::processIOFrame( const uint8_t* const p_data, size_t p_len, const size_t p_start )
johnb 52:0950b05d5270 436 {
johnb 52:0950b05d5270 437 #if 0
johnb 52:0950b05d5270 438 /* This is the number of sample sets that are contained in the packet, set using the IT AT command */
johnb 52:0950b05d5270 439 uint8_t sampleCount = p_data[ p_start ];
johnb 52:0950b05d5270 440 #endif
johnb 52:0950b05d5270 441
johnb 53:7b65422d7a32 442 const uint16_t channelMask = (((uint16_t)p_data[ p_start + 1 ]) << 8) |
johnb 53:7b65422d7a32 443 ((uint16_t)p_data[ p_start + 2 ]);
johnb 52:0950b05d5270 444 const uint8_t* dataPtr = &( p_data[ p_start + 3 ] );
johnb 52:0950b05d5270 445 const uint16_t dioMask = channelMask & DIO_CHANNEL_MASK;
johnb 52:0950b05d5270 446 uint16_t adcMask = (channelMask & ADC_CHANNEL_MASK) >> 9U;
johnb 52:0950b05d5270 447 uint8_t adc = 0;
johnb 52:0950b05d5270 448
johnb 52:0950b05d5270 449 time_t seconds = time( NULL );
johnb 52:0950b05d5270 450
johnb 52:0950b05d5270 451 if( dioMask )
johnb 52:0950b05d5270 452 {
johnb 52:0950b05d5270 453 uint16_t dioData = (((uint16_t)dataPtr[ 0 ]) << 8U) |
johnb 52:0950b05d5270 454 (uint16_t)dataPtr[ 1 ];
johnb 52:0950b05d5270 455 dataPtr += 2;
johnb 52:0950b05d5270 456
johnb 52:0950b05d5270 457 for( unsigned i = 0;
johnb 52:0950b05d5270 458 i < XBEE_API_DIO_CHANNEL_COUNT;
johnb 52:0950b05d5270 459 i++ )
johnb 52:0950b05d5270 460 {
johnb 52:0950b05d5270 461 if(( dioMask >> i ) & 0x01 )
johnb 52:0950b05d5270 462 {
johnb 52:0950b05d5270 463 m_ioDigitalState[i] = ( dioData >> i ) & 0x01;
johnb 52:0950b05d5270 464 m_ioDigitalUpdatedTime[i] = seconds;
johnb 52:0950b05d5270 465 }
johnb 52:0950b05d5270 466 }
johnb 52:0950b05d5270 467 }
johnb 52:0950b05d5270 468
johnb 52:0950b05d5270 469 while( adcMask )
johnb 52:0950b05d5270 470 {
johnb 52:0950b05d5270 471 if( adcMask & 0x01 )
johnb 52:0950b05d5270 472 {
johnb 52:0950b05d5270 473 uint16_t adcData = (((uint16_t)dataPtr[ 0 ]) << 8U) |
johnb 52:0950b05d5270 474 (uint16_t)dataPtr[ 1 ];
johnb 52:0950b05d5270 475 dataPtr += 2;
johnb 52:0950b05d5270 476
johnb 52:0950b05d5270 477 m_ioAnalogueVal[adc] = adcData;
johnb 52:0950b05d5270 478 m_ioAnalogueUpdatedTime[adc] = seconds;
johnb 52:0950b05d5270 479 }
johnb 52:0950b05d5270 480 adcMask = adcMask >> 1U;
johnb 52:0950b05d5270 481 adc++;
johnb 52:0950b05d5270 482 }
johnb 52:0950b05d5270 483
johnb 52:0950b05d5270 484 return true;
johnb 52:0950b05d5270 485 }
johnb 52:0950b05d5270 486
johnb 52:0950b05d5270 487 #define XBEE_IO_PACKET_ADDRESS (XBEE_CMD_POSN_ID_SPECIFIC_DATA)
johnb 52:0950b05d5270 488 #define XBEE_IO_PACKET_64BIT_DATA_START (XBEE_IO_PACKET_ADDRESS + sizeof( uint64_t) + 1U + 1U)
johnb 52:0950b05d5270 489 #define XBEE_IO_PACKET_16BIT_DATA_START (XBEE_IO_PACKET_ADDRESS + sizeof( uint16_t) + 1U + 1U)
johnb 52:0950b05d5270 490
johnb 8:1b48b619d7f6 491 bool XBeeApiCmdAt::decodeCallback( const uint8_t* const p_data, size_t p_len )
johnb 8:1b48b619d7f6 492 {
johnb 8:1b48b619d7f6 493 bool ret_val = false;
johnb 13:302e7c1ea0b3 494
johnb 50:f76b7e7959a2 495 if( XBEE_CMD_AT_RESPONSE == p_data[ XBEE_CMD_POSN_API_ID ] )
johnb 50:f76b7e7959a2 496 {
johnb 50:f76b7e7959a2 497 ret_val = processResponseFrame( p_data, p_len );
johnb 52:0950b05d5270 498 }
johnb 52:0950b05d5270 499 else if( XBEE_CMD_RX_16B_IO == p_data[ XBEE_CMD_POSN_API_ID ] )
johnb 52:0950b05d5270 500 {
johnb 52:0950b05d5270 501 uint16_t src16BitAddr = (((uint16_t)p_data[ XBEE_IO_PACKET_ADDRESS ]) << 8U) |
johnb 52:0950b05d5270 502 p_data[ XBEE_IO_PACKET_ADDRESS + 1 ];
johnb 52:0950b05d5270 503 if( m_have_sourceAddress &&
johnb 52:0950b05d5270 504 ( src16BitAddr == m_sourceAddress ))
johnb 52:0950b05d5270 505 {
johnb 52:0950b05d5270 506 ret_val = processIOFrame( p_data, p_len, XBEE_IO_PACKET_16BIT_DATA_START );
johnb 52:0950b05d5270 507 }
johnb 8:1b48b619d7f6 508 }
johnb 52:0950b05d5270 509 else if( XBEE_CMD_RX_64B_IO == p_data[ XBEE_CMD_POSN_API_ID ] )
johnb 52:0950b05d5270 510 {
johnb 52:0950b05d5270 511 uint32_t srcAddrHigh = (((uint64_t)p_data[ XBEE_IO_PACKET_ADDRESS ]) << 24U) |
johnb 52:0950b05d5270 512 (((uint64_t)p_data[ XBEE_IO_PACKET_ADDRESS + 1 ]) << 16U) |
johnb 52:0950b05d5270 513 (((uint64_t)p_data[ XBEE_IO_PACKET_ADDRESS + 2 ]) << 8U) |
johnb 52:0950b05d5270 514 (((uint64_t)p_data[ XBEE_IO_PACKET_ADDRESS + 3 ]));
johnb 52:0950b05d5270 515 uint32_t srcAddrLow = (((uint64_t)p_data[ XBEE_IO_PACKET_ADDRESS + 4 ]) << 24U) |
johnb 52:0950b05d5270 516 (((uint64_t)p_data[ XBEE_IO_PACKET_ADDRESS + 5 ]) << 16U) |
johnb 52:0950b05d5270 517 (((uint64_t)p_data[ XBEE_IO_PACKET_ADDRESS + 6 ]) << 8U) |
johnb 52:0950b05d5270 518 ((uint64_t)p_data[ XBEE_IO_PACKET_ADDRESS + 7 ]);
johnb 52:0950b05d5270 519 if( m_have_snLow &&
johnb 52:0950b05d5270 520 m_have_snHigh &&
johnb 52:0950b05d5270 521 ( srcAddrHigh == m_snHigh ) &&
johnb 52:0950b05d5270 522 ( srcAddrLow == m_snLow ))
johnb 52:0950b05d5270 523 {
johnb 52:0950b05d5270 524 ret_val = processIOFrame( p_data, p_len, XBEE_IO_PACKET_64BIT_DATA_START );
johnb 52:0950b05d5270 525 }
johnb 52:0950b05d5270 526 }
johnb 52:0950b05d5270 527 else
johnb 52:0950b05d5270 528 {
johnb 52:0950b05d5270 529 }
johnb 52:0950b05d5270 530
johnb 8:1b48b619d7f6 531 return ret_val;
johnb 8:1b48b619d7f6 532 }
johnb 8:1b48b619d7f6 533
johnb 8:1b48b619d7f6 534 bool XBeeApiCmdAt::setChannel( uint8_t const p_chan )
johnb 8:1b48b619d7f6 535 {
johnb 29:c6d037cceb02 536 bool ret_val = false;
johnb 29:c6d037cceb02 537
johnb 29:c6d037cceb02 538 if((( m_device->getXBeeModel() == XBeeDevice::XBEEDEVICE_S1 ) &&
johnb 29:c6d037cceb02 539 ( p_chan >= XBEE_CHAN_MIN ) &&
johnb 29:c6d037cceb02 540 ( p_chan <= XBEE_CHAN_MAX )) ||
johnb 29:c6d037cceb02 541 (( m_device->getXBeeModel() == XBeeDevice::XBEEDEVICE_S1_PRO ) &&
johnb 29:c6d037cceb02 542 ( p_chan >= XBEE_PRO_CHAN_MIN ) &&
johnb 29:c6d037cceb02 543 ( p_chan <= XBEE_PRO_CHAN_MAX )))
johnb 29:c6d037cceb02 544 {
johnb 29:c6d037cceb02 545 m_chanPend = p_chan;
johnb 50:f76b7e7959a2 546 SendCmd_uint8_t( cmd_ch_set_fid, cmd_ch_set, p_chan );
johnb 29:c6d037cceb02 547 ret_val = true;
johnb 29:c6d037cceb02 548 }
johnb 29:c6d037cceb02 549 return ret_val;
johnb 8:1b48b619d7f6 550 }
johnb 8:1b48b619d7f6 551
johnb 50:f76b7e7959a2 552 void XBeeApiCmdAt::SendReq( const uint8_t p_frameId,
johnb 50:f76b7e7959a2 553 const uint8_t* p_data )
johnb 50:f76b7e7959a2 554 {
johnb 50:f76b7e7959a2 555 XBeeApiCmdAtReq req( p_frameId, p_data );
johnb 50:f76b7e7959a2 556 m_device->SendFrame( &req );
johnb 50:f76b7e7959a2 557 }
johnb 50:f76b7e7959a2 558
johnb 50:f76b7e7959a2 559
johnb 31:c144106e55b5 560 #define MAKE_REQUEST( _name, _mnemonic, _cmd ) \
johnb 31:c144106e55b5 561 bool XBeeApiCmdAt::request ## _name( void ) \
johnb 31:c144106e55b5 562 {\
johnb 50:f76b7e7959a2 563 m_have_ ## _mnemonic = false; \
johnb 50:f76b7e7959a2 564 SendReq( _cmd ## _get_fid, _cmd ); \
johnb 31:c144106e55b5 565 return true;\
johnb 8:1b48b619d7f6 566 }
johnb 8:1b48b619d7f6 567
johnb 51:a7d0d2ef9261 568 MAKE_REQUEST( HardwareVersion, hwVer, cmd_hv )
johnb 51:a7d0d2ef9261 569 MAKE_REQUEST( FirmwareVersion, fwVer, cmd_vr )
johnb 51:a7d0d2ef9261 570 MAKE_REQUEST( Channel, chan, cmd_ch )
johnb 51:a7d0d2ef9261 571 MAKE_REQUEST( PanId, PANId, cmd_pid )
johnb 51:a7d0d2ef9261 572 MAKE_REQUEST( CoordinatorEnabled, CE, cmd_ce )
johnb 51:a7d0d2ef9261 573 MAKE_REQUEST( EndDeviceAssociationEnabled, EDA, cmd_eda )
johnb 51:a7d0d2ef9261 574 MAKE_REQUEST( SourceAddress, sourceAddress, cmd_my )
johnb 51:a7d0d2ef9261 575 MAKE_REQUEST( Retries, retries, cmd_rr )
johnb 51:a7d0d2ef9261 576 MAKE_REQUEST( RandomDelaySlots, randomDelaySlots, cmd_rn )
johnb 51:a7d0d2ef9261 577 MAKE_REQUEST( MacMode, macMode, cmd_mm )
johnb 51:a7d0d2ef9261 578 MAKE_REQUEST( SerialNumberHigh, snHigh, cmd_sh )
johnb 51:a7d0d2ef9261 579 MAKE_REQUEST( SerialNumberLow, snLow, cmd_sl )
johnb 51:a7d0d2ef9261 580 MAKE_REQUEST( DioChangeDetectMask, dioChangeDetectMask, cmd_ic )
johnb 51:a7d0d2ef9261 581 MAKE_REQUEST( SampleRate, sampleRate, cmd_ir )
johnb 51:a7d0d2ef9261 582 MAKE_REQUEST( DestinationAddressHigh, destHigh, cmd_dh )
johnb 51:a7d0d2ef9261 583 MAKE_REQUEST( DestinationAddressLow, destLow, cmd_dl )
johnb 51:a7d0d2ef9261 584
johnb 51:a7d0d2ef9261 585 bool XBeeApiCmdAt::requestWriteSettings( void )
johnb 51:a7d0d2ef9261 586 {
johnb 51:a7d0d2ef9261 587 SendReq( cmd_wr_set_fid, cmd_wr );
johnb 51:a7d0d2ef9261 588 return true;
johnb 51:a7d0d2ef9261 589 }
johnb 51:a7d0d2ef9261 590
johnb 51:a7d0d2ef9261 591 bool XBeeApiCmdAt::requestApplyChanges( void )
johnb 51:a7d0d2ef9261 592 {
johnb 51:a7d0d2ef9261 593 SendReq( cmd_ac_set_fid, cmd_ac );
johnb 51:a7d0d2ef9261 594 return true;
johnb 51:a7d0d2ef9261 595 }
johnb 51:a7d0d2ef9261 596
johnb 51:a7d0d2ef9261 597 bool XBeeApiCmdAt::requestReset( void )
johnb 51:a7d0d2ef9261 598 {
johnb 51:a7d0d2ef9261 599 SendReq( cmd_fr_set_fid, cmd_fr );
johnb 51:a7d0d2ef9261 600 return true;
johnb 51:a7d0d2ef9261 601 }
johnb 51:a7d0d2ef9261 602
johnb 51:a7d0d2ef9261 603 bool XBeeApiCmdAt::requestForceSample( void )
johnb 51:a7d0d2ef9261 604 {
johnb 51:a7d0d2ef9261 605 SendReq( cmd_is_set_fid, cmd_is );
johnb 51:a7d0d2ef9261 606 return true;
johnb 51:a7d0d2ef9261 607 }
johnb 32:af4e495afd62 608
johnb 55:610aa4a2ed3b 609 bool XBeeApiCmdAt::requestRestoreDefaults( void )
johnb 55:610aa4a2ed3b 610 {
johnb 55:610aa4a2ed3b 611 SendReq( cmd_re_set_fid, cmd_re );
johnb 55:610aa4a2ed3b 612 return true;
johnb 55:610aa4a2ed3b 613 }
johnb 55:610aa4a2ed3b 614
johnb 32:af4e495afd62 615 bool XBeeApiCmdAt::requestSerialNumber( void )
johnb 32:af4e495afd62 616 {
johnb 50:f76b7e7959a2 617 requestSerialNumberHigh();
johnb 50:f76b7e7959a2 618 requestSerialNumberLow();
johnb 32:af4e495afd62 619 return true;
johnb 32:af4e495afd62 620 }
johnb 8:1b48b619d7f6 621
johnb 51:a7d0d2ef9261 622 bool XBeeApiCmdAt::requestDestinationAddress( void )
johnb 51:a7d0d2ef9261 623 {
johnb 51:a7d0d2ef9261 624 requestDestinationAddressHigh();
johnb 51:a7d0d2ef9261 625 requestDestinationAddressLow();
johnb 51:a7d0d2ef9261 626 return true;
johnb 51:a7d0d2ef9261 627 }
johnb 51:a7d0d2ef9261 628
johnb 50:f76b7e7959a2 629 bool XBeeApiCmdAt::requestDioConfig( const uint8_t p_chanNo )
johnb 50:f76b7e7959a2 630 {
johnb 50:f76b7e7959a2 631 bool ret_val = false;
johnb 50:f76b7e7959a2 632 if( p_chanNo < XBEE_API_DIO_CHANNEL_COUNT )
johnb 50:f76b7e7959a2 633 {
johnb 50:f76b7e7959a2 634 m_have_d[ p_chanNo ] = false;
johnb 50:f76b7e7959a2 635 SendReq( cmd_d_get_fid[ p_chanNo ], cmd_d[ p_chanNo ] );
johnb 50:f76b7e7959a2 636 ret_val = true;
johnb 50:f76b7e7959a2 637 }
johnb 50:f76b7e7959a2 638 return ret_val;
johnb 50:f76b7e7959a2 639 }
johnb 50:f76b7e7959a2 640
johnb 52:0950b05d5270 641 time_t XBeeApiCmdAt::getDigitalState( const uint8_t p_chanNo, bool& p_state )
johnb 52:0950b05d5270 642 {
johnb 52:0950b05d5270 643 time_t ret_val = 0;
johnb 52:0950b05d5270 644 if( p_chanNo < XBEE_API_DIO_CHANNEL_COUNT )
johnb 52:0950b05d5270 645 {
johnb 52:0950b05d5270 646 p_state = m_ioDigitalState[ p_chanNo ];
johnb 52:0950b05d5270 647 ret_val = m_ioDigitalUpdatedTime[ p_chanNo ];
johnb 52:0950b05d5270 648 }
johnb 52:0950b05d5270 649 return ret_val;
johnb 52:0950b05d5270 650 }
johnb 52:0950b05d5270 651
johnb 52:0950b05d5270 652 time_t XBeeApiCmdAt::getAnalogueValue( const uint8_t p_chanNo, uint16_t& p_val )
johnb 52:0950b05d5270 653 {
johnb 52:0950b05d5270 654 time_t ret_val = 0;
johnb 52:0950b05d5270 655 if( p_chanNo < XBEE_API_ADC_CHANNEL_COUNT )
johnb 52:0950b05d5270 656 {
johnb 52:0950b05d5270 657 p_val = m_ioAnalogueVal[ p_chanNo ];
johnb 52:0950b05d5270 658 ret_val = m_ioAnalogueUpdatedTime[ p_chanNo ];
johnb 52:0950b05d5270 659 }
johnb 52:0950b05d5270 660 return ret_val;
johnb 52:0950b05d5270 661 }
johnb 50:f76b7e7959a2 662
johnb 31:c144106e55b5 663 #define MAKE_GET(_name, _mnemonic, _type ) \
johnb 31:c144106e55b5 664 bool XBeeApiCmdAt::get ## _name( _type* const p_param ) \
johnb 31:c144106e55b5 665 {\
johnb 31:c144106e55b5 666 if( m_have_ ## _mnemonic ) {\
johnb 31:c144106e55b5 667 *p_param = m_ ## _mnemonic;\
johnb 31:c144106e55b5 668 } \
johnb 31:c144106e55b5 669 return m_have_ ## _mnemonic; \
johnb 13:302e7c1ea0b3 670 }
johnb 13:302e7c1ea0b3 671
johnb 51:a7d0d2ef9261 672 MAKE_GET( FirmwareVersion, fwVer, uint16_t )
johnb 51:a7d0d2ef9261 673 MAKE_GET( HardwareVersion, hwVer, uint16_t )
johnb 51:a7d0d2ef9261 674 MAKE_GET( Channel, chan, uint8_t )
johnb 51:a7d0d2ef9261 675 MAKE_GET( CoordinatorEnabled, CE, bool )
johnb 51:a7d0d2ef9261 676 MAKE_GET( EndDeviceAssociationEnabled, EDA, bool )
johnb 51:a7d0d2ef9261 677 MAKE_GET( PanId, PANId, panId_t )
johnb 51:a7d0d2ef9261 678 MAKE_GET( SourceAddress, sourceAddress, uint16_t )
johnb 51:a7d0d2ef9261 679 MAKE_GET( Retries, retries, uint8_t )
johnb 51:a7d0d2ef9261 680 MAKE_GET( RandomDelaySlots, randomDelaySlots, uint8_t )
johnb 51:a7d0d2ef9261 681 MAKE_GET( MacMode, macMode, XBeeApiMACMode_e )
johnb 51:a7d0d2ef9261 682 MAKE_GET( DioChangeDetectMask, dioChangeDetectMask, uint8_t )
johnb 51:a7d0d2ef9261 683 MAKE_GET( DioLevels, dioLevels, uint8_t )
johnb 51:a7d0d2ef9261 684 MAKE_GET( SampleRate, sampleRate, uint16_t )
johnb 51:a7d0d2ef9261 685 MAKE_GET( DestinationAddressHigh, destHigh, uint32_t )
johnb 51:a7d0d2ef9261 686 MAKE_GET( DestinationAddressLow, destLow, uint32_t )
johnb 32:af4e495afd62 687
johnb 32:af4e495afd62 688 bool XBeeApiCmdAt::getSerialNumber( uint64_t* const p_sn )
johnb 32:af4e495afd62 689 {
johnb 32:af4e495afd62 690 /* Need both halves to have the complete serial number */
johnb 32:af4e495afd62 691 bool have_sn = m_have_snLow && m_have_snHigh;
johnb 32:af4e495afd62 692 if( have_sn )
johnb 32:af4e495afd62 693 {
johnb 32:af4e495afd62 694 *p_sn = m_snHigh;
johnb 32:af4e495afd62 695 *p_sn = *p_sn << 32U;
johnb 32:af4e495afd62 696 *p_sn |= m_snLow;
johnb 32:af4e495afd62 697 }
johnb 32:af4e495afd62 698 return( have_sn );
johnb 32:af4e495afd62 699 }
johnb 25:db6874b7ac4b 700
johnb 51:a7d0d2ef9261 701 bool XBeeApiCmdAt::getDestinationAddress( uint64_t* const p_addr )
johnb 51:a7d0d2ef9261 702 {
johnb 51:a7d0d2ef9261 703 bool have_da = m_have_destLow && m_have_destHigh;
johnb 51:a7d0d2ef9261 704 if( have_da )
johnb 51:a7d0d2ef9261 705 {
johnb 51:a7d0d2ef9261 706 *p_addr = m_destHigh;
johnb 51:a7d0d2ef9261 707 *p_addr = *p_addr << 32U;
johnb 51:a7d0d2ef9261 708 *p_addr |= m_destLow;
johnb 51:a7d0d2ef9261 709 }
johnb 51:a7d0d2ef9261 710 return( have_da );
johnb 51:a7d0d2ef9261 711
johnb 51:a7d0d2ef9261 712 }
johnb 51:a7d0d2ef9261 713
johnb 50:f76b7e7959a2 714 bool XBeeApiCmdAt::getDioConfig( const uint8_t p_chanNo, XBeeApiDioConfig_e* const p_conf )
johnb 50:f76b7e7959a2 715 {
johnb 50:f76b7e7959a2 716 bool ret_val = false;
johnb 50:f76b7e7959a2 717 if( p_chanNo < XBEE_API_DIO_CHANNEL_COUNT )
johnb 50:f76b7e7959a2 718 {
johnb 50:f76b7e7959a2 719 if( m_have_d[ p_chanNo ] )
johnb 50:f76b7e7959a2 720 {
johnb 50:f76b7e7959a2 721 *p_conf = m_d[ p_chanNo ];
johnb 50:f76b7e7959a2 722 ret_val = true;
johnb 50:f76b7e7959a2 723 }
johnb 50:f76b7e7959a2 724 }
johnb 50:f76b7e7959a2 725 return ret_val;
johnb 50:f76b7e7959a2 726 }
johnb 50:f76b7e7959a2 727
johnb 50:f76b7e7959a2 728 #define MAKE_SET( _name, _mnemonic, _cmd, _type, _transmit_type ) \
johnb 31:c144106e55b5 729 bool XBeeApiCmdAt::set ## _name( const _type p_param ) \
johnb 31:c144106e55b5 730 {\
johnb 31:c144106e55b5 731 m_have_ ## _mnemonic = false;\
johnb 31:c144106e55b5 732 m_## _mnemonic ## Pend = p_param;\
johnb 50:f76b7e7959a2 733 SendCmd_ ## _transmit_type ( _cmd ## _fid, _cmd, p_param ); \
johnb 31:c144106e55b5 734 return true;\
johnb 13:302e7c1ea0b3 735 }
johnb 13:302e7c1ea0b3 736
johnb 51:a7d0d2ef9261 737 MAKE_SET( CoordinatorEnabled, CE, cmd_ce_set, bool, uint8_t )
johnb 51:a7d0d2ef9261 738 MAKE_SET( EndDeviceAssociationEnabled, EDA, cmd_eda_set, bool, uint8_t )
johnb 51:a7d0d2ef9261 739 MAKE_SET( PanId, PANId, cmd_pid_set, uint16_t, uint16_t )
johnb 51:a7d0d2ef9261 740 MAKE_SET( SourceAddress, sourceAddress, cmd_my_set, uint16_t, uint16_t )
johnb 51:a7d0d2ef9261 741 MAKE_SET( Retries, retries, cmd_rr_set, uint8_t, uint16_t )
johnb 51:a7d0d2ef9261 742 MAKE_SET( RandomDelaySlots, randomDelaySlots, cmd_rn_set, uint8_t, uint16_t )
johnb 51:a7d0d2ef9261 743 MAKE_SET( MacMode, macMode, cmd_mm_set, XBeeApiMACMode_e, uint8_t )
johnb 51:a7d0d2ef9261 744 MAKE_SET( DioChangeDetectMask, dioChangeDetectMask, cmd_ic_set, uint8_t, uint8_t )
johnb 51:a7d0d2ef9261 745 MAKE_SET( DioLevels, dioLevels, cmd_io_set, uint8_t, uint8_t )
johnb 51:a7d0d2ef9261 746 MAKE_SET( SampleRate, sampleRate, cmd_ir_set, uint16_t, uint16_t )
johnb 51:a7d0d2ef9261 747 MAKE_SET( DestinationAddressHigh, destHigh, cmd_dh_set, uint32_t, uint32_t )
johnb 51:a7d0d2ef9261 748 MAKE_SET( DestinationAddressLow, destLow, cmd_dl_set, uint32_t, uint32_t )
johnb 50:f76b7e7959a2 749
johnb 50:f76b7e7959a2 750
johnb 50:f76b7e7959a2 751 bool XBeeApiCmdAt::setDioConfig( const uint8_t p_chanNo, const XBeeApiDioConfig_e p_conf )
johnb 50:f76b7e7959a2 752 {
johnb 50:f76b7e7959a2 753 bool ret_val = false;
johnb 50:f76b7e7959a2 754 if( p_chanNo < XBEE_API_DIO_CHANNEL_COUNT )
johnb 50:f76b7e7959a2 755 {
johnb 51:a7d0d2ef9261 756 /* TODO: Add check that p_conf is valid for this channel */
johnb 50:f76b7e7959a2 757 m_have_d[ p_chanNo ] = false;
johnb 50:f76b7e7959a2 758 m_dPend[ p_chanNo ] = p_conf;
johnb 50:f76b7e7959a2 759 SendCmd_uint8_t( cmd_d_get_fid[ p_chanNo ], cmd_d[ p_chanNo ], p_conf );
johnb 50:f76b7e7959a2 760 }
johnb 50:f76b7e7959a2 761 return ret_val;
johnb 50:f76b7e7959a2 762 }
johnb 50:f76b7e7959a2 763
johnb 51:a7d0d2ef9261 764 bool XBeeApiCmdAt::setDestinationAddress( const uint64_t p_addr )
johnb 51:a7d0d2ef9261 765 {
johnb 51:a7d0d2ef9261 766 m_have_destHigh = m_have_destLow = false;
johnb 51:a7d0d2ef9261 767
johnb 51:a7d0d2ef9261 768 setDestinationAddressHigh( p_addr >> 32U );
johnb 51:a7d0d2ef9261 769 setDestinationAddressLow( p_addr );
johnb 51:a7d0d2ef9261 770
johnb 51:a7d0d2ef9261 771 return true;
johnb 51:a7d0d2ef9261 772 }
johnb 51:a7d0d2ef9261 773
johnb 51:a7d0d2ef9261 774
johnb 51:a7d0d2ef9261 775
johnb 50:f76b7e7959a2 776 void XBeeApiCmdAt::SendCmd_uint8_t( const uint8_t p_frameId,
johnb 50:f76b7e7959a2 777 const uint8_t* const p_data,
johnb 50:f76b7e7959a2 778 const uint8_t& p_val )
johnb 50:f76b7e7959a2 779 {
johnb 50:f76b7e7959a2 780 XBeeApiCmdAtSet<uint8_t> req( p_frameId, p_data, p_val );
johnb 50:f76b7e7959a2 781 m_device->SendFrame( &req );
johnb 50:f76b7e7959a2 782 }
johnb 50:f76b7e7959a2 783
johnb 50:f76b7e7959a2 784 void XBeeApiCmdAt::SendCmd_uint16_t( const uint8_t p_frameId,
johnb 50:f76b7e7959a2 785 const uint8_t* const p_data,
johnb 50:f76b7e7959a2 786 const uint16_t& p_val )
johnb 50:f76b7e7959a2 787 {
johnb 50:f76b7e7959a2 788 XBeeApiCmdAtSet<uint16_t> req( p_frameId, p_data, p_val );
johnb 50:f76b7e7959a2 789 m_device->SendFrame( &req );
johnb 50:f76b7e7959a2 790 }
johnb 13:302e7c1ea0b3 791
johnb 51:a7d0d2ef9261 792 void XBeeApiCmdAt::SendCmd_uint32_t( const uint8_t p_frameId,
johnb 51:a7d0d2ef9261 793 const uint8_t* const p_data,
johnb 51:a7d0d2ef9261 794 const uint32_t& p_val )
johnb 8:1b48b619d7f6 795 {
johnb 51:a7d0d2ef9261 796 XBeeApiCmdAtSet<uint32_t> req( p_frameId, p_data, p_val );
johnb 51:a7d0d2ef9261 797 m_device->SendFrame( &req );
johnb 50:f76b7e7959a2 798 }
johnb 31:c144106e55b5 799
johnb 25:db6874b7ac4b 800 template < typename T >
johnb 50:f76b7e7959a2 801 XBeeApiCmdAtSet<T>::XBeeApiCmdAtSet( const uint8_t p_frameId,
johnb 50:f76b7e7959a2 802 const uint8_t* const p_data,
johnb 50:f76b7e7959a2 803 const T p_val ) : XBeeApiFrame( )
johnb 8:1b48b619d7f6 804 {
johnb 25:db6874b7ac4b 805 size_t s;
johnb 25:db6874b7ac4b 806 uint8_t* dest;
johnb 25:db6874b7ac4b 807 const uint8_t* src = (uint8_t*)(&p_val);
johnb 25:db6874b7ac4b 808
johnb 13:302e7c1ea0b3 809 m_apiId = XBEE_CMD_AT_CMD;
johnb 25:db6874b7ac4b 810
johnb 50:f76b7e7959a2 811 m_buffer[0] = p_frameId;
johnb 50:f76b7e7959a2 812 m_buffer[1] = p_data[0];
johnb 50:f76b7e7959a2 813 m_buffer[2] = p_data[1];
johnb 25:db6874b7ac4b 814
johnb 36:cc7e8d1e35dd 815 m_dataLen = sizeof( m_buffer );
johnb 36:cc7e8d1e35dd 816
johnb 36:cc7e8d1e35dd 817 /* TODO: This copy code isn't portable - it's assuming that the data in
johnb 36:cc7e8d1e35dd 818 * p_data is little endian */
johnb 36:cc7e8d1e35dd 819
johnb 36:cc7e8d1e35dd 820 dest = &( m_buffer[ m_dataLen - 1 ] );
johnb 25:db6874b7ac4b 821
johnb 25:db6874b7ac4b 822 for( s = 0;
johnb 25:db6874b7ac4b 823 s < sizeof( T );
johnb 36:cc7e8d1e35dd 824 s++, dest--, src++ ) {
johnb 25:db6874b7ac4b 825 *dest = *src;
johnb 25:db6874b7ac4b 826 }
johnb 25:db6874b7ac4b 827
johnb 50:f76b7e7959a2 828 m_data = m_buffer;
johnb 50:f76b7e7959a2 829 }
johnb 13:302e7c1ea0b3 830
johnb 25:db6874b7ac4b 831 template < typename T >
johnb 50:f76b7e7959a2 832 XBeeApiCmdAtSet<T>::~XBeeApiCmdAtSet()
johnb 50:f76b7e7959a2 833 {
johnb 50:f76b7e7959a2 834 }
johnb 50:f76b7e7959a2 835
johnb 50:f76b7e7959a2 836 XBeeApiCmdAtReq::XBeeApiCmdAtReq( const uint8_t p_frameId,
johnb 50:f76b7e7959a2 837 const uint8_t* const p_data )
johnb 50:f76b7e7959a2 838 {
johnb 50:f76b7e7959a2 839 m_apiId = XBEE_CMD_AT_CMD;
johnb 50:f76b7e7959a2 840
johnb 50:f76b7e7959a2 841 m_buffer[0] = p_frameId;
johnb 50:f76b7e7959a2 842 m_buffer[1] = p_data[0];
johnb 50:f76b7e7959a2 843 m_buffer[2] = p_data[1];
johnb 50:f76b7e7959a2 844
johnb 50:f76b7e7959a2 845 m_dataLen = sizeof( m_buffer );
johnb 50:f76b7e7959a2 846 m_data = m_buffer;
johnb 50:f76b7e7959a2 847 }
johnb 50:f76b7e7959a2 848
johnb 50:f76b7e7959a2 849 XBeeApiCmdAtReq::~XBeeApiCmdAtReq()
johnb 13:302e7c1ea0b3 850 {
johnb 25:db6874b7ac4b 851 }