update BLE library for ESP32 env compatibility

with the last version of ESP32 arduino env it is not possible to compile on ESP32, we get "missing gatt_api.h" ERROR. So as to avoid that we need to use the last version of the nkolban library for BLE 0.4.16
This commit is contained in:
Florian committed 2018-06-30 15:24:47 +02:00
1 parent 1dd68ab078
commit 42be3fe0f2
48 files changed
+2970 -426

No files matched your search

+57 -17
View File
@@ -11,6 +11,8 @@
#include <sstream>
#include <iomanip>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include "BLEUUID.h"
static const char* LOG_TAG = "BLEUUID";
@@ -188,6 +190,32 @@ BLEUUID::BLEUUID() {
} // BLEUUID
/**
* @brief Get the number of bits in this uuid.
* @return The number of bits in the UUID. One of 16, 32 or 128.
*/
int BLEUUID::bitSize() {
if (m_valueSet == false) {
return 0;
}
switch(m_uuid.len) {
case ESP_UUID_LEN_16: {
return 16;
}
case ESP_UUID_LEN_32: {
return 32;
}
case ESP_UUID_LEN_128: {
return 128;
}
default: {
ESP_LOGE(LOG_TAG, "Unknown UUID length: %d", m_uuid.len);
return 0;
}
} // End of switch
} // bitSize
/**
* @brief Compare a UUID against this UUID.
*
@@ -216,6 +244,35 @@ bool BLEUUID::equals(BLEUUID uuid) {
} // equals
/**
* Create a BLEUUID from a string of the form:
* 0xNNNN
* 0xNNNNNNNN
* 0x<UUID>
* NNNN
* NNNNNNNN
* <UUID>
*/
BLEUUID BLEUUID::fromString(std::string _uuid){
uint8_t start = 0;
if (strstr(_uuid.c_str(), "0x") != nullptr) { // If the string starts with 0x, skip those characters.
start = 2;
}
uint8_t len = _uuid.length() - start; // Calculate the length of the string we are going to use.
if( len == 4) {
uint16_t x = strtoul(_uuid.substr(start, len).c_str(), NULL, 16);
return BLEUUID(x);
} else if (len == 8) {
uint32_t x = strtoul(_uuid.substr(start, len).c_str(), NULL, 16);
return BLEUUID(x);
} else if (len == 36) {
return BLEUUID(_uuid);
}
return BLEUUID();
} // fromString
/**
* @brief Get the native UUID value.
*
@@ -350,21 +407,4 @@ std::string BLEUUID::toString() {
return ss.str();
} // toString
BLEUUID BLEUUID::fromString(std::string _uuid){
uint8_t start = 0;
if(strstr(_uuid.c_str(), "0x") != nullptr){
start = 2;
}
uint8_t len = _uuid.length() - start;
if(len == 4 ){
uint16_t x = strtoul(_uuid.substr(start, len).c_str(), NULL, 16);
return BLEUUID(x);
}else if(len == 8){
uint32_t x = strtoul(_uuid.substr(start, len).c_str(), NULL, 16);
return BLEUUID(x);
}else if (len == 36){
return BLEUUID(_uuid);
}
return BLEUUID();
}
#endif /* CONFIG_BT_ENABLED */