Fork of my MQTTGateway

Dependencies:   mbed-http

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

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vpcola 0:f1d3878b8dd9 1 /**
vpcola 0:f1d3878b8dd9 2 * Copyright (c) 2015 Digi International Inc.,
vpcola 0:f1d3878b8dd9 3 * All rights not expressly granted are reserved.
vpcola 0:f1d3878b8dd9 4 *
vpcola 0:f1d3878b8dd9 5 * This Source Code Form is subject to the terms of the Mozilla Public
vpcola 0:f1d3878b8dd9 6 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
vpcola 0:f1d3878b8dd9 7 * You can obtain one at http://mozilla.org/MPL/2.0/.
vpcola 0:f1d3878b8dd9 8 *
vpcola 0:f1d3878b8dd9 9 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
vpcola 0:f1d3878b8dd9 10 * =======================================================================
vpcola 0:f1d3878b8dd9 11 */
vpcola 0:f1d3878b8dd9 12
vpcola 0:f1d3878b8dd9 13 #if !defined(__XBEE_ZB_H_)
vpcola 0:f1d3878b8dd9 14 #define __XBEE_ZB_H_
vpcola 0:f1d3878b8dd9 15
vpcola 0:f1d3878b8dd9 16 #include "XBee/XBee.h"
vpcola 0:f1d3878b8dd9 17 #include "FrameHandlers/FH_AtCmdResp.h"
vpcola 0:f1d3878b8dd9 18 #include "FrameHandlers/FH_RxPacketZB.h"
vpcola 0:f1d3878b8dd9 19 #include "FrameHandlers/FH_IoDataSampleZB.h"
vpcola 0:f1d3878b8dd9 20 #include "RemoteXBee/RemoteXBee.h"
vpcola 0:f1d3878b8dd9 21
vpcola 0:f1d3878b8dd9 22 namespace XBeeLib {
vpcola 0:f1d3878b8dd9 23
vpcola 0:f1d3878b8dd9 24 /** Class for XBee ZigBee modules, derived from XBee */
vpcola 0:f1d3878b8dd9 25 class XBeeZB : public XBee
vpcola 0:f1d3878b8dd9 26 {
vpcola 0:f1d3878b8dd9 27 public:
vpcola 0:f1d3878b8dd9 28
vpcola 0:f1d3878b8dd9 29 /**
vpcola 0:f1d3878b8dd9 30 * IoLine for XBeeZB Modules
vpcola 0:f1d3878b8dd9 31 */
vpcola 0:f1d3878b8dd9 32 enum IoLine {
vpcola 0:f1d3878b8dd9 33 DIO0_AD0 = 0, /**< DIO0_AD0 pin */
vpcola 0:f1d3878b8dd9 34 DIO1_AD1 = 1, /**< DIO1_AD1 pin */
vpcola 0:f1d3878b8dd9 35 DIO2_AD2 = 2, /**< DIO2_AD2 pin */
vpcola 0:f1d3878b8dd9 36 DIO3_AD3 = 3, /**< DIO3_AD3 pin */
vpcola 0:f1d3878b8dd9 37 DIO4 = 4, /**< DIO4 pin */
vpcola 0:f1d3878b8dd9 38 DIO5 = 5, /**< DIO5 pin */
vpcola 0:f1d3878b8dd9 39 DIO6 = 6, /**< DIO6 pin */
vpcola 0:f1d3878b8dd9 40 DIO7 = 7, /**< DIO7 pin */
vpcola 0:f1d3878b8dd9 41 DIO10 = 10, /**< DIO10 pin */
vpcola 0:f1d3878b8dd9 42 DIO11 = 11, /**< DIO11 pin */
vpcola 0:f1d3878b8dd9 43 DIO12 = 12, /**< DIO12 pin */
vpcola 0:f1d3878b8dd9 44 SUPPLY_VOLTAGE = 7, /**< SUPPLY_VOLTAGE is not a real pin */
vpcola 0:f1d3878b8dd9 45 };
vpcola 0:f1d3878b8dd9 46
vpcola 0:f1d3878b8dd9 47 enum AssocStatus {
vpcola 0:f1d3878b8dd9 48 ErrorReading = -1, /**< Error occurred when reading parameter. */
vpcola 0:f1d3878b8dd9 49 Joined = 0x00, /**< Successfully formed or joined a network. (Coordinators form a network, routers and end devices join a network.) */
vpcola 0:f1d3878b8dd9 50 NoPANs = 0x21, /**< Scan found no PANs */
vpcola 0:f1d3878b8dd9 51 NoValidPAN = 0x22, /**< Scan found no valid PANs based on current SC and ID settings */
vpcola 0:f1d3878b8dd9 52 JoinNotAllowed = 0x23, /**< Valid Coordinator or Routers found, but they are not allowing joining (NJ expired). */
vpcola 0:f1d3878b8dd9 53 NoBeacons = 0x24, /**< No joinable beacons were found. */
vpcola 0:f1d3878b8dd9 54 Unexpected = 0x25, /**< Unexpected state, node should not be attempting to join at this time. */
vpcola 0:f1d3878b8dd9 55 JoinFailed = 0x27, /**< Node Joining attempt failed (typically due to incompatible security settings). */
vpcola 0:f1d3878b8dd9 56 CoordStartFail = 0x2A, /**< Coordinator start attempt failed */
vpcola 0:f1d3878b8dd9 57 CheckingCoord = 0x2B, /**< Checking for an existing coordinator. */
vpcola 0:f1d3878b8dd9 58 LeaveFail = 0x2C, /**< Attempt to leave the network failed. */
vpcola 0:f1d3878b8dd9 59 JoinNoResponse = 0xAB, /**< Attempted to join a device that did not respond. */
vpcola 0:f1d3878b8dd9 60 SecKeyUnsec = 0xAC, /**< Secure join error - network security key received unsecured. */
vpcola 0:f1d3878b8dd9 61 SecKeyNotRec = 0xAD, /**< Secure join error - network security key not received. */
vpcola 0:f1d3878b8dd9 62 SecBadKey = 0xAF, /**< Secure join error - joining device does not have the right preconfigured link key. */
vpcola 0:f1d3878b8dd9 63 Scanning = 0xFF /**< Scanning for a ZigBee network (routers and end devices). */
vpcola 0:f1d3878b8dd9 64 };
vpcola 0:f1d3878b8dd9 65
vpcola 0:f1d3878b8dd9 66 /** Class constructor
vpcola 0:f1d3878b8dd9 67 * @param tx the TX pin of the UART that will interface the XBee module
vpcola 0:f1d3878b8dd9 68 * @param rx the RX pin of the UART that will interface the XBee module
vpcola 0:f1d3878b8dd9 69 * @param reset the pin to which the XBee's reset line is attached to, use NC if not available
vpcola 0:f1d3878b8dd9 70 * @param rts the RTS pin for the UART that will interface the XBee module, use NC if not available
vpcola 0:f1d3878b8dd9 71 * @param cts the CTS pin for the UART that will interface the XBee module, use NC if not available
vpcola 0:f1d3878b8dd9 72 * @param baud the baudrate for the UART that will interface the XBee module. Note that the module has to be already configured
vpcola 0:f1d3878b8dd9 73 * to this baud rate (ATBD parameter). By default it is configured to 9600 bps
vpcola 0:f1d3878b8dd9 74 */
vpcola 0:f1d3878b8dd9 75 XBeeZB(PinName tx, PinName rx, PinName reset = NC, PinName rts = NC, PinName cts = NC, int baud = 9600);
vpcola 0:f1d3878b8dd9 76
vpcola 0:f1d3878b8dd9 77 /** Class destructor */
vpcola 0:f1d3878b8dd9 78 virtual ~XBeeZB();
vpcola 0:f1d3878b8dd9 79
vpcola 0:f1d3878b8dd9 80 /** init- initializes object
vpcola 0:f1d3878b8dd9 81 * This function must be called just after creating the object so it initializes internal data.
vpcola 0:f1d3878b8dd9 82 * @returns
vpcola 0:f1d3878b8dd9 83 * Success if the module has been properly initialized and is ready to process data.
vpcola 0:f1d3878b8dd9 84 * Failure otherwise.
vpcola 0:f1d3878b8dd9 85 */
vpcola 0:f1d3878b8dd9 86 RadioStatus init();
vpcola 0:f1d3878b8dd9 87
vpcola 0:f1d3878b8dd9 88 /** set_panid - sets the 64bit extended PAN ID.
vpcola 0:f1d3878b8dd9 89 *
vpcola 0:f1d3878b8dd9 90 * @note on ZigBee devices, if set to 0, the coordinator will select a random PAN ID
vpcola 0:f1d3878b8dd9 91 * and the routers will join any extended PAN ID
vpcola 0:f1d3878b8dd9 92 * @param panid the PAN ID value that will be set on the radio
vpcola 0:f1d3878b8dd9 93 * @returns
vpcola 0:f1d3878b8dd9 94 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 95 * Failure otherwise
vpcola 0:f1d3878b8dd9 96 */
vpcola 0:f1d3878b8dd9 97 RadioStatus set_panid(uint64_t panid);
vpcola 0:f1d3878b8dd9 98
vpcola 0:f1d3878b8dd9 99 /** get_configured_panid - gets the configured PAN ID, as it was set by @ref set_panid().
vpcola 0:f1d3878b8dd9 100 *
vpcola 0:f1d3878b8dd9 101 * @note on ZigBee devices, if set to 0, the coordinator will select a random PAN ID
vpcola 0:f1d3878b8dd9 102 * and the routers will join any extended PAN ID
vpcola 0:f1d3878b8dd9 103 * @param panid pointer where the configured PAN ID will be stored
vpcola 0:f1d3878b8dd9 104 * @returns
vpcola 0:f1d3878b8dd9 105 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 106 * Failure otherwise
vpcola 0:f1d3878b8dd9 107 */
vpcola 0:f1d3878b8dd9 108 RadioStatus get_configured_panid(uint64_t * const panid);
vpcola 0:f1d3878b8dd9 109
vpcola 0:f1d3878b8dd9 110 /** get_operating_panid - gets the operating 64bit extended PAN ID the module is running on. This is useful to determine the PAN ID when the ID parameter (@ref set_panid) is set to 0x00.
vpcola 0:f1d3878b8dd9 111 *
vpcola 0:f1d3878b8dd9 112 * @param panid pointer where the operating PAN ID will be stored
vpcola 0:f1d3878b8dd9 113 * @returns
vpcola 0:f1d3878b8dd9 114 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 115 * Failure otherwise
vpcola 0:f1d3878b8dd9 116 */
vpcola 0:f1d3878b8dd9 117 RadioStatus get_operating_panid(uint64_t * const panid);
vpcola 0:f1d3878b8dd9 118
vpcola 0:f1d3878b8dd9 119 /** set_panid - sets the 64bit extended PAN ID.
vpcola 0:f1d3878b8dd9 120 *
vpcola 0:f1d3878b8dd9 121 * @note on ZigBee devices, if set to 0, the coordinator will select a random PAN ID
vpcola 0:f1d3878b8dd9 122 * and the routers will join any extended PAN ID
vpcola 0:f1d3878b8dd9 123 * @param remote remote device
vpcola 0:f1d3878b8dd9 124 * @param panid the PAN ID value that will be set on the radio
vpcola 0:f1d3878b8dd9 125 * @returns
vpcola 0:f1d3878b8dd9 126 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 127 * Failure otherwise
vpcola 0:f1d3878b8dd9 128 */
vpcola 0:f1d3878b8dd9 129 RadioStatus set_panid(const RemoteXBee& remote, uint64_t panid);
vpcola 0:f1d3878b8dd9 130
vpcola 0:f1d3878b8dd9 131 /** get_configured_panid - gets the configured PAN ID in a remote node, as it was set by @ref set_panid()
vpcola 0:f1d3878b8dd9 132 *
vpcola 0:f1d3878b8dd9 133 * @note on ZigBee devices, if set to 0, the coordinator will select a random PAN ID
vpcola 0:f1d3878b8dd9 134 * and the routers will join any extended PAN ID
vpcola 0:f1d3878b8dd9 135 *
vpcola 0:f1d3878b8dd9 136 * @param remote remote device
vpcola 0:f1d3878b8dd9 137 * @param panid pointer where the configured PAN ID will be stored
vpcola 0:f1d3878b8dd9 138 * @returns
vpcola 0:f1d3878b8dd9 139 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 140 * Failure otherwise
vpcola 0:f1d3878b8dd9 141 */
vpcola 0:f1d3878b8dd9 142 RadioStatus get_configured_panid(const RemoteXBee& remote, uint64_t * const panid);
vpcola 0:f1d3878b8dd9 143
vpcola 0:f1d3878b8dd9 144 /** get_operating_panid - gets the operating 64bit extended PAN ID in which a remote node is running on. This is useful to determine the PAN ID when the ID parameter (@ref set_panid) is set to 0x00.
vpcola 0:f1d3878b8dd9 145 *
vpcola 0:f1d3878b8dd9 146 * @param remote remote device
vpcola 0:f1d3878b8dd9 147 * @param panid pointer where the operating PAN ID will be stored
vpcola 0:f1d3878b8dd9 148 * @returns
vpcola 0:f1d3878b8dd9 149 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 150 * Failure otherwise
vpcola 0:f1d3878b8dd9 151 */
vpcola 0:f1d3878b8dd9 152 RadioStatus get_operating_panid(const RemoteXBee& remote, uint64_t * const panid);
vpcola 0:f1d3878b8dd9 153
vpcola 0:f1d3878b8dd9 154 /** set_channel_mask - sets the channel mask in which the module will scan for the PAN ID (if it is a router or end-device) or start the network (if it is a coordinator).
vpcola 0:f1d3878b8dd9 155 * It should be set to the minimum available set of channels of all nodes in the network. Refer to "SC" parameter in the product manual for more information.
vpcola 0:f1d3878b8dd9 156 *
vpcola 0:f1d3878b8dd9 157 * @param chmask bit field list of channels to scan (router/end-devices) or to choose when starting a network (coordinator). Bit 0 is for channel 0x0B and bit 15 for channel 0x1A.
vpcola 0:f1d3878b8dd9 158 * @returns
vpcola 0:f1d3878b8dd9 159 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 160 * Failure otherwise
vpcola 0:f1d3878b8dd9 161 */
vpcola 0:f1d3878b8dd9 162 RadioStatus set_channel_mask(uint16_t const chmask);
vpcola 0:f1d3878b8dd9 163
vpcola 0:f1d3878b8dd9 164 /** get_channel_mask - gets the channel mask in which the module will scan for the PAN ID (if it is a router or end-device) or start the network (if it is a coordinator).
vpcola 0:f1d3878b8dd9 165 *
vpcola 0:f1d3878b8dd9 166 * @param chmask pointer to where the configured channel mask will be stored
vpcola 0:f1d3878b8dd9 167 * @returns
vpcola 0:f1d3878b8dd9 168 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 169 * Failure otherwise
vpcola 0:f1d3878b8dd9 170 */
vpcola 0:f1d3878b8dd9 171 RadioStatus get_channel_mask(uint16_t * const chmask);
vpcola 0:f1d3878b8dd9 172
vpcola 0:f1d3878b8dd9 173 /** get_network_address - gets the 16bit network address of the device
vpcola 0:f1d3878b8dd9 174 *
vpcola 0:f1d3878b8dd9 175 * @param addr pointer where the device 16bit network address will be stored
vpcola 0:f1d3878b8dd9 176 * @returns
vpcola 0:f1d3878b8dd9 177 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 178 * Failure otherwise
vpcola 0:f1d3878b8dd9 179 */
vpcola 0:f1d3878b8dd9 180 RadioStatus get_network_address(uint16_t * const addr);
vpcola 0:f1d3878b8dd9 181
vpcola 0:f1d3878b8dd9 182 /** check_for_coordinator_at_start - (Routers only) If enabled, a router will verify the coordinator is on its operating channel when joining or coming up from a power cycle.
vpcola 0:f1d3878b8dd9 183 * If a coordinator is not detected, the router will leave its current channel and attempt to join a new PAN. If JV=0, the router will continue operating on its current channel even if a coordinator is not detected.
vpcola 0:f1d3878b8dd9 184 *
vpcola 0:f1d3878b8dd9 185 * @param enable whether to enable this feature or not
vpcola 0:f1d3878b8dd9 186 * @returns
vpcola 0:f1d3878b8dd9 187 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 188 * Failure otherwise
vpcola 0:f1d3878b8dd9 189 */
vpcola 0:f1d3878b8dd9 190 RadioStatus check_for_coordinator_at_start(bool enable);
vpcola 0:f1d3878b8dd9 191
vpcola 0:f1d3878b8dd9 192 /** 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.
vpcola 0:f1d3878b8dd9 193 * It is not recommended to set the key programmatically, because it could be read through the raw serial port bits.
vpcola 0:f1d3878b8dd9 194 * @param key pointer to the 128-bit AES key
vpcola 0:f1d3878b8dd9 195 * @param length size of the buffer pointed by 'key'
vpcola 0:f1d3878b8dd9 196 * @returns
vpcola 0:f1d3878b8dd9 197 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 198 * Failure otherwise
vpcola 0:f1d3878b8dd9 199 */
vpcola 0:f1d3878b8dd9 200 RadioStatus set_network_security_key(const uint8_t * const key, const uint16_t length);
vpcola 0:f1d3878b8dd9 201
vpcola 0:f1d3878b8dd9 202 #define XBEE_ZB_ENC_OPT_SEND_KEY_ON_JOIN 0x01
vpcola 0:f1d3878b8dd9 203 #define XBEE_ZB_ENC_OPT_USE_TRUST_CENTER 0x02
vpcola 0:f1d3878b8dd9 204 /** set_encryption_options - Configure options for encryption. Unused option bits should be set to 0. Options include:
vpcola 0:f1d3878b8dd9 205 * - XBEE_ZB_ENC_OPT_SEND_KEY_ON_JOIN - Send the security key unsecured over-the-air during joins
vpcola 0:f1d3878b8dd9 206 * - XBEE_ZB_ENC_OPT_USE_TRUST_CENTER - Use trust center (coordinator only)
vpcola 0:f1d3878b8dd9 207 * @param options bit mask with the encryption options
vpcola 0:f1d3878b8dd9 208 * @returns
vpcola 0:f1d3878b8dd9 209 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 210 * Failure otherwise
vpcola 0:f1d3878b8dd9 211 */
vpcola 0:f1d3878b8dd9 212 RadioStatus set_encryption_options(const uint8_t options);
vpcola 0:f1d3878b8dd9 213
vpcola 0:f1d3878b8dd9 214 /** register_node_discovery_cb - registers the callback function that will be called
vpcola 0:f1d3878b8dd9 215 * when the responses to the node discovery command arrive
vpcola 0:f1d3878b8dd9 216 *
vpcola 0:f1d3878b8dd9 217 * @param function function pointer with the callback function
vpcola 0:f1d3878b8dd9 218 */
vpcola 0:f1d3878b8dd9 219 void register_node_discovery_cb(node_discovery_zb_cb_t function);
vpcola 0:f1d3878b8dd9 220
vpcola 0:f1d3878b8dd9 221 /** unregister_node_discovery_cb - removes the node discovery callback */
vpcola 0:f1d3878b8dd9 222 void unregister_node_discovery_cb();
vpcola 0:f1d3878b8dd9 223
vpcola 0:f1d3878b8dd9 224 /** register_receive_cb - registers the callback function that will be called
vpcola 0:f1d3878b8dd9 225 * when a data packet is received
vpcola 0:f1d3878b8dd9 226 *
vpcola 0:f1d3878b8dd9 227 * @param function function pointer with the callback function
vpcola 0:f1d3878b8dd9 228 */
vpcola 0:f1d3878b8dd9 229 void register_receive_cb(receive_zb_cb_t function);
vpcola 0:f1d3878b8dd9 230
vpcola 0:f1d3878b8dd9 231 /** unregister_receive_cb - removes the rx packet callback */
vpcola 0:f1d3878b8dd9 232 void unregister_receive_cb();
vpcola 0:f1d3878b8dd9 233
vpcola 0:f1d3878b8dd9 234 /** register_io_sample_cb - registers the callback function that will be called
vpcola 0:f1d3878b8dd9 235 * when a IO Sample Data packet is received
vpcola 0:f1d3878b8dd9 236 *
vpcola 0:f1d3878b8dd9 237 * @param function function pointer with the callback function
vpcola 0:f1d3878b8dd9 238 */
vpcola 0:f1d3878b8dd9 239 void register_io_sample_cb(io_data_cb_zb_t function);
vpcola 0:f1d3878b8dd9 240
vpcola 0:f1d3878b8dd9 241 /** unregister_io_sample_cb - removes the IO Sample Data reception callback */
vpcola 0:f1d3878b8dd9 242 void unregister_io_sample_cb();
vpcola 0:f1d3878b8dd9 243
vpcola 0:f1d3878b8dd9 244 /*********************** send_data member methods ************************/
vpcola 0:f1d3878b8dd9 245 /** send_data - sends data to a remote device
vpcola 0:f1d3878b8dd9 246 *
vpcola 0:f1d3878b8dd9 247 * @param remote remote device
vpcola 0:f1d3878b8dd9 248 * @param data pointer to the data that will be sent
vpcola 0:f1d3878b8dd9 249 * @param len number of bytes that will be transmitted
vpcola 0:f1d3878b8dd9 250 * @param syncr if true, method waits for the packet answer with the result of the operation
vpcola 0:f1d3878b8dd9 251 * @returns the result of the data transfer
vpcola 0:f1d3878b8dd9 252 * TxStatusSuccess if the operation was successful,
vpcola 0:f1d3878b8dd9 253 * the error code otherwise
vpcola 0:f1d3878b8dd9 254 */
vpcola 0:f1d3878b8dd9 255 virtual TxStatus send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len, bool syncr = true);
vpcola 0:f1d3878b8dd9 256
vpcola 0:f1d3878b8dd9 257 /** send_data - sends data to a remote device. This method uses
vpcola 0:f1d3878b8dd9 258 * the explicit addressing frame, allowing to use source and
vpcola 0:f1d3878b8dd9 259 * destination end points and cluster and profile IDs
vpcola 0:f1d3878b8dd9 260 *
vpcola 0:f1d3878b8dd9 261 * @param remote remote device
vpcola 0:f1d3878b8dd9 262 * @param source_ep source end point
vpcola 0:f1d3878b8dd9 263 * @param dest_ep destination end point
vpcola 0:f1d3878b8dd9 264 * @param cluster_id cluster ID
vpcola 0:f1d3878b8dd9 265 * @param profile_id profile ID
vpcola 0:f1d3878b8dd9 266 * @param data pointer to the data that will be sent
vpcola 0:f1d3878b8dd9 267 * @param len number of bytes that will be transmitted
vpcola 0:f1d3878b8dd9 268 * @param syncr if true, method waits for the packet answer with the result of the operation
vpcola 0:f1d3878b8dd9 269 * @returns the result of the data transfer
vpcola 0:f1d3878b8dd9 270 * TxStatusSuccess if the operation was successful,
vpcola 0:f1d3878b8dd9 271 * the error code otherwise
vpcola 0:f1d3878b8dd9 272 */
vpcola 0:f1d3878b8dd9 273 TxStatus send_data(const RemoteXBee& remote, uint8_t source_ep,
vpcola 0:f1d3878b8dd9 274 uint8_t dest_ep, uint16_t cluster_id, uint16_t profile_id,
vpcola 0:f1d3878b8dd9 275 const uint8_t *const data, uint16_t len, bool syncr = true);
vpcola 0:f1d3878b8dd9 276
vpcola 0:f1d3878b8dd9 277 /** send_data_to_coordinator - sends data to the ZigBee coordinator
vpcola 0:f1d3878b8dd9 278 *
vpcola 0:f1d3878b8dd9 279 * @param data pointer to the data that will be sent
vpcola 0:f1d3878b8dd9 280 * @param len number of bytes that will be transmitted
vpcola 0:f1d3878b8dd9 281 * @param syncr if true, method waits for the packet answer with the result of the operation
vpcola 0:f1d3878b8dd9 282 * @returns the result of the data transfer
vpcola 0:f1d3878b8dd9 283 * TxStatusSuccess if the operation was successful,
vpcola 0:f1d3878b8dd9 284 * the error code otherwise
vpcola 0:f1d3878b8dd9 285 */
vpcola 0:f1d3878b8dd9 286 TxStatus send_data_to_coordinator(const uint8_t *const data, uint16_t len, bool syncr = true);
vpcola 0:f1d3878b8dd9 287
vpcola 0:f1d3878b8dd9 288 /** get_assoc_status - returns current network association status. This wraps AI parameter, for more information refer to moudle's Reference Manual.
vpcola 0:f1d3878b8dd9 289 *
vpcola 0:f1d3878b8dd9 290 * @returns an AssocStatus with current network association status.
vpcola 0:f1d3878b8dd9 291 */
vpcola 0:f1d3878b8dd9 292 AssocStatus get_assoc_status(void);
vpcola 0:f1d3878b8dd9 293
vpcola 0:f1d3878b8dd9 294 /** is_joined - checks if the device is joined to ZigBee network
vpcola 0:f1d3878b8dd9 295 * @returns true if joined, false otherwise
vpcola 0:f1d3878b8dd9 296 */
vpcola 0:f1d3878b8dd9 297 bool is_joined();
vpcola 0:f1d3878b8dd9 298
vpcola 0:f1d3878b8dd9 299 /** get_remote_node_by_id - searches for a device in the network with the specified Node Identifier.
vpcola 0:f1d3878b8dd9 300 *
vpcola 0:f1d3878b8dd9 301 * @param node_id node id of the device we are looking for
vpcola 0:f1d3878b8dd9 302 * @returns a RemoteXBeeZB with the 16-bit and 64-bit address of the remote device whose node id matches with the parameter.
vpcola 0:f1d3878b8dd9 303 * If node is not found, the returned object will have invalid addresses (RemoteXBeeZB::is_valid() will return false).
vpcola 0:f1d3878b8dd9 304 */
vpcola 0:f1d3878b8dd9 305 RemoteXBeeZB get_remote_node_by_id(const char * const node_id);
vpcola 0:f1d3878b8dd9 306
vpcola 0:f1d3878b8dd9 307 /* Allow using XBee::set_param() methods for local radio from this class */
vpcola 0:f1d3878b8dd9 308 using XBee::set_param;
vpcola 0:f1d3878b8dd9 309
vpcola 0:f1d3878b8dd9 310 /** set_param - sets a parameter in a remote radio by sending an AT command and waiting for the response.
vpcola 0:f1d3878b8dd9 311 *
vpcola 0:f1d3878b8dd9 312 * @param remote remote device
vpcola 0:f1d3878b8dd9 313 * @param param parameter to be set.
vpcola 0:f1d3878b8dd9 314 * @param data the parameter value (4 bytes) to be set.
vpcola 0:f1d3878b8dd9 315 * @returns the command response status.
vpcola 0:f1d3878b8dd9 316 */
vpcola 0:f1d3878b8dd9 317 virtual AtCmdFrame::AtCmdResp set_param(const RemoteXBee& remote, const char * const param, uint32_t data);
vpcola 0:f1d3878b8dd9 318
vpcola 0:f1d3878b8dd9 319 /** set_param - sets a parameter in a remote radio by sending an AT command and waiting for the response.
vpcola 0:f1d3878b8dd9 320 *
vpcola 0:f1d3878b8dd9 321 * @param remote remote device
vpcola 0:f1d3878b8dd9 322 * @param param parameter to be set.
vpcola 0:f1d3878b8dd9 323 * @param data the parameter value byte array (len bytes) to be set.
vpcola 0:f1d3878b8dd9 324 * @param len number of bytes of the parameter value.
vpcola 0:f1d3878b8dd9 325 * @returns the command response status.
vpcola 0:f1d3878b8dd9 326 */
vpcola 0:f1d3878b8dd9 327 virtual AtCmdFrame::AtCmdResp set_param(const RemoteXBee& remote, const char * const param, const uint8_t * data = NULL, uint16_t len = 0);
vpcola 0:f1d3878b8dd9 328
vpcola 0:f1d3878b8dd9 329 /* Allow using XBee::get_param() methods for local radio from this class */
vpcola 0:f1d3878b8dd9 330 using XBee::get_param;
vpcola 0:f1d3878b8dd9 331
vpcola 0:f1d3878b8dd9 332 /** get_param - gets a parameter from a remote radio by sending an AT command and waiting for the response.
vpcola 0:f1d3878b8dd9 333 *
vpcola 0:f1d3878b8dd9 334 * @param remote remote device
vpcola 0:f1d3878b8dd9 335 * @param param parameter to be get.
vpcola 0:f1d3878b8dd9 336 * @param data pointer where the param value (4 bytes) will be stored.
vpcola 0:f1d3878b8dd9 337 * @returns the command response status.
vpcola 0:f1d3878b8dd9 338 */
vpcola 0:f1d3878b8dd9 339 virtual AtCmdFrame::AtCmdResp get_param(const RemoteXBee& remote, const char * const param, uint32_t * const data);
vpcola 0:f1d3878b8dd9 340
vpcola 0:f1d3878b8dd9 341 /** get_param - gets a parameter from a remote radio by sending an AT command and waiting for the response.
vpcola 0:f1d3878b8dd9 342 *
vpcola 0:f1d3878b8dd9 343 * @param remote remote device
vpcola 0:f1d3878b8dd9 344 * @param param parameter to be get.
vpcola 0:f1d3878b8dd9 345 * @param data pointer where the param value (n bytes) will be stored.
vpcola 0:f1d3878b8dd9 346 * @param len pointer where the number of bytes of the param value will be stored.
vpcola 0:f1d3878b8dd9 347 * @returns the command response status.
vpcola 0:f1d3878b8dd9 348 */
vpcola 0:f1d3878b8dd9 349 virtual AtCmdFrame::AtCmdResp get_param(const RemoteXBee& remote, const char * const param, uint8_t * const data, uint16_t * const len);
vpcola 0:f1d3878b8dd9 350
vpcola 0:f1d3878b8dd9 351 /************************* IO member methods **************************/
vpcola 0:f1d3878b8dd9 352 /** set_pin_config - configures a radio IO line
vpcola 0:f1d3878b8dd9 353 *
vpcola 0:f1d3878b8dd9 354 * @param remote remote device
vpcola 0:f1d3878b8dd9 355 * @param line IO line being configured
vpcola 0:f1d3878b8dd9 356 * @param mode configuration mode for the selected line
vpcola 0:f1d3878b8dd9 357 * @returns
vpcola 0:f1d3878b8dd9 358 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 359 * Failure otherwise
vpcola 0:f1d3878b8dd9 360 */
vpcola 0:f1d3878b8dd9 361 RadioStatus set_pin_config(const RemoteXBee& remote, IoLine line, IoMode mode);
vpcola 0:f1d3878b8dd9 362
vpcola 0:f1d3878b8dd9 363 /** get_pin_config - gets the configuration of a radio IO line
vpcola 0:f1d3878b8dd9 364 *
vpcola 0:f1d3878b8dd9 365 * @param remote remote device
vpcola 0:f1d3878b8dd9 366 * @param line IO line being read to get its configuration
vpcola 0:f1d3878b8dd9 367 * @param mode pointer where the configuration will be stored
vpcola 0:f1d3878b8dd9 368 * @returns
vpcola 0:f1d3878b8dd9 369 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 370 * Failure otherwise
vpcola 0:f1d3878b8dd9 371 */
vpcola 0:f1d3878b8dd9 372 RadioStatus get_pin_config(const RemoteXBee& remote, IoLine line, IoMode * const mode);
vpcola 0:f1d3878b8dd9 373
vpcola 0:f1d3878b8dd9 374 /** set_dio - sets to low/high a DIO line
vpcola 0:f1d3878b8dd9 375 *
vpcola 0:f1d3878b8dd9 376 * @param remote remote device
vpcola 0:f1d3878b8dd9 377 * @param line DIO line being set
vpcola 0:f1d3878b8dd9 378 * @param val value that will be set in the DIO line
vpcola 0:f1d3878b8dd9 379 * @returns
vpcola 0:f1d3878b8dd9 380 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 381 * Failure otherwise
vpcola 0:f1d3878b8dd9 382 */
vpcola 0:f1d3878b8dd9 383 RadioStatus set_dio(const RemoteXBee& remote, IoLine line, DioVal val);
vpcola 0:f1d3878b8dd9 384
vpcola 0:f1d3878b8dd9 385 /** get_dio - read the value of a DIO configured as digital input
vpcola 0:f1d3878b8dd9 386 *
vpcola 0:f1d3878b8dd9 387 * @param remote remote device
vpcola 0:f1d3878b8dd9 388 * @param line DIO line being read
vpcola 0:f1d3878b8dd9 389 * @param val pointer where the DIO value read will be stored
vpcola 0:f1d3878b8dd9 390 * @returns
vpcola 0:f1d3878b8dd9 391 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 392 * Failure otherwise
vpcola 0:f1d3878b8dd9 393 */
vpcola 0:f1d3878b8dd9 394 RadioStatus get_dio(const RemoteXBee& remote, IoLine line, DioVal * const val);
vpcola 0:f1d3878b8dd9 395
vpcola 0:f1d3878b8dd9 396 /** get_adc - read the value of the espcified ADC line
vpcola 0:f1d3878b8dd9 397 *
vpcola 0:f1d3878b8dd9 398 * @param remote remote device
vpcola 0:f1d3878b8dd9 399 * @param line ADC line being read
vpcola 0:f1d3878b8dd9 400 * @param val pointer where the value read from hte ADC will be stored
vpcola 0:f1d3878b8dd9 401 * @returns
vpcola 0:f1d3878b8dd9 402 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 403 * Failure otherwise
vpcola 0:f1d3878b8dd9 404 */
vpcola 0:f1d3878b8dd9 405 RadioStatus get_adc(const RemoteXBee& remote, IoLine line, uint16_t * const val);
vpcola 0:f1d3878b8dd9 406
vpcola 0:f1d3878b8dd9 407 /** get_iosample - retrieves an @ref IOSampleZB from a remote node. This object can be used to get the remote node's ADC and DIO values.
vpcola 0:f1d3878b8dd9 408 *
vpcola 0:f1d3878b8dd9 409 * @param remote remote device
vpcola 0:f1d3878b8dd9 410 * @returns IOSampleZB object with the remote node's DIO and ADC values.
vpcola 0:f1d3878b8dd9 411 */
vpcola 0:f1d3878b8dd9 412 IOSampleZB get_iosample(const RemoteXBee& remote);
vpcola 0:f1d3878b8dd9 413
vpcola 0:f1d3878b8dd9 414 /** set_pin_pull_up - enables or disables the internal pull-up resistor of a line
vpcola 0:f1d3878b8dd9 415 *
vpcola 0:f1d3878b8dd9 416 * @param remote remote device
vpcola 0:f1d3878b8dd9 417 * @param line line being configured for pull-up
vpcola 0:f1d3878b8dd9 418 * @param enable whether to enable the internal pull-up resistor.
vpcola 0:f1d3878b8dd9 419 * @returns
vpcola 0:f1d3878b8dd9 420 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 421 * Failure otherwise
vpcola 0:f1d3878b8dd9 422 */
vpcola 0:f1d3878b8dd9 423 RadioStatus set_pin_pull_up(const RemoteXBee& remote, IoLine line, bool enable);
vpcola 0:f1d3878b8dd9 424
vpcola 0:f1d3878b8dd9 425 /** enable_dio_change_detection - enables or disables the notification when a change is detected in a digital input line.
vpcola 0:f1d3878b8dd9 426 * In other words, it will force an IO Sample transmission when the DIO state changes. Only for DIO0 to DIO11.
vpcola 0:f1d3878b8dd9 427 *
vpcola 0:f1d3878b8dd9 428 * @param remote remote device
vpcola 0:f1d3878b8dd9 429 * @param line line being configured for pull-up
vpcola 0:f1d3878b8dd9 430 * @param enable whether to enable the internal pull-up resistor.
vpcola 0:f1d3878b8dd9 431 * @returns
vpcola 0:f1d3878b8dd9 432 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 433 * Failure otherwise
vpcola 0:f1d3878b8dd9 434 */
vpcola 0:f1d3878b8dd9 435 RadioStatus enable_dio_change_detection(const RemoteXBee& remote, IoLine line, bool enable);
vpcola 0:f1d3878b8dd9 436
vpcola 0:f1d3878b8dd9 437 protected:
vpcola 0:f1d3878b8dd9 438
vpcola 0:f1d3878b8dd9 439 /** Frame handler used for the node discovery. Registered when a callback function
vpcola 0:f1d3878b8dd9 440 * is registered */
vpcola 0:f1d3878b8dd9 441 FH_NodeDiscoveryZB *_nd_handler;
vpcola 0:f1d3878b8dd9 442
vpcola 0:f1d3878b8dd9 443 /** Frame handler used for the rx packets. Automatically registered when a callback
vpcola 0:f1d3878b8dd9 444 * function is registered */
vpcola 0:f1d3878b8dd9 445 FH_RxPacketZB *_rx_pkt_handler;
vpcola 0:f1d3878b8dd9 446
vpcola 0:f1d3878b8dd9 447 /** Frame handler used for the IO Data Sample packets. Automatically registered when a callback
vpcola 0:f1d3878b8dd9 448 * function is registered */
vpcola 0:f1d3878b8dd9 449 FH_IoDataSampeZB *_io_data_handler;
vpcola 0:f1d3878b8dd9 450
vpcola 0:f1d3878b8dd9 451 /** Method called directly by the library when a modem status frame is received to
vpcola 0:f1d3878b8dd9 452 * update the internal status variables */
vpcola 0:f1d3878b8dd9 453 virtual void radio_status_update(AtCmdFrame::ModemStatus modem_status);
vpcola 0:f1d3878b8dd9 454
vpcola 0:f1d3878b8dd9 455 /* Allow using XBee::send_data() methods from this class */
vpcola 0:f1d3878b8dd9 456 using XBee::send_data;
vpcola 0:f1d3878b8dd9 457
vpcola 0:f1d3878b8dd9 458 /** get_node_discovery_timeout - gets the node discovery timeout
vpcola 0:f1d3878b8dd9 459 *
vpcola 0:f1d3878b8dd9 460 * @param timeout_ms pointer where the node discovery timeout value will be stored
vpcola 0:f1d3878b8dd9 461 * @param wait_for_complete_timeout pointer where the function will store if the operator
vpcola 0:f1d3878b8dd9 462 * has to wait for the complete nd timeout after issuing
vpcola 0:f1d3878b8dd9 463 * a directed nd request
vpcola 0:f1d3878b8dd9 464 * @returns
vpcola 0:f1d3878b8dd9 465 * Success if the operation was successful,
vpcola 0:f1d3878b8dd9 466 * Failure otherwise
vpcola 0:f1d3878b8dd9 467 */
vpcola 0:f1d3878b8dd9 468 virtual RadioStatus get_node_discovery_timeout(uint16_t * const timeout_ms);
vpcola 0:f1d3878b8dd9 469 virtual RadioStatus get_node_discovery_timeout(uint16_t * const timeout_ms, bool * const wait_for_complete_timeout);
vpcola 0:f1d3878b8dd9 470 };
vpcola 0:f1d3878b8dd9 471
vpcola 0:f1d3878b8dd9 472 } /* namespace XBeeLib */
vpcola 0:f1d3878b8dd9 473
vpcola 0:f1d3878b8dd9 474 #endif /* __XBEE_ZB_H_ */