project de marde si tu touch le no-homo s'applique pas
Fork of XBeeLib by
XBee802/XBee802.h@9:780db84ce891, 2016-07-29 (annotated)
- Committer:
- hbujanda
- Date:
- Fri Jul 29 13:10:07 2016 +0200
- Revision:
- 9:780db84ce891
- Parent:
- 8:b5f4a0e92249
Automatic upload
Who changed what in which revision?
User | Revision | Line number | New 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_802_H_) |
spastor | 0:fcaad0dfa051 | 14 | #define __XBEE_802_H_ |
spastor | 0:fcaad0dfa051 | 15 | |
spastor | 0:fcaad0dfa051 | 16 | #include "FrameHandlers/FH_AtCmdResp.h" |
spastor | 0:fcaad0dfa051 | 17 | #include "FrameHandlers/FH_RxPacket802.h" |
spastor | 0:fcaad0dfa051 | 18 | #include "FrameHandlers/FH_IoDataSample802.h" |
spastor | 0:fcaad0dfa051 | 19 | #include "RemoteXBee/RemoteXBee.h" |
spastor | 0:fcaad0dfa051 | 20 | |
spastor | 0:fcaad0dfa051 | 21 | namespace XBeeLib { |
spastor | 0:fcaad0dfa051 | 22 | |
spastor | 0:fcaad0dfa051 | 23 | /** Class for XBee ZigBee modules, derived from XBee */ |
spastor | 0:fcaad0dfa051 | 24 | class XBee802 : public XBee |
spastor | 0:fcaad0dfa051 | 25 | { |
spastor | 0:fcaad0dfa051 | 26 | public: |
spastor | 0:fcaad0dfa051 | 27 | |
spastor | 0:fcaad0dfa051 | 28 | /** |
spastor | 0:fcaad0dfa051 | 29 | * IoLine for XBee802 Modules |
spastor | 0:fcaad0dfa051 | 30 | */ |
spastor | 0:fcaad0dfa051 | 31 | enum IoLine { |
spastor | 0:fcaad0dfa051 | 32 | DIO0_AD0 = 0, /**< DIO0_AD0 pin */ |
spastor | 0:fcaad0dfa051 | 33 | DIO1_AD1 = 1, /**< DIO1_AD1 pin */ |
spastor | 0:fcaad0dfa051 | 34 | DIO2_AD2 = 2, /**< DIO2_AD2 pin */ |
spastor | 0:fcaad0dfa051 | 35 | DIO3_AD3 = 3, /**< DIO3_AD3 pin */ |
spastor | 0:fcaad0dfa051 | 36 | DIO4_AD4 = 4, /**< DIO4_AD4 pin */ |
spastor | 0:fcaad0dfa051 | 37 | DIO5_AD5 = 5, /**< DIO5_AD5 pin */ |
spastor | 0:fcaad0dfa051 | 38 | DIO6 = 6, /**< DIO6 pin */ |
spastor | 0:fcaad0dfa051 | 39 | DIO7 = 7, /**< DIO7 pin */ |
spastor | 0:fcaad0dfa051 | 40 | DI8 = 8, /**< DI8 pin */ |
spastor | 0:fcaad0dfa051 | 41 | PWM0, /**< PWM0 pin */ |
spastor | 0:fcaad0dfa051 | 42 | PWM1 /**< PWM1 pin */ |
spastor | 0:fcaad0dfa051 | 43 | }; |
spastor | 4:629712865107 | 44 | |
spastor | 4:629712865107 | 45 | enum AssocStatus { |
spastor | 4:629712865107 | 46 | ErrorReading = -1, /**< Error occurred when reading parameter. */ |
spastor | 4:629712865107 | 47 | Joined = 0x00, /**< Successful Completion - Coordinator successfully started or End Device association complete. */ |
spastor | 4:629712865107 | 48 | ActiveScanTimeOut = 0x01, /**< Active Scan Timeout. */ |
spastor | 4:629712865107 | 49 | NoPANs = 0x02, /**< Active Scan found no PANs. */ |
spastor | 4:629712865107 | 50 | JoinNotAllowed = 0x03, /**< Active Scan found PAN, but the Coordinator's Allow Association bit is not set. */ |
spastor | 4:629712865107 | 51 | BeaconsFailed = 0x04, /**< Active Scan found PAN, but Coordinator and End Device are not configured to support beacons. */ |
spastor | 4:629712865107 | 52 | BadPAN = 0x05, /**< Active Scan found PAN, but Coordinator ID (PAN ID) value does not match the ID of the End Device. */ |
spastor | 4:629712865107 | 53 | BadChannel = 0x06, /**< Active Scan found PAN, but Coordinator CH (Channel) value does not match the CH of the End Device */ |
spastor | 4:629712865107 | 54 | EnergyScanTimeout = 0x07, /**< Energy Scan timed out. */ |
spastor | 4:629712865107 | 55 | CoordStartFailed = 0x08, /**< Coordinator start request failed. */ |
spastor | 4:629712865107 | 56 | CoordBadParameters = 0x09, /**< Coordinator could not start due to Invalid Parameter. */ |
spastor | 4:629712865107 | 57 | CoordRealignment = 0x0A, /**< Coordinator Realignment is in progress. */ |
spastor | 4:629712865107 | 58 | AssocReqNotSent = 0x0B, /**< Association Request not sent. */ |
spastor | 4:629712865107 | 59 | AssocReqTimeout = 0x0C, /**< Association Request timed out - no reply was received. */ |
spastor | 4:629712865107 | 60 | AssocReqInvalidPara = 0x0D, /**< Association Request had an Invalid Parameter. */ |
spastor | 4:629712865107 | 61 | AssocReqChannelFail = 0x0E, /**< Association Request Channel Access Failure - Request was not transmitted - CCA failure. */ |
spastor | 4:629712865107 | 62 | RemCoordNoACK = 0x0F, /**< Remote Coordinator did not send an ACK after Association Request was sent. */ |
spastor | 4:629712865107 | 63 | RemCoordLateACK = 0x10, /**< Remote Coordinator did not reply to the Association Request, but an ACK was received after sending the request. */ |
spastor | 4:629712865107 | 64 | Associating = 0xFF /**< RF Module is attempting to associate. */ |
spastor | 4:629712865107 | 65 | }; |
spastor | 4:629712865107 | 66 | |
spastor | 0:fcaad0dfa051 | 67 | /** Class constructor |
spastor | 0:fcaad0dfa051 | 68 | * @param tx the TX pin of the UART that will interface the XBee module |
spastor | 0:fcaad0dfa051 | 69 | * @param rx the RX pin of the UART that will interface the XBee module |
spastor | 0:fcaad0dfa051 | 70 | * @param reset the pin to which the XBee's reset line is attached to, use NC if not available |
spastor | 0:fcaad0dfa051 | 71 | * @param rts the RTS pin for the UART that will interface the XBee module, use NC if not available |
spastor | 0:fcaad0dfa051 | 72 | * @param cts the CTS pin for the UART that will interface the XBee module, use NC if not available |
spastor | 0:fcaad0dfa051 | 73 | * @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 | 74 | * to this baud rate (ATBD parameter). By default it is configured to 9600 bps |
spastor | 0:fcaad0dfa051 | 75 | */ |
spastor | 0:fcaad0dfa051 | 76 | XBee802(PinName tx, PinName rx, PinName reset = NC, PinName rts = NC, PinName cts = NC, int baud = 9600); |
spastor | 4:629712865107 | 77 | |
spastor | 0:fcaad0dfa051 | 78 | /** Class destructor */ |
spastor | 0:fcaad0dfa051 | 79 | virtual ~XBee802(); |
spastor | 4:629712865107 | 80 | |
spastor | 0:fcaad0dfa051 | 81 | /** init - initializes object |
spastor | 0:fcaad0dfa051 | 82 | * This function must be called just after creating the object so it initializes internal data. |
spastor | 0:fcaad0dfa051 | 83 | * @returns |
spastor | 0:fcaad0dfa051 | 84 | * Success if the module has been properly initialized and is ready to process data. |
spastor | 0:fcaad0dfa051 | 85 | * Failure otherwise. |
spastor | 0:fcaad0dfa051 | 86 | */ |
spastor | 0:fcaad0dfa051 | 87 | RadioStatus init(); |
spastor | 0:fcaad0dfa051 | 88 | |
spastor | 4:629712865107 | 89 | /** set_panid - sets the 16 bit PAN ID. |
spastor | 0:fcaad0dfa051 | 90 | * |
spastor | 0:fcaad0dfa051 | 91 | * @param panid the PAN ID value that will be set on the radio |
spastor | 0:fcaad0dfa051 | 92 | * @returns |
spastor | 0:fcaad0dfa051 | 93 | * Success if the operation was successful, |
spastor | 0:fcaad0dfa051 | 94 | * Failure otherwise |
spastor | 0:fcaad0dfa051 | 95 | */ |
spastor | 0:fcaad0dfa051 | 96 | RadioStatus set_panid(uint16_t panid); |
spastor | 4:629712865107 | 97 | |
spastor | 0:fcaad0dfa051 | 98 | /** get_panid - gets the configured 16 bit PAN ID |
spastor | 0:fcaad0dfa051 | 99 | * |
spastor | 0:fcaad0dfa051 | 100 | * @param panid pointer where the read PAN ID value will be stored |
spastor | 0:fcaad0dfa051 | 101 | * @returns |
spastor | 0:fcaad0dfa051 | 102 | * Success if the operation was successful, |
spastor | 0:fcaad0dfa051 | 103 | * Failure otherwise |
spastor | 0:fcaad0dfa051 | 104 | */ |
spastor | 0:fcaad0dfa051 | 105 | RadioStatus get_panid(uint16_t * const panid); |
spastor | 4:629712865107 | 106 | |
spastor | 0:fcaad0dfa051 | 107 | /** set_channel - sets the network channel number |
spastor | 0:fcaad0dfa051 | 108 | * |
spastor | 0:fcaad0dfa051 | 109 | * @param channel the channel in which the radio operates. Range is 0x0B - 0x1A for XBee and 0x0C - 0x17 for XBee-PRO. |
spastor | 0:fcaad0dfa051 | 110 | * The Center Frequency = 2.405 + (CH - 11) * 5 MHz |
spastor | 0:fcaad0dfa051 | 111 | * @returns |
spastor | 0:fcaad0dfa051 | 112 | * Success if the operation was successful, |
spastor | 0:fcaad0dfa051 | 113 | * Failure otherwise |
spastor | 0:fcaad0dfa051 | 114 | */ |
spastor | 0:fcaad0dfa051 | 115 | RadioStatus set_channel(uint8_t channel); |
spastor | 0:fcaad0dfa051 | 116 | |
spastor | 0:fcaad0dfa051 | 117 | /** get_panid - gets the network channel number |
spastor | 0:fcaad0dfa051 | 118 | * |
spastor | 0:fcaad0dfa051 | 119 | * @param channel pointer where the channel value will be stored. |
spastor | 0:fcaad0dfa051 | 120 | * @returns |
spastor | 0:fcaad0dfa051 | 121 | * Success if the operation was successful, |
spastor | 0:fcaad0dfa051 | 122 | * Failure otherwise |
spastor | 0:fcaad0dfa051 | 123 | */ |
spastor | 0:fcaad0dfa051 | 124 | RadioStatus get_channel(uint8_t * const channel); |
spastor | 0:fcaad0dfa051 | 125 | |
hbujanda | 6:06522f3a6642 | 126 | /** get_network_address - gets the 16bit network address of the device |
hbujanda | 6:06522f3a6642 | 127 | * |
hbujanda | 6:06522f3a6642 | 128 | * @param addr pointer where the device 16bit network address will be stored |
hbujanda | 6:06522f3a6642 | 129 | * @returns |
hbujanda | 6:06522f3a6642 | 130 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 131 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 132 | */ |
hbujanda | 6:06522f3a6642 | 133 | RadioStatus get_network_address(uint16_t * const addr); |
hbujanda | 6:06522f3a6642 | 134 | |
spastor | 0:fcaad0dfa051 | 135 | /** set_network_address - sets the 16 bit network address of the device |
spastor | 0:fcaad0dfa051 | 136 | * |
spastor | 0:fcaad0dfa051 | 137 | * @param addr the device 16bit network address (0x0 - 0xFFFF) |
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 set_network_address(uint16_t addr); |
spastor | 0:fcaad0dfa051 | 143 | |
spastor | 0:fcaad0dfa051 | 144 | /** register_node_discovery_cb - registers the callback function that will be called |
spastor | 0:fcaad0dfa051 | 145 | * when the responses to the node discovery command arrive |
spastor | 0:fcaad0dfa051 | 146 | * |
spastor | 0:fcaad0dfa051 | 147 | * @param function function pointer with the callback function |
spastor | 0:fcaad0dfa051 | 148 | */ |
spastor | 0:fcaad0dfa051 | 149 | void register_node_discovery_cb(node_discovery_802_cb_t function); |
spastor | 0:fcaad0dfa051 | 150 | |
spastor | 0:fcaad0dfa051 | 151 | /** unregister_node_discovery_cb - removes the node discovery callback */ |
spastor | 0:fcaad0dfa051 | 152 | void unregister_node_discovery_cb(); |
spastor | 0:fcaad0dfa051 | 153 | |
spastor | 0:fcaad0dfa051 | 154 | /** register_receive_cb - registers the callback function that will be called |
spastor | 0:fcaad0dfa051 | 155 | * when a rx packet is received |
spastor | 0:fcaad0dfa051 | 156 | * |
spastor | 0:fcaad0dfa051 | 157 | * @param function function pointer with the callback function |
spastor | 0:fcaad0dfa051 | 158 | */ |
spastor | 0:fcaad0dfa051 | 159 | void register_receive_cb(receive_802_cb_t function); |
spastor | 0:fcaad0dfa051 | 160 | |
spastor | 0:fcaad0dfa051 | 161 | /** unregister_receive_cb - removes the rx packet callback */ |
spastor | 0:fcaad0dfa051 | 162 | void unregister_receive_cb(); |
spastor | 4:629712865107 | 163 | |
spastor | 0:fcaad0dfa051 | 164 | /** register_io_sample_cb - registers the callback function that will be called |
spastor | 0:fcaad0dfa051 | 165 | * when a IO Sample Data packet is received |
spastor | 0:fcaad0dfa051 | 166 | * |
spastor | 0:fcaad0dfa051 | 167 | * @param function function pointer with the callback function |
spastor | 0:fcaad0dfa051 | 168 | */ |
spastor | 0:fcaad0dfa051 | 169 | void register_io_sample_cb(io_data_cb_802_t function); |
spastor | 0:fcaad0dfa051 | 170 | |
spastor | 0:fcaad0dfa051 | 171 | /** unregister_io_sample_cb - removes the IO Sample Data reception callback */ |
spastor | 0:fcaad0dfa051 | 172 | void unregister_io_sample_cb(); |
spastor | 0:fcaad0dfa051 | 173 | |
spastor | 0:fcaad0dfa051 | 174 | /*********************** send_data member methods ************************/ |
spastor | 3:8662ebe83570 | 175 | /** send_data - sends data to a remote device |
spastor | 0:fcaad0dfa051 | 176 | * |
spastor | 0:fcaad0dfa051 | 177 | * @param remote remote device |
spastor | 0:fcaad0dfa051 | 178 | * @param data pointer to the data that will be sent |
spastor | 0:fcaad0dfa051 | 179 | * @param len number of bytes that will be transmitted |
spastor | 3:8662ebe83570 | 180 | * @param syncr if true, method waits for the packet answer with the result of the operation |
spastor | 0:fcaad0dfa051 | 181 | * @returns the result of the data transfer |
spastor | 0:fcaad0dfa051 | 182 | * TxStatusSuccess if the operation was successful, |
spastor | 0:fcaad0dfa051 | 183 | * the error code otherwise |
spastor | 0:fcaad0dfa051 | 184 | */ |
spastor | 3:8662ebe83570 | 185 | virtual TxStatus send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len, bool syncr = true); |
hbujanda | 1:794d1d3e4a08 | 186 | |
spastor | 4:629712865107 | 187 | /** get_assoc_status - returns current network association status. This wraps AI parameter, for more information refer to moudle's Reference Manual. |
spastor | 4:629712865107 | 188 | * |
spastor | 4:629712865107 | 189 | * @returns an AssocStatus with current network association status. |
spastor | 4:629712865107 | 190 | */ |
spastor | 4:629712865107 | 191 | AssocStatus get_assoc_status(void); |
spastor | 4:629712865107 | 192 | |
hbujanda | 2:2ee1b6d51df2 | 193 | /** get_remote_node_by_id - searches for a device in the network with the specified Node Identifier. |
hbujanda | 1:794d1d3e4a08 | 194 | * |
hbujanda | 2:2ee1b6d51df2 | 195 | * @param node_id node id of the device we are looking for |
hbujanda | 2:2ee1b6d51df2 | 196 | * @returns a RemoteXBee802 with the 16-bit and 64-bit address of the remote device whose node id matches with the parameter. |
hbujanda | 2:2ee1b6d51df2 | 197 | * If node is not found, the returned object will have invalid addresses (RemoteXBee802::is_valid() will return false). |
hbujanda | 1:794d1d3e4a08 | 198 | */ |
hbujanda | 2:2ee1b6d51df2 | 199 | RemoteXBee802 get_remote_node_by_id(const char * const node_id); |
spastor | 0:fcaad0dfa051 | 200 | |
spastor | 0:fcaad0dfa051 | 201 | /* Allow using XBee::set_param() methods for local radio from this class */ |
spastor | 0:fcaad0dfa051 | 202 | using XBee::set_param; |
spastor | 0:fcaad0dfa051 | 203 | |
spastor | 0:fcaad0dfa051 | 204 | /** set_param - sets a parameter in a remote radio by sending an AT command and waiting for the response. |
spastor | 0:fcaad0dfa051 | 205 | * |
spastor | 0:fcaad0dfa051 | 206 | * @param remote remote device |
spastor | 0:fcaad0dfa051 | 207 | * @param param parameter to be set. |
spastor | 0:fcaad0dfa051 | 208 | * @param data the parameter value (4 bytes) to be set. |
spastor | 0:fcaad0dfa051 | 209 | * @returns the command response status. |
spastor | 0:fcaad0dfa051 | 210 | */ |
spastor | 0:fcaad0dfa051 | 211 | virtual AtCmdFrame::AtCmdResp set_param(const RemoteXBee& remote, const char * const param, uint32_t data); |
spastor | 4:629712865107 | 212 | |
spastor | 0:fcaad0dfa051 | 213 | /** set_param - sets a parameter in a remote radio by sending an AT command and waiting for the response. |
spastor | 0:fcaad0dfa051 | 214 | * |
spastor | 0:fcaad0dfa051 | 215 | * @param remote remote device |
spastor | 0:fcaad0dfa051 | 216 | * @param param parameter to be set. |
spastor | 4:629712865107 | 217 | * @param the parameter value byte array (len bytes) to be set. |
spastor | 0:fcaad0dfa051 | 218 | * @param len number of bytes of the parameter value. |
spastor | 0:fcaad0dfa051 | 219 | * @returns the command response status. |
spastor | 0:fcaad0dfa051 | 220 | */ |
spastor | 0:fcaad0dfa051 | 221 | virtual AtCmdFrame::AtCmdResp set_param(const RemoteXBee& remote, const char * const param, const uint8_t * data = NULL, uint16_t len = 0); |
spastor | 0:fcaad0dfa051 | 222 | |
spastor | 0:fcaad0dfa051 | 223 | /* Allow using XBee::get_param() methods for local radio from this class */ |
spastor | 0:fcaad0dfa051 | 224 | using XBee::get_param; |
spastor | 4:629712865107 | 225 | |
spastor | 0:fcaad0dfa051 | 226 | /** get_param - gets a parameter from a remote radio by sending an AT command and waiting for the response. |
spastor | 0:fcaad0dfa051 | 227 | * |
spastor | 0:fcaad0dfa051 | 228 | * @param remote remote device |
spastor | 0:fcaad0dfa051 | 229 | * @param param parameter to be get. |
spastor | 4:629712865107 | 230 | * @param data pointer where the param value (4 bytes) will be stored. |
spastor | 0:fcaad0dfa051 | 231 | * @returns the command response status. |
spastor | 0:fcaad0dfa051 | 232 | */ |
spastor | 0:fcaad0dfa051 | 233 | virtual AtCmdFrame::AtCmdResp get_param(const RemoteXBee& remote, const char * const param, uint32_t * const data); |
spastor | 4:629712865107 | 234 | |
spastor | 0:fcaad0dfa051 | 235 | /** get_param - gets a parameter from a remote radio by sending an AT command and waiting for the response. |
spastor | 0:fcaad0dfa051 | 236 | * |
spastor | 0:fcaad0dfa051 | 237 | * @param remote remote device |
spastor | 0:fcaad0dfa051 | 238 | * @param param parameter to be get. |
spastor | 4:629712865107 | 239 | * @param data pointer where the param value (n bytes) will be stored. |
spastor | 4:629712865107 | 240 | * @param len pointer where the number of bytes of the param value will be stored. |
spastor | 0:fcaad0dfa051 | 241 | * @returns the command response status. |
spastor | 0:fcaad0dfa051 | 242 | */ |
spastor | 0:fcaad0dfa051 | 243 | virtual AtCmdFrame::AtCmdResp get_param(const RemoteXBee& remote, const char * const param, uint8_t * const data, uint16_t * const len); |
spastor | 0:fcaad0dfa051 | 244 | |
spastor | 0:fcaad0dfa051 | 245 | /************************* IO member methods **************************/ |
spastor | 0:fcaad0dfa051 | 246 | /** set_pin_config - configures a radio IO line |
spastor | 0:fcaad0dfa051 | 247 | * |
spastor | 0:fcaad0dfa051 | 248 | * @param remote remote device |
spastor | 0:fcaad0dfa051 | 249 | * @param line IO line being configured |
spastor | 0:fcaad0dfa051 | 250 | * @param mode configuration mode for the selected line |
spastor | 0:fcaad0dfa051 | 251 | * @returns |
spastor | 0:fcaad0dfa051 | 252 | * Success if the operation was successful, |
spastor | 0:fcaad0dfa051 | 253 | * Failure otherwise |
spastor | 0:fcaad0dfa051 | 254 | */ |
spastor | 0:fcaad0dfa051 | 255 | RadioStatus set_pin_config(const RemoteXBee& remote, IoLine line, IoMode mode); |
spastor | 0:fcaad0dfa051 | 256 | |
spastor | 0:fcaad0dfa051 | 257 | /** get_pin_config - gets the configuration of a radio IO line |
spastor | 0:fcaad0dfa051 | 258 | * |
spastor | 0:fcaad0dfa051 | 259 | * @param remote remote device |
spastor | 0:fcaad0dfa051 | 260 | * @param line IO line being read to get its configuration |
spastor | 0:fcaad0dfa051 | 261 | * @param mode pointer where the configuration will be stored |
spastor | 0:fcaad0dfa051 | 262 | * @returns |
spastor | 0:fcaad0dfa051 | 263 | * Success if the operation was successful, |
spastor | 0:fcaad0dfa051 | 264 | * Failure otherwise |
spastor | 0:fcaad0dfa051 | 265 | */ |
spastor | 0:fcaad0dfa051 | 266 | RadioStatus get_pin_config(const RemoteXBee& remote, IoLine line, IoMode * const mode); |
spastor | 0:fcaad0dfa051 | 267 | |
spastor | 0:fcaad0dfa051 | 268 | /** set_dio - sets to low/high a DIO line |
spastor | 0:fcaad0dfa051 | 269 | * |
spastor | 0:fcaad0dfa051 | 270 | * @param remote remote device |
spastor | 0:fcaad0dfa051 | 271 | * @param line DIO line being set |
spastor | 0:fcaad0dfa051 | 272 | * @param val value that will be set in the DIO line |
spastor | 0:fcaad0dfa051 | 273 | * @returns |
spastor | 0:fcaad0dfa051 | 274 | * Success if the operation was successful, |
spastor | 0:fcaad0dfa051 | 275 | * Failure otherwise |
spastor | 0:fcaad0dfa051 | 276 | */ |
spastor | 0:fcaad0dfa051 | 277 | RadioStatus set_dio(const RemoteXBee& remote, IoLine line, DioVal val); |
spastor | 0:fcaad0dfa051 | 278 | |
spastor | 0:fcaad0dfa051 | 279 | /** get_dio - read the value of a DIO configured as digital input |
spastor | 0:fcaad0dfa051 | 280 | * |
spastor | 0:fcaad0dfa051 | 281 | * @param remote remote device |
spastor | 0:fcaad0dfa051 | 282 | * @param line DIO line being read |
spastor | 0:fcaad0dfa051 | 283 | * @param val pointer where the DIO value read will be stored |
spastor | 0:fcaad0dfa051 | 284 | * @returns |
spastor | 0:fcaad0dfa051 | 285 | * Success if the operation was successful, |
spastor | 0:fcaad0dfa051 | 286 | * Failure otherwise |
spastor | 0:fcaad0dfa051 | 287 | */ |
spastor | 0:fcaad0dfa051 | 288 | RadioStatus get_dio(const RemoteXBee& remote, IoLine line, DioVal * const val); |
spastor | 0:fcaad0dfa051 | 289 | |
spastor | 0:fcaad0dfa051 | 290 | /** get_adc - read the value of the espcified ADC line |
spastor | 0:fcaad0dfa051 | 291 | * |
spastor | 0:fcaad0dfa051 | 292 | * @param remote remote device |
spastor | 0:fcaad0dfa051 | 293 | * @param line ADC line being read |
spastor | 0:fcaad0dfa051 | 294 | * @param val pointer where the value read from the ADC will be stored |
spastor | 0:fcaad0dfa051 | 295 | * @returns |
spastor | 0:fcaad0dfa051 | 296 | * Success if the operation was successful, |
spastor | 0:fcaad0dfa051 | 297 | * Failure otherwise |
spastor | 0:fcaad0dfa051 | 298 | */ |
spastor | 0:fcaad0dfa051 | 299 | RadioStatus get_adc(const RemoteXBee& remote, IoLine line, uint16_t * const val); |
spastor | 0:fcaad0dfa051 | 300 | |
spastor | 3:8662ebe83570 | 301 | /** get_iosample - retrieves an @ref IOSample802 from a remote node. This object can be used to get the remote node's ADC and DIO values. |
spastor | 3:8662ebe83570 | 302 | * |
spastor | 3:8662ebe83570 | 303 | * @param remote remote device |
spastor | 3:8662ebe83570 | 304 | * @returns IOSample802 object with the remote node's DIO and ADC values. |
spastor | 3:8662ebe83570 | 305 | */ |
spastor | 3:8662ebe83570 | 306 | IOSample802 get_iosample(const RemoteXBee& remote); |
spastor | 3:8662ebe83570 | 307 | |
spastor | 0:fcaad0dfa051 | 308 | /** set_pwm - sets the duty cycle of a PWM line |
spastor | 0:fcaad0dfa051 | 309 | * |
spastor | 0:fcaad0dfa051 | 310 | * @param remote remote device |
spastor | 0:fcaad0dfa051 | 311 | * @param line PWM line being set |
spastor | 0:fcaad0dfa051 | 312 | * @param duty_cycle duty cycle that will be set in the PWM line |
spastor | 0:fcaad0dfa051 | 313 | * @returns |
spastor | 0:fcaad0dfa051 | 314 | * Success if the operation was successful, |
spastor | 0:fcaad0dfa051 | 315 | * Failure otherwise |
spastor | 0:fcaad0dfa051 | 316 | */ |
spastor | 0:fcaad0dfa051 | 317 | RadioStatus set_pwm(const RemoteXBee& remote, IoLine line, float duty_cycle); |
spastor | 0:fcaad0dfa051 | 318 | |
spastor | 0:fcaad0dfa051 | 319 | /** set_pin_pull_up - enables or disables the internal pull-up resistor of a line |
spastor | 0:fcaad0dfa051 | 320 | * |
spastor | 0:fcaad0dfa051 | 321 | * @param remote remote device |
spastor | 0:fcaad0dfa051 | 322 | * @param line line being configured for pull-up |
spastor | 0:fcaad0dfa051 | 323 | * @param enable whether to enable the internal pull-up resistor. |
spastor | 0:fcaad0dfa051 | 324 | * @returns |
spastor | 0:fcaad0dfa051 | 325 | * Success if the operation was successful, |
spastor | 0:fcaad0dfa051 | 326 | * Failure otherwise |
spastor | 0:fcaad0dfa051 | 327 | */ |
spastor | 0:fcaad0dfa051 | 328 | RadioStatus set_pin_pull_up(const RemoteXBee& remote, IoLine line, bool enable); |
spastor | 0:fcaad0dfa051 | 329 | |
spastor | 0:fcaad0dfa051 | 330 | /** enable_dio_change_detection - enables or disables the notification when a change is detected in a digital input line. |
spastor | 0:fcaad0dfa051 | 331 | * In other words, it will force an IO Sample transmission when the DIO state changes. Only for DIO0 to DIO7. |
spastor | 0:fcaad0dfa051 | 332 | * |
spastor | 0:fcaad0dfa051 | 333 | * @param remote remote device |
spastor | 0:fcaad0dfa051 | 334 | * @param line line being configured for pull-up |
spastor | 0:fcaad0dfa051 | 335 | * @param enable whether to enable the internal pull-up resistor. |
spastor | 0:fcaad0dfa051 | 336 | * @returns |
spastor | 0:fcaad0dfa051 | 337 | * Success if the operation was successful, |
spastor | 0:fcaad0dfa051 | 338 | * Failure otherwise |
spastor | 0:fcaad0dfa051 | 339 | */ |
spastor | 0:fcaad0dfa051 | 340 | RadioStatus enable_dio_change_detection(const RemoteXBee& remote, IoLine line, bool enable); |
spastor | 0:fcaad0dfa051 | 341 | |
spastor | 0:fcaad0dfa051 | 342 | /* TODO: With current firmware ATM0 fails: Returns just OK and sets pwm to 0 */ |
spastor | 0:fcaad0dfa051 | 343 | #ifdef GET_PWM_AVAILABLE |
spastor | 0:fcaad0dfa051 | 344 | /** get_pwm - gets the duty cycle of a PWM line |
spastor | 0:fcaad0dfa051 | 345 | * |
spastor | 0:fcaad0dfa051 | 346 | * @param remote remote device |
spastor | 0:fcaad0dfa051 | 347 | * @param line PWM line being read |
spastor | 0:fcaad0dfa051 | 348 | * @param duty_cycle pointer where the value of the duty cycle read from |
spastor | 0:fcaad0dfa051 | 349 | * the PWM line will be stored |
spastor | 0:fcaad0dfa051 | 350 | * @returns |
spastor | 0:fcaad0dfa051 | 351 | * Success if the operation was successful, |
spastor | 0:fcaad0dfa051 | 352 | * Failure otherwise |
spastor | 0:fcaad0dfa051 | 353 | */ |
spastor | 0:fcaad0dfa051 | 354 | RadioStatus get_pwm(const RemoteXBee& remote, IoLine line, float * const duty_cycle); |
spastor | 0:fcaad0dfa051 | 355 | #endif |
spastor | 0:fcaad0dfa051 | 356 | |
spastor | 0:fcaad0dfa051 | 357 | protected: |
spastor | 0:fcaad0dfa051 | 358 | |
spastor | 0:fcaad0dfa051 | 359 | /** Frame handler used for the node discovery. Registered when a callback function |
spastor | 0:fcaad0dfa051 | 360 | * is registered */ |
spastor | 0:fcaad0dfa051 | 361 | FH_NodeDiscovery802 *_nd_handler; |
spastor | 4:629712865107 | 362 | |
spastor | 0:fcaad0dfa051 | 363 | /** Frame handler used for the rx 64 bit packets. Automatically registered when a callback |
spastor | 4:629712865107 | 364 | * function is registered */ |
spastor | 0:fcaad0dfa051 | 365 | FH_RxPacket64b802 *_rx_64b_handler; |
spastor | 4:629712865107 | 366 | |
spastor | 0:fcaad0dfa051 | 367 | /** Frame handler used for the rx 16 bit packets. Automatically registered when a callback |
spastor | 0:fcaad0dfa051 | 368 | * function is registered */ |
spastor | 0:fcaad0dfa051 | 369 | FH_RxPacket16b802 *_rx_16b_handler; |
spastor | 0:fcaad0dfa051 | 370 | |
spastor | 0:fcaad0dfa051 | 371 | /** Frame handler used for the 64 bit IO Data Samples packets. Automatically registered when a callback |
spastor | 0:fcaad0dfa051 | 372 | * function is registered */ |
spastor | 0:fcaad0dfa051 | 373 | FH_IoDataSampe64b802 *_io_data_64b_handler; |
spastor | 0:fcaad0dfa051 | 374 | |
spastor | 0:fcaad0dfa051 | 375 | /** Frame handler used for the 16 bit IO Data Samples packets. Automatically registered when a callback |
spastor | 0:fcaad0dfa051 | 376 | * function is registered */ |
spastor | 0:fcaad0dfa051 | 377 | FH_IoDataSampe16b802 *_io_data_16b_handler; |
spastor | 0:fcaad0dfa051 | 378 | |
spastor | 4:629712865107 | 379 | /** Method called directly by the library when a modem status frame is received to |
spastor | 0:fcaad0dfa051 | 380 | * update the internal status variables */ |
spastor | 0:fcaad0dfa051 | 381 | virtual void radio_status_update(AtCmdFrame::ModemStatus modem_status); |
spastor | 0:fcaad0dfa051 | 382 | |
spastor | 0:fcaad0dfa051 | 383 | /* Allow using XBee::send_data() methods from this class */ |
spastor | 0:fcaad0dfa051 | 384 | using XBee::send_data; |
spastor | 4:629712865107 | 385 | |
hbujanda | 6:06522f3a6642 | 386 | /** get_node_discovery_timeout - gets the node discovery timeout |
hbujanda | 6:06522f3a6642 | 387 | * |
hbujanda | 6:06522f3a6642 | 388 | * @param timeout_ms pointer where the node discovery timeout value will be stored |
hbujanda | 6:06522f3a6642 | 389 | * @param wait_for_complete_timeout pointer where the function will store if the operator |
hbujanda | 6:06522f3a6642 | 390 | * has to wait for the complete nd timeout after issuing |
hbujanda | 6:06522f3a6642 | 391 | * a directed nd request |
hbujanda | 6:06522f3a6642 | 392 | * @returns |
hbujanda | 6:06522f3a6642 | 393 | * Success if the operation was successful, |
hbujanda | 6:06522f3a6642 | 394 | * Failure otherwise |
hbujanda | 6:06522f3a6642 | 395 | */ |
hbujanda | 6:06522f3a6642 | 396 | virtual RadioStatus get_node_discovery_timeout(uint16_t * const timeout_ms); |
hbujanda | 6:06522f3a6642 | 397 | virtual RadioStatus get_node_discovery_timeout(uint16_t * const timeout_ms, bool * const wait_for_complete_timeout); |
hbujanda | 6:06522f3a6642 | 398 | |
spastor | 0:fcaad0dfa051 | 399 | private: |
spastor | 0:fcaad0dfa051 | 400 | |
spastor | 0:fcaad0dfa051 | 401 | }; |
spastor | 0:fcaad0dfa051 | 402 | |
spastor | 0:fcaad0dfa051 | 403 | } /* namespace XBeeLib */ |
spastor | 0:fcaad0dfa051 | 404 | |
spastor | 0:fcaad0dfa051 | 405 | #endif /* __XBEE_802_H_ */ |