added debugging
Fork of BLE_nRF8001 by
BLE_nRF8001/BLEUuid.cpp@0:075ea2812998, 2014-10-17 (annotated)
- Committer:
- RedBearLab
- Date:
- Fri Oct 17 22:40:32 2014 +0800
- Revision:
- 0:075ea2812998
BLE_nRF8001 library first commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RedBearLab | 0:075ea2812998 | 1 | #include "Arduino.h" |
RedBearLab | 0:075ea2812998 | 2 | |
RedBearLab | 0:075ea2812998 | 3 | #include "BLEUuid.h" |
RedBearLab | 0:075ea2812998 | 4 | |
RedBearLab | 0:075ea2812998 | 5 | BLEUuid::BLEUuid(const char * str) |
RedBearLab | 0:075ea2812998 | 6 | { |
RedBearLab | 0:075ea2812998 | 7 | char temp[] = {0, 0, 0}; |
RedBearLab | 0:075ea2812998 | 8 | |
RedBearLab | 0:075ea2812998 | 9 | this->_length = 0; |
RedBearLab | 0:075ea2812998 | 10 | for (int i = strlen(str) - 1; i >= 0 && this->_length < MAX_UUID_LENGTH; i -= 2) { |
RedBearLab | 0:075ea2812998 | 11 | if (str[i] == '-') { |
RedBearLab | 0:075ea2812998 | 12 | i++; |
RedBearLab | 0:075ea2812998 | 13 | continue; |
RedBearLab | 0:075ea2812998 | 14 | } |
RedBearLab | 0:075ea2812998 | 15 | |
RedBearLab | 0:075ea2812998 | 16 | temp[0] = str[i - 1]; |
RedBearLab | 0:075ea2812998 | 17 | temp[1] = str[i]; |
RedBearLab | 0:075ea2812998 | 18 | |
RedBearLab | 0:075ea2812998 | 19 | this->_data[this->_length] = strtoul(temp, NULL, 16); |
RedBearLab | 0:075ea2812998 | 20 | |
RedBearLab | 0:075ea2812998 | 21 | this->_length++; |
RedBearLab | 0:075ea2812998 | 22 | } |
RedBearLab | 0:075ea2812998 | 23 | } |
RedBearLab | 0:075ea2812998 | 24 | |
RedBearLab | 0:075ea2812998 | 25 | const char* BLEUuid::str() { |
RedBearLab | 0:075ea2812998 | 26 | return this->_str; |
RedBearLab | 0:075ea2812998 | 27 | } |
RedBearLab | 0:075ea2812998 | 28 | |
RedBearLab | 0:075ea2812998 | 29 | const unsigned char* BLEUuid::data() { |
RedBearLab | 0:075ea2812998 | 30 | return this->_data; |
RedBearLab | 0:075ea2812998 | 31 | } |
RedBearLab | 0:075ea2812998 | 32 | |
RedBearLab | 0:075ea2812998 | 33 | unsigned char BLEUuid::length() { |
RedBearLab | 0:075ea2812998 | 34 | return this->_length; |
RedBearLab | 0:075ea2812998 | 35 | } |