#include <WaspUtils.h>
Public Member Functions | |
| WaspUtils (void) | |
| class constructor | |
| uint8_t | getFreeMemory (void) |
| It gets the free available memory. | |
| void | setLED (uint8_t led, uint8_t state) |
| It sets the specified LED to the specified state(ON or OFF). | |
| uint8_t | getLED (uint8_t led) |
| It gets the state of the specified LED. | |
| void | blinkLEDs (uint16_t time) |
| It blinks LEDs, with the specified time for blinking. | |
| long | map (long x, long in_min, long in_max, long out_min, long out_max) |
| It maps 'x' from the read range to the specified range. | |
| void | setMux (uint8_t MUX_LOW, uint8_t MUX_HIGH) |
| It sets MUX to the desired combination. | |
| void | setMuxGPS () |
| It sets MUX to the desired combination (0,1) to enable GPS module. | |
| void | setMuxGPRS () |
| It sets MUX to the desired combination (1,1) to enable GPRS module. | |
| void | setMuxAux1 () |
| It sets MUX to the desired combination (1,0) to enable AUX1 module. | |
| void | setMuxAux2 () |
| It sets MUX to the desired combination (0,0) to enable AUX2 module. | |
| uint8_t | readEEPROM (int address) |
| It reads a value from the specified EEPROM address. | |
| void | writeEEPROM (int address, uint8_t value) |
| It writes the specified value to the specified EEPROM address. | |
| long | parse_decimal (char *str) |
| It gets a number out of a string. It gets till the 2nd decimal of the number. | |
| double | parse_degrees (char *str) |
| It gets the degree number out of a string. | |
| long | gpsatol (char *str) |
| It gets the integer part of a number out of a string. | |
| bool | gpsisdigit (char c) |
| It checks if the char is a digit or not. | |
| double | parse_latitude (char *str) |
| It parses latitude or longitude, getting the number out of a string. | |
| uint8_t | dec2hex (uint8_t number) |
| It converts a decimal number into an hexadecimal number. | |
| long | array2long (char *num) |
| It converts a number stored in an array into a decimal number. | |
| uint8_t | long2array (long num, char *numb) |
| It converts a decimal number into a string. | |
| uint8_t | str2hex (char *str) |
| It converts a number stored in a string into a hexadecimal number. | |
| uint8_t | str2hex (uint8_t *str) |
| It converts a number stored in a string into a hexadecimal number. | |
| void | hex2str (uint8_t *number, char *macDest) |
| It converts a hexadecimal number stored in an array to a string (8 Byte numbers). | |
| void | hex2str (uint8_t *number, char *macDest, uint8_t length) |
| It converts a hexadecimal number stored in an array to a string (8 Byte numbers). | |
| uint32_t | strtolong (const char *str) |
| It converts a number stored in an array into a decimal number. | |
| int | sizeOf (const char *str) |
| It gets the size of a string or array. | |
| uint8_t | strCmp (const char *str1, const char *str2, uint8_t size) |
| It compares two strings. | |
| void | strCp (char *str1, char *str2) |
| It copies one string into another. | |
| void | clearArguments (void) |
| It clears the arguments[][] data matrix. | |
| void | clearBuffer (void) |
| It clears the inBuffer array. | |
| void | strExplode (const char *str, char separator) |
| It breaks a string into its arguments separated by "separators". The pieces are stored in 'arguments' array. | |
| uint8_t | converter (uint8_t conv1, uint8_t conv2) |
| It generates a decimal number from two ASCII characters which were numbers. | |
| void | float2String (float fl, char str[], int N) |
| It converts a float into a string. | |
Data Fields | |
| uint16_t | freeMemory |
| Variable : Free available memory. | |
| char | inBuffer [GPS_BUFFER_SIZE] |
| Variable : buffer to store incoming data. | |
| char | arguments [MAX_ARGS][MAX_ARG_LENGTH] |
| Variable : bidimensional array of arguments in Waspmote, mainly used with the GPS. | |
WaspUtils Class defines all the variables and functions used to set LEDs, multiplexor and useful general functions
Definition at line 91 of file WaspUtils.h.
| WaspUtils::WaspUtils | ( | void | ) |
class constructor
It does nothing
| void |
Definition at line 33 of file WaspUtils.cpp.
| uint8_t WaspUtils::getFreeMemory | ( | void | ) |
It gets the free available memory.
| void |
Definition at line 133 of file WaspUtils.cpp.
References freeMemory.
00134 { 00135 char* resul2[90]; 00136 int i=0; 00137 int error=2; 00138 00139 while(1) 00140 { 00141 resul2[i]= (char*) calloc(100,sizeof(char)); 00142 if(resul2[i]==NULL) 00143 { 00144 int b=i*100; 00145 freeMemory = b; 00146 error=0; 00147 break; 00148 } 00149 i++; 00150 } 00151 for(int a=0;a<i;a++) 00152 { 00153 free(resul2[a]); 00154 resul2[a]=NULL; 00155 } 00156 return freeMemory; 00157 }
| void WaspUtils::setLED | ( | uint8_t | led, | |
| uint8_t | state | |||
| ) |
It sets the specified LED to the specified state(ON or OFF).
| uint8_t | led : the LED to set ON/OFF | |
| uint8_t | state : the state to set the LED |
Definition at line 275 of file WaspUtils.cpp.
References digitalWrite(), HIGH, LED_OFF, LED_ON, LOW, OUTPUT, and pinMode().
Referenced by blinkLEDs().
00276 { 00277 pinMode(led,OUTPUT); 00278 if(state==LED_ON) 00279 { 00280 digitalWrite(led,HIGH); 00281 } 00282 if(state==LED_OFF) 00283 { 00284 digitalWrite(led,LOW); 00285 } 00286 }


| uint8_t WaspUtils::getLED | ( | uint8_t | led | ) |
It gets the state of the specified LED.
| uint8_t | led : the LED to get the state |
Definition at line 293 of file WaspUtils.cpp.
References digitalRead().
00294 { 00295 return digitalRead(led); 00296 }

| void WaspUtils::blinkLEDs | ( | uint16_t | time | ) |
It blinks LEDs, with the specified time for blinking.
| uint16_t | time : time for blinking |
Definition at line 303 of file WaspUtils.cpp.
References delay(), LED0, LED1, LED_OFF, LED_ON, and setLED().
00304 { 00305 setLED(LED0,LED_ON); 00306 setLED(LED1,LED_ON); 00307 delay(time); 00308 setLED(LED0,LED_OFF); 00309 setLED(LED1,LED_OFF); 00310 delay(time); 00311 }

| long WaspUtils::map | ( | long | x, | |
| long | in_min, | |||
| long | in_max, | |||
| long | out_min, | |||
| long | out_max | |||
| ) |
It maps 'x' from the read range to the specified range.
| long | x : value to map | |
| long | in_min : minimum input value for 'x' | |
| long | in_max : maximum input value for 'x' | |
| long | out_min : minimum output value for 'x' | |
| long | out_max : maximum output value for 'x' |
Definition at line 321 of file WaspUtils.cpp.
| void WaspUtils::setMux | ( | uint8_t | MUX_LOW, | |
| uint8_t | MUX_HIGH | |||
| ) |
It sets MUX to the desired combination.
It sets MUX to the desired combination. Possible combinations are:
MUX_LOW = 0 & MUX_HIGH = 1 ---> GPS MODULE MUX_LOW = 1 & MUX_HIGH = 1 ---> GPRS MODULE MUX_LOW = 1 & MUX_HIGH = 0 ---> AUX1 MODULE MUX_LOW = 0 & MUX_HIGH = 0 ---> AUX2 MODULE
| uint8_t | MUX_LOW : low combination part | |
| uint8_t | MUX_HIGH : high combination part |
Definition at line 337 of file WaspUtils.cpp.
References digitalWrite(), HIGH, MUX0, MUX1, MUX_PW, OUTPUT, and pinMode().
Referenced by WaspGPS::close(), and WaspGPRS::close().
00338 { 00339 pinMode(MUX_PW, OUTPUT); 00340 pinMode(MUX0, OUTPUT); 00341 pinMode(MUX1, OUTPUT); 00342 digitalWrite(MUX_PW, HIGH); 00343 digitalWrite(MUX0, MUX_LOW); 00344 digitalWrite(MUX1, MUX_HIGH); 00345 }


| void WaspUtils::setMuxGPS | ( | ) |
It sets MUX to the desired combination (0,1) to enable GPS module.
Possible combinatios are:
MUX_LOW = 0 & MUX_HIGH = 1 ---> GPS MODULE MUX_LOW = 1 & MUX_HIGH = 1 ---> GPRS MODULE MUX_LOW = 1 & MUX_HIGH = 0 ---> AUX1 MODULE MUX_LOW = 0 & MUX_HIGH = 0 ---> AUX2 MODULE
Definition at line 358 of file WaspUtils.cpp.
References digitalWrite(), HIGH, LOW, MUX0, MUX1, MUX_PW, OUTPUT, and pinMode().
Referenced by WaspGPS::begin().
00359 { 00360 pinMode(MUX_PW, OUTPUT); 00361 pinMode(MUX0, OUTPUT); 00362 pinMode(MUX1, OUTPUT); 00363 digitalWrite(MUX_PW, HIGH); 00364 digitalWrite(MUX0, LOW); 00365 digitalWrite(MUX1, HIGH); 00366 }


| void WaspUtils::setMuxGPRS | ( | ) |
It sets MUX to the desired combination (1,1) to enable GPRS module.
Possible combinatios are:
MUX_LOW = 0 & MUX_HIGH = 1 ---> GPS MODULE MUX_LOW = 1 & MUX_HIGH = 1 ---> GPRS MODULE MUX_LOW = 1 & MUX_HIGH = 0 ---> AUX1 MODULE MUX_LOW = 0 & MUX_HIGH = 0 ---> AUX2 MODULE
Definition at line 379 of file WaspUtils.cpp.
References digitalWrite(), HIGH, MUX0, MUX1, MUX_PW, OUTPUT, and pinMode().
Referenced by WaspGPRS::begin().
00380 { 00381 pinMode(MUX_PW, OUTPUT); 00382 pinMode(MUX0, OUTPUT); 00383 pinMode(MUX1, OUTPUT); 00384 digitalWrite(MUX_PW, HIGH); 00385 digitalWrite(MUX0, HIGH); 00386 digitalWrite(MUX1, HIGH); 00387 }


| void WaspUtils::setMuxAux1 | ( | ) |
It sets MUX to the desired combination (1,0) to enable AUX1 module.
Possible combinatios are:
MUX_LOW = 0 & MUX_HIGH = 1 ---> GPS MODULE MUX_LOW = 1 & MUX_HIGH = 1 ---> GPRS MODULE MUX_LOW = 1 & MUX_HIGH = 0 ---> AUX1 MODULE MUX_LOW = 0 & MUX_HIGH = 0 ---> AUX2 MODULE
Definition at line 400 of file WaspUtils.cpp.
References digitalWrite(), HIGH, LOW, MUX0, MUX1, MUX_PW, OUTPUT, and pinMode().
00401 { 00402 pinMode(MUX_PW, OUTPUT); 00403 pinMode(MUX0, OUTPUT); 00404 pinMode(MUX1, OUTPUT); 00405 digitalWrite(MUX_PW, HIGH); 00406 digitalWrite(MUX0, HIGH); 00407 digitalWrite(MUX1, LOW); 00408 }

| void WaspUtils::setMuxAux2 | ( | ) |
It sets MUX to the desired combination (0,0) to enable AUX2 module.
Possible combinatios are:
MUX_LOW = 0 & MUX_HIGH = 1 ---> GPS MODULE MUX_LOW = 1 & MUX_HIGH = 1 ---> GPRS MODULE MUX_LOW = 1 & MUX_HIGH = 0 ---> AUX1 MODULE MUX_LOW = 0 & MUX_HIGH = 0 ---> AUX2 MODULE
Definition at line 421 of file WaspUtils.cpp.
References digitalWrite(), HIGH, LOW, MUX0, MUX1, MUX_PW, OUTPUT, and pinMode().
00422 { 00423 pinMode(MUX_PW, OUTPUT); 00424 pinMode(MUX0, OUTPUT); 00425 pinMode(MUX1, OUTPUT); 00426 digitalWrite(MUX_PW, HIGH); 00427 digitalWrite(MUX0, LOW); 00428 digitalWrite(MUX1, LOW); 00429 }

| uint8_t WaspUtils::readEEPROM | ( | int | address | ) |
It reads a value from the specified EEPROM address.
| int | address : EEPROM address to read from |
Definition at line 438 of file WaspUtils.cpp.
Referenced by WaspPWR::ifHibernate().

| void WaspUtils::writeEEPROM | ( | int | address, | |
| uint8_t | value | |||
| ) |
It writes the specified value to the specified EEPROM address.
| int | address : EEPROM address to write to | |
| uint8_t | value: value to write to the EEPROM |
Definition at line 450 of file WaspUtils.cpp.
Referenced by WaspPWR::hibernate(), and WaspPWR::ifHibernate().

| long WaspUtils::parse_decimal | ( | char * | str | ) |
It gets a number out of a string. It gets till the 2nd decimal of the number.
| char* | str: string containing the number to extract |
Definition at line 165 of file WaspUtils.cpp.
References gpsatol(), and gpsisdigit().
00166 { 00167 bool isneg = *str == '-'; 00168 if (isneg) *str++; 00169 unsigned long ret = 100UL * gpsatol(str); 00170 while (gpsisdigit(*str)) ++str; 00171 if (*str == '.') 00172 { 00173 if (gpsisdigit(str[1])) 00174 { 00175 ret += 10 * (str[1] - '0'); 00176 if (gpsisdigit(str[2])) 00177 ret += str[2] - '0'; 00178 } 00179 } 00180 return isneg ? -ret : ret; 00181 }

| double WaspUtils::parse_degrees | ( | char * | str | ) |
It gets the degree number out of a string.
| char* | str: string containing the number to extract |
Definition at line 189 of file WaspUtils.cpp.
References gpsatol(), and gpsisdigit().
Referenced by parse_latitude().
00190 { 00191 unsigned long left = gpsatol(str); 00192 unsigned long tenk_minutes = (left % 100UL) * 10000UL; 00193 while (gpsisdigit(*str)) ++str; 00194 if (*str == '.') 00195 { 00196 unsigned long mult = 1000; 00197 while (gpsisdigit(*++str)) 00198 { 00199 tenk_minutes += mult * (*str - '0'); 00200 mult /= 10; 00201 } 00202 } 00203 double aux=0.0; 00204 long aux2=0; 00205 aux=(double) tenk_minutes / 6; 00206 aux2=((left / 100) * 100000); 00207 aux = aux + aux2; 00208 return aux; 00209 }


| long WaspUtils::gpsatol | ( | char * | str | ) |
It gets the integer part of a number out of a string.
| char* | str: string containing the number to extract |
Definition at line 217 of file WaspUtils.cpp.
References gpsisdigit().
Referenced by parse_decimal(), and parse_degrees().
00218 { 00219 long ret = 0; 00220 while (gpsisdigit(*str)) 00221 ret = 10 * ret + *str++ - '0'; 00222 return ret; 00223 }


| bool WaspUtils::gpsisdigit | ( | char | c | ) | [inline] |
It checks if the char is a digit or not.
| char | c: character to determine if it is a digit or not |
Definition at line 282 of file WaspUtils.h.
Referenced by gpsatol(), parse_decimal(), and parse_degrees().

| double WaspUtils::parse_latitude | ( | char * | str | ) |
It parses latitude or longitude, getting the number out of a string.
| char* | str: string containing the latitude or longitude to parse |
Definition at line 226 of file WaspUtils.cpp.
References parse_degrees().
00227 { 00228 double aux=0; 00229 double aux2=0.0; 00230 00231 aux=(double) parse_degrees(str); 00232 aux2=(double) aux/100000; 00233 aux2=aux2*M_PI/180; 00234 return aux2; 00235 }

| uint8_t WaspUtils::dec2hex | ( | uint8_t | number | ) |
It converts a decimal number into an hexadecimal number.
| uint8_t | number: number to convert |
Definition at line 455 of file WaspUtils.cpp.
Referenced by WaspXBeeXSC::readData().
00456 { 00457 int aux=0, aux2=0; 00458 aux=number/16; 00459 aux2=number-(aux*16); 00460 return (aux*10+aux2); 00461 }

| long WaspUtils::array2long | ( | char * | num | ) |
It converts a number stored in an array into a decimal number.
| char* | num : string that contains the number to extract |
Definition at line 498 of file WaspUtils.cpp.
00499 { 00500 int j=0; 00501 long resul=0; 00502 long aux=1; 00503 uint8_t counter=0; 00504 00505 while( (num[counter]>='0') && (num[counter]<='9') ){ 00506 counter++; 00507 } 00508 while( (num[j]>='0') && (num[j]<='9') ){ 00509 for(int a=0;a<counter-1;a++) 00510 { 00511 aux=aux*10; 00512 } 00513 resul=resul+(num[j]-'0')*aux; 00514 counter--; 00515 j++; 00516 aux=1; 00517 } 00518 return resul; 00519 }
| uint8_t WaspUtils::long2array | ( | long | num, | |
| char * | numb | |||
| ) |
It converts a decimal number into a string.
| long | num : number to convert | |
| char* | numb : string where store the converted number |
Definition at line 525 of file WaspUtils.cpp.
Referenced by WaspXBeeCore::setDestinationParams(), and WaspXBeeCore::synchronization().
00526 { 00527 long aux=num; 00528 uint8_t i=0; 00529 00530 if( num<0 ) 00531 { 00532 num = ~(num); 00533 num+=1; 00534 numb[i]='-'; 00535 i++; 00536 } 00537 aux=num; 00538 while(aux>=10) 00539 { 00540 aux=aux/10; 00541 i++; 00542 } 00543 numb[i+1]='\0'; 00544 aux=num; 00545 while(aux>=10) 00546 { 00547 numb[i]=aux%10 + '0'; 00548 aux=aux/10; 00549 i--; 00550 } 00551 numb[i]=aux + '0'; 00552 return i; 00553 }

| uint8_t WaspUtils::str2hex | ( | char * | str | ) |
It converts a number stored in a string into a hexadecimal number.
| char* | str : string where the number is stored |
Definition at line 558 of file WaspUtils.cpp.
Referenced by WaspXBeeCore::getRSSI(), WaspXBeeCore::send(), WaspXBeeCore::setDestinationParams(), and WaspXBeeCore::setOriginParams().
00559 { 00560 int aux=0, aux2=0; 00561 00562 00563 if( (*str>='0') && (*str<='9') ) 00564 { 00565 aux=*str++-'0'; 00566 } 00567 else if( (*str>='A') && (*str<='F') ) 00568 { 00569 aux=*str++-'A'+10; 00570 } 00571 if( (*str>='0') && (*str<='9') ) 00572 { 00573 aux2=*str-'0'; 00574 } 00575 else if( (*str>='A') && (*str<='F') ) 00576 { 00577 aux2=*str-'A'+10; 00578 } 00579 return aux*16+aux2; 00580 }

| uint8_t WaspUtils::str2hex | ( | uint8_t * | str | ) |
It converts a number stored in a string into a hexadecimal number.
| char* | str : string where thember is stored |
Definition at line 586 of file WaspUtils.cpp.
00587 { 00588 int aux=0, aux2=0; 00589 00590 00591 if( (*str>='0') && (*str<='9') ) 00592 { 00593 aux=*str++-'0'; 00594 } 00595 else if( (*str>='A') && (*str<='F') ) 00596 { 00597 aux=*str++-'A'+10; 00598 } 00599 if( (*str>='0') && (*str<='9') ) 00600 { 00601 aux2=*str-'0'; 00602 } 00603 else if( (*str>='A') && (*str<='F') ) 00604 { 00605 aux2=*str-'A'+10; 00606 } 00607 return aux*16+aux2; 00608 }
| void WaspUtils::hex2str | ( | uint8_t * | number, | |
| char * | macDest | |||
| ) |
It converts a hexadecimal number stored in an array to a string (8 Byte numbers).
| uint8_t* | number : hexadecimal array to conver to a string | |
| const | char* macDest : char array where the converted number is stored |
Definition at line 464 of file WaspUtils.cpp.
Referenced by WaspXBeeCore::send(), and WaspXBeeCore::setDestinationParams().
00465 { 00466 hex2str(number,macDest,8); 00467 }

| void WaspUtils::hex2str | ( | uint8_t * | number, | |
| char * | macDest, | |||
| uint8_t | length | |||
| ) |
It converts a hexadecimal number stored in an array to a string (8 Byte numbers).
| uint8_t* | number : hexadecimal array to conver to a string | |
| const | char* macDest : char array where the converted number is stored | |
| uint8_t | length : length to copy |
Definition at line 470 of file WaspUtils.cpp.
00471 { 00472 uint8_t aux_1=0; 00473 uint8_t aux_2=0; 00474 00475 for(int i=0;i<length;i++){ 00476 aux_1=number[i]/16; 00477 aux_2=number[i]%16; 00478 if (aux_1<10){ 00479 macDest[2*i]=aux_1+'0'; 00480 } 00481 else{ 00482 macDest[2*i]=aux_1+('A'-10); 00483 } 00484 if (aux_2<10){ 00485 macDest[2*i+1]=aux_2+'0'; 00486 } 00487 else{ 00488 macDest[2*i+1]=aux_2+('A'-10); 00489 } 00490 } 00491 macDest[length*2]='\0'; 00492 }
| uint32_t WaspUtils::strtolong | ( | const char * | str | ) |
It converts a number stored in an array into a decimal number.
| const | char* str : string that contains the number to extract |
Definition at line 40 of file WaspUtils.cpp.
00041 { 00042 uint32_t l = 0; 00043 while(*str >= '0' && *str <= '9') 00044 l = l * 10 + (*str++ - '0'); 00045 00046 return l; 00047 }
| int WaspUtils::sizeOf | ( | const char * | str | ) |
It gets the size of a string or array.
| const | char* str : string to get the size from |
Definition at line 55 of file WaspUtils.cpp.
Referenced by WaspGPS::checkSum(), WaspGPS::getChecksum(), WaspSD::indexOf(), WaspGPRS::readDataFTP(), WaspGPS::setChecksum(), WaspXBeeCore::setOriginParams(), strCp(), strExplode(), and WaspSD::writeSD().
00056 { 00057 int cont = 0; 00058 while(*str++) cont++; 00059 if (*str == '\0') 00060 return cont--; // it will end with '\0', therefore we gotta take it out 00061 return cont; 00062 }

| uint8_t WaspUtils::strCmp | ( | const char * | str1, | |
| const char * | str2, | |||
| uint8_t | size | |||
| ) |
It compares two strings.
| const | char* str1 : string to compare | |
| const | char* str2 : string to compare | |
| uint8_t | size : string size |
Definition at line 70 of file WaspUtils.cpp.
Referenced by WaspSD::del(), WaspSD::delDir(), and WaspSD::indexOf().
00071 { 00072 uint8_t cmp = 0; 00073 for (int i = 0; i < size; i++) 00074 if (str1[i] != str2[i]) cmp = 1; 00075 return cmp; 00076 }

| void WaspUtils::strCp | ( | char * | str1, | |
| char * | str2 | |||
| ) |
It copies one string into another.
| char* | str1 : origin string | |
| char* | str2 : target string |
Definition at line 84 of file WaspUtils.cpp.
References sizeOf().
00085 { 00086 uint16_t size = sizeOf(str1); 00087 for (int i = 0; i < size; i++) 00088 str2[i] = str1[i]; 00089 }

| void WaspUtils::clearArguments | ( | void | ) |
It clears the arguments[][] data matrix.
| void |
Definition at line 94 of file WaspUtils.cpp.
References arguments, MAX_ARG_LENGTH, and MAX_ARGS.
Referenced by strExplode().
00095 { 00096 for (int index = 0; index < MAX_ARGS; index++) 00097 for (int count = 0; count < MAX_ARG_LENGTH; count++) 00098 arguments[index][count] = '\0'; // clear each cell in the arguments matrix 00099 }

| void WaspUtils::clearBuffer | ( | void | ) | [inline] |
It clears the inBuffer array.
| void |
Definition at line 403 of file WaspUtils.h.
References GPS_BUFFER_SIZE, and inBuffer.
Referenced by WaspGPS::getRaw().
00403 {for (int i = 0; i < GPS_BUFFER_SIZE; i++) inBuffer[i] = '\0';};

| void WaspUtils::strExplode | ( | const char * | str, | |
| char | separator | |||
| ) |
It breaks a string into its arguments separated by "separators". The pieces are stored in 'arguments' array.
| const | char* str : string to separate | |
| char | separator : the separator used to separate the string in pieces |
Definition at line 104 of file WaspUtils.cpp.
References arguments, clearArguments(), sizeOf(), and Utils.
Referenced by WaspGPS::check(), WaspGPS::extractDate(), WaspGPS::extractTime(), WaspGPS::getAltitude(), WaspGPS::getCourse(), WaspGPS::getLatitude(), WaspGPS::getLongitude(), WaspGPS::getPosition(), WaspGPS::getSpeed(), WaspGPRS::readDataFTP(), WaspGPRS::sendDataFTP(), and WaspGPS::setCommMode().
00104 { 00105 int count = 0, index = 0, sIndex = 0; 00106 int theSize = Utils.sizeOf(str); 00107 clearArguments(); 00108 while (theSize >= sIndex + 1){ 00109 if (*str != separator) 00110 { 00111 arguments[index][count] = *str; 00112 *str++; 00113 count++; 00114 } 00115 else 00116 { 00117 *str++; // jump over the separator 00118 count = 0; 00119 index++; 00120 } 00121 sIndex++; 00122 } 00123 }


| uint8_t WaspUtils::converter | ( | uint8_t | conv1, | |
| uint8_t | conv2 | |||
| ) |
It generates a decimal number from two ASCII characters which were numbers.
| uint8_t | conv1 : the ASCII number first digit to convert | |
| uint8_t | conv2 : the ASCII number second digit to convert |
Definition at line 614 of file WaspUtils.cpp.
Referenced by WaspXBeeCore::gen_data().
00615 { 00616 uint8_t aux=0; 00617 uint8_t aux2=0; 00618 uint8_t resul=0; 00619 00620 switch(conv1) 00621 { 00622 case 48: aux=0; 00623 break; 00624 case 49: aux=1; 00625 break; 00626 case 50: aux=2; 00627 break; 00628 case 51: aux=3; 00629 break; 00630 case 52: aux=4; 00631 break; 00632 case 53: aux=5; 00633 break; 00634 case 54: aux=6; 00635 break; 00636 case 55: aux=7; 00637 break; 00638 case 56: aux=8; 00639 break; 00640 case 57: aux=9; 00641 break; 00642 case 65: aux=10; 00643 break; 00644 case 66: aux=11; 00645 break; 00646 case 67: aux=12; 00647 break; 00648 case 68: aux=13; 00649 break; 00650 case 69: aux=14; 00651 break; 00652 case 70: aux=15; 00653 break; 00654 } 00655 switch(conv2) 00656 { 00657 case 48: aux2=0; 00658 break; 00659 case 49: aux2=1; 00660 break; 00661 case 50: aux2=2; 00662 break; 00663 case 51: aux2=3; 00664 break; 00665 case 52: aux2=4; 00666 break; 00667 case 53: aux2=5; 00668 break; 00669 case 54: aux2=6; 00670 break; 00671 case 55: aux2=7; 00672 break; 00673 case 56: aux2=8; 00674 break; 00675 case 57: aux2=9; 00676 break; 00677 case 65: aux2=10; 00678 break; 00679 case 66: aux2=11; 00680 break; 00681 case 67: aux2=12; 00682 break; 00683 case 68: aux2=13; 00684 break; 00685 case 69: aux2=14; 00686 break; 00687 case 70: aux2=15; 00688 break; 00689 default: aux2=100; 00690 break; 00691 } 00692 if(aux2==100) // Only one character but we have treated two, so We have to fix it 00693 { 00694 resul=aux; 00695 } 00696 else 00697 { 00698 resul=(aux*16)+aux2; 00699 } 00700 return resul; 00701 }

| void WaspUtils::float2String | ( | float | fl, | |
| char | str[], | |||
| int | N | |||
| ) |
It converts a float into a string.
| float | fl : the float to convert | |
| char | str[] : the string where store the float converted | |
| int | N : the number of decimals |
Definition at line 704 of file WaspUtils.cpp.
00704 { 00705 00706 boolean neg = false; 00707 00708 if( fl<0 ){ 00709 neg = true; 00710 fl*=-1; 00711 } 00712 00713 float numeroFloat=fl; //variable local e la que guardo el float para no machacarlo 00714 //defino una cadena de enteros para guardar la parte entera en sentido ascendente. Es decir el indice 0 00715 int parteEntera[10]; 00716 int cifra; //guardo temporalmente la cifra 00717 long numero=(long)numeroFloat; 00718 int size=0; //size nos da el numero de unidades del float: 1->decenas, 2->centenas etc. Asi sabemos el numero de cifras de la parte entera. 00719 00720 while(1){ 00721 size=size+1; 00722 cifra=numero%10; 00723 numero=numero/10; 00724 parteEntera[size-1]=cifra; //metemos en la cadena la cifra correspondiente 00725 if (numero==0){ 00726 break; 00727 } 00728 }//while 00729 00730 //procesamos la parte entera del FLOAT 00731 int indice=0; 00732 if( neg ){ 00733 indice++; 00734 str[0]='-'; 00735 } 00736 for (int i=size-1; i>=0; i--) 00737 { str[indice]=parteEntera[i]+'0'; //introduzco la cifra en ASCII dentro de la cadena str 00738 indice++; 00739 } 00740 00741 //ahora introduzco la 'coma' o 'punto' dentro del String 00742 str[indice]=','; 00743 indice++; 00744 00745 //ahora procesamos la parte decimal del FLOAT 00746 numeroFloat=(numeroFloat-(int)numeroFloat); 00747 for (int i=1; i<=N ; i++) 00748 { 00749 numeroFloat=numeroFloat*10; 00750 cifra= (long)numeroFloat; 00751 numeroFloat=numeroFloat-cifra; 00752 str[indice]=char(cifra)+48; //introduzco la cifra en ASCII dentro de la cadena str 00753 indice++; 00754 } 00755 }
| uint16_t WaspUtils::freeMemory |
Variable : Free available memory.
It stores the last free available memory size returned by 'getFreeMemory' function
Definition at line 100 of file WaspUtils.h.
Referenced by getFreeMemory().
| char WaspUtils::inBuffer[GPS_BUFFER_SIZE] |
Variable : buffer to store incoming data.
Definition at line 105 of file WaspUtils.h.
Referenced by WaspGPS::check(), clearBuffer(), WaspGPS::extractDate(), WaspGPS::extractTime(), WaspGPS::getAltitude(), WaspGPS::getCourse(), WaspGPS::getLatitude(), WaspGPS::getLongitude(), WaspGPS::getPosition(), WaspGPS::getRaw(), WaspGPS::getSpeed(), WaspGPS::init(), WaspGPS::setChecksum(), and WaspGPS::setCommMode().
| char WaspUtils::arguments[MAX_ARGS][MAX_ARG_LENGTH] |
Variable : bidimensional array of arguments in Waspmote, mainly used with the GPS.
Definition at line 110 of file WaspUtils.h.
Referenced by WaspGPS::check(), clearArguments(), WaspGPS::extractDate(), WaspGPS::extractTime(), WaspGPS::getAltitude(), WaspGPS::getCourse(), WaspGPS::getLatitude(), WaspGPS::getLongitude(), WaspGPS::getPosition(), WaspGPS::getSpeed(), WaspGPRS::readDataFTP(), WaspGPRS::sendDataFTP(), WaspGPS::setCommMode(), and strExplode().
1.5.6