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