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