00001 /*! \file WaspXBee868.h 00002 \brief Library for managing XBee 868MHz modules 00003 00004 Copyright (C) 2009 Libelium Comunicaciones Distribuidas S.L. 00005 http://www.libelium.com 00006 00007 This program is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU Lesser General Public License as published by 00009 the Free Software Foundation, either version 2.1 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 00020 Version: 0.2 00021 00022 Design: David Gascón 00023 00024 Implementation: Alberto Bielsa 00025 00026 */ 00027 00028 /*! \def WaspXBee868_h 00029 \brief The library flag 00030 00031 */ 00032 #ifndef WaspXBee868_h 00033 #define WaspXBee868_h 00034 00035 /****************************************************************************** 00036 * Includes 00037 ******************************************************************************/ 00038 00039 #include <string.h> 00040 #include <stdint.h> 00041 #include <stdlib.h> 00042 #include "WConstants.h" 00043 #include "WaspXBee.h" 00044 #include "WaspUSB.h" 00045 #include "WaspXBeeCore.h" 00046 #include <inttypes.h> 00047 00048 #ifndef __WASPXBEECONSTANTS_H__ 00049 #include "WaspXBeeConstants.h" 00050 #endif 00051 00052 /****************************************************************************** 00053 * Class 00054 ******************************************************************************/ 00055 00056 //! WaspXBee868 Class 00057 /*! 00058 WaspXBee868 Class defines all the variables and functions used to manage XBee 868 modules. It inherits from 'WaspXBeeCore' class the necessary functions, variables and definitions 00059 */ 00060 class WaspXBee868 : public WaspXBeeCore 00061 { 00062 public: 00063 00064 //! class constructor 00065 /*! 00066 It does nothing 00067 \param void 00068 \return void 00069 */ 00070 WaspXBee868(){}; 00071 00072 //! It initializes the necessary variables 00073 /*! 00074 It initalizes all the necessary variables including its father's variables 00075 \param uint8_t protocol_used : specifies the protocol used in the XBee module (XBEE_868 in this case) 00076 \param uint8_t frequency : specifies the frequency used in the XBee module (FREQ868M in this case) 00077 \param uint8_t model_used : specifies the XBee model used (PRO in this case) 00078 \return void 00079 */ 00080 void init(uint8_t protocol_used,uint8_t frequency, uint8_t model_used); 00081 00082 //! It gets the number of times the RF receiver detected a CRC or length error 00083 /*! 00084 It stores in global 'errorsRF' variable the number of times the RF receiver detected a CRC or length error 00085 \return '0' on success, '1' otherwise 00086 */ 00087 uint8_t getRFerrors(); 00088 00089 //! It gets the number of good frames with valid MAC headers that are received on the RF interface 00090 /*! 00091 It stores in global 'goodPackets' variable the number of good frames with valid MAC headers that are received on the RF interface 00092 \return '0' on success, '1' otherwise 00093 */ 00094 uint8_t getGoodPackets(); 00095 00096 //! It gets the DBM level of the designated channel 00097 /*! 00098 It stores in global 'channelRSSI' variable the DBM level of the designated channel 00099 \param uint8_t channel : the channel where to get the DBM level (range [0-11]) 00100 \return '0' on success, '1' otherwise 00101 */ 00102 uint8_t getChannelRSSI(uint8_t channel); 00103 00104 //! It gets the number of MAC frames that exhaust MAC retries without ever receiving a MAC acknowledgement message from the adjacent node 00105 /*! 00106 It stores in global 'transmisionErrors' variable the number of MAC frames that exhaust MAC retries without ever receiving a MAC acknowledgement message from the adjacent node 00107 \return '0' on success, '1' otherwise 00108 */ 00109 uint8_t getTransmisionErrors(); 00110 00111 //! It gets module temperature in Celsius. Negatives temperatures can be returned 00112 /*! 00113 It stores in global 'temperature' variable module temperature in Celsius 00114 \return '0' on success, '1' otherwise 00115 */ 00116 uint8_t getTemperature(); 00117 00118 //! It gets the voltage on the Vcc pin 00119 /*! 00120 It stores in global 'supplyVoltage' variable the voltage on the Vcc pin 00121 \return '0' on success, '1' otherwise 00122 */ 00123 uint8_t getSupplyVoltage(); 00124 00125 //! It gets the current device type 00126 /*! 00127 It stores in global 'deviceType' variable the current device type 00128 \return '0' on success, '1' otherwise 00129 */ 00130 uint8_t getDeviceType(); 00131 00132 //! It gets the bytes that can be used in the payload 00133 /*! 00134 It stores in global 'maxPayloadBytes' variable the bytes that can be used in the payload 00135 \return '0' on success, '1' otherwise 00136 */ 00137 uint8_t getPayloadBytes(); 00138 00139 //! It sets the number of additional broadcast retransmissions 00140 /*! 00141 \param uint8_t mtrans : specifies the number of additional broadcast retransmissions (range [0x00-0x0F]) 00142 \return '0' on success, '1' otherwise 00143 */ 00144 uint8_t setMultipleBroadcast(uint8_t mtrans); 00145 00146 //! It gets the number of additional broadcast retransmissions 00147 /*! 00148 It stores in global 'multipleBroadcast' variable the number of additional broadcast retransmissions 00149 \return '0' on success, '1' otherwise 00150 */ 00151 uint8_t getMultipleBroadcast(); 00152 00153 //! It sets the number of retries than can be sent for a given unicast RF packet 00154 /*! 00155 \param uint8_t macretries : specifies the number of retries than can be sent for a given unicast RF packet (range [0x00-0x0F]) 00156 \return '0' on success, '1' otherwise 00157 */ 00158 uint8_t setMacRetries(uint8_t macretries); 00159 00160 //! It gets the number of retries than can be sent for a given unicast RF packet 00161 /*! 00162 It stores in global 'macRetries' variable the number of retries than can be sent for a given unicast RF packet 00163 \return '0' on success, '1' otherwise 00164 */ 00165 uint8_t getMacRetries(); 00166 00167 //! It gets the % it has been used of available Duty Cicle 00168 /*! 00169 It stores in global 'dutyCicle' variable the % it has been used of available Duty Cicle 00170 \return '0' on success, '1' otherwise 00171 */ 00172 uint8_t getDutyCicle(); 00173 00174 //! It gets the reason for the last module reset 00175 /*! 00176 It stores in global 'resetReason' variable the reason for the last module reset 00177 \return '0' on success, '1' otherwise 00178 */ 00179 uint8_t getResetReason(); 00180 00181 //! It gets the number of failed ACK retries 00182 /*! 00183 It stores in global 'ACKerrors' variable the number of failed ACK retries 00184 \return '0' on success, '1' otherwise 00185 */ 00186 uint8_t getACKerrors(); 00187 00188 //! Variable : the number of failed ACK retries 00189 /*! 00190 */ 00191 uint8_t ACKerrors[2]; 00192 00193 //! Variable : the number of times the RF receiver detected a CRC or length error 00194 /*! 00195 */ 00196 uint8_t errorsRF[2]; 00197 00198 //! Variable : the number of good frames with valid MAC headers that are received on the RF interface 00199 /*! 00200 */ 00201 uint8_t goodPackets[2]; 00202 00203 //! Variable : the DBM level of the designated channel 00204 /*! 00205 */ 00206 uint8_t channelRSSI; 00207 00208 //! Variable : the number of MAC frames that exhaust MAC retries without ever receiving a MAC acknowledgement message from the adjacent node 00209 /*! 00210 */ 00211 uint8_t transmisionErrors[2]; 00212 00213 //! Variable : module temperature in Celsius. Negatives temperatures can be returned 00214 /*! 00215 */ 00216 uint8_t temperature[2]; 00217 00218 //! Variable : Voltage on the Vcc pin 00219 /*! 00220 */ 00221 uint8_t supplyVoltage[2]; 00222 00223 //! Variable : Max payload to be used for transmission 00224 /*! 00225 */ 00226 uint8_t maxPayloadBytes[2]; 00227 00228 //! Variable : the current device type 00229 /*! 00230 */ 00231 uint8_t deviceType[4]; 00232 00233 //! Variable : the number of additional broadcast retransmissions (range [0x00-0x0F]) 00234 /*! 00235 */ 00236 uint8_t multipleBroadcast; 00237 00238 //! Variable : the number of retries than can be sent for a given unicast RF packet (range [0x00-0x0F]) 00239 /*! 00240 */ 00241 uint8_t macRetries; 00242 00243 //! Variable : the % it has been used of available Duty Cicle 00244 /*! 00245 */ 00246 uint8_t dutyCicle; 00247 00248 //! Variable : Reason for the last module reset 00249 /*! 00250 */ 00251 uint8_t resetReason; 00252 }; 00253 00254 extern WaspXBee868 xbee868; 00255 00256 #endif
1.5.6