#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. | |
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.
| WaspXBee::WaspXBee | ( | ) |
class constructor
It initializes some variables
| void |
Definition at line 31 of file WaspXBee.cpp.
References _uart.
00032 { 00033 _uart = 0; 00034 }
| void WaspXBee::printNumber | ( | unsigned long | n, | |
| uint8_t | base | |||
| ) | [private] |
It prints a number in the specified base.
| unsigned | long n : the number to print | |
| uint8_t | base : the base for printing the number |
Definition at line 206 of file WaspXBee.cpp.
References _uart, and printIntegerInBase().
Referenced by print().
00207 { 00208 printIntegerInBase(n, base, _uart); 00209 }


| void WaspXBee::printFloat | ( | double | number, | |
| uint8_t | digits | |||
| ) | [private] |
It prints a 'float' number.
| double | number : the number to print | |
| uint8_t | digits : the number of non-integer part digits |
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 }


| void WaspXBee::begin | ( | void | ) |
It opens UART to be able to communicate with the XBee.
It gets the baud rate from 'XBEE_RATE'
| 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().


| void WaspXBee::begin | ( | uint16_t | speed | ) |
It opens UART to be able to communicate with the XBee.
| uint16_t | speed : the baud rate to set to the UART |
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 }

| void WaspXBee::close | ( | void | ) |
It closes the previously opened UART.
| 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 }


| void WaspXBee::setMode | ( | uint8_t | mode | ) |
It sets ON/OFF the XBee switch or sets the XBee to sleep.
| uint8_t | mode : XBEE_ON, XBEE_OFF, XBEE_HIBERNATE |
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 }


| uint8_t WaspXBee::available | ( | ) |
It checks if there is available data waiting to be read.
| void |
Definition at line 81 of file WaspXBee.cpp.
References _uart, and serialAvailable().
Referenced by WaspXBeeXSC::check(), WaspXBeeXSC::clean(), WaspXBeeCore::freeXBee(), 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(), WaspXBeeCore::parse_message(), WaspXBeeXSC::readData(), WaspXBeeXSC::sendCommandAT(), WaspXBeeCore::txStatusResponse(), and WaspXBeeCore::txZBStatusResponse().
00082 { 00083 return serialAvailable( _uart); 00084 }


| int WaspXBee::read | ( | ) |
It reads a byte from the UART.
| void |
Definition at line 86 of file WaspXBee.cpp.
References _uart, and serialRead().
Referenced by WaspXBeeXSC::check(), WaspXBeeXSC::clean(), WaspXBeeCore::freeXBee(), 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(), WaspXBeeCore::parse_message(), WaspXBeeXSC::readData(), WaspXBeeXSC::sendCommandAT(), WaspXBeeCore::txStatusResponse(), and WaspXBeeCore::txZBStatusResponse().
00087 { 00088 return serialRead(_uart); 00089 }


| void WaspXBee::flush | ( | ) |
It clears the UART buffer.
| 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 }


| void WaspXBee::print | ( | char | c | ) |
It prints a character.
| char | c : the character to print |
Definition at line 96 of file WaspXBee.cpp.
References _uart, and printByte().
Referenced by WaspXBeeCore::gen_send(), WaspXBeeCore::getRSSI(), WaspXBeeCore::nodeSearch(), print(), printFloat(), println(), WaspXBeeCore::readXBee(), WaspXBeeCore::scanNetwork(), WaspXBeeCore::send(), WaspXBeeXSC::sendCommandAT(), WaspXBeeCore::sendCommandAT(), WaspXBeeXSC::sendData(), WaspXBeeCore::sendXBeePriv(), WaspXBeeXSC::setAddressMask(), WaspXBeeXSC::setAwakeTime(), WaspXBeeXSC::setBaudRate(), WaspXBeeXSC::setCommandMode(), WaspXBeeXSC::setDelaySlots(), WaspXBeeXSC::setDestAddress(), WaspXBeeXSC::setHoppingChannel(), WaspXBeeCore::setNodeIdentifier(), 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(), and WaspXBeeXSC::setVendorID().


| void WaspXBee::print | ( | const char | c[] | ) |
It prints a string.
| const | char[] c : the string to print |
Definition at line 101 of file WaspXBee.cpp.
References _uart, and printString().
00102 { 00103 printString(c, _uart); 00104 }

| void WaspXBee::print | ( | uint8_t | b | ) |
It prints an unsigned 8-bit integer.
| uint8_t | b : the number to print |
Definition at line 106 of file WaspXBee.cpp.
References _uart, and printByte().

| void WaspXBee::print | ( | int | n | ) |
It prints an integer.
| int | n : the number to print |
Definition at line 111 of file WaspXBee.cpp.
References print().
00112 { 00113 print((long) n); 00114 }

| void WaspXBee::print | ( | unsigned int | n | ) |
It prints an unsigned integer.
| unsigned | int n : the number to print |
Definition at line 116 of file WaspXBee.cpp.
References print().
00117 { 00118 print((unsigned long) n); 00119 }

| void WaspXBee::print | ( | long | n | ) |
It prints a long integer.
| long | n : the number to print |
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 }

| void WaspXBee::print | ( | unsigned long | n | ) |
It prints an unsigned long integer.
| unsigned | long n : the number to print |
Definition at line 130 of file WaspXBee.cpp.
References printNumber().
00131 { 00132 printNumber(n, 10); 00133 }

| void WaspXBee::print | ( | long | n, | |
| int | base | |||
| ) |
It prints a long number in the specified base.
| long | n : the number to print | |
| int | base : the base for printing the number |
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 }

| void WaspXBee::print | ( | double | n | ) |
It prints a double number.
| double | n : the number to print |
Definition at line 135 of file WaspXBee.cpp.
References printFloat().
00136 { 00137 printFloat(n, 10); 00138 }

| void WaspXBee::println | ( | ) |
It prints an EOL and a carriage return.
| 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().


| void WaspXBee::println | ( | char | c | ) |
| void WaspXBee::println | ( | const char | c[] | ) |
| void WaspXBee::println | ( | uint8_t | b | ) |
It prints an unsigned 8-bit integer adding an EOL and a carriage return.
| uint8_t | b : the number to print |
Definition at line 168 of file WaspXBee.cpp.
References print(), and println().

| void WaspXBee::println | ( | int | n | ) |
| void WaspXBee::println | ( | long | n | ) |
| void WaspXBee::println | ( | unsigned long | n | ) |
It prints an unsigned long integer adding an EOL and a carriage return.
| unsigned | long n : the number to print |
Definition at line 186 of file WaspXBee.cpp.
References print(), and println().

| void WaspXBee::println | ( | long | n, | |
| int | base | |||
| ) |
It prints a long number in the specified base adding an EOL and a carriage return.
| long | n : the number to print | |
| int | base : the base for printing the number |
Definition at line 192 of file WaspXBee.cpp.
References print(), and println().

| void WaspXBee::println | ( | double | n | ) |
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().
1.5.6