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