WaspXBee Class Reference

WaspXBee Class. More...

#include <WaspXBee.h>


Public Member Functions

 WaspXBee ()
 class constructor
void begin ()
 It opens UART to be able to communicate with the XBee.
void begin (uint16_t speed)
 It opens UART to be able to communicate with the XBee.
void close ()
 It closes the previously opened UART.
void setMode (uint8_t mode)
 It sets ON/OFF the XBee switch or sets the XBee to sleep.
uint8_t available ()
 It checks if there is available data waiting to be read.
int read ()
 It reads a byte from the UART.
void flush ()
 It clears the UART buffer.
void print (char c)
 It prints a character.
void print (const char[])
 It prints a string.
void print (uint8_t b)
 It prints an unsigned 8-bit integer.
void print (int n)
 It prints an integer.
void print (unsigned int n)
 It prints an unsigned integer.
void print (long n)
 It prints a long integer.
void print (unsigned long n)
 It prints an unsigned long integer.
void print (long n, int base)
 It prints a long number in the specified base.
void print (double n)
 It prints a double number.
void println ()
 It prints an EOL and a carriage return.
void println (char c)
 It prints a character adding an EOL and a carriage return.
void println (const char[])
 It prints a string adding an EOL and a carriage return.
void println (uint8_t b)
 It prints an unsigned 8-bit integer adding an EOL and a carriage return.
void println (int n)
 It prints an integer adding an EOL and a carriage return.
void println (long n)
 It prints a long integer adding an EOL and a carriage return.
void println (unsigned long n)
 It prints an unsigned long integer adding an EOL and a carriage return.
void println (long n, int base)
 It prints a long number in the specified base adding an EOL and a carriage return.
void println (double n)
 It prints a double number adding an EOL and a carriage return.

Private Member Functions

void printNumber (unsigned long n, uint8_t base)
 It prints a number in the specified base.
void printFloat (double number, uint8_t digits)
 It prints a 'float' number.

Private Attributes

uint8_t _uart
 Variable : specifies the UART where the USB is connected.
uint8_t _pwrMode
 Variable : specifies the power mode, enabling or disabling the XBee switch or setting the XBee to sleep.


Detailed Description

WaspXBee Class.

WaspXBee Class defines all the variables and functions used to manage the UART related with the XBee

Definition at line 76 of file WaspXBee.h.


Constructor & Destructor Documentation

WaspXBee::WaspXBee (  ) 

class constructor

It initializes some variables

Parameters:
void 
Returns:
void

Definition at line 31 of file WaspXBee.cpp.

References _uart.

00032 {
00033     _uart = 0;
00034 }


Member Function Documentation

void WaspXBee::printNumber ( unsigned long  n,
uint8_t  base 
) [private]

It prints a number in the specified base.

Parameters:
unsigned long n : the number to print
uint8_t base : the base for printing the number
Returns:
void

Definition at line 206 of file WaspXBee.cpp.

References _uart, and printIntegerInBase().

Referenced by print().

00207 {
00208   printIntegerInBase(n, base,  _uart);
00209 }

Here is the call graph for this function:

Here is the caller graph for this function:

void WaspXBee::printFloat ( double  number,
uint8_t  digits 
) [private]

It prints a 'float' number.

Parameters:
double number : the number to print
uint8_t digits : the number of non-integer part digits
Returns:
void

Definition at line 211 of file WaspXBee.cpp.

References print().

Referenced by print().

00212 {
00213   // Handle negative numbers
00214   if (number < 0.0)
00215   {
00216      print('-');
00217      number = -number;
00218   }
00219 
00220   // Round correctly so that print(1.999, 2) prints as "2.00"
00221   double rounding = 0.5;
00222   for (uint8_t i=0; i<digits; ++i)
00223     rounding /= 10.0;
00224   
00225   number += rounding;
00226 
00227   // Extract the integer part of the number and print it
00228   unsigned long int_part = (unsigned long)number;
00229   double remainder = number - (double)int_part;
00230   print(int_part);
00231 
00232   // Print the decimal point, but only if there are digits beyond
00233   if (digits > 0)
00234     print("."); 
00235 
00236   // Extract digits from the remainder one at a time
00237   while (digits-- > 0)
00238   {
00239     remainder *= 10.0;
00240     int toPrint = int(remainder);
00241     print(toPrint);
00242     remainder -= toPrint; 
00243   }
00244 }

Here is the call graph for this function:

Here is the caller graph for this function:

void WaspXBee::begin ( void   ) 

It opens UART to be able to communicate with the XBee.

It gets the baud rate from 'XBEE_RATE'

Parameters:
void 
Returns:
void

Definition at line 38 of file WaspXBee.cpp.

References _uart, beginSerial(), OUTPUT, pinMode(), XBEE_PW, and XBEE_RATE.

Referenced by WaspXBeeXSC::ON(), WaspXBeeCore::ON(), setMode(), WaspXBeeXSC::wake(), and WaspXBeeCore::wake().

00039 {
00040   beginSerial(XBEE_RATE, _uart);
00041   pinMode(XBEE_PW,OUTPUT);
00042 }

Here is the call graph for this function:

Here is the caller graph for this function:

void WaspXBee::begin ( uint16_t  speed  ) 

It opens UART to be able to communicate with the XBee.

Parameters:
uint16_t speed : the baud rate to set to the UART
Returns:
void

Definition at line 44 of file WaspXBee.cpp.

References _uart, beginSerial(), OUTPUT, pinMode(), and XBEE_PW.

00045 {
00046         beginSerial(speed, _uart);
00047         pinMode(XBEE_PW,OUTPUT);
00048 }

Here is the call graph for this function:

void WaspXBee::close ( void   ) 

It closes the previously opened UART.

Parameters:
void 
Returns:
void

Definition at line 50 of file WaspXBee.cpp.

References _uart, and closeSerial().

Referenced by WaspXBeeCore::OFF(), setMode(), WaspXBeeXSC::sleep(), and WaspXBeeCore::sleep().

00051 {
00052   closeSerial(_uart);
00053 }

Here is the call graph for this function:

Here is the caller graph for this function:

void WaspXBee::setMode ( uint8_t  mode  ) 

It sets ON/OFF the XBee switch or sets the XBee to sleep.

Parameters:
uint8_t mode : XBEE_ON, XBEE_OFF, XBEE_HIBERNATE
Returns:
void

Definition at line 55 of file WaspXBee.cpp.

References _pwrMode, begin(), close(), digitalWrite(), HIGH, LOW, WaspXBeeCore::setSleepMode(), xbee, XBEE_HIBERNATE, XBEE_OFF, XBEE_ON, and XBEE_PW.

Referenced by WaspXBeeCore::OFF(), WaspXBeeXSC::ON(), WaspXBeeCore::ON(), and WaspPWR::switchesOFF().

00056 {
00057   _pwrMode = mode;
00058   // set the GPS in the defined power mode
00059   switch (_pwrMode)
00060   {
00061   case XBEE_ON:
00062         begin();
00063         digitalWrite(XBEE_PW,HIGH);
00064 
00065     break;
00066 
00067   case XBEE_OFF:
00068         digitalWrite(XBEE_PW,LOW);
00069         close();
00070     break;
00071 
00072   case XBEE_HIBERNATE:
00073         xbee.setSleepMode(1);
00074         break;
00075 
00076   default:
00077         break;
00078   }
00079 }

Here is the call graph for this function:

Here is the caller graph for this function:

uint8_t WaspXBee::available (  ) 

int WaspXBee::read (  ) 

void WaspXBee::flush (  ) 

It clears the UART buffer.

Parameters:
void 
Returns:
void

Definition at line 91 of file WaspXBee.cpp.

References _uart, and serialFlush().

Referenced by WaspXBeeXSC::check(), WaspXBeeCore::getRSSI(), WaspXBeeXSC::readData(), WaspXBeeCore::txStatusResponse(), and WaspXBeeCore::txZBStatusResponse().

00092 {
00093   serialFlush(_uart);
00094 }

Here is the call graph for this function:

Here is the caller graph for this function:

void WaspXBee::print ( char  c  ) 

void WaspXBee::print ( const char  c[]  ) 

It prints a string.

Parameters:
const char[] c : the string to print
Returns:
void

Definition at line 101 of file WaspXBee.cpp.

References _uart, and printString().

00102 {
00103   printString(c,  _uart);
00104 }

Here is the call graph for this function:

void WaspXBee::print ( uint8_t  b  ) 

It prints an unsigned 8-bit integer.

Parameters:
uint8_t b : the number to print
Returns:
void

Definition at line 106 of file WaspXBee.cpp.

References _uart, and printByte().

00107 {
00108   printByte(b,  _uart);
00109 }

Here is the call graph for this function:

void WaspXBee::print ( int  n  ) 

It prints an integer.

Parameters:
int n : the number to print
Returns:
void

Definition at line 111 of file WaspXBee.cpp.

References print().

00112 {
00113   print((long) n);
00114 }

Here is the call graph for this function:

void WaspXBee::print ( unsigned int  n  ) 

It prints an unsigned integer.

Parameters:
unsigned int n : the number to print
Returns:
void

Definition at line 116 of file WaspXBee.cpp.

References print().

00117 {
00118   print((unsigned long) n);
00119 }

Here is the call graph for this function:

void WaspXBee::print ( long  n  ) 

It prints a long integer.

Parameters:
long n : the number to print
Returns:
void

Definition at line 121 of file WaspXBee.cpp.

References print(), and printNumber().

00122 {
00123   if (n < 0) {
00124     print('-');
00125     n = -n;
00126   }
00127   printNumber(n, 10);
00128 }

Here is the call graph for this function:

void WaspXBee::print ( unsigned long  n  ) 

It prints an unsigned long integer.

Parameters:
unsigned long n : the number to print
Returns:
void

Definition at line 130 of file WaspXBee.cpp.

References printNumber().

00131 {
00132   printNumber(n, 10);
00133 }

Here is the call graph for this function:

void WaspXBee::print ( long  n,
int  base 
)

It prints a long number in the specified base.

Parameters:
long n : the number to print
int base : the base for printing the number
Returns:
void

Definition at line 140 of file WaspXBee.cpp.

References print(), and printNumber().

00141 {
00142   if (base == 0)
00143     print((char) n);
00144   else if (base == 10)
00145     print(n);
00146   else
00147     printNumber(n, base);
00148 }

Here is the call graph for this function:

void WaspXBee::print ( double  n  ) 

It prints a double number.

Parameters:
double n : the number to print
Returns:
void

Definition at line 135 of file WaspXBee.cpp.

References printFloat().

00136 {
00137         printFloat(n, 10);
00138 }

Here is the call graph for this function:

void WaspXBee::println (  ) 

It prints an EOL and a carriage return.

Parameters:
void 
Returns:
void

Definition at line 150 of file WaspXBee.cpp.

References print().

Referenced by WaspXBeeXSC::exitCommandMode(), WaspXBeeXSC::forceReset(), WaspXBeeXSC::forceWakeUP(), WaspXBeeXSC::getAddressMask(), WaspXBeeXSC::getAwakeTime(), WaspXBeeXSC::getBaudRate(), WaspXBeeXSC::getDelaySlots(), WaspXBeeXSC::getDestAddress(), WaspXBeeXSC::getHoppingChannel(), WaspXBeeXSC::getPacketTimeout(), WaspXBeeXSC::getPinWakeUP(), WaspXBeeXSC::getReceiveErrorCount(), WaspXBeeXSC::getReceiveGoodCount(), WaspXBeeXSC::getRetries(), WaspXBeeXSC::getRSSI(), WaspXBeeCore::getRSSI(), WaspXBeeXSC::getRSSItime(), WaspXBeeXSC::getRSSIvalue(), WaspXBeeXSC::getSleepMode(), WaspXBeeXSC::getSoftVersion(), WaspXBeeXSC::getSourceMacHigh(), WaspXBeeXSC::getSourceMacLow(), WaspXBeeXSC::getStopBits(), WaspXBeeXSC::getTimeBeforeInit(), WaspXBeeXSC::getTimeBeforeWakeUP(), WaspXBeeXSC::getTimeWakeUpInit(), WaspXBeeXSC::getTransmitErrorCount(), WaspXBeeXSC::getTransmitLimit(), WaspXBeeXSC::getVendorID(), println(), WaspXBeeCore::readXBee(), WaspXBeeXSC::restoreDefaults(), WaspXBeeXSC::sendCommandAT(), WaspXBeeXSC::setAddressMask(), WaspXBeeXSC::setAwakeTime(), WaspXBeeXSC::setBaudRate(), WaspXBeeXSC::setDelaySlots(), WaspXBeeXSC::setDestAddress(), WaspXBeeXSC::setHoppingChannel(), WaspXBeeXSC::setPacketTimeout(), WaspXBeeXSC::setPinWakeUP(), WaspXBeeXSC::setReceiveErrorCount(), WaspXBeeXSC::setReceiveGoodCount(), WaspXBeeXSC::setRetries(), WaspXBeeXSC::setRSSItime(), WaspXBeeXSC::setSleepMode(), WaspXBeeXSC::setStopBits(), WaspXBeeXSC::setTimeBeforeInit(), WaspXBeeXSC::setTimeBeforeWakeUP(), WaspXBeeXSC::setTimeWakeUpInit(), WaspXBeeXSC::setTransmitErrorCount(), WaspXBeeXSC::setTransmitLimit(), WaspXBeeXSC::setVendorID(), and WaspXBeeXSC::writeValues().

00151 {
00152   print('\r');
00153   print('\n');  
00154 }

Here is the call graph for this function:

Here is the caller graph for this function:

void WaspXBee::println ( char  c  ) 

It prints a character adding an EOL and a carriage return.

Parameters:
char c : the character to print
Returns:
void

Definition at line 156 of file WaspXBee.cpp.

References print(), and println().

00157 {
00158   print(c);
00159   println();  
00160 }

Here is the call graph for this function:

void WaspXBee::println ( const char  c[]  ) 

It prints a string adding an EOL and a carriage return.

Parameters:
const char[] c : the string to print
Returns:
void

Definition at line 162 of file WaspXBee.cpp.

References print(), and println().

00163 {
00164   print(c);
00165   println();
00166 }

Here is the call graph for this function:

void WaspXBee::println ( uint8_t  b  ) 

It prints an unsigned 8-bit integer adding an EOL and a carriage return.

Parameters:
uint8_t b : the number to print
Returns:
void

Definition at line 168 of file WaspXBee.cpp.

References print(), and println().

00169 {
00170   print(b);
00171   println();
00172 }

Here is the call graph for this function:

void WaspXBee::println ( int  n  ) 

It prints an integer adding an EOL and a carriage return.

Parameters:
int n : the number to print
Returns:
void

Definition at line 174 of file WaspXBee.cpp.

References print(), and println().

00175 {
00176   print(n);
00177   println();
00178 }

Here is the call graph for this function:

void WaspXBee::println ( long  n  ) 

It prints a long integer adding an EOL and a carriage return.

Parameters:
long n : the number to print
Returns:
void

Definition at line 180 of file WaspXBee.cpp.

References print(), and println().

00181 {
00182   print(n);
00183   println();  
00184 }

Here is the call graph for this function:

void WaspXBee::println ( unsigned long  n  ) 

It prints an unsigned long integer adding an EOL and a carriage return.

Parameters:
unsigned long n : the number to print
Returns:
void

Definition at line 186 of file WaspXBee.cpp.

References print(), and println().

00187 {
00188   print(n);
00189   println();  
00190 }

Here is the call graph for this function:

void WaspXBee::println ( long  n,
int  base 
)

It prints a long number in the specified base adding an EOL and a carriage return.

Parameters:
long n : the number to print
int base : the base for printing the number
Returns:
void

Definition at line 192 of file WaspXBee.cpp.

References print(), and println().

00193 {
00194   print(n, base);
00195   println();
00196 }

Here is the call graph for this function:

void WaspXBee::println ( double  n  ) 

It prints a double number adding an EOL and a carriage return.

Parameters:
double n : the number to print
Returns:
void

Definition at line 198 of file WaspXBee.cpp.

References print(), and println().

00199 {
00200         print(n);
00201         println();
00202 }

Here is the call graph for this function:


Field Documentation

uint8_t WaspXBee::_uart [private]

Variable : specifies the UART where the USB is connected.

Definition at line 83 of file WaspXBee.h.

Referenced by available(), begin(), close(), flush(), print(), printNumber(), read(), and WaspXBee().

uint8_t WaspXBee::_pwrMode [private]

Variable : specifies the power mode, enabling or disabling the XBee switch or setting the XBee to sleep.

Definition at line 88 of file WaspXBee.h.

Referenced by setMode().


The documentation for this class was generated from the following files:

Generated on Tue Jul 20 09:31:04 2010 for WaspmoteAPI by  doxygen 1.5.6