Library to easily communicate with XBee modules.
Fork of XBeeLib by
XBeeDM/XBeeDM.h@6:06522f3a6642, 2016-07-28 (annotated)
- Committer:
- hbujanda
- Date:
- Thu Jul 28 10:17:20 2016 +0200
- Revision:
- 6:06522f3a6642
- Child:
- 7:3ac2a461ce76
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 | enum AssocStatus { |
hbujanda | 6:06522f3a6642 | 49 | ErrorReading = -1, /**< Error occurred when reading parameter. */ |
hbujanda | 6:06522f3a6642 | 50 | Joined = 0x00, /**< Successfully formed or joined a network. (Coordinators form a network, routers and end devices join a network.) */ |
hbujanda | 6:06522f3a6642 | 51 | NoPANs = 0x21, /**< Scan found no PANs */ |
hbujanda | 6:06522f3a6642 | 52 | NoValidPAN = 0x22, /**< Scan found no valid PANs based on current SC and ID settings */ |
hbujanda | 6:06522f3a6642 | 53 | JoinNotAllowed = 0x23, /**< Valid Coordinator or Routers found, but they are not allowing joining (NJ expired). */ |
hbujanda | 6:06522f3a6642 | 54 | NoBeacons = 0x24, /**< No joinable beacons were found. */ |
hbujanda | 6:06522f3a6642 | 55 | Unexpected = 0x25, /**< Unexpected state, node should not be attempting to join at this time. */ |
hbujanda | 6:06522f3a6642 | 56 | JoinFailed = 0x27, /**< Node Joining attempt failed (typically due to incompatible security settings). */ |
hbujanda | 6:06522f3a6642 | 57 | CoordStartFail = 0x2A, /**< Coordinator start attempt failed */ |
hbujanda | 6:06522f3a6642 | 58 | CheckingCoord = 0x2B, /**< Checking for an existing coordinator. */ |
hbujanda | 6:06522f3a6642 | 59 | LeaveFail = 0x2C, /**< Attempt to leave the network failed. */ |
hbujanda | 6:06522f3a6642 | 60 | JoinNoResponse = 0xAB, /**< Attempted to join a device that did not respond. */ |
hbujanda | 6:06522f3a6642 | 61 | SecKeyUnsec = 0xAC, /**< Secure join error - network security key received unsecured. */ |
hbujanda | 6:06522f3a6642 | 62 | SecKeyNotRec = 0xAD, /**< Secure join error - network security key not received. */ |
hbujanda | 6:06522f3a6642 | 63 | SecBadKey = 0xAF, /**< Secure join error - joining device does not have the right preconfigured link key. */ |
hbujanda | 6:06522f3a6642 | 64 | Scanning = 0xFF /**< Scanning for a ZigBee network (routers and end devices). */ |
hbujanda | 6:06522f3a6642 | 65 | }; |
hbujanda | 6:06522f3a6642 | 66 | |
hbujanda | 6:06522f3a6642 | 67 | /** Class constructor |
hbujanda | 6:06522f3a6642 | 68 | * @param tx the TX pin of the UART that will interface the XBee module |
hbujanda | 6:06522f3a6642 | 69 | * @param rx the RX pin of the UART that will interface the XBee module |
hbujanda | 6:06522f3a6642 | 70 | * @param reset the pin to which the XBee's reset line is attached to, use NC if not available |
hbujanda | 6:06522f3a6642 | 71 | * @param rts the RTS pin for the UART that will interface the XBee module, use NC if not available |
hbujanda | 6:06522f3a6642 | 72 | * @param cts the CTS pin for the UART that will interface the XBee module, use NC if not available |
hbujanda | 6:06522f3a6642 | 73 | * @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 | 74 | * to this baud rate (ATBD parameter). By default it is configured to 9600 bps |
hbujanda | 6:06522f3a6642 | 75 | */ |
hbujanda | 6:06522f3a6642 | 76 | XBeeDM(PinName tx, PinName rx, PinName reset = NC, PinName rts = NC, PinName cts = NC, int baud = 9600); |
hbujanda | 6:06522f3a6642 | 77 | |
hbujanda | 6:06522f3a6642 | 78 | /** Class destructor */ |
hbujanda | 6:06522f3a6642 | 79 | virtual ~XBeeDM(); |
hbujanda | 6:06522f3a6642 | 80 | |
hbujanda | 6:06522f3a6642 | 81 | /** init- initializes object |
hbujanda | 6:06522f3a6642 | 82 | * This function must be called just after creating the object so it initializes internal data. |
hbujanda | 6:06522f3a6642 | 83 | * @returns |
hbujanda | 6:06522f3a6642 | 84 | * Success if the module has been properly initialized and is ready to process data. |
hbujanda | 6:06522f3a6642 | 85 | * Failure otherwise. |
hbujanda | 6:06522f3a6642 | 86 | */ |
hbujanda | 6:06522f3a6642 | 87 | RadioStatus init(); |
hbujanda | 6:06522f3a6642 | 88 | |
hbujanda | 6:06522f3a6642 | 89 | /** set_channel - sets the channel number |
hbujanda | 6:06522f3a6642 | 90 | * |
hbujanda | 6:06522f3a6642 | 91 | * @param channel the channel in which the radio operates. Range is 0x0B - 0x1A for XBee and 0x0C - 0x17 for XBee-PRO. |
hbujanda | 6:06522f3a6642 | 92 | * The Center Frequency = 2.405 + (CH - 11) * 5 MHz |
hbujanda | 6:06522f3a6642 | 93 | * @returns |
hbujanda | 6:06522f3a6642 | 94 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 95 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 96 | */ |
hbujanda | 6:06522f3a6642 | 97 | RadioStatus set_channel(uint8_t channel); |
hbujanda | 6:06522f3a6642 | 98 | |
hbujanda | 6:06522f3a6642 | 99 | /** get_channel - gets the channel number |
hbujanda | 6:06522f3a6642 | 100 | * |
hbujanda | 6:06522f3a6642 | 101 | * @param channel pointer where the channel value will be stored. |
hbujanda | 6:06522f3a6642 | 102 | * @returns |
hbujanda | 6:06522f3a6642 | 103 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 104 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 105 | */ |
hbujanda | 6:06522f3a6642 | 106 | RadioStatus get_channel(uint8_t * const channel); |
hbujanda | 6:06522f3a6642 | 107 | |
hbujanda | 6:06522f3a6642 | 108 | /** set_network_id - sets the Network ID. |
hbujanda | 6:06522f3a6642 | 109 | * |
hbujanda | 6:06522f3a6642 | 110 | * @param network_id the Network ID value that will be set on the radio |
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 | 6:06522f3a6642 | 115 | RadioStatus set_network_id(uint16_t network_id); |
hbujanda | 6:06522f3a6642 | 116 | |
hbujanda | 6:06522f3a6642 | 117 | /** get_network_id - gets the Network ID, as it was set by @ref set_network_id(). |
hbujanda | 6:06522f3a6642 | 118 | * |
hbujanda | 6:06522f3a6642 | 119 | * @param network_id pointer where the Network ID will be stored |
hbujanda | 6:06522f3a6642 | 120 | * @returns |
hbujanda | 6:06522f3a6642 | 121 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 122 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 123 | */ |
hbujanda | 6:06522f3a6642 | 124 | RadioStatus get_network_id(uint16_t * const network_id); |
hbujanda | 6:06522f3a6642 | 125 | |
hbujanda | 6:06522f3a6642 | 126 | /** set_network_security_key - (Coordinator only) Set the 128-bit AES network encryption key. If set to 0 (default), the module will select a random network key. |
hbujanda | 6:06522f3a6642 | 127 | * It is not recommended to set the key programmatically, because it could be read through the raw serial port bits. |
hbujanda | 6:06522f3a6642 | 128 | * @param key pointer to the 128-bit AES key |
hbujanda | 6:06522f3a6642 | 129 | * @param length size of the buffer pointed by 'key' |
hbujanda | 6:06522f3a6642 | 130 | * @returns |
hbujanda | 6:06522f3a6642 | 131 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 132 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 133 | */ |
hbujanda | 6:06522f3a6642 | 134 | RadioStatus set_network_security_key(const uint8_t * const key, const uint16_t length); |
hbujanda | 6:06522f3a6642 | 135 | |
hbujanda | 6:06522f3a6642 | 136 | #define XBEE_DM_ENC_OPT_SEND_KEY_ON_JOIN 0x01 |
hbujanda | 6:06522f3a6642 | 137 | #define XBEE_DM_ENC_OPT_USE_TRUST_CENTER 0x02 |
hbujanda | 6:06522f3a6642 | 138 | /** set_encryption_options - Configure options for encryption. Unused option bits should be set to 0. Options include: |
hbujanda | 6:06522f3a6642 | 139 | * - XBEE_DM_ENC_OPT_SEND_KEY_ON_JOIN - Send the security key unsecured over-the-air during joins |
hbujanda | 6:06522f3a6642 | 140 | * - XBEE_DM_ENC_OPT_USE_TRUST_CENTER - Use trust center (coordinator only) |
hbujanda | 6:06522f3a6642 | 141 | * @param options bit mask with the encryption options |
hbujanda | 6:06522f3a6642 | 142 | * @returns |
hbujanda | 6:06522f3a6642 | 143 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 144 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 145 | */ |
hbujanda | 6:06522f3a6642 | 146 | RadioStatus set_encryption_options(const uint8_t options); |
hbujanda | 6:06522f3a6642 | 147 | |
hbujanda | 6:06522f3a6642 | 148 | /** register_node_discovery_cb - registers the callback function that will be called |
hbujanda | 6:06522f3a6642 | 149 | * when the responses to the node discovery command arrive |
hbujanda | 6:06522f3a6642 | 150 | * |
hbujanda | 6:06522f3a6642 | 151 | * @param function function pointer with the callback function |
hbujanda | 6:06522f3a6642 | 152 | */ |
hbujanda | 6:06522f3a6642 | 153 | void register_node_discovery_cb(node_discovery_dm_cb_t function); |
hbujanda | 6:06522f3a6642 | 154 | |
hbujanda | 6:06522f3a6642 | 155 | /** unregister_node_discovery_cb - removes the node discovery callback */ |
hbujanda | 6:06522f3a6642 | 156 | void unregister_node_discovery_cb(); |
hbujanda | 6:06522f3a6642 | 157 | |
hbujanda | 6:06522f3a6642 | 158 | /** register_receive_cb - registers the callback function that will be called |
hbujanda | 6:06522f3a6642 | 159 | * when a data packet is received |
hbujanda | 6:06522f3a6642 | 160 | * |
hbujanda | 6:06522f3a6642 | 161 | * @param function function pointer with the callback function |
hbujanda | 6:06522f3a6642 | 162 | */ |
hbujanda | 6:06522f3a6642 | 163 | void register_receive_cb(receive_dm_cb_t function); |
hbujanda | 6:06522f3a6642 | 164 | |
hbujanda | 6:06522f3a6642 | 165 | /** unregister_receive_cb - removes the rx packet callback */ |
hbujanda | 6:06522f3a6642 | 166 | void unregister_receive_cb(); |
hbujanda | 6:06522f3a6642 | 167 | |
hbujanda | 6:06522f3a6642 | 168 | /** register_io_sample_cb - registers the callback function that will be called |
hbujanda | 6:06522f3a6642 | 169 | * when a IO Sample Data packet is received |
hbujanda | 6:06522f3a6642 | 170 | * |
hbujanda | 6:06522f3a6642 | 171 | * @param function function pointer with the callback function |
hbujanda | 6:06522f3a6642 | 172 | */ |
hbujanda | 6:06522f3a6642 | 173 | void register_io_sample_cb(io_data_cb_dm_t function); |
hbujanda | 6:06522f3a6642 | 174 | |
hbujanda | 6:06522f3a6642 | 175 | /** unregister_io_sample_cb - removes the IO Sample Data reception callback */ |
hbujanda | 6:06522f3a6642 | 176 | void unregister_io_sample_cb(); |
hbujanda | 6:06522f3a6642 | 177 | |
hbujanda | 6:06522f3a6642 | 178 | /*********************** send_data member methods ************************/ |
hbujanda | 6:06522f3a6642 | 179 | /** send_data - sends data to a remote device |
hbujanda | 6:06522f3a6642 | 180 | * |
hbujanda | 6:06522f3a6642 | 181 | * @param remote remote device |
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 | virtual TxStatus send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len, bool syncr = true); |
hbujanda | 6:06522f3a6642 | 190 | |
hbujanda | 6:06522f3a6642 | 191 | /** send_data - sends data to a remote device. This method uses |
hbujanda | 6:06522f3a6642 | 192 | * the explicit addressing frame, allowing to use source and |
hbujanda | 6:06522f3a6642 | 193 | * destination end points and cluster and profile IDs |
hbujanda | 6:06522f3a6642 | 194 | * |
hbujanda | 6:06522f3a6642 | 195 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 196 | * @param source_ep source end point |
hbujanda | 6:06522f3a6642 | 197 | * @param dest_ep destination end point |
hbujanda | 6:06522f3a6642 | 198 | * @param cluster_id cluster ID |
hbujanda | 6:06522f3a6642 | 199 | * @param profile_id profile ID |
hbujanda | 6:06522f3a6642 | 200 | * @param data pointer to the data that will be sent |
hbujanda | 6:06522f3a6642 | 201 | * @param len number of bytes that will be transmitted |
hbujanda | 6:06522f3a6642 | 202 | * @param syncr if true, method waits for the packet answer with the result of the operation |
hbujanda | 6:06522f3a6642 | 203 | * @returns the result of the data transfer |
hbujanda | 6:06522f3a6642 | 204 | * TxStatusSuccess if the operation was successful, |
hbujanda | 6:06522f3a6642 | 205 | * the error code otherwise |
hbujanda | 6:06522f3a6642 | 206 | */ |
hbujanda | 6:06522f3a6642 | 207 | TxStatus send_data(const RemoteXBee& remote, uint8_t source_ep, |
hbujanda | 6:06522f3a6642 | 208 | uint8_t dest_ep, uint16_t cluster_id, uint16_t profile_id, |
hbujanda | 6:06522f3a6642 | 209 | const uint8_t *const data, uint16_t len, bool syncr = true); |
hbujanda | 6:06522f3a6642 | 210 | |
hbujanda | 6:06522f3a6642 | 211 | /** send_data_to_coordinator - sends data to the ZigBee coordinator |
hbujanda | 6:06522f3a6642 | 212 | * |
hbujanda | 6:06522f3a6642 | 213 | * @param data pointer to the data that will be sent |
hbujanda | 6:06522f3a6642 | 214 | * @param len number of bytes that will be transmitted |
hbujanda | 6:06522f3a6642 | 215 | * @param syncr if true, method waits for the packet answer with the result of the operation |
hbujanda | 6:06522f3a6642 | 216 | * @returns the result of the data transfer |
hbujanda | 6:06522f3a6642 | 217 | * TxStatusSuccess if the operation was successful, |
hbujanda | 6:06522f3a6642 | 218 | * the error code otherwise |
hbujanda | 6:06522f3a6642 | 219 | */ |
hbujanda | 6:06522f3a6642 | 220 | TxStatus send_data_to_coordinator(const uint8_t *const data, uint16_t len, bool syncr = true); |
hbujanda | 6:06522f3a6642 | 221 | |
hbujanda | 6:06522f3a6642 | 222 | /** get_assoc_status - returns current network association status. This wraps AI parameter, for more information refer to moudle's Reference Manual. |
hbujanda | 6:06522f3a6642 | 223 | * |
hbujanda | 6:06522f3a6642 | 224 | * @returns an AssocStatus with current network association status. |
hbujanda | 6:06522f3a6642 | 225 | */ |
hbujanda | 6:06522f3a6642 | 226 | AssocStatus get_assoc_status(void); |
hbujanda | 6:06522f3a6642 | 227 | |
hbujanda | 6:06522f3a6642 | 228 | /** get_remote_node_by_id - searches for a device in the network with the specified Node Identifier. |
hbujanda | 6:06522f3a6642 | 229 | * |
hbujanda | 6:06522f3a6642 | 230 | * @param node_id node id of the device we are looking for |
hbujanda | 6:06522f3a6642 | 231 | * @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 | 232 | * If node is not found, the returned object will have invalid addresses (RemoteXBeeDM::is_valid() will return false). |
hbujanda | 6:06522f3a6642 | 233 | */ |
hbujanda | 6:06522f3a6642 | 234 | RemoteXBeeDM get_remote_node_by_id(const char * const node_id); |
hbujanda | 6:06522f3a6642 | 235 | |
hbujanda | 6:06522f3a6642 | 236 | /* Allow using XBee::set_param() methods for local radio from this class */ |
hbujanda | 6:06522f3a6642 | 237 | using XBee::set_param; |
hbujanda | 6:06522f3a6642 | 238 | |
hbujanda | 6:06522f3a6642 | 239 | /** set_param - sets a parameter in a remote radio by sending an AT command and waiting for the response. |
hbujanda | 6:06522f3a6642 | 240 | * |
hbujanda | 6:06522f3a6642 | 241 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 242 | * @param param parameter to be set. |
hbujanda | 6:06522f3a6642 | 243 | * @param data the parameter value (4 bytes) to be set. |
hbujanda | 6:06522f3a6642 | 244 | * @returns the command response status. |
hbujanda | 6:06522f3a6642 | 245 | */ |
hbujanda | 6:06522f3a6642 | 246 | virtual AtCmdFrame::AtCmdResp set_param(const RemoteXBee& remote, const char * const param, uint32_t data); |
hbujanda | 6:06522f3a6642 | 247 | |
hbujanda | 6:06522f3a6642 | 248 | /** set_param - sets a parameter in a remote radio by sending an AT command and waiting for the response. |
hbujanda | 6:06522f3a6642 | 249 | * |
hbujanda | 6:06522f3a6642 | 250 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 251 | * @param param parameter to be set. |
hbujanda | 6:06522f3a6642 | 252 | * @param data the parameter value byte array (len bytes) to be set. |
hbujanda | 6:06522f3a6642 | 253 | * @param len number of bytes of the parameter value. |
hbujanda | 6:06522f3a6642 | 254 | * @returns the command response status. |
hbujanda | 6:06522f3a6642 | 255 | */ |
hbujanda | 6:06522f3a6642 | 256 | virtual AtCmdFrame::AtCmdResp set_param(const RemoteXBee& remote, const char * const param, const uint8_t * data = NULL, uint16_t len = 0); |
hbujanda | 6:06522f3a6642 | 257 | |
hbujanda | 6:06522f3a6642 | 258 | /* Allow using XBee::get_param() methods for local radio from this class */ |
hbujanda | 6:06522f3a6642 | 259 | using XBee::get_param; |
hbujanda | 6:06522f3a6642 | 260 | |
hbujanda | 6:06522f3a6642 | 261 | /** get_param - gets a parameter from a remote radio by sending an AT command and waiting for the response. |
hbujanda | 6:06522f3a6642 | 262 | * |
hbujanda | 6:06522f3a6642 | 263 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 264 | * @param param parameter to be get. |
hbujanda | 6:06522f3a6642 | 265 | * @param data pointer where the param value (4 bytes) will be stored. |
hbujanda | 6:06522f3a6642 | 266 | * @returns the command response status. |
hbujanda | 6:06522f3a6642 | 267 | */ |
hbujanda | 6:06522f3a6642 | 268 | virtual AtCmdFrame::AtCmdResp get_param(const RemoteXBee& remote, const char * const param, uint32_t * const data); |
hbujanda | 6:06522f3a6642 | 269 | |
hbujanda | 6:06522f3a6642 | 270 | /** get_param - gets a parameter from a remote radio by sending an AT command and waiting for the response. |
hbujanda | 6:06522f3a6642 | 271 | * |
hbujanda | 6:06522f3a6642 | 272 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 273 | * @param param parameter to be get. |
hbujanda | 6:06522f3a6642 | 274 | * @param data pointer where the param value (n bytes) will be stored. |
hbujanda | 6:06522f3a6642 | 275 | * @param len pointer where the number of bytes of the param value will be stored. |
hbujanda | 6:06522f3a6642 | 276 | * @returns the command response status. |
hbujanda | 6:06522f3a6642 | 277 | */ |
hbujanda | 6:06522f3a6642 | 278 | virtual AtCmdFrame::AtCmdResp get_param(const RemoteXBee& remote, const char * const param, uint8_t * const data, uint16_t * const len); |
hbujanda | 6:06522f3a6642 | 279 | |
hbujanda | 6:06522f3a6642 | 280 | /************************* IO member methods **************************/ |
hbujanda | 6:06522f3a6642 | 281 | /** set_pin_config - configures a radio IO line |
hbujanda | 6:06522f3a6642 | 282 | * |
hbujanda | 6:06522f3a6642 | 283 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 284 | * @param line IO line being configured |
hbujanda | 6:06522f3a6642 | 285 | * @param mode configuration mode for the selected line |
hbujanda | 6:06522f3a6642 | 286 | * @returns |
hbujanda | 6:06522f3a6642 | 287 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 288 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 289 | */ |
hbujanda | 6:06522f3a6642 | 290 | RadioStatus set_pin_config(const RemoteXBee& remote, IoLine line, IoMode mode); |
hbujanda | 6:06522f3a6642 | 291 | |
hbujanda | 6:06522f3a6642 | 292 | /** get_pin_config - gets the configuration of a radio IO line |
hbujanda | 6:06522f3a6642 | 293 | * |
hbujanda | 6:06522f3a6642 | 294 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 295 | * @param line IO line being read to get its configuration |
hbujanda | 6:06522f3a6642 | 296 | * @param mode pointer where the configuration will be stored |
hbujanda | 6:06522f3a6642 | 297 | * @returns |
hbujanda | 6:06522f3a6642 | 298 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 299 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 300 | */ |
hbujanda | 6:06522f3a6642 | 301 | RadioStatus get_pin_config(const RemoteXBee& remote, IoLine line, IoMode * const mode); |
hbujanda | 6:06522f3a6642 | 302 | |
hbujanda | 6:06522f3a6642 | 303 | /** set_dio - sets to low/high a DIO line |
hbujanda | 6:06522f3a6642 | 304 | * |
hbujanda | 6:06522f3a6642 | 305 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 306 | * @param line DIO line being set |
hbujanda | 6:06522f3a6642 | 307 | * @param val value that will be set in the DIO line |
hbujanda | 6:06522f3a6642 | 308 | * @returns |
hbujanda | 6:06522f3a6642 | 309 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 310 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 311 | */ |
hbujanda | 6:06522f3a6642 | 312 | RadioStatus set_dio(const RemoteXBee& remote, IoLine line, DioVal val); |
hbujanda | 6:06522f3a6642 | 313 | |
hbujanda | 6:06522f3a6642 | 314 | /** get_dio - read the value of a DIO configured as digital input |
hbujanda | 6:06522f3a6642 | 315 | * |
hbujanda | 6:06522f3a6642 | 316 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 317 | * @param line DIO line being read |
hbujanda | 6:06522f3a6642 | 318 | * @param val pointer where the DIO value read will be stored |
hbujanda | 6:06522f3a6642 | 319 | * @returns |
hbujanda | 6:06522f3a6642 | 320 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 321 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 322 | */ |
hbujanda | 6:06522f3a6642 | 323 | RadioStatus get_dio(const RemoteXBee& remote, IoLine line, DioVal * const val); |
hbujanda | 6:06522f3a6642 | 324 | |
hbujanda | 6:06522f3a6642 | 325 | /** get_adc - read the value of the espcified ADC line |
hbujanda | 6:06522f3a6642 | 326 | * |
hbujanda | 6:06522f3a6642 | 327 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 328 | * @param line ADC line being read |
hbujanda | 6:06522f3a6642 | 329 | * @param val pointer where the value read from hte ADC will be stored |
hbujanda | 6:06522f3a6642 | 330 | * @returns |
hbujanda | 6:06522f3a6642 | 331 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 332 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 333 | */ |
hbujanda | 6:06522f3a6642 | 334 | RadioStatus get_adc(const RemoteXBee& remote, IoLine line, uint16_t * const val); |
hbujanda | 6:06522f3a6642 | 335 | |
hbujanda | 6:06522f3a6642 | 336 | /** 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 | 337 | * |
hbujanda | 6:06522f3a6642 | 338 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 339 | * @returns IOSampleDM object with the remote node's DIO and ADC values. |
hbujanda | 6:06522f3a6642 | 340 | */ |
hbujanda | 6:06522f3a6642 | 341 | IOSampleDM get_iosample(const RemoteXBee& remote); |
hbujanda | 6:06522f3a6642 | 342 | |
hbujanda | 6:06522f3a6642 | 343 | /** set_pwm - sets the duty cycle of a PWM line |
hbujanda | 6:06522f3a6642 | 344 | * |
hbujanda | 6:06522f3a6642 | 345 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 346 | * @param line PWM line being set |
hbujanda | 6:06522f3a6642 | 347 | * @param duty_cycle duty cycle that will be set in the PWM line |
hbujanda | 6:06522f3a6642 | 348 | * @returns |
hbujanda | 6:06522f3a6642 | 349 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 350 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 351 | */ |
hbujanda | 6:06522f3a6642 | 352 | RadioStatus set_pwm(const RemoteXBee& remote, IoLine line, float duty_cycle); |
hbujanda | 6:06522f3a6642 | 353 | |
hbujanda | 6:06522f3a6642 | 354 | /** set_pin_pull_up - enables or disables the internal pull-up resistor of a line |
hbujanda | 6:06522f3a6642 | 355 | * |
hbujanda | 6:06522f3a6642 | 356 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 357 | * @param line line being configured for pull-up |
hbujanda | 6:06522f3a6642 | 358 | * @param enable whether to enable the internal pull-up resistor. |
hbujanda | 6:06522f3a6642 | 359 | * @returns |
hbujanda | 6:06522f3a6642 | 360 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 361 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 362 | */ |
hbujanda | 6:06522f3a6642 | 363 | RadioStatus set_pin_pull_up(const RemoteXBee& remote, IoLine line, bool enable); |
hbujanda | 6:06522f3a6642 | 364 | |
hbujanda | 6:06522f3a6642 | 365 | /** enable_dio_change_detection - enables or disables the notification when a change is detected in a digital input line. |
hbujanda | 6:06522f3a6642 | 366 | * In other words, it will force an IO Sample transmission when the DIO state changes. Only for DIO0 to DIO11. |
hbujanda | 6:06522f3a6642 | 367 | * |
hbujanda | 6:06522f3a6642 | 368 | * @param remote remote device |
hbujanda | 6:06522f3a6642 | 369 | * @param line line being configured for pull-up |
hbujanda | 6:06522f3a6642 | 370 | * @param enable whether to enable the internal pull-up resistor. |
hbujanda | 6:06522f3a6642 | 371 | * @returns |
hbujanda | 6:06522f3a6642 | 372 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 373 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 374 | */ |
hbujanda | 6:06522f3a6642 | 375 | RadioStatus enable_dio_change_detection(const RemoteXBee& remote, IoLine line, bool enable); |
hbujanda | 6:06522f3a6642 | 376 | |
hbujanda | 6:06522f3a6642 | 377 | protected: |
hbujanda | 6:06522f3a6642 | 378 | |
hbujanda | 6:06522f3a6642 | 379 | /** Frame handler used for the node discovery. Registered when a callback function |
hbujanda | 6:06522f3a6642 | 380 | * is registered */ |
hbujanda | 6:06522f3a6642 | 381 | FH_NodeDiscoveryDM *_nd_handler; |
hbujanda | 6:06522f3a6642 | 382 | |
hbujanda | 6:06522f3a6642 | 383 | /** Frame handler used for the rx packets. Automatically registered when a callback |
hbujanda | 6:06522f3a6642 | 384 | * function is registered */ |
hbujanda | 6:06522f3a6642 | 385 | FH_RxPacketDM *_rx_pkt_handler; |
hbujanda | 6:06522f3a6642 | 386 | |
hbujanda | 6:06522f3a6642 | 387 | /** Frame handler used for the IO Data Sample packets. Automatically registered when a callback |
hbujanda | 6:06522f3a6642 | 388 | * function is registered */ |
hbujanda | 6:06522f3a6642 | 389 | FH_IoDataSampeDM *_io_data_handler; |
hbujanda | 6:06522f3a6642 | 390 | |
hbujanda | 6:06522f3a6642 | 391 | /** Method called directly by the library when a modem status frame is received to |
hbujanda | 6:06522f3a6642 | 392 | * update the internal status variables */ |
hbujanda | 6:06522f3a6642 | 393 | virtual void radio_status_update(AtCmdFrame::ModemStatus modem_status); |
hbujanda | 6:06522f3a6642 | 394 | |
hbujanda | 6:06522f3a6642 | 395 | /* Allow using XBee::send_data() methods from this class */ |
hbujanda | 6:06522f3a6642 | 396 | using XBee::send_data; |
hbujanda | 6:06522f3a6642 | 397 | |
hbujanda | 6:06522f3a6642 | 398 | /** get_node_discovery_timeout - gets the node discovery timeout |
hbujanda | 6:06522f3a6642 | 399 | * |
hbujanda | 6:06522f3a6642 | 400 | * @param timeout_ms pointer where the node discovery timeout value will be stored |
hbujanda | 6:06522f3a6642 | 401 | * @param wait_for_complete_timeout pointer where the function will store if the operator |
hbujanda | 6:06522f3a6642 | 402 | * has to wait for the complete nd timeout after issuing |
hbujanda | 6:06522f3a6642 | 403 | * a directed nd request |
hbujanda | 6:06522f3a6642 | 404 | * @returns |
hbujanda | 6:06522f3a6642 | 405 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 406 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 407 | */ |
hbujanda | 6:06522f3a6642 | 408 | virtual RadioStatus get_node_discovery_timeout(uint16_t * const timeout_ms); |
hbujanda | 6:06522f3a6642 | 409 | virtual RadioStatus get_node_discovery_timeout(uint16_t * const timeout_ms, bool * const wait_for_complete_timeout); |
hbujanda | 6:06522f3a6642 | 410 | }; |
hbujanda | 6:06522f3a6642 | 411 | |
hbujanda | 6:06522f3a6642 | 412 | } /* namespace XBeeLib */ |
hbujanda | 6:06522f3a6642 | 413 | |
hbujanda | 6:06522f3a6642 | 414 | #endif /* __XBEE_DM_H_ */ |