lel
Fork of XBeeLib by
XBeeDM/XBeeDM.h@8:b5f4a0e92249, 2016-07-29 (annotated)
- Committer:
- hbujanda
- Date:
- Fri Jul 29 12:10:38 2016 +0200
- Revision:
- 8:b5f4a0e92249
- Parent:
- 7:3ac2a461ce76
- Child:
- 9:780db84ce891
Automatic upload
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 | 8:b5f4a0e92249 | 107 | /** set_tc_link_key - Sets key used for encryption and decryption (ZigBee trust center link key). |
hbujanda | 6:06522f3a6642 | 108 | * It is not recommended to set the key programmatically, because it could be read through the raw serial port bits. |
hbujanda | 6:06522f3a6642 | 109 | * @param key pointer to the 128-bit AES key |
hbujanda | 6:06522f3a6642 | 110 | * @param length size of the buffer pointed by 'key' |
hbujanda | 6:06522f3a6642 | 111 | * @returns |
hbujanda | 6:06522f3a6642 | 112 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 113 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 114 | */ |
hbujanda | 8:b5f4a0e92249 | 115 | RadioStatus set_tc_link_key(const uint8_t * const key, const uint16_t length); |
hbujanda | 6:06522f3a6642 | 116 | |
hbujanda | 6:06522f3a6642 | 117 | /** register_node_discovery_cb - registers the callback function that will be called |
hbujanda | 6:06522f3a6642 | 118 | * when the responses to the node discovery command arrive |
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_node_discovery_cb(node_discovery_dm_cb_t function); |
hbujanda | 6:06522f3a6642 | 123 | |
hbujanda | 6:06522f3a6642 | 124 | /** unregister_node_discovery_cb - removes the node discovery callback */ |
hbujanda | 6:06522f3a6642 | 125 | void unregister_node_discovery_cb(); |
hbujanda | 6:06522f3a6642 | 126 | |
hbujanda | 6:06522f3a6642 | 127 | /** register_receive_cb - registers the callback function that will be called |
hbujanda | 6:06522f3a6642 | 128 | * when a 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_receive_cb(receive_dm_cb_t function); |
hbujanda | 6:06522f3a6642 | 133 | |
hbujanda | 6:06522f3a6642 | 134 | /** unregister_receive_cb - removes the rx packet callback */ |
hbujanda | 6:06522f3a6642 | 135 | void unregister_receive_cb(); |
hbujanda | 6:06522f3a6642 | 136 | |
hbujanda | 6:06522f3a6642 | 137 | /** register_io_sample_cb - registers the callback function that will be called |
hbujanda | 6:06522f3a6642 | 138 | * when a IO Sample Data packet is received |
hbujanda | 6:06522f3a6642 | 139 | * |
hbujanda | 6:06522f3a6642 | 140 | * @param function function pointer with the callback function |
hbujanda | 6:06522f3a6642 | 141 | */ |
hbujanda | 6:06522f3a6642 | 142 | void register_io_sample_cb(io_data_cb_dm_t function); |
hbujanda | 6:06522f3a6642 | 143 | |
hbujanda | 6:06522f3a6642 | 144 | /** unregister_io_sample_cb - removes the IO Sample Data reception callback */ |
hbujanda | 6:06522f3a6642 | 145 | void unregister_io_sample_cb(); |
hbujanda | 6:06522f3a6642 | 146 | |
hbujanda | 6:06522f3a6642 | 147 | /*********************** send_data member methods ************************/ |
hbujanda | 6:06522f3a6642 | 148 | /** send_data - sends data to a remote device |
hbujanda | 6:06522f3a6642 | 149 | * |
hbujanda | 6:06522f3a6642 | 150 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 151 | * @param data pointer to the data that will be sent |
hbujanda | 6:06522f3a6642 | 152 | * @param len number of bytes that will be transmitted |
hbujanda | 6:06522f3a6642 | 153 | * @param syncr if true, method waits for the packet answer with the result of the operation |
hbujanda | 6:06522f3a6642 | 154 | * @returns the result of the data transfer |
hbujanda | 6:06522f3a6642 | 155 | * TxStatusSuccess if the operation was successful, |
hbujanda | 6:06522f3a6642 | 156 | * the error code otherwise |
hbujanda | 6:06522f3a6642 | 157 | */ |
hbujanda | 6:06522f3a6642 | 158 | virtual TxStatus send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len, bool syncr = true); |
hbujanda | 6:06522f3a6642 | 159 | |
hbujanda | 6:06522f3a6642 | 160 | /** send_data - sends data to a remote device. This method uses |
hbujanda | 6:06522f3a6642 | 161 | * the explicit addressing frame, allowing to use source and |
hbujanda | 6:06522f3a6642 | 162 | * destination end points and cluster and profile IDs |
hbujanda | 6:06522f3a6642 | 163 | * |
hbujanda | 6:06522f3a6642 | 164 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 165 | * @param source_ep source end point |
hbujanda | 6:06522f3a6642 | 166 | * @param dest_ep destination end point |
hbujanda | 6:06522f3a6642 | 167 | * @param cluster_id cluster ID |
hbujanda | 6:06522f3a6642 | 168 | * @param profile_id profile ID |
hbujanda | 6:06522f3a6642 | 169 | * @param data pointer to the data that will be sent |
hbujanda | 6:06522f3a6642 | 170 | * @param len number of bytes that will be transmitted |
hbujanda | 6:06522f3a6642 | 171 | * @param syncr if true, method waits for the packet answer with the result of the operation |
hbujanda | 6:06522f3a6642 | 172 | * @returns the result of the data transfer |
hbujanda | 6:06522f3a6642 | 173 | * TxStatusSuccess if the operation was successful, |
hbujanda | 6:06522f3a6642 | 174 | * the error code otherwise |
hbujanda | 6:06522f3a6642 | 175 | */ |
hbujanda | 6:06522f3a6642 | 176 | TxStatus send_data(const RemoteXBee& remote, uint8_t source_ep, |
hbujanda | 6:06522f3a6642 | 177 | uint8_t dest_ep, uint16_t cluster_id, uint16_t profile_id, |
hbujanda | 6:06522f3a6642 | 178 | const uint8_t *const data, uint16_t len, bool syncr = true); |
hbujanda | 6:06522f3a6642 | 179 | |
hbujanda | 6:06522f3a6642 | 180 | /** send_data_to_coordinator - sends data to the ZigBee coordinator |
hbujanda | 6:06522f3a6642 | 181 | * |
hbujanda | 6:06522f3a6642 | 182 | * @param data pointer to the data that will be sent |
hbujanda | 6:06522f3a6642 | 183 | * @param len number of bytes that will be transmitted |
hbujanda | 6:06522f3a6642 | 184 | * @param syncr if true, method waits for the packet answer with the result of the operation |
hbujanda | 6:06522f3a6642 | 185 | * @returns the result of the data transfer |
hbujanda | 6:06522f3a6642 | 186 | * TxStatusSuccess if the operation was successful, |
hbujanda | 6:06522f3a6642 | 187 | * the error code otherwise |
hbujanda | 6:06522f3a6642 | 188 | */ |
hbujanda | 6:06522f3a6642 | 189 | TxStatus send_data_to_coordinator(const uint8_t *const data, uint16_t len, bool syncr = true); |
hbujanda | 6:06522f3a6642 | 190 | |
hbujanda | 6:06522f3a6642 | 191 | /** get_remote_node_by_id - searches for a device in the network with the specified Node Identifier. |
hbujanda | 6:06522f3a6642 | 192 | * |
hbujanda | 6:06522f3a6642 | 193 | * @param node_id node id of the device we are looking for |
hbujanda | 6:06522f3a6642 | 194 | * @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 | 195 | * If node is not found, the returned object will have invalid addresses (RemoteXBeeDM::is_valid() will return false). |
hbujanda | 6:06522f3a6642 | 196 | */ |
hbujanda | 6:06522f3a6642 | 197 | RemoteXBeeDM get_remote_node_by_id(const char * const node_id); |
hbujanda | 6:06522f3a6642 | 198 | |
hbujanda | 6:06522f3a6642 | 199 | /* Allow using XBee::set_param() methods for local radio from this class */ |
hbujanda | 6:06522f3a6642 | 200 | using XBee::set_param; |
hbujanda | 6:06522f3a6642 | 201 | |
hbujanda | 6:06522f3a6642 | 202 | /** set_param - sets a parameter in a remote radio by sending an AT command and waiting for the response. |
hbujanda | 6:06522f3a6642 | 203 | * |
hbujanda | 6:06522f3a6642 | 204 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 205 | * @param param parameter to be set. |
hbujanda | 6:06522f3a6642 | 206 | * @param data the parameter value (4 bytes) to be set. |
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, uint32_t data); |
hbujanda | 6:06522f3a6642 | 210 | |
hbujanda | 6:06522f3a6642 | 211 | /** set_param - sets a parameter in a remote radio by sending an AT command and waiting for the response. |
hbujanda | 6:06522f3a6642 | 212 | * |
hbujanda | 6:06522f3a6642 | 213 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 214 | * @param param parameter to be set. |
hbujanda | 6:06522f3a6642 | 215 | * @param data the parameter value byte array (len bytes) to be set. |
hbujanda | 6:06522f3a6642 | 216 | * @param len number of bytes of the parameter value. |
hbujanda | 6:06522f3a6642 | 217 | * @returns the command response status. |
hbujanda | 6:06522f3a6642 | 218 | */ |
hbujanda | 6:06522f3a6642 | 219 | virtual AtCmdFrame::AtCmdResp set_param(const RemoteXBee& remote, const char * const param, const uint8_t * data = NULL, uint16_t len = 0); |
hbujanda | 6:06522f3a6642 | 220 | |
hbujanda | 6:06522f3a6642 | 221 | /* Allow using XBee::get_param() methods for local radio from this class */ |
hbujanda | 6:06522f3a6642 | 222 | using XBee::get_param; |
hbujanda | 6:06522f3a6642 | 223 | |
hbujanda | 6:06522f3a6642 | 224 | /** get_param - gets a parameter from a remote radio by sending an AT command and waiting for the response. |
hbujanda | 6:06522f3a6642 | 225 | * |
hbujanda | 6:06522f3a6642 | 226 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 227 | * @param param parameter to be get. |
hbujanda | 6:06522f3a6642 | 228 | * @param data pointer where the param value (4 bytes) 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, uint32_t * const data); |
hbujanda | 6:06522f3a6642 | 232 | |
hbujanda | 6:06522f3a6642 | 233 | /** get_param - gets a parameter from a remote radio by sending an AT command and waiting for the response. |
hbujanda | 6:06522f3a6642 | 234 | * |
hbujanda | 6:06522f3a6642 | 235 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 236 | * @param param parameter to be get. |
hbujanda | 6:06522f3a6642 | 237 | * @param data pointer where the param value (n bytes) will be stored. |
hbujanda | 6:06522f3a6642 | 238 | * @param len pointer where the number of bytes of the param value will be stored. |
hbujanda | 6:06522f3a6642 | 239 | * @returns the command response status. |
hbujanda | 6:06522f3a6642 | 240 | */ |
hbujanda | 6:06522f3a6642 | 241 | virtual AtCmdFrame::AtCmdResp get_param(const RemoteXBee& remote, const char * const param, uint8_t * const data, uint16_t * const len); |
hbujanda | 6:06522f3a6642 | 242 | |
hbujanda | 6:06522f3a6642 | 243 | /************************* IO member methods **************************/ |
hbujanda | 6:06522f3a6642 | 244 | /** set_pin_config - configures a radio IO line |
hbujanda | 6:06522f3a6642 | 245 | * |
hbujanda | 6:06522f3a6642 | 246 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 247 | * @param line IO line being configured |
hbujanda | 6:06522f3a6642 | 248 | * @param mode configuration mode for the selected line |
hbujanda | 6:06522f3a6642 | 249 | * @returns |
hbujanda | 6:06522f3a6642 | 250 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 251 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 252 | */ |
hbujanda | 6:06522f3a6642 | 253 | RadioStatus set_pin_config(const RemoteXBee& remote, IoLine line, IoMode mode); |
hbujanda | 6:06522f3a6642 | 254 | |
hbujanda | 6:06522f3a6642 | 255 | /** get_pin_config - gets the configuration of a radio IO line |
hbujanda | 6:06522f3a6642 | 256 | * |
hbujanda | 6:06522f3a6642 | 257 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 258 | * @param line IO line being read to get its configuration |
hbujanda | 6:06522f3a6642 | 259 | * @param mode pointer where the configuration will be stored |
hbujanda | 6:06522f3a6642 | 260 | * @returns |
hbujanda | 6:06522f3a6642 | 261 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 262 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 263 | */ |
hbujanda | 6:06522f3a6642 | 264 | RadioStatus get_pin_config(const RemoteXBee& remote, IoLine line, IoMode * const mode); |
hbujanda | 6:06522f3a6642 | 265 | |
hbujanda | 6:06522f3a6642 | 266 | /** set_dio - sets to low/high a DIO line |
hbujanda | 6:06522f3a6642 | 267 | * |
hbujanda | 6:06522f3a6642 | 268 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 269 | * @param line DIO line being set |
hbujanda | 6:06522f3a6642 | 270 | * @param val value that will be set in the DIO line |
hbujanda | 6:06522f3a6642 | 271 | * @returns |
hbujanda | 6:06522f3a6642 | 272 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 273 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 274 | */ |
hbujanda | 6:06522f3a6642 | 275 | RadioStatus set_dio(const RemoteXBee& remote, IoLine line, DioVal val); |
hbujanda | 6:06522f3a6642 | 276 | |
hbujanda | 6:06522f3a6642 | 277 | /** get_dio - read the value of a DIO configured as digital input |
hbujanda | 6:06522f3a6642 | 278 | * |
hbujanda | 6:06522f3a6642 | 279 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 280 | * @param line DIO line being read |
hbujanda | 6:06522f3a6642 | 281 | * @param val pointer where the DIO value read will be stored |
hbujanda | 6:06522f3a6642 | 282 | * @returns |
hbujanda | 6:06522f3a6642 | 283 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 284 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 285 | */ |
hbujanda | 6:06522f3a6642 | 286 | RadioStatus get_dio(const RemoteXBee& remote, IoLine line, DioVal * const val); |
hbujanda | 6:06522f3a6642 | 287 | |
hbujanda | 6:06522f3a6642 | 288 | /** get_adc - read the value of the espcified ADC line |
hbujanda | 6:06522f3a6642 | 289 | * |
hbujanda | 6:06522f3a6642 | 290 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 291 | * @param line ADC line being read |
hbujanda | 6:06522f3a6642 | 292 | * @param val pointer where the value read from hte ADC will be stored |
hbujanda | 6:06522f3a6642 | 293 | * @returns |
hbujanda | 6:06522f3a6642 | 294 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 295 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 296 | */ |
hbujanda | 6:06522f3a6642 | 297 | RadioStatus get_adc(const RemoteXBee& remote, IoLine line, uint16_t * const val); |
hbujanda | 6:06522f3a6642 | 298 | |
hbujanda | 6:06522f3a6642 | 299 | /** 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 | 300 | * |
hbujanda | 6:06522f3a6642 | 301 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 302 | * @returns IOSampleDM object with the remote node's DIO and ADC values. |
hbujanda | 6:06522f3a6642 | 303 | */ |
hbujanda | 6:06522f3a6642 | 304 | IOSampleDM get_iosample(const RemoteXBee& remote); |
hbujanda | 6:06522f3a6642 | 305 | |
hbujanda | 6:06522f3a6642 | 306 | /** set_pwm - sets the duty cycle of a PWM line |
hbujanda | 6:06522f3a6642 | 307 | * |
hbujanda | 6:06522f3a6642 | 308 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 309 | * @param line PWM line being set |
hbujanda | 6:06522f3a6642 | 310 | * @param duty_cycle duty cycle that will be set in the PWM line |
hbujanda | 6:06522f3a6642 | 311 | * @returns |
hbujanda | 6:06522f3a6642 | 312 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 313 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 314 | */ |
hbujanda | 6:06522f3a6642 | 315 | RadioStatus set_pwm(const RemoteXBee& remote, IoLine line, float duty_cycle); |
hbujanda | 6:06522f3a6642 | 316 | |
hbujanda | 6:06522f3a6642 | 317 | /** set_pin_pull_up - enables or disables the internal pull-up resistor of a line |
hbujanda | 6:06522f3a6642 | 318 | * |
hbujanda | 6:06522f3a6642 | 319 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 320 | * @param line line being configured for pull-up |
hbujanda | 6:06522f3a6642 | 321 | * @param enable whether to enable the internal pull-up resistor. |
hbujanda | 6:06522f3a6642 | 322 | * @returns |
hbujanda | 6:06522f3a6642 | 323 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 324 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 325 | */ |
hbujanda | 6:06522f3a6642 | 326 | RadioStatus set_pin_pull_up(const RemoteXBee& remote, IoLine line, bool enable); |
hbujanda | 6:06522f3a6642 | 327 | |
hbujanda | 6:06522f3a6642 | 328 | /** enable_dio_change_detection - enables or disables the notification when a change is detected in a digital input line. |
hbujanda | 6:06522f3a6642 | 329 | * In other words, it will force an IO Sample transmission when the DIO state changes. Only for DIO0 to DIO11. |
hbujanda | 6:06522f3a6642 | 330 | * |
hbujanda | 6:06522f3a6642 | 331 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 332 | * @param line line being configured for pull-up |
hbujanda | 6:06522f3a6642 | 333 | * @param enable whether to enable the internal pull-up resistor. |
hbujanda | 6:06522f3a6642 | 334 | * @returns |
hbujanda | 6:06522f3a6642 | 335 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 336 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 337 | */ |
hbujanda | 6:06522f3a6642 | 338 | RadioStatus enable_dio_change_detection(const RemoteXBee& remote, IoLine line, bool enable); |
hbujanda | 6:06522f3a6642 | 339 | |
hbujanda | 7:3ac2a461ce76 | 340 | /** config_poll_destination - configures to which node poll messages will be sent once module awakes if configured as |
hbujanda | 7:3ac2a461ce76 | 341 | * an Indirect Msg Poller (CE==0x4). |
hbujanda | 7:3ac2a461ce76 | 342 | * Consult the module's reference manual for more information. |
hbujanda | 7:3ac2a461ce76 | 343 | * |
hbujanda | 7:3ac2a461ce76 | 344 | * @param destination remote device where the poll messages will be sent |
hbujanda | 7:3ac2a461ce76 | 345 | * @returns the result of the data transfer |
hbujanda | 7:3ac2a461ce76 | 346 | * Success if the operation was successful, |
hbujanda | 7:3ac2a461ce76 | 347 | * Failure otherwise |
hbujanda | 7:3ac2a461ce76 | 348 | */ |
hbujanda | 7:3ac2a461ce76 | 349 | RadioStatus config_poll_destination(const RemoteXBee& destination); |
hbujanda | 7:3ac2a461ce76 | 350 | |
hbujanda | 6:06522f3a6642 | 351 | protected: |
hbujanda | 6:06522f3a6642 | 352 | |
hbujanda | 6:06522f3a6642 | 353 | /** Frame handler used for the node discovery. Registered when a callback function |
hbujanda | 6:06522f3a6642 | 354 | * is registered */ |
hbujanda | 6:06522f3a6642 | 355 | FH_NodeDiscoveryDM *_nd_handler; |
hbujanda | 6:06522f3a6642 | 356 | |
hbujanda | 6:06522f3a6642 | 357 | /** Frame handler used for the rx packets. Automatically registered when a callback |
hbujanda | 6:06522f3a6642 | 358 | * function is registered */ |
hbujanda | 6:06522f3a6642 | 359 | FH_RxPacketDM *_rx_pkt_handler; |
hbujanda | 6:06522f3a6642 | 360 | |
hbujanda | 6:06522f3a6642 | 361 | /** Frame handler used for the IO Data Sample packets. Automatically registered when a callback |
hbujanda | 6:06522f3a6642 | 362 | * function is registered */ |
hbujanda | 6:06522f3a6642 | 363 | FH_IoDataSampeDM *_io_data_handler; |
hbujanda | 6:06522f3a6642 | 364 | |
hbujanda | 6:06522f3a6642 | 365 | /** Method called directly by the library when a modem status frame is received to |
hbujanda | 6:06522f3a6642 | 366 | * update the internal status variables */ |
hbujanda | 6:06522f3a6642 | 367 | virtual void radio_status_update(AtCmdFrame::ModemStatus modem_status); |
hbujanda | 6:06522f3a6642 | 368 | |
hbujanda | 6:06522f3a6642 | 369 | /* Allow using XBee::send_data() methods from this class */ |
hbujanda | 6:06522f3a6642 | 370 | using XBee::send_data; |
hbujanda | 6:06522f3a6642 | 371 | |
hbujanda | 6:06522f3a6642 | 372 | /** get_node_discovery_timeout - gets the node discovery timeout |
hbujanda | 6:06522f3a6642 | 373 | * |
hbujanda | 6:06522f3a6642 | 374 | * @param timeout_ms pointer where the node discovery timeout value will be stored |
hbujanda | 6:06522f3a6642 | 375 | * @param wait_for_complete_timeout pointer where the function will store if the operator |
hbujanda | 6:06522f3a6642 | 376 | * has to wait for the complete nd timeout after issuing |
hbujanda | 6:06522f3a6642 | 377 | * a directed nd request |
hbujanda | 6:06522f3a6642 | 378 | * @returns |
hbujanda | 6:06522f3a6642 | 379 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 380 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 381 | */ |
hbujanda | 6:06522f3a6642 | 382 | virtual RadioStatus get_node_discovery_timeout(uint16_t * const timeout_ms); |
hbujanda | 6:06522f3a6642 | 383 | virtual RadioStatus get_node_discovery_timeout(uint16_t * const timeout_ms, bool * const wait_for_complete_timeout); |
hbujanda | 6:06522f3a6642 | 384 | }; |
hbujanda | 6:06522f3a6642 | 385 | |
hbujanda | 6:06522f3a6642 | 386 | } /* namespace XBeeLib */ |
hbujanda | 6:06522f3a6642 | 387 | |
hbujanda | 6:06522f3a6642 | 388 | #endif /* __XBEE_DM_H_ */ |