summaryrefslogtreecommitdiff
path: root/src/BLEUUID.cpp
diff options
context:
space:
mode:
authorNeil Kolban <kolban1@kolban.com>2017-11-21 09:51:03 -0600
committerNeil Kolban <kolban1@kolban.com>2017-11-21 09:51:03 -0600
commit4a781e01832176d61af010669b8c362f5a777768 (patch)
tree6a7a16309d61c4728512f5eb632d3ad565288c36 /src/BLEUUID.cpp
parentFixes for #121 (diff)
downloadthermostat-4a781e01832176d61af010669b8c362f5a777768.tar.gz
thermostat-4a781e01832176d61af010669b8c362f5a777768.tar.bz2
thermostat-4a781e01832176d61af010669b8c362f5a777768.zip
Updates 2017-11-21 0950
Diffstat (limited to 'src/BLEUUID.cpp')
-rw-r--r--src/BLEUUID.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/BLEUUID.cpp b/src/BLEUUID.cpp
index 19da518..f5c6cee 100644
--- a/src/BLEUUID.cpp
+++ b/src/BLEUUID.cpp
@@ -14,6 +14,9 @@
#include "BLEUUID.h"
static const char* LOG_TAG = "BLEUUID";
+#ifdef ARDUINO_ARCH_ESP32
+#include "esp32-hal-log.h"
+#endif
/**
* @brief Copy memory from source to target but in reverse order.
@@ -144,6 +147,7 @@ BLEUUID::BLEUUID(uint16_t uuid) {
m_uuid.len = ESP_UUID_LEN_16;
m_uuid.uuid.uuid16 = uuid;
m_valueSet = true;
+
} // BLEUUID
@@ -345,4 +349,22 @@ std::string BLEUUID::toString() {
std::setw(2) << (int)m_uuid.uuid.uuid128[0];
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 */