Fork of my MQTTGateway

Dependencies:   mbed-http

Committer:
vpcola
Date:
Sat Apr 08 14:45:51 2017 +0000
Revision:
0:f1d3878b8dd9
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vpcola 0:f1d3878b8dd9 1 /**
vpcola 0:f1d3878b8dd9 2 * Copyright (c) 2015 Digi International Inc.,
vpcola 0:f1d3878b8dd9 3 * All rights not expressly granted are reserved.
vpcola 0:f1d3878b8dd9 4 *
vpcola 0:f1d3878b8dd9 5 * This Source Code Form is subject to the terms of the Mozilla Public
vpcola 0:f1d3878b8dd9 6 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
vpcola 0:f1d3878b8dd9 7 * You can obtain one at http://mozilla.org/MPL/2.0/.
vpcola 0:f1d3878b8dd9 8 *
vpcola 0:f1d3878b8dd9 9 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
vpcola 0:f1d3878b8dd9 10 * =======================================================================
vpcola 0:f1d3878b8dd9 11 */
vpcola 0:f1d3878b8dd9 12
vpcola 0:f1d3878b8dd9 13 #if !defined(__XBEE_DM_H_)
vpcola 0:f1d3878b8dd9 14 #define __XBEE_DM_H_
vpcola 0:f1d3878b8dd9 15
vpcola 0:f1d3878b8dd9 16 #include "XBee/XBee.h"
vpcola 0:f1d3878b8dd9 17 #include "FrameHandlers/FH_AtCmdResp.h"
vpcola 0:f1d3878b8dd9 18 #include "FrameHandlers/FH_RxPacketDM.h"
vpcola 0:f1d3878b8dd9 19 #include "FrameHandlers/FH_IoDataSampleDM.h"
vpcola 0:f1d3878b8dd9 20 #include "RemoteXBee/RemoteXBee.h"
vpcola 0:f1d3878b8dd9 21
vpcola 0:f1d3878b8dd9 22 namespace XBeeLib {
vpcola 0:f1d3878b8dd9 23
vpcola 0:f1d3878b8dd9 24 /** Class for XBee ZigBee modules, derived from XBee */
vpcola 0:f1d3878b8dd9 25 class XBeeDM : public XBee
vpcola 0:f1d3878b8dd9 26 {
vpcola 0:f1d3878b8dd9 27 public:
vpcola 0:f1d3878b8dd9 28
vpcola 0:f1d3878b8dd9 29 /**
vpcola 0:f1d3878b8dd9 30 * IoLine for XBeeDM Modules
vpcola 0:f1d3878b8dd9 31 */
vpcola 0:f1d3878b8dd9 32 enum IoLine {
vpcola 0:f1d3878b8dd9 33 DIO0_AD0 = 0, /**< DIO0_AD0 pin */
vpcola 0:f1d3878b8dd9 34 DIO1_AD1 = 1, /**< DIO1_AD1 pin */
vpcola 0:f1d3878b8dd9 35 DIO2_AD2 = 2, /**< DIO2_AD2 pin */
vpcola 0:f1d3878b8dd9 36 DIO3_AD3 = 3, /**< DIO3_AD3 pin */
vpcola 0:f1d3878b8dd9 37 DIO4 = 4, /**< DIO4 pin */
vpcola 0:f1d3878b8dd9 38 DIO5 = 5, /**< DIO5 pin */
vpcola 0:f1d3878b8dd9 39 DIO6 = 6, /**< DIO6 pin */
vpcola 0:f1d3878b8dd9 40 DIO7 = 7, /**< DIO7 pin */
vpcola 0:f1d3878b8dd9 41 DIO8 = 8, /**< DIO8 pin */
vpcola 0:f1d3878b8dd9 42 DIO9 = 9, /**< DIO9 pin */
vpcola 0:f1d3878b8dd9 43 DIO10_PWM0 = 10, /**< DIO10_PWM0 pin */
vpcola 0:f1d3878b8dd9 44 DIO11_PWM1 = 11, /**< DIO11_PWM1 pin */
vpcola 0:f1d3878b8dd9 45 DIO12 = 12 /**< DIO12 pin */
vpcola 0:f1d3878b8dd9 46 };
vpcola 0:f1d3878b8dd9 47
vpcola 0:f1d3878b8dd9 48 /** Class constructor
vpcola 0:f1d3878b8dd9 49 * @param tx the TX pin of the UART that will interface the XBee module
vpcola 0:f1d3878b8dd9 50 * @param rx the RX pin of the UART that will interface the XBee module
vpcola 0:f1d3878b8dd9 51 * @param reset the pin to which the XBee's reset line is attached to, use NC if not available
vpcola 0:f1d3878b8dd9 52 * @param rts the RTS pin for the UART that will interface the XBee module, use NC if not available
vpcola 0:f1d3878b8dd9 53 * @param cts the CTS pin for the UART that will interface the XBee module, use NC if not available
vpcola 0:f1d3878b8dd9 54 * @param baud the baudrate for the UART that will interface the XBee module. Note that the module has to be already configured
vpcola 0:f1d3878b8dd9 55 * to this baud rate (ATBD parameter). By default it is configured to 9600 bps
vpcola 0:f1d3878b8dd9 56 */
vpcola 0:f1d3878b8dd9 57 XBeeDM(PinName tx, PinName rx, PinName reset = NC, PinName rts = NC, PinName cts = NC, int baud = 9600);
vpcola 0:f1d3878b8dd9 58
vpcola 0:f1d3878b8dd9 59 /** Class destructor */
vpcola 0:f1d3878b8dd9 60 virtual ~XBeeDM();
vpcola 0:f1d3878b8dd9 61
vpcola 0:f1d3878b8dd9 62 /** init- initializes object
vpcola 0:f1d3878b8dd9 63 * This function must be called just after creating the object so it initializes internal data.
vpcola 0:f1d3878b8dd9 64 * @returns
vpcola 0:f1d3878b8dd9 65 * Success if the module has been properly initialized and is ready to process data.
vpcola 0:f1d3878b8dd9 66 * Failure otherwise.
vpcola 0:f1d3878b8dd9 67 */
vpcola 0:f1d3878b8dd9 68 RadioStatus init();
vpcola 0:f1d3878b8dd9 69
vpcola 0:f1d3878b8dd9 70 /** set_channel - sets the channel number
vpcola 0:f1d3878b8dd9 71 *
vpcola 0:f1d3878b8dd9 72 * @param channel the channel in which the radio operates. Range is 0x0B - 0x1A for XBee and 0x0C - 0x17 for XBee-PRO.
vpcola 0:f1d3878b8dd9 73 * The Center Frequency = 2.405 + (CH - 11) * 5 MHz
vpcola 0:f1d3878b8dd9 74 * @returns
vpcola 0:f1d3878b8dd9 75 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 76 * Failure otherwise
vpcola 0:f1d3878b8dd9 77 */
vpcola 0:f1d3878b8dd9 78 RadioStatus set_channel(uint8_t channel);
vpcola 0:f1d3878b8dd9 79
vpcola 0:f1d3878b8dd9 80 /** get_channel - gets the channel number
vpcola 0:f1d3878b8dd9 81 *
vpcola 0:f1d3878b8dd9 82 * @param channel pointer where the channel value will be stored.
vpcola 0:f1d3878b8dd9 83 * @returns
vpcola 0:f1d3878b8dd9 84 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 85 * Failure otherwise
vpcola 0:f1d3878b8dd9 86 */
vpcola 0:f1d3878b8dd9 87 RadioStatus get_channel(uint8_t * const channel);
vpcola 0:f1d3878b8dd9 88
vpcola 0:f1d3878b8dd9 89 /** set_network_id - sets the Network ID.
vpcola 0:f1d3878b8dd9 90 *
vpcola 0:f1d3878b8dd9 91 * @param network_id the Network ID value that will be set on the radio
vpcola 0:f1d3878b8dd9 92 * @returns
vpcola 0:f1d3878b8dd9 93 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 94 * Failure otherwise
vpcola 0:f1d3878b8dd9 95 */
vpcola 0:f1d3878b8dd9 96 RadioStatus set_network_id(uint16_t network_id);
vpcola 0:f1d3878b8dd9 97
vpcola 0:f1d3878b8dd9 98 /** get_network_id - gets the Network ID, as it was set by @ref set_network_id().
vpcola 0:f1d3878b8dd9 99 *
vpcola 0:f1d3878b8dd9 100 * @param network_id pointer where the Network ID will be stored
vpcola 0:f1d3878b8dd9 101 * @returns
vpcola 0:f1d3878b8dd9 102 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 103 * Failure otherwise
vpcola 0:f1d3878b8dd9 104 */
vpcola 0:f1d3878b8dd9 105 RadioStatus get_network_id(uint16_t * const network_id);
vpcola 0:f1d3878b8dd9 106
vpcola 0:f1d3878b8dd9 107 /** register_node_discovery_cb - registers the callback function that will be called
vpcola 0:f1d3878b8dd9 108 * when the responses to the node discovery command arrive
vpcola 0:f1d3878b8dd9 109 *
vpcola 0:f1d3878b8dd9 110 * @param function function pointer with the callback function
vpcola 0:f1d3878b8dd9 111 */
vpcola 0:f1d3878b8dd9 112 void register_node_discovery_cb(node_discovery_dm_cb_t function);
vpcola 0:f1d3878b8dd9 113
vpcola 0:f1d3878b8dd9 114 /** unregister_node_discovery_cb - removes the node discovery callback */
vpcola 0:f1d3878b8dd9 115 void unregister_node_discovery_cb();
vpcola 0:f1d3878b8dd9 116
vpcola 0:f1d3878b8dd9 117 /** register_receive_cb - registers the callback function that will be called
vpcola 0:f1d3878b8dd9 118 * when a data packet is received
vpcola 0:f1d3878b8dd9 119 *
vpcola 0:f1d3878b8dd9 120 * @param function function pointer with the callback function
vpcola 0:f1d3878b8dd9 121 */
vpcola 0:f1d3878b8dd9 122 void register_receive_cb(receive_dm_cb_t function);
vpcola 0:f1d3878b8dd9 123
vpcola 0:f1d3878b8dd9 124 /** unregister_receive_cb - removes the rx packet callback */
vpcola 0:f1d3878b8dd9 125 void unregister_receive_cb();
vpcola 0:f1d3878b8dd9 126
vpcola 0:f1d3878b8dd9 127 /** register_io_sample_cb - registers the callback function that will be called
vpcola 0:f1d3878b8dd9 128 * when a IO Sample Data packet is received
vpcola 0:f1d3878b8dd9 129 *
vpcola 0:f1d3878b8dd9 130 * @param function function pointer with the callback function
vpcola 0:f1d3878b8dd9 131 */
vpcola 0:f1d3878b8dd9 132 void register_io_sample_cb(io_data_cb_dm_t function);
vpcola 0:f1d3878b8dd9 133
vpcola 0:f1d3878b8dd9 134 /** unregister_io_sample_cb - removes the IO Sample Data reception callback */
vpcola 0:f1d3878b8dd9 135 void unregister_io_sample_cb();
vpcola 0:f1d3878b8dd9 136
vpcola 0:f1d3878b8dd9 137 /*********************** send_data member methods ************************/
vpcola 0:f1d3878b8dd9 138 /** send_data - sends data to a remote device
vpcola 0:f1d3878b8dd9 139 *
vpcola 0:f1d3878b8dd9 140 * @param remote remote device
vpcola 0:f1d3878b8dd9 141 * @param data pointer to the data that will be sent
vpcola 0:f1d3878b8dd9 142 * @param len number of bytes that will be transmitted
vpcola 0:f1d3878b8dd9 143 * @param syncr if true, method waits for the packet answer with the result of the operation
vpcola 0:f1d3878b8dd9 144 * @returns the result of the data transfer
vpcola 0:f1d3878b8dd9 145 * TxStatusSuccess if the operation was successful,
vpcola 0:f1d3878b8dd9 146 * the error code otherwise
vpcola 0:f1d3878b8dd9 147 */
vpcola 0:f1d3878b8dd9 148 virtual TxStatus send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len, bool syncr = true);
vpcola 0:f1d3878b8dd9 149
vpcola 0:f1d3878b8dd9 150 /** send_data - sends data to a remote device. This method uses
vpcola 0:f1d3878b8dd9 151 * the explicit addressing frame, allowing to use source and
vpcola 0:f1d3878b8dd9 152 * destination end points and cluster and profile IDs
vpcola 0:f1d3878b8dd9 153 *
vpcola 0:f1d3878b8dd9 154 * @param remote remote device
vpcola 0:f1d3878b8dd9 155 * @param source_ep source end point
vpcola 0:f1d3878b8dd9 156 * @param dest_ep destination end point
vpcola 0:f1d3878b8dd9 157 * @param cluster_id cluster ID
vpcola 0:f1d3878b8dd9 158 * @param profile_id profile ID
vpcola 0:f1d3878b8dd9 159 * @param data pointer to the data that will be sent
vpcola 0:f1d3878b8dd9 160 * @param len number of bytes that will be transmitted
vpcola 0:f1d3878b8dd9 161 * @param syncr if true, method waits for the packet answer with the result of the operation
vpcola 0:f1d3878b8dd9 162 * @returns the result of the data transfer
vpcola 0:f1d3878b8dd9 163 * TxStatusSuccess if the operation was successful,
vpcola 0:f1d3878b8dd9 164 * the error code otherwise
vpcola 0:f1d3878b8dd9 165 */
vpcola 0:f1d3878b8dd9 166 TxStatus send_data(const RemoteXBee& remote, uint8_t source_ep,
vpcola 0:f1d3878b8dd9 167 uint8_t dest_ep, uint16_t cluster_id, uint16_t profile_id,
vpcola 0:f1d3878b8dd9 168 const uint8_t *const data, uint16_t len, bool syncr = true);
vpcola 0:f1d3878b8dd9 169
vpcola 0:f1d3878b8dd9 170 /** send_data_to_coordinator - sends data to the ZigBee coordinator
vpcola 0:f1d3878b8dd9 171 *
vpcola 0:f1d3878b8dd9 172 * @param data pointer to the data that will be sent
vpcola 0:f1d3878b8dd9 173 * @param len number of bytes that will be transmitted
vpcola 0:f1d3878b8dd9 174 * @param syncr if true, method waits for the packet answer with the result of the operation
vpcola 0:f1d3878b8dd9 175 * @returns the result of the data transfer
vpcola 0:f1d3878b8dd9 176 * TxStatusSuccess if the operation was successful,
vpcola 0:f1d3878b8dd9 177 * the error code otherwise
vpcola 0:f1d3878b8dd9 178 */
vpcola 0:f1d3878b8dd9 179 TxStatus send_data_to_coordinator(const uint8_t *const data, uint16_t len, bool syncr = true);
vpcola 0:f1d3878b8dd9 180
vpcola 0:f1d3878b8dd9 181 /** get_remote_node_by_id - searches for a device in the network with the specified Node Identifier.
vpcola 0:f1d3878b8dd9 182 *
vpcola 0:f1d3878b8dd9 183 * @param node_id node id of the device we are looking for
vpcola 0:f1d3878b8dd9 184 * @returns a RemoteXBeeDM with the 16-bit and 64-bit address of the remote device whose node id matches with the parameter.
vpcola 0:f1d3878b8dd9 185 * If node is not found, the returned object will have invalid addresses (RemoteXBeeDM::is_valid() will return false).
vpcola 0:f1d3878b8dd9 186 */
vpcola 0:f1d3878b8dd9 187 RemoteXBeeDM get_remote_node_by_id(const char * const node_id);
vpcola 0:f1d3878b8dd9 188
vpcola 0:f1d3878b8dd9 189 /* Allow using XBee::set_param() methods for local radio from this class */
vpcola 0:f1d3878b8dd9 190 using XBee::set_param;
vpcola 0:f1d3878b8dd9 191
vpcola 0:f1d3878b8dd9 192 /** set_param - sets a parameter in a remote radio by sending an AT command and waiting for the response.
vpcola 0:f1d3878b8dd9 193 *
vpcola 0:f1d3878b8dd9 194 * @param remote remote device
vpcola 0:f1d3878b8dd9 195 * @param param parameter to be set.
vpcola 0:f1d3878b8dd9 196 * @param data the parameter value (4 bytes) to be set.
vpcola 0:f1d3878b8dd9 197 * @returns the command response status.
vpcola 0:f1d3878b8dd9 198 */
vpcola 0:f1d3878b8dd9 199 virtual AtCmdFrame::AtCmdResp set_param(const RemoteXBee& remote, const char * const param, uint32_t data);
vpcola 0:f1d3878b8dd9 200
vpcola 0:f1d3878b8dd9 201 /** set_param - sets a parameter in a remote radio by sending an AT command and waiting for the response.
vpcola 0:f1d3878b8dd9 202 *
vpcola 0:f1d3878b8dd9 203 * @param remote remote device
vpcola 0:f1d3878b8dd9 204 * @param param parameter to be set.
vpcola 0:f1d3878b8dd9 205 * @param data the parameter value byte array (len bytes) to be set.
vpcola 0:f1d3878b8dd9 206 * @param len number of bytes of the parameter value.
vpcola 0:f1d3878b8dd9 207 * @returns the command response status.
vpcola 0:f1d3878b8dd9 208 */
vpcola 0:f1d3878b8dd9 209 virtual AtCmdFrame::AtCmdResp set_param(const RemoteXBee& remote, const char * const param, const uint8_t * data = NULL, uint16_t len = 0);
vpcola 0:f1d3878b8dd9 210
vpcola 0:f1d3878b8dd9 211 /* Allow using XBee::get_param() methods for local radio from this class */
vpcola 0:f1d3878b8dd9 212 using XBee::get_param;
vpcola 0:f1d3878b8dd9 213
vpcola 0:f1d3878b8dd9 214 /** get_param - gets a parameter from a remote radio by sending an AT command and waiting for the response.
vpcola 0:f1d3878b8dd9 215 *
vpcola 0:f1d3878b8dd9 216 * @param remote remote device
vpcola 0:f1d3878b8dd9 217 * @param param parameter to be get.
vpcola 0:f1d3878b8dd9 218 * @param data pointer where the param value (4 bytes) will be stored.
vpcola 0:f1d3878b8dd9 219 * @returns the command response status.
vpcola 0:f1d3878b8dd9 220 */
vpcola 0:f1d3878b8dd9 221 virtual AtCmdFrame::AtCmdResp get_param(const RemoteXBee& remote, const char * const param, uint32_t * const data);
vpcola 0:f1d3878b8dd9 222
vpcola 0:f1d3878b8dd9 223 /** get_param - gets a parameter from a remote radio by sending an AT command and waiting for the response.
vpcola 0:f1d3878b8dd9 224 *
vpcola 0:f1d3878b8dd9 225 * @param remote remote device
vpcola 0:f1d3878b8dd9 226 * @param param parameter to be get.
vpcola 0:f1d3878b8dd9 227 * @param data pointer where the param value (n bytes) will be stored.
vpcola 0:f1d3878b8dd9 228 * @param len pointer where the number of bytes of the param value will be stored.
vpcola 0:f1d3878b8dd9 229 * @returns the command response status.
vpcola 0:f1d3878b8dd9 230 */
vpcola 0:f1d3878b8dd9 231 virtual AtCmdFrame::AtCmdResp get_param(const RemoteXBee& remote, const char * const param, uint8_t * const data, uint16_t * const len);
vpcola 0:f1d3878b8dd9 232
vpcola 0:f1d3878b8dd9 233 /************************* IO member methods **************************/
vpcola 0:f1d3878b8dd9 234 /** set_pin_config - configures a radio IO line
vpcola 0:f1d3878b8dd9 235 *
vpcola 0:f1d3878b8dd9 236 * @param remote remote device
vpcola 0:f1d3878b8dd9 237 * @param line IO line being configured
vpcola 0:f1d3878b8dd9 238 * @param mode configuration mode for the selected line
vpcola 0:f1d3878b8dd9 239 * @returns
vpcola 0:f1d3878b8dd9 240 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 241 * Failure otherwise
vpcola 0:f1d3878b8dd9 242 */
vpcola 0:f1d3878b8dd9 243 RadioStatus set_pin_config(const RemoteXBee& remote, IoLine line, IoMode mode);
vpcola 0:f1d3878b8dd9 244
vpcola 0:f1d3878b8dd9 245 /** get_pin_config - gets the configuration of a radio IO line
vpcola 0:f1d3878b8dd9 246 *
vpcola 0:f1d3878b8dd9 247 * @param remote remote device
vpcola 0:f1d3878b8dd9 248 * @param line IO line being read to get its configuration
vpcola 0:f1d3878b8dd9 249 * @param mode pointer where the configuration will be stored
vpcola 0:f1d3878b8dd9 250 * @returns
vpcola 0:f1d3878b8dd9 251 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 252 * Failure otherwise
vpcola 0:f1d3878b8dd9 253 */
vpcola 0:f1d3878b8dd9 254 RadioStatus get_pin_config(const RemoteXBee& remote, IoLine line, IoMode * const mode);
vpcola 0:f1d3878b8dd9 255
vpcola 0:f1d3878b8dd9 256 /** set_dio - sets to low/high a DIO line
vpcola 0:f1d3878b8dd9 257 *
vpcola 0:f1d3878b8dd9 258 * @param remote remote device
vpcola 0:f1d3878b8dd9 259 * @param line DIO line being set
vpcola 0:f1d3878b8dd9 260 * @param val value that will be set in the DIO line
vpcola 0:f1d3878b8dd9 261 * @returns
vpcola 0:f1d3878b8dd9 262 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 263 * Failure otherwise
vpcola 0:f1d3878b8dd9 264 */
vpcola 0:f1d3878b8dd9 265 RadioStatus set_dio(const RemoteXBee& remote, IoLine line, DioVal val);
vpcola 0:f1d3878b8dd9 266
vpcola 0:f1d3878b8dd9 267 /** get_dio - read the value of a DIO configured as digital input
vpcola 0:f1d3878b8dd9 268 *
vpcola 0:f1d3878b8dd9 269 * @param remote remote device
vpcola 0:f1d3878b8dd9 270 * @param line DIO line being read
vpcola 0:f1d3878b8dd9 271 * @param val pointer where the DIO value read will be stored
vpcola 0:f1d3878b8dd9 272 * @returns
vpcola 0:f1d3878b8dd9 273 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 274 * Failure otherwise
vpcola 0:f1d3878b8dd9 275 */
vpcola 0:f1d3878b8dd9 276 RadioStatus get_dio(const RemoteXBee& remote, IoLine line, DioVal * const val);
vpcola 0:f1d3878b8dd9 277
vpcola 0:f1d3878b8dd9 278 /** get_adc - read the value of the espcified ADC line
vpcola 0:f1d3878b8dd9 279 *
vpcola 0:f1d3878b8dd9 280 * @param remote remote device
vpcola 0:f1d3878b8dd9 281 * @param line ADC line being read
vpcola 0:f1d3878b8dd9 282 * @param val pointer where the value read from hte ADC will be stored
vpcola 0:f1d3878b8dd9 283 * @returns
vpcola 0:f1d3878b8dd9 284 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 285 * Failure otherwise
vpcola 0:f1d3878b8dd9 286 */
vpcola 0:f1d3878b8dd9 287 RadioStatus get_adc(const RemoteXBee& remote, IoLine line, uint16_t * const val);
vpcola 0:f1d3878b8dd9 288
vpcola 0:f1d3878b8dd9 289 /** get_iosample - retrieves an @ref IOSampleDM from a remote node. This object can be used to get the remote node's ADC and DIO values.
vpcola 0:f1d3878b8dd9 290 *
vpcola 0:f1d3878b8dd9 291 * @param remote remote device
vpcola 0:f1d3878b8dd9 292 * @returns IOSampleDM object with the remote node's DIO and ADC values.
vpcola 0:f1d3878b8dd9 293 */
vpcola 0:f1d3878b8dd9 294 IOSampleDM get_iosample(const RemoteXBee& remote);
vpcola 0:f1d3878b8dd9 295
vpcola 0:f1d3878b8dd9 296 /** set_pwm - sets the duty cycle of a PWM line
vpcola 0:f1d3878b8dd9 297 *
vpcola 0:f1d3878b8dd9 298 * @param remote remote device
vpcola 0:f1d3878b8dd9 299 * @param line PWM line being set
vpcola 0:f1d3878b8dd9 300 * @param duty_cycle duty cycle that will be set in the PWM line
vpcola 0:f1d3878b8dd9 301 * @returns
vpcola 0:f1d3878b8dd9 302 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 303 * Failure otherwise
vpcola 0:f1d3878b8dd9 304 */
vpcola 0:f1d3878b8dd9 305 RadioStatus set_pwm(const RemoteXBee& remote, IoLine line, float duty_cycle);
vpcola 0:f1d3878b8dd9 306
vpcola 0:f1d3878b8dd9 307 /** set_pin_pull_up - enables or disables the internal pull-up resistor of a line
vpcola 0:f1d3878b8dd9 308 *
vpcola 0:f1d3878b8dd9 309 * @param remote remote device
vpcola 0:f1d3878b8dd9 310 * @param line line being configured for pull-up
vpcola 0:f1d3878b8dd9 311 * @param enable whether to enable the internal pull-up resistor.
vpcola 0:f1d3878b8dd9 312 * @returns
vpcola 0:f1d3878b8dd9 313 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 314 * Failure otherwise
vpcola 0:f1d3878b8dd9 315 */
vpcola 0:f1d3878b8dd9 316 RadioStatus set_pin_pull_up(const RemoteXBee& remote, IoLine line, bool enable);
vpcola 0:f1d3878b8dd9 317
vpcola 0:f1d3878b8dd9 318 /** enable_dio_change_detection - enables or disables the notification when a change is detected in a digital input line.
vpcola 0:f1d3878b8dd9 319 * In other words, it will force an IO Sample transmission when the DIO state changes. Only for DIO0 to DIO11.
vpcola 0:f1d3878b8dd9 320 *
vpcola 0:f1d3878b8dd9 321 * @param remote remote device
vpcola 0:f1d3878b8dd9 322 * @param line line being configured for pull-up
vpcola 0:f1d3878b8dd9 323 * @param enable whether to enable the internal pull-up resistor.
vpcola 0:f1d3878b8dd9 324 * @returns
vpcola 0:f1d3878b8dd9 325 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 326 * Failure otherwise
vpcola 0:f1d3878b8dd9 327 */
vpcola 0:f1d3878b8dd9 328 RadioStatus enable_dio_change_detection(const RemoteXBee& remote, IoLine line, bool enable);
vpcola 0:f1d3878b8dd9 329
vpcola 0:f1d3878b8dd9 330 /** config_poll_destination - configures to which node poll messages will be sent once module awakes if configured as
vpcola 0:f1d3878b8dd9 331 * an Indirect Msg Poller (CE==0x4).
vpcola 0:f1d3878b8dd9 332 * Consult the module's reference manual for more information.
vpcola 0:f1d3878b8dd9 333 *
vpcola 0:f1d3878b8dd9 334 * @param destination remote device where the poll messages will be sent
vpcola 0:f1d3878b8dd9 335 * @returns the result of the data transfer
vpcola 0:f1d3878b8dd9 336 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 337 * Failure otherwise
vpcola 0:f1d3878b8dd9 338 */
vpcola 0:f1d3878b8dd9 339 RadioStatus config_poll_destination(const RemoteXBee& destination);
vpcola 0:f1d3878b8dd9 340
vpcola 0:f1d3878b8dd9 341 protected:
vpcola 0:f1d3878b8dd9 342
vpcola 0:f1d3878b8dd9 343 /** Frame handler used for the node discovery. Registered when a callback function
vpcola 0:f1d3878b8dd9 344 * is registered */
vpcola 0:f1d3878b8dd9 345 FH_NodeDiscoveryDM *_nd_handler;
vpcola 0:f1d3878b8dd9 346
vpcola 0:f1d3878b8dd9 347 /** Frame handler used for the rx packets. Automatically registered when a callback
vpcola 0:f1d3878b8dd9 348 * function is registered */
vpcola 0:f1d3878b8dd9 349 FH_RxPacketDM *_rx_pkt_handler;
vpcola 0:f1d3878b8dd9 350
vpcola 0:f1d3878b8dd9 351 /** Frame handler used for the IO Data Sample packets. Automatically registered when a callback
vpcola 0:f1d3878b8dd9 352 * function is registered */
vpcola 0:f1d3878b8dd9 353 FH_IoDataSampeDM *_io_data_handler;
vpcola 0:f1d3878b8dd9 354
vpcola 0:f1d3878b8dd9 355 /** Method called directly by the library when a modem status frame is received to
vpcola 0:f1d3878b8dd9 356 * update the internal status variables */
vpcola 0:f1d3878b8dd9 357 virtual void radio_status_update(AtCmdFrame::ModemStatus modem_status);
vpcola 0:f1d3878b8dd9 358
vpcola 0:f1d3878b8dd9 359 /* Allow using XBee::send_data() methods from this class */
vpcola 0:f1d3878b8dd9 360 using XBee::send_data;
vpcola 0:f1d3878b8dd9 361
vpcola 0:f1d3878b8dd9 362 /** get_node_discovery_timeout - gets the node discovery timeout
vpcola 0:f1d3878b8dd9 363 *
vpcola 0:f1d3878b8dd9 364 * @param timeout_ms pointer where the node discovery timeout value will be stored
vpcola 0:f1d3878b8dd9 365 * @param wait_for_complete_timeout pointer where the function will store if the operator
vpcola 0:f1d3878b8dd9 366 * has to wait for the complete nd timeout after issuing
vpcola 0:f1d3878b8dd9 367 * a directed nd request
vpcola 0:f1d3878b8dd9 368 * @returns
vpcola 0:f1d3878b8dd9 369 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 370 * Failure otherwise
vpcola 0:f1d3878b8dd9 371 */
vpcola 0:f1d3878b8dd9 372 virtual RadioStatus get_node_discovery_timeout(uint16_t * const timeout_ms);
vpcola 0:f1d3878b8dd9 373 virtual RadioStatus get_node_discovery_timeout(uint16_t * const timeout_ms, bool * const wait_for_complete_timeout);
vpcola 0:f1d3878b8dd9 374 };
vpcola 0:f1d3878b8dd9 375
vpcola 0:f1d3878b8dd9 376 } /* namespace XBeeLib */
vpcola 0:f1d3878b8dd9 377
vpcola 0:f1d3878b8dd9 378 #endif /* __XBEE_DM_H_ */