00001 /*! \file WaspXBeeZB.h 00002 \brief Library for managing XBee ZigBee 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 WaspXBeeZB_h 00029 \brief The library flag 00030 00031 */ 00032 #ifndef WaspXBeeZB_h 00033 #define WaspXBeeZB_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 //! WaspXBeeZB Class 00057 /*! 00058 WaspXBeeZB Class defines all the variables and functions used to manage XBee ZigBee modules. It inherits from 'WaspXBeeCore' class the necessary functions, variables and definitions 00059 */ 00060 class WaspXBeeZB : public WaspXBeeCore 00061 { 00062 public: 00063 00064 //! class constructor 00065 /*! 00066 It does nothing 00067 \param void 00068 \return void 00069 */ 00070 WaspXBeeZB(){}; 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 (ZIGBEE 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 resets the network 00083 /*! 00084 \param uint8_t reset : specifies the reset to do (0: reset the node network interface || 1: reset the entirely network) 00085 \return '0' on success, '1' otherwise 00086 */ 00087 uint8_t resetNetwork(uint8_t reset); 00088 00089 //! It gets the 16b parent´s network address 00090 /*! 00091 It stores in global 'parentNA' variable the 16b parent´s network address 00092 \return '0' on success, '1' otherwise 00093 */ 00094 uint8_t getParentNetworkAddress(); 00095 00096 //! It gets the number of children which can still connect to the current device 00097 /*! 00098 It stores in global 'remainingChildren' variable the number of children which can still connect to the current device 00099 \return '0' on success, '1' otherwise 00100 */ 00101 uint8_t getRemainingChildren(); 00102 00103 //! It sets the current device type 00104 /*! 00105 \param uint8_t* type : the current device type (range [0-0xFFFFFFFF]) 00106 \return '0' on success, '1' otherwise 00107 */ 00108 uint8_t setDeviceType(uint8_t* type); 00109 00110 //! It gets the current device type 00111 /*! 00112 It stores in global 'deviceType' variable the current device type 00113 \return '0' on success, '1' otherwise 00114 */ 00115 uint8_t getDeviceType(); 00116 00117 //! It gets the bytes that can be used in the payload 00118 /*! 00119 It stores in global 'maxPayloadBytes' variable the bytes that can be used in the payload 00120 \return '0' on success, '1' otherwise 00121 */ 00122 uint8_t getPayloadBytes(); 00123 00124 //! It gets the Extended PAN ID 00125 /*! 00126 It stores in global 'extendedPan' variable the Extended PAN ID 00127 \return '0' on success, '1' otherwise 00128 */ 00129 uint8_t getExtendedPAN(); 00130 00131 //! It gets the Operating PAN ID 00132 /*! 00133 It stores in global 'operatingPAN' variable the Operating PAN ID 00134 \return '0' on success, '1' otherwise 00135 */ 00136 uint8_t getOperatingPAN(); 00137 00138 //! It sets the maximum hops limit 00139 /*! 00140 \param uint8_t type : the maximum hops limit (range [0x00-0xFF]) 00141 \return '0' on success, '1' otherwise 00142 */ 00143 uint8_t setMaxUnicastHops(uint8_t hops); 00144 00145 //! It gets the maximum hop limits 00146 /*! 00147 It stores in global 'maxUnicastHops' variable the maximum hop limits 00148 \return '0' on success, '1' otherwise 00149 */ 00150 uint8_t getMaxUnicastHops(); 00151 00152 //! It sets the maximum number of hops for each broadcast data transmission 00153 /*! 00154 \param uint8_t bhops : the maximum number of hops for each broadcast data transmission (range [0x00-0x20]) 00155 \return '0' on success, '1' otherwise 00156 */ 00157 uint8_t setMaxBroadcastHops(uint8_t bhops); 00158 00159 //! It gets the maximum number of hops for each broadcast data transmission 00160 /*! 00161 It stores in global 'maxBroadcastHops' variable the maximum number of hops for each broadcast data transmission 00162 \return '0' on success, '1' otherwise 00163 */ 00164 uint8_t getMaxBroadcastHops(); 00165 00166 //! It sets the ZigBee Stack profile 00167 /*! 00168 \param uint8_t profile : the ZigBee Stack profile (range [0-2]) 00169 \return '0' on success, '1' otherwise 00170 */ 00171 uint8_t setStackProfile(uint8_t profile); 00172 00173 //! It gets the ZigBee Stack profile 00174 /*! 00175 It stores in global 'stackProfile' variable the ZigBee Stack profile 00176 \return '0' on success, '1' otherwise 00177 */ 00178 uint8_t getStackProfile(); 00179 00180 //! It sets the number of Sleep Periods to not assert XBee pin 00181 /*! 00182 \param uint8_t* periods : the number of Sleep Periods to not assert XBee pin (range [0x20-0xAF0]) 00183 \return '0' on success, '1' otherwise 00184 */ 00185 uint8_t setPeriodSleep(uint8_t* periods); 00186 00187 //! It sets the time that a Coordinator/Router allows nodes to join 00188 /*! 00189 \param uint8_t time : the time that a Coordinator/Router allows nodes to join (range [0x00-0xFF]) 00190 \return '0' on success, '1' otherwise 00191 */ 00192 uint8_t setJoinTime(uint8_t time); 00193 00194 //! It gets the time that a Coordinator/Router allows nodes to join 00195 /*! 00196 It stores in global 'joinTime' variable the time that a Coordinator/Router allows nodes to join 00197 \return '0' on success, '1' otherwise 00198 */ 00199 uint8_t getJoinTime(); 00200 00201 //! It sets the channel verification parameter 00202 /*! 00203 \param uint8_t time : the channel verification parameter (range [0-1]) 00204 \return '0' on success, '1' otherwise 00205 */ 00206 uint8_t setChannelVerification(uint8_t verif); 00207 00208 //! It gets the channel verification parameter 00209 /*! 00210 It stores in global 'channelVerification' variable the channel verification parameter 00211 \return '0' on success, '1' otherwise 00212 */ 00213 uint8_t getChannelVerification(); 00214 00215 //! It sets the join notification setting 00216 /*! 00217 \param uint8_t notif : the join notification setting (range [0-1]) 00218 \return '0' on success, '1' otherwise 00219 */ 00220 uint8_t setJoinNotification(uint8_t notif); 00221 00222 //! It gets the join notification setting 00223 /*! 00224 It stores in global 'joinNotification' variable the join notification setting 00225 \return '0' on success, '1' otherwise 00226 */ 00227 uint8_t getJoinNotification(); 00228 00229 //! It sets the time between consecutive aggregate route broadcast messages 00230 /*! 00231 \param uint8_t anotif : the time between consecutive aggregate route broadcast messages (range [0x00-0xFF]) 00232 \return '0' on success, '1' otherwise 00233 */ 00234 uint8_t setAggregateNotification(uint8_t anotif); 00235 00236 //! It gets the time between consecutive aggregate route broadcast messages 00237 /*! 00238 It stores in global 'aggregateNotification' variable the time between consecutive aggregate route broadcast messages 00239 \return '0' on success, '1' otherwise 00240 */ 00241 uint8_t getAggregateNotification(); 00242 00243 //! It gets information regarding last node join request 00244 /*! 00245 It stores in global 'associationIndication' variable information regarding last node join request 00246 \return '0' on success, '1' otherwise 00247 */ 00248 uint8_t getAssociationIndication(); 00249 00250 //! It sets options for encryption 00251 /*! 00252 \param uint8_t eoptions : options for encryption (range [0-2]) 00253 \return '0' on success, '1' otherwise 00254 */ 00255 uint8_t setEncryptionOptions(uint8_t eoptions); 00256 00257 //! It gets options for encryption 00258 /*! 00259 It stores in global 'encrypOptions' variable options for encryption 00260 \return '0' on success, '1' otherwise 00261 */ 00262 uint8_t getEncryptionOptions(); 00263 00264 //! It sets the 128-bit AES encryption key 00265 /*! 00266 \param char* key : the 128-bit AES encryption key (range [0-0xFFFFFFFFFFFFFFFF]) 00267 \return '0' on success, '1' otherwise 00268 */ 00269 uint8_t setNetworkKey(char* key); 00270 00271 //! It sets the power mode of the device 00272 /*! 00273 \param uint8_t power : the power mode of the device (range [0-1]) 00274 \return '0' on success, '1' otherwise 00275 */ 00276 uint8_t setPowerMode(uint8_t power); 00277 00278 //! It gets the power mode of the device 00279 /*! 00280 It stores in global 'powerMode' variable the power mode of the device 00281 \return '0' on success, '1' otherwise 00282 */ 00283 uint8_t getPowerMode(); 00284 00285 //! It gets the voltage on the Vcc pin 00286 /*! 00287 It stores in global 'supplyVoltage' variable the voltage on the Vcc pin 00288 \return '0' on success, '1' otherwise 00289 */ 00290 uint8_t getSupplyVoltage(); 00291 00292 //! It sets the Application Layer Encryption 00293 /*! 00294 \param uint8_t mode : enables or disables this encryption mode (XBEE_ON or XBEE_OFF) 00295 \return '0' on success, '1' otherwise 00296 */ 00297 uint8_t setAPSencryption(uint8_t mode); 00298 00299 //! Variable : the 16b parent´s network address 00300 /*! 00301 */ 00302 uint8_t parentNA[2]; 00303 00304 //! Variable : the number of children which can still connect to the current device 00305 /*! 00306 */ 00307 uint8_t remainingChildren; 00308 00309 //! Variable : the current device type 00310 /*! 00311 */ 00312 uint8_t deviceType[4]; 00313 00314 //! Variable : the bytes that can be used in the payload 00315 /*! 00316 */ 00317 uint8_t maxPayloadBytes[2]; 00318 00319 //! Variable : the extended PAN ID 00320 /*! 00321 */ 00322 uint8_t extendedPAN[8]; 00323 00324 //! Variable : the operating PAN ID 00325 /*! 00326 */ 00327 uint8_t operatingPAN[2]; 00328 00329 //! Variable : the maximum hops limit (range [0x00-0xFF]) 00330 /*! 00331 */ 00332 uint8_t maxUnicastHops; 00333 00334 //! Variable : the maximum number of hops for each broadcast data transmission (range [0x00-0x20]) 00335 /*! 00336 */ 00337 uint8_t maxBroadcastHops; 00338 00339 //! Variable : the ZigBee Stack profile (range [0-2]) 00340 /*! 00341 */ 00342 uint8_t stackProfile; 00343 00344 //! Variable : the number of Sleep Periods to not assert XBee pin 00345 /*! 00346 */ 00347 uint8_t periodSleep[2]; 00348 00349 //! Variable : the time that a Coordinator/Router allows nodes to join (range [0x00-0xFF]) 00350 /*! 00351 */ 00352 uint8_t joinTime; 00353 00354 //! Variable : the channel verification parameter (range [0-1]) 00355 /*! 00356 */ 00357 uint8_t channelVerification; 00358 00359 //! Variable : the join notification setting (range [0-1]) 00360 /*! 00361 */ 00362 uint8_t joinNotification; 00363 00364 //! Variable : the time between consecutive aggregate route broadcast messages (range [0x00-0xFF]) 00365 /*! 00366 */ 00367 uint8_t aggregateNotification; 00368 00369 //! Variable : information regarding last node join request 00370 /*! 00371 */ 00372 uint8_t associationIndication; 00373 00374 //! Variable : options for encryption (range [0-2]) 00375 /*! 00376 */ 00377 uint8_t encryptOptions; 00378 00379 //! Variable : the 128-bit AES encryption key (range [0-0xFFFFFFFFFFFFFFFF]) 00380 /*! 00381 */ 00382 uint8_t networkKey[16]; 00383 00384 //! Variable : the power mode of the device (range [0-1]) 00385 /*! 00386 */ 00387 uint8_t powerMode; 00388 00389 //! Variable : the voltage on the Vcc pin 00390 /*! 00391 */ 00392 uint8_t supplyVoltage[2]; 00393 }; 00394 00395 extern WaspXBeeZB xbeeZB; 00396 00397 #endif
1.5.6