project de marde si tu touch le no-homo s'applique pas

Fork of XBeeLib by Digi International Inc.

Committer:
hbujanda
Date:
Fri Jul 29 12:10:38 2016 +0200
Revision:
8:b5f4a0e92249
Parent:
6:06522f3a6642
Child:
9:780db84ce891
Automatic upload

Who changed what in which revision?

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