00001 /*! \file WaspXBee802.h 00002 \brief Library for managing XBee 802.15.4 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 WaspXBee802_h 00029 \brief The library flag 00030 00031 */ 00032 #ifndef WaspXBee802_h 00033 #define WaspXBee802_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 //! WaspXBee802 Class 00057 /*! 00058 WaspXBee802 Class defines all the variables and functions used to manage XBee 802.15.4 modules. It inherits from 'WaspXBeeCore' class the necessary functions, variables and definitions 00059 */ 00060 class WaspXBee802 : public WaspXBeeCore 00061 { 00062 public: 00063 00064 //! class constructor 00065 /*! 00066 It does nothing 00067 \param void 00068 \return void 00069 */ 00070 WaspXBee802(){}; 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_802_15_4 in this case) 00076 \param uint8_t frequency : specifies the frequency used in the XBee module (FREQ2_4G in this case) 00077 \param uint8_t model_used : specifies the XBee model used (NORMAL or PRO) 00078 \return void 00079 */ 00080 void init(uint8_t protocol_used, uint8_t frequency, uint8_t model_used); 00081 00082 //! It sets the maximum number of retries to execute in addition to the three retries defined in the 802.15.4 protocol 00083 /*! 00084 \param uint8_t retry : specifies the number of retries to set (range [0-6]) 00085 \return '0' on success, '1' otherwise 00086 */ 00087 uint8_t setRetries(uint8_t retry); 00088 00089 //! It gets the maximum number of retries to execute in addition to the three retries defined in the 802.15.4 protocol 00090 /*! 00091 It stores in global 'retries' variable the number of retries 00092 \return '0' on success, '1' otherwise 00093 */ 00094 uint8_t getRetries(); 00095 00096 //! It sets the minimun value of the back-off exponent in CSMA/CA 00097 /*! 00098 \param uint8_t exponent : specifies the value of the back-off exponent in CSMA/CA (range [0-3]) 00099 \return '0' on success, '1' otherwise 00100 */ 00101 uint8_t setDelaySlots(uint8_t exponent); 00102 00103 //! It gets the minimun value of the back-off exponent in CSMA/CA 00104 /*! 00105 It stores in global 'delaySlots' variable the minimun value of the back-off exponent in CSMA/CA 00106 \return '0' on success, '1' otherwise 00107 */ 00108 uint8_t getDelaySlots(); 00109 00110 //! It sets the MAC mode 00111 /*! 00112 \param uint8_t mac : specifies the MAC mode (range [0-3]) 00113 \return '0' on success, '1' otherwise 00114 */ 00115 uint8_t setMacMode(uint8_t mac); 00116 00117 //! It gets the MAC mode 00118 /*! 00119 It stores in global 'macMode' variable the MAC mode 00120 \return '0' on success, '1' otherwise 00121 */ 00122 uint8_t getMacMode(); 00123 00124 //! It sets the CA threshold in the CCA process to detect energy on the channel 00125 /*! 00126 \param uint8_t threshold : specifies the CA threshold in the CCA process to detect energy on the channel (range [0x00-0x50]) 00127 \return '0' on success, '1' otherwise 00128 */ 00129 uint8_t setEnergyThreshold(uint8_t threshold); 00130 00131 //! It gets the Energy Threshold used in the CCA process 00132 /*! 00133 It stores in global 'energyThreshold' variable the Energy Threshold used in the CCA process 00134 \return '0' on success, '1' otherwise 00135 */ 00136 uint8_t getEnergyThreshold(); 00137 00138 //! It gets the number of times too much energy has been found on the channel 00139 /*! 00140 It stores in global 'counterCCA' variable the number of times too much energy has been found on the channel 00141 \return '0' on success, '1' otherwise 00142 */ 00143 uint8_t getCCAcounter(); 00144 00145 //! It resets the CCA counter 00146 /*! 00147 \param void 00148 \return '0' on success, '1' otherwise 00149 */ 00150 uint8_t resetCCAcounter(); 00151 00152 //! It gets the number of times there has been an ACK failure 00153 /*! 00154 It stores in global 'counterACK' variable the number of times there has been an ACK failure 00155 \return '0' on success, '1' otherwise 00156 */ 00157 uint8_t getACKcounter(); 00158 00159 //! It resets the ACK counter 00160 /*! 00161 \param void 00162 \return '0' on success, '1' otherwise 00163 */ 00164 uint8_t resetACKcounter(); 00165 00166 00167 //! Variable : number of retries to execute in addition to the three retries defined in the 802.15.4 protocol (range [0-6]) 00168 /*! 00169 */ 00170 uint8_t retries; 00171 00172 //! Variable : the minimun value of the back-off exponent in CSMA/CA (range [0-3]) 00173 /*! 00174 */ 00175 uint8_t delaySlots; 00176 00177 //! Variable : the MAC mode(range [0-3]) 00178 /*! 00179 */ 00180 uint8_t macMode; 00181 00182 //! Variable : the CA threshold in the CCA process to detect energy on the channel (range [0x00-0x50]) 00183 /*! 00184 */ 00185 uint8_t energyThreshold; 00186 00187 //! Variable : the number of times too much energy has been found on the channel 00188 /*! 00189 */ 00190 uint8_t counterCCA[2]; 00191 00192 //! Variable : the number of times there has been an ACK failure 00193 /*! 00194 */ 00195 uint8_t counterACK[2]; 00196 00197 private: 00198 00199 //! Variable : internal counter 00200 /*! 00201 */ 00202 uint8_t counter; 00203 }; 00204 00205 extern WaspXBee802 xbee802; 00206 00207 #endif
1.5.6