Fork of my original MQTTGateway

Dependencies:   mbed-http

Committer:
vpcola
Date:
Sat Apr 08 14:43:14 2017 +0000
Revision:
0:a1734fe1ec4b
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vpcola 0:a1734fe1ec4b 1 /**
vpcola 0:a1734fe1ec4b 2 * Copyright (c) 2015 Digi International Inc.,
vpcola 0:a1734fe1ec4b 3 * All rights not expressly granted are reserved.
vpcola 0:a1734fe1ec4b 4 *
vpcola 0:a1734fe1ec4b 5 * This Source Code Form is subject to the terms of the Mozilla Public
vpcola 0:a1734fe1ec4b 6 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
vpcola 0:a1734fe1ec4b 7 * You can obtain one at http://mozilla.org/MPL/2.0/.
vpcola 0:a1734fe1ec4b 8 *
vpcola 0:a1734fe1ec4b 9 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
vpcola 0:a1734fe1ec4b 10 * =======================================================================
vpcola 0:a1734fe1ec4b 11 */
vpcola 0:a1734fe1ec4b 12
vpcola 0:a1734fe1ec4b 13 #if !defined(__XBEE_802_H_)
vpcola 0:a1734fe1ec4b 14 #define __XBEE_802_H_
vpcola 0:a1734fe1ec4b 15
vpcola 0:a1734fe1ec4b 16 #include "FrameHandlers/FH_AtCmdResp.h"
vpcola 0:a1734fe1ec4b 17 #include "FrameHandlers/FH_RxPacket802.h"
vpcola 0:a1734fe1ec4b 18 #include "FrameHandlers/FH_IoDataSample802.h"
vpcola 0:a1734fe1ec4b 19 #include "RemoteXBee/RemoteXBee.h"
vpcola 0:a1734fe1ec4b 20
vpcola 0:a1734fe1ec4b 21 namespace XBeeLib {
vpcola 0:a1734fe1ec4b 22
vpcola 0:a1734fe1ec4b 23 /** Class for XBee ZigBee modules, derived from XBee */
vpcola 0:a1734fe1ec4b 24 class XBee802 : public XBee
vpcola 0:a1734fe1ec4b 25 {
vpcola 0:a1734fe1ec4b 26 public:
vpcola 0:a1734fe1ec4b 27
vpcola 0:a1734fe1ec4b 28 /**
vpcola 0:a1734fe1ec4b 29 * IoLine for XBee802 Modules
vpcola 0:a1734fe1ec4b 30 */
vpcola 0:a1734fe1ec4b 31 enum IoLine {
vpcola 0:a1734fe1ec4b 32 DIO0_AD0 = 0, /**< DIO0_AD0 pin */
vpcola 0:a1734fe1ec4b 33 DIO1_AD1 = 1, /**< DIO1_AD1 pin */
vpcola 0:a1734fe1ec4b 34 DIO2_AD2 = 2, /**< DIO2_AD2 pin */
vpcola 0:a1734fe1ec4b 35 DIO3_AD3 = 3, /**< DIO3_AD3 pin */
vpcola 0:a1734fe1ec4b 36 DIO4_AD4 = 4, /**< DIO4_AD4 pin */
vpcola 0:a1734fe1ec4b 37 DIO5_AD5 = 5, /**< DIO5_AD5 pin */
vpcola 0:a1734fe1ec4b 38 DIO6 = 6, /**< DIO6 pin */
vpcola 0:a1734fe1ec4b 39 DIO7 = 7, /**< DIO7 pin */
vpcola 0:a1734fe1ec4b 40 DI8 = 8, /**< DI8 pin */
vpcola 0:a1734fe1ec4b 41 PWM0, /**< PWM0 pin */
vpcola 0:a1734fe1ec4b 42 PWM1 /**< PWM1 pin */
vpcola 0:a1734fe1ec4b 43 };
vpcola 0:a1734fe1ec4b 44
vpcola 0:a1734fe1ec4b 45 enum AssocStatus {
vpcola 0:a1734fe1ec4b 46 ErrorReading = -1, /**< Error occurred when reading parameter. */
vpcola 0:a1734fe1ec4b 47 Joined = 0x00, /**< Successful Completion - Coordinator successfully started or End Device association complete. */
vpcola 0:a1734fe1ec4b 48 ActiveScanTimeOut = 0x01, /**< Active Scan Timeout. */
vpcola 0:a1734fe1ec4b 49 NoPANs = 0x02, /**< Active Scan found no PANs. */
vpcola 0:a1734fe1ec4b 50 JoinNotAllowed = 0x03, /**< Active Scan found PAN, but the Coordinator's Allow Association bit is not set. */
vpcola 0:a1734fe1ec4b 51 BeaconsFailed = 0x04, /**< Active Scan found PAN, but Coordinator and End Device are not configured to support beacons. */
vpcola 0:a1734fe1ec4b 52 BadPAN = 0x05, /**< Active Scan found PAN, but Coordinator ID (PAN ID) value does not match the ID of the End Device. */
vpcola 0:a1734fe1ec4b 53 BadChannel = 0x06, /**< Active Scan found PAN, but Coordinator CH (Channel) value does not match the CH of the End Device */
vpcola 0:a1734fe1ec4b 54 EnergyScanTimeout = 0x07, /**< Energy Scan timed out. */
vpcola 0:a1734fe1ec4b 55 CoordStartFailed = 0x08, /**< Coordinator start request failed. */
vpcola 0:a1734fe1ec4b 56 CoordBadParameters = 0x09, /**< Coordinator could not start due to Invalid Parameter. */
vpcola 0:a1734fe1ec4b 57 CoordRealignment = 0x0A, /**< Coordinator Realignment is in progress. */
vpcola 0:a1734fe1ec4b 58 AssocReqNotSent = 0x0B, /**< Association Request not sent. */
vpcola 0:a1734fe1ec4b 59 AssocReqTimeout = 0x0C, /**< Association Request timed out - no reply was received. */
vpcola 0:a1734fe1ec4b 60 AssocReqInvalidPara = 0x0D, /**< Association Request had an Invalid Parameter. */
vpcola 0:a1734fe1ec4b 61 AssocReqChannelFail = 0x0E, /**< Association Request Channel Access Failure - Request was not transmitted - CCA failure. */
vpcola 0:a1734fe1ec4b 62 RemCoordNoACK = 0x0F, /**< Remote Coordinator did not send an ACK after Association Request was sent. */
vpcola 0:a1734fe1ec4b 63 RemCoordLateACK = 0x10, /**< Remote Coordinator did not reply to the Association Request, but an ACK was received after sending the request. */
vpcola 0:a1734fe1ec4b 64 Associating = 0xFF /**< RF Module is attempting to associate. */
vpcola 0:a1734fe1ec4b 65 };
vpcola 0:a1734fe1ec4b 66
vpcola 0:a1734fe1ec4b 67 /** Class constructor
vpcola 0:a1734fe1ec4b 68 * @param tx the TX pin of the UART that will interface the XBee module
vpcola 0:a1734fe1ec4b 69 * @param rx the RX pin of the UART that will interface the XBee module
vpcola 0:a1734fe1ec4b 70 * @param reset the pin to which the XBee's reset line is attached to, use NC if not available
vpcola 0:a1734fe1ec4b 71 * @param rts the RTS pin for the UART that will interface the XBee module, use NC if not available
vpcola 0:a1734fe1ec4b 72 * @param cts the CTS pin for the UART that will interface the XBee module, use NC if not available
vpcola 0:a1734fe1ec4b 73 * @param baud the baudrate for the UART that will interface the XBee module. Note that the module has to be already configured
vpcola 0:a1734fe1ec4b 74 * to this baud rate (ATBD parameter). By default it is configured to 9600 bps
vpcola 0:a1734fe1ec4b 75 */
vpcola 0:a1734fe1ec4b 76 XBee802(PinName tx, PinName rx, PinName reset = NC, PinName rts = NC, PinName cts = NC, int baud = 9600);
vpcola 0:a1734fe1ec4b 77
vpcola 0:a1734fe1ec4b 78 /** Class destructor */
vpcola 0:a1734fe1ec4b 79 virtual ~XBee802();
vpcola 0:a1734fe1ec4b 80
vpcola 0:a1734fe1ec4b 81 /** init - initializes object
vpcola 0:a1734fe1ec4b 82 * This function must be called just after creating the object so it initializes internal data.
vpcola 0:a1734fe1ec4b 83 * @returns
vpcola 0:a1734fe1ec4b 84 * Success if the module has been properly initialized and is ready to process data.
vpcola 0:a1734fe1ec4b 85 * Failure otherwise.
vpcola 0:a1734fe1ec4b 86 */
vpcola 0:a1734fe1ec4b 87 RadioStatus init();
vpcola 0:a1734fe1ec4b 88
vpcola 0:a1734fe1ec4b 89 /** set_panid - sets the 16 bit PAN ID.
vpcola 0:a1734fe1ec4b 90 *
vpcola 0:a1734fe1ec4b 91 * @param panid the PAN ID value that will be set on the radio
vpcola 0:a1734fe1ec4b 92 * @returns
vpcola 0:a1734fe1ec4b 93 * Success if the operation was successful,
vpcola 0:a1734fe1ec4b 94 * Failure otherwise
vpcola 0:a1734fe1ec4b 95 */
vpcola 0:a1734fe1ec4b 96 RadioStatus set_panid(uint16_t panid);
vpcola 0:a1734fe1ec4b 97
vpcola 0:a1734fe1ec4b 98 /** get_panid - gets the configured 16 bit PAN ID
vpcola 0:a1734fe1ec4b 99 *
vpcola 0:a1734fe1ec4b 100 * @param panid pointer where the read PAN ID value will be stored
vpcola 0:a1734fe1ec4b 101 * @returns
vpcola 0:a1734fe1ec4b 102 * Success if the operation was successful,
vpcola 0:a1734fe1ec4b 103 * Failure otherwise
vpcola 0:a1734fe1ec4b 104 */
vpcola 0:a1734fe1ec4b 105 RadioStatus get_panid(uint16_t * const panid);
vpcola 0:a1734fe1ec4b 106
vpcola 0:a1734fe1ec4b 107 /** set_channel - sets the network channel number
vpcola 0:a1734fe1ec4b 108 *
vpcola 0:a1734fe1ec4b 109 * @param channel the channel in which the radio operates. Range is 0x0B - 0x1A for XBee and 0x0C - 0x17 for XBee-PRO.
vpcola 0:a1734fe1ec4b 110 * The Center Frequency = 2.405 + (CH - 11) * 5 MHz
vpcola 0:a1734fe1ec4b 111 * @returns
vpcola 0:a1734fe1ec4b 112 * Success if the operation was successful,
vpcola 0:a1734fe1ec4b 113 * Failure otherwise
vpcola 0:a1734fe1ec4b 114 */
vpcola 0:a1734fe1ec4b 115 RadioStatus set_channel(uint8_t channel);
vpcola 0:a1734fe1ec4b 116
vpcola 0:a1734fe1ec4b 117 /** get_panid - gets the network channel number
vpcola 0:a1734fe1ec4b 118 *
vpcola 0:a1734fe1ec4b 119 * @param channel pointer where the channel value will be stored.
vpcola 0:a1734fe1ec4b 120 * @returns
vpcola 0:a1734fe1ec4b 121 * Success if the operation was successful,
vpcola 0:a1734fe1ec4b 122 * Failure otherwise
vpcola 0:a1734fe1ec4b 123 */
vpcola 0:a1734fe1ec4b 124 RadioStatus get_channel(uint8_t * const channel);
vpcola 0:a1734fe1ec4b 125
vpcola 0:a1734fe1ec4b 126 /** get_network_address - gets the 16bit network address of the device
vpcola 0:a1734fe1ec4b 127 *
vpcola 0:a1734fe1ec4b 128 * @param addr pointer where the device 16bit network address will be stored
vpcola 0:a1734fe1ec4b 129 * @returns
vpcola 0:a1734fe1ec4b 130 * Success if the operation was successful,
vpcola 0:a1734fe1ec4b 131 * Failure otherwise
vpcola 0:a1734fe1ec4b 132 */
vpcola 0:a1734fe1ec4b 133 RadioStatus get_network_address(uint16_t * const addr);
vpcola 0:a1734fe1ec4b 134
vpcola 0:a1734fe1ec4b 135 /** set_network_address - sets the 16 bit network address of the device
vpcola 0:a1734fe1ec4b 136 *
vpcola 0:a1734fe1ec4b 137 * @param addr the device 16bit network address (0x0 - 0xFFFF)
vpcola 0:a1734fe1ec4b 138 * @returns
vpcola 0:a1734fe1ec4b 139 * Success if the operation was successful,
vpcola 0:a1734fe1ec4b 140 * Failure otherwise
vpcola 0:a1734fe1ec4b 141 */
vpcola 0:a1734fe1ec4b 142 RadioStatus set_network_address(uint16_t addr);
vpcola 0:a1734fe1ec4b 143
vpcola 0:a1734fe1ec4b 144 /** register_node_discovery_cb - registers the callback function that will be called
vpcola 0:a1734fe1ec4b 145 * when the responses to the node discovery command arrive
vpcola 0:a1734fe1ec4b 146 *
vpcola 0:a1734fe1ec4b 147 * @param function function pointer with the callback function
vpcola 0:a1734fe1ec4b 148 */
vpcola 0:a1734fe1ec4b 149 void register_node_discovery_cb(node_discovery_802_cb_t function);
vpcola 0:a1734fe1ec4b 150
vpcola 0:a1734fe1ec4b 151 /** unregister_node_discovery_cb - removes the node discovery callback */
vpcola 0:a1734fe1ec4b 152 void unregister_node_discovery_cb();
vpcola 0:a1734fe1ec4b 153
vpcola 0:a1734fe1ec4b 154 /** register_receive_cb - registers the callback function that will be called
vpcola 0:a1734fe1ec4b 155 * when a rx packet is received
vpcola 0:a1734fe1ec4b 156 *
vpcola 0:a1734fe1ec4b 157 * @param function function pointer with the callback function
vpcola 0:a1734fe1ec4b 158 */
vpcola 0:a1734fe1ec4b 159 void register_receive_cb(receive_802_cb_t function);
vpcola 0:a1734fe1ec4b 160
vpcola 0:a1734fe1ec4b 161 /** unregister_receive_cb - removes the rx packet callback */
vpcola 0:a1734fe1ec4b 162 void unregister_receive_cb();
vpcola 0:a1734fe1ec4b 163
vpcola 0:a1734fe1ec4b 164 /** register_io_sample_cb - registers the callback function that will be called
vpcola 0:a1734fe1ec4b 165 * when a IO Sample Data packet is received
vpcola 0:a1734fe1ec4b 166 *
vpcola 0:a1734fe1ec4b 167 * @param function function pointer with the callback function
vpcola 0:a1734fe1ec4b 168 */
vpcola 0:a1734fe1ec4b 169 void register_io_sample_cb(io_data_cb_802_t function);
vpcola 0:a1734fe1ec4b 170
vpcola 0:a1734fe1ec4b 171 /** unregister_io_sample_cb - removes the IO Sample Data reception callback */
vpcola 0:a1734fe1ec4b 172 void unregister_io_sample_cb();
vpcola 0:a1734fe1ec4b 173
vpcola 0:a1734fe1ec4b 174 /*********************** send_data member methods ************************/
vpcola 0:a1734fe1ec4b 175 /** send_data - sends data to a remote device
vpcola 0:a1734fe1ec4b 176 *
vpcola 0:a1734fe1ec4b 177 * @param remote remote device
vpcola 0:a1734fe1ec4b 178 * @param data pointer to the data that will be sent
vpcola 0:a1734fe1ec4b 179 * @param len number of bytes that will be transmitted
vpcola 0:a1734fe1ec4b 180 * @param syncr if true, method waits for the packet answer with the result of the operation
vpcola 0:a1734fe1ec4b 181 * @returns the result of the data transfer
vpcola 0:a1734fe1ec4b 182 * TxStatusSuccess if the operation was successful,
vpcola 0:a1734fe1ec4b 183 * the error code otherwise
vpcola 0:a1734fe1ec4b 184 */
vpcola 0:a1734fe1ec4b 185 virtual TxStatus send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len, bool syncr = true);
vpcola 0:a1734fe1ec4b 186
vpcola 0:a1734fe1ec4b 187 /** get_assoc_status - returns current network association status. This wraps AI parameter, for more information refer to moudle's Reference Manual.
vpcola 0:a1734fe1ec4b 188 *
vpcola 0:a1734fe1ec4b 189 * @returns an AssocStatus with current network association status.
vpcola 0:a1734fe1ec4b 190 */
vpcola 0:a1734fe1ec4b 191 AssocStatus get_assoc_status(void);
vpcola 0:a1734fe1ec4b 192
vpcola 0:a1734fe1ec4b 193 /** get_remote_node_by_id - searches for a device in the network with the specified Node Identifier.
vpcola 0:a1734fe1ec4b 194 *
vpcola 0:a1734fe1ec4b 195 * @param node_id node id of the device we are looking for
vpcola 0:a1734fe1ec4b 196 * @returns a RemoteXBee802 with the 16-bit and 64-bit address of the remote device whose node id matches with the parameter.
vpcola 0:a1734fe1ec4b 197 * If node is not found, the returned object will have invalid addresses (RemoteXBee802::is_valid() will return false).
vpcola 0:a1734fe1ec4b 198 */
vpcola 0:a1734fe1ec4b 199 RemoteXBee802 get_remote_node_by_id(const char * const node_id);
vpcola 0:a1734fe1ec4b 200
vpcola 0:a1734fe1ec4b 201 /* Allow using XBee::set_param() methods for local radio from this class */
vpcola 0:a1734fe1ec4b 202 using XBee::set_param;
vpcola 0:a1734fe1ec4b 203
vpcola 0:a1734fe1ec4b 204 /** set_param - sets a parameter in a remote radio by sending an AT command and waiting for the response.
vpcola 0:a1734fe1ec4b 205 *
vpcola 0:a1734fe1ec4b 206 * @param remote remote device
vpcola 0:a1734fe1ec4b 207 * @param param parameter to be set.
vpcola 0:a1734fe1ec4b 208 * @param data the parameter value (4 bytes) to be set.
vpcola 0:a1734fe1ec4b 209 * @returns the command response status.
vpcola 0:a1734fe1ec4b 210 */
vpcola 0:a1734fe1ec4b 211 virtual AtCmdFrame::AtCmdResp set_param(const RemoteXBee& remote, const char * const param, uint32_t data);
vpcola 0:a1734fe1ec4b 212
vpcola 0:a1734fe1ec4b 213 /** set_param - sets a parameter in a remote radio by sending an AT command and waiting for the response.
vpcola 0:a1734fe1ec4b 214 *
vpcola 0:a1734fe1ec4b 215 * @param remote remote device
vpcola 0:a1734fe1ec4b 216 * @param param parameter to be set.
vpcola 0:a1734fe1ec4b 217 * @param the parameter value byte array (len bytes) to be set.
vpcola 0:a1734fe1ec4b 218 * @param len number of bytes of the parameter value.
vpcola 0:a1734fe1ec4b 219 * @returns the command response status.
vpcola 0:a1734fe1ec4b 220 */
vpcola 0:a1734fe1ec4b 221 virtual AtCmdFrame::AtCmdResp set_param(const RemoteXBee& remote, const char * const param, const uint8_t * data = NULL, uint16_t len = 0);
vpcola 0:a1734fe1ec4b 222
vpcola 0:a1734fe1ec4b 223 /* Allow using XBee::get_param() methods for local radio from this class */
vpcola 0:a1734fe1ec4b 224 using XBee::get_param;
vpcola 0:a1734fe1ec4b 225
vpcola 0:a1734fe1ec4b 226 /** get_param - gets a parameter from a remote radio by sending an AT command and waiting for the response.
vpcola 0:a1734fe1ec4b 227 *
vpcola 0:a1734fe1ec4b 228 * @param remote remote device
vpcola 0:a1734fe1ec4b 229 * @param param parameter to be get.
vpcola 0:a1734fe1ec4b 230 * @param data pointer where the param value (4 bytes) will be stored.
vpcola 0:a1734fe1ec4b 231 * @returns the command response status.
vpcola 0:a1734fe1ec4b 232 */
vpcola 0:a1734fe1ec4b 233 virtual AtCmdFrame::AtCmdResp get_param(const RemoteXBee& remote, const char * const param, uint32_t * const data);
vpcola 0:a1734fe1ec4b 234
vpcola 0:a1734fe1ec4b 235 /** get_param - gets a parameter from a remote radio by sending an AT command and waiting for the response.
vpcola 0:a1734fe1ec4b 236 *
vpcola 0:a1734fe1ec4b 237 * @param remote remote device
vpcola 0:a1734fe1ec4b 238 * @param param parameter to be get.
vpcola 0:a1734fe1ec4b 239 * @param data pointer where the param value (n bytes) will be stored.
vpcola 0:a1734fe1ec4b 240 * @param len pointer where the number of bytes of the param value will be stored.
vpcola 0:a1734fe1ec4b 241 * @returns the command response status.
vpcola 0:a1734fe1ec4b 242 */
vpcola 0:a1734fe1ec4b 243 virtual AtCmdFrame::AtCmdResp get_param(const RemoteXBee& remote, const char * const param, uint8_t * const data, uint16_t * const len);
vpcola 0:a1734fe1ec4b 244
vpcola 0:a1734fe1ec4b 245 /************************* IO member methods **************************/
vpcola 0:a1734fe1ec4b 246 /** set_pin_config - configures a radio IO line
vpcola 0:a1734fe1ec4b 247 *
vpcola 0:a1734fe1ec4b 248 * @param remote remote device
vpcola 0:a1734fe1ec4b 249 * @param line IO line being configured
vpcola 0:a1734fe1ec4b 250 * @param mode configuration mode for the selected line
vpcola 0:a1734fe1ec4b 251 * @returns
vpcola 0:a1734fe1ec4b 252 * Success if the operation was successful,
vpcola 0:a1734fe1ec4b 253 * Failure otherwise
vpcola 0:a1734fe1ec4b 254 */
vpcola 0:a1734fe1ec4b 255 RadioStatus set_pin_config(const RemoteXBee& remote, IoLine line, IoMode mode);
vpcola 0:a1734fe1ec4b 256
vpcola 0:a1734fe1ec4b 257 /** get_pin_config - gets the configuration of a radio IO line
vpcola 0:a1734fe1ec4b 258 *
vpcola 0:a1734fe1ec4b 259 * @param remote remote device
vpcola 0:a1734fe1ec4b 260 * @param line IO line being read to get its configuration
vpcola 0:a1734fe1ec4b 261 * @param mode pointer where the configuration will be stored
vpcola 0:a1734fe1ec4b 262 * @returns
vpcola 0:a1734fe1ec4b 263 * Success if the operation was successful,
vpcola 0:a1734fe1ec4b 264 * Failure otherwise
vpcola 0:a1734fe1ec4b 265 */
vpcola 0:a1734fe1ec4b 266 RadioStatus get_pin_config(const RemoteXBee& remote, IoLine line, IoMode * const mode);
vpcola 0:a1734fe1ec4b 267
vpcola 0:a1734fe1ec4b 268 /** set_dio - sets to low/high a DIO line
vpcola 0:a1734fe1ec4b 269 *
vpcola 0:a1734fe1ec4b 270 * @param remote remote device
vpcola 0:a1734fe1ec4b 271 * @param line DIO line being set
vpcola 0:a1734fe1ec4b 272 * @param val value that will be set in the DIO line
vpcola 0:a1734fe1ec4b 273 * @returns
vpcola 0:a1734fe1ec4b 274 * Success if the operation was successful,
vpcola 0:a1734fe1ec4b 275 * Failure otherwise
vpcola 0:a1734fe1ec4b 276 */
vpcola 0:a1734fe1ec4b 277 RadioStatus set_dio(const RemoteXBee& remote, IoLine line, DioVal val);
vpcola 0:a1734fe1ec4b 278
vpcola 0:a1734fe1ec4b 279 /** get_dio - read the value of a DIO configured as digital input
vpcola 0:a1734fe1ec4b 280 *
vpcola 0:a1734fe1ec4b 281 * @param remote remote device
vpcola 0:a1734fe1ec4b 282 * @param line DIO line being read
vpcola 0:a1734fe1ec4b 283 * @param val pointer where the DIO value read will be stored
vpcola 0:a1734fe1ec4b 284 * @returns
vpcola 0:a1734fe1ec4b 285 * Success if the operation was successful,
vpcola 0:a1734fe1ec4b 286 * Failure otherwise
vpcola 0:a1734fe1ec4b 287 */
vpcola 0:a1734fe1ec4b 288 RadioStatus get_dio(const RemoteXBee& remote, IoLine line, DioVal * const val);
vpcola 0:a1734fe1ec4b 289
vpcola 0:a1734fe1ec4b 290 /** get_adc - read the value of the espcified ADC line
vpcola 0:a1734fe1ec4b 291 *
vpcola 0:a1734fe1ec4b 292 * @param remote remote device
vpcola 0:a1734fe1ec4b 293 * @param line ADC line being read
vpcola 0:a1734fe1ec4b 294 * @param val pointer where the value read from the ADC will be stored
vpcola 0:a1734fe1ec4b 295 * @returns
vpcola 0:a1734fe1ec4b 296 * Success if the operation was successful,
vpcola 0:a1734fe1ec4b 297 * Failure otherwise
vpcola 0:a1734fe1ec4b 298 */
vpcola 0:a1734fe1ec4b 299 RadioStatus get_adc(const RemoteXBee& remote, IoLine line, uint16_t * const val);
vpcola 0:a1734fe1ec4b 300
vpcola 0:a1734fe1ec4b 301 /** get_iosample - retrieves an @ref IOSample802 from a remote node. This object can be used to get the remote node's ADC and DIO values.
vpcola 0:a1734fe1ec4b 302 *
vpcola 0:a1734fe1ec4b 303 * @param remote remote device
vpcola 0:a1734fe1ec4b 304 * @returns IOSample802 object with the remote node's DIO and ADC values.
vpcola 0:a1734fe1ec4b 305 */
vpcola 0:a1734fe1ec4b 306 IOSample802 get_iosample(const RemoteXBee& remote);
vpcola 0:a1734fe1ec4b 307
vpcola 0:a1734fe1ec4b 308 /** set_pwm - sets the duty cycle of a PWM line
vpcola 0:a1734fe1ec4b 309 *
vpcola 0:a1734fe1ec4b 310 * @param remote remote device
vpcola 0:a1734fe1ec4b 311 * @param line PWM line being set
vpcola 0:a1734fe1ec4b 312 * @param duty_cycle duty cycle that will be set in the PWM line
vpcola 0:a1734fe1ec4b 313 * @returns
vpcola 0:a1734fe1ec4b 314 * Success if the operation was successful,
vpcola 0:a1734fe1ec4b 315 * Failure otherwise
vpcola 0:a1734fe1ec4b 316 */
vpcola 0:a1734fe1ec4b 317 RadioStatus set_pwm(const RemoteXBee& remote, IoLine line, float duty_cycle);
vpcola 0:a1734fe1ec4b 318
vpcola 0:a1734fe1ec4b 319 /** set_pin_pull_up - enables or disables the internal pull-up resistor of a line
vpcola 0:a1734fe1ec4b 320 *
vpcola 0:a1734fe1ec4b 321 * @param remote remote device
vpcola 0:a1734fe1ec4b 322 * @param line line being configured for pull-up
vpcola 0:a1734fe1ec4b 323 * @param enable whether to enable the internal pull-up resistor.
vpcola 0:a1734fe1ec4b 324 * @returns
vpcola 0:a1734fe1ec4b 325 * Success if the operation was successful,
vpcola 0:a1734fe1ec4b 326 * Failure otherwise
vpcola 0:a1734fe1ec4b 327 */
vpcola 0:a1734fe1ec4b 328 RadioStatus set_pin_pull_up(const RemoteXBee& remote, IoLine line, bool enable);
vpcola 0:a1734fe1ec4b 329
vpcola 0:a1734fe1ec4b 330 /** enable_dio_change_detection - enables or disables the notification when a change is detected in a digital input line.
vpcola 0:a1734fe1ec4b 331 * In other words, it will force an IO Sample transmission when the DIO state changes. Only for DIO0 to DIO7.
vpcola 0:a1734fe1ec4b 332 *
vpcola 0:a1734fe1ec4b 333 * @param remote remote device
vpcola 0:a1734fe1ec4b 334 * @param line line being configured for pull-up
vpcola 0:a1734fe1ec4b 335 * @param enable whether to enable the internal pull-up resistor.
vpcola 0:a1734fe1ec4b 336 * @returns
vpcola 0:a1734fe1ec4b 337 * Success if the operation was successful,
vpcola 0:a1734fe1ec4b 338 * Failure otherwise
vpcola 0:a1734fe1ec4b 339 */
vpcola 0:a1734fe1ec4b 340 RadioStatus enable_dio_change_detection(const RemoteXBee& remote, IoLine line, bool enable);
vpcola 0:a1734fe1ec4b 341
vpcola 0:a1734fe1ec4b 342 /* TODO: With current firmware ATM0 fails: Returns just OK and sets pwm to 0 */
vpcola 0:a1734fe1ec4b 343 #ifdef GET_PWM_AVAILABLE
vpcola 0:a1734fe1ec4b 344 /** get_pwm - gets the duty cycle of a PWM line
vpcola 0:a1734fe1ec4b 345 *
vpcola 0:a1734fe1ec4b 346 * @param remote remote device
vpcola 0:a1734fe1ec4b 347 * @param line PWM line being read
vpcola 0:a1734fe1ec4b 348 * @param duty_cycle pointer where the value of the duty cycle read from
vpcola 0:a1734fe1ec4b 349 * the PWM line will be stored
vpcola 0:a1734fe1ec4b 350 * @returns
vpcola 0:a1734fe1ec4b 351 * Success if the operation was successful,
vpcola 0:a1734fe1ec4b 352 * Failure otherwise
vpcola 0:a1734fe1ec4b 353 */
vpcola 0:a1734fe1ec4b 354 RadioStatus get_pwm(const RemoteXBee& remote, IoLine line, float * const duty_cycle);
vpcola 0:a1734fe1ec4b 355 #endif
vpcola 0:a1734fe1ec4b 356
vpcola 0:a1734fe1ec4b 357 protected:
vpcola 0:a1734fe1ec4b 358
vpcola 0:a1734fe1ec4b 359 /** Frame handler used for the node discovery. Registered when a callback function
vpcola 0:a1734fe1ec4b 360 * is registered */
vpcola 0:a1734fe1ec4b 361 FH_NodeDiscovery802 *_nd_handler;
vpcola 0:a1734fe1ec4b 362
vpcola 0:a1734fe1ec4b 363 /** Frame handler used for the rx 64 bit packets. Automatically registered when a callback
vpcola 0:a1734fe1ec4b 364 * function is registered */
vpcola 0:a1734fe1ec4b 365 FH_RxPacket64b802 *_rx_64b_handler;
vpcola 0:a1734fe1ec4b 366
vpcola 0:a1734fe1ec4b 367 /** Frame handler used for the rx 16 bit packets. Automatically registered when a callback
vpcola 0:a1734fe1ec4b 368 * function is registered */
vpcola 0:a1734fe1ec4b 369 FH_RxPacket16b802 *_rx_16b_handler;
vpcola 0:a1734fe1ec4b 370
vpcola 0:a1734fe1ec4b 371 /** Frame handler used for the 64 bit IO Data Samples packets. Automatically registered when a callback
vpcola 0:a1734fe1ec4b 372 * function is registered */
vpcola 0:a1734fe1ec4b 373 FH_IoDataSampe64b802 *_io_data_64b_handler;
vpcola 0:a1734fe1ec4b 374
vpcola 0:a1734fe1ec4b 375 /** Frame handler used for the 16 bit IO Data Samples packets. Automatically registered when a callback
vpcola 0:a1734fe1ec4b 376 * function is registered */
vpcola 0:a1734fe1ec4b 377 FH_IoDataSampe16b802 *_io_data_16b_handler;
vpcola 0:a1734fe1ec4b 378
vpcola 0:a1734fe1ec4b 379 /** Method called directly by the library when a modem status frame is received to
vpcola 0:a1734fe1ec4b 380 * update the internal status variables */
vpcola 0:a1734fe1ec4b 381 virtual void radio_status_update(AtCmdFrame::ModemStatus modem_status);
vpcola 0:a1734fe1ec4b 382
vpcola 0:a1734fe1ec4b 383 /* Allow using XBee::send_data() methods from this class */
vpcola 0:a1734fe1ec4b 384 using XBee::send_data;
vpcola 0:a1734fe1ec4b 385
vpcola 0:a1734fe1ec4b 386 /** get_node_discovery_timeout - gets the node discovery timeout
vpcola 0:a1734fe1ec4b 387 *
vpcola 0:a1734fe1ec4b 388 * @param timeout_ms pointer where the node discovery timeout value will be stored
vpcola 0:a1734fe1ec4b 389 * @param wait_for_complete_timeout pointer where the function will store if the operator
vpcola 0:a1734fe1ec4b 390 * has to wait for the complete nd timeout after issuing
vpcola 0:a1734fe1ec4b 391 * a directed nd request
vpcola 0:a1734fe1ec4b 392 * @returns
vpcola 0:a1734fe1ec4b 393 * Success if the operation was successful,
vpcola 0:a1734fe1ec4b 394 * Failure otherwise
vpcola 0:a1734fe1ec4b 395 */
vpcola 0:a1734fe1ec4b 396 virtual RadioStatus get_node_discovery_timeout(uint16_t * const timeout_ms);
vpcola 0:a1734fe1ec4b 397 virtual RadioStatus get_node_discovery_timeout(uint16_t * const timeout_ms, bool * const wait_for_complete_timeout);
vpcola 0:a1734fe1ec4b 398
vpcola 0:a1734fe1ec4b 399 private:
vpcola 0:a1734fe1ec4b 400
vpcola 0:a1734fe1ec4b 401 };
vpcola 0:a1734fe1ec4b 402
vpcola 0:a1734fe1ec4b 403 } /* namespace XBeeLib */
vpcola 0:a1734fe1ec4b 404
vpcola 0:a1734fe1ec4b 405 #endif /* __XBEE_802_H_ */