Refactored use of LOG_X(LOG_TAG, ...) to log_x(...) (#2672)

* Replaced ARDUINO_VARIANT with const char

* Fixed missing return value

* Added quotes around defined value in macro (Issue #2193)

* Change logging from Error to Verbose when not found and default available

* Move Enter and Exit logging to Verbose Level

* Refactored LOG_X() into log_x()
This commit is contained in:
Bascy
2019-04-15 17:26:35 +02:00
committed by Me No Dev
parent af23d0bb10
commit 01d7ea7b80
21 changed files with 399 additions and 530 deletions

View File

@ -13,15 +13,7 @@
#include <assert.h>
#include <stdlib.h>
#include "BLEUUID.h"
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
#include "esp32-hal-log.h"
#define LOG_TAG ""
#else
#include "esp_log.h"
static const char* LOG_TAG = "BLEUUID";
#endif
/**
* @brief Copy memory from source to target but in reverse order.
@ -121,7 +113,7 @@ BLEUUID::BLEUUID(std::string value) {
}
}
else {
ESP_LOGE(LOG_TAG, "ERROR: UUID value not 2, 4, 16 or 36 bytes");
log_e("ERROR: UUID value not 2, 4, 16 or 36 bytes");
m_valueSet = false;
}
} //BLEUUID(std::string)
@ -136,7 +128,7 @@ BLEUUID::BLEUUID(std::string value) {
*/
BLEUUID::BLEUUID(uint8_t* pData, size_t size, bool msbFirst) {
if (size != 16) {
ESP_LOGE(LOG_TAG, "ERROR: UUID length not 16 bytes");
log_e("ERROR: UUID length not 16 bytes");
return;
}
m_uuid.len = ESP_UUID_LEN_128;
@ -212,7 +204,7 @@ uint8_t BLEUUID::bitSize() {
case ESP_UUID_LEN_128:
return 128;
default:
ESP_LOGE(LOG_TAG, "Unknown UUID length: %d", m_uuid.len);
log_e("Unknown UUID length: %d", m_uuid.len);
return 0;
} // End of switch
} // bitSize
@ -225,7 +217,7 @@ uint8_t BLEUUID::bitSize() {
* @return True if the UUIDs are equal and false otherwise.
*/
bool BLEUUID::equals(BLEUUID uuid) {
//ESP_LOGD(TAG, "Comparing: %s to %s", toString().c_str(), uuid.toString().c_str());
//log_d("Comparing: %s to %s", toString().c_str(), uuid.toString().c_str());
if (!m_valueSet || !uuid.m_valueSet) return false;
if (uuid.m_uuid.len != m_uuid.len) {
@ -279,12 +271,12 @@ BLEUUID BLEUUID::fromString(std::string _uuid) {
* @return The native UUID value or NULL if not set.
*/
esp_bt_uuid_t* BLEUUID::getNative() {
//ESP_LOGD(TAG, ">> getNative()")
//log_d(">> getNative()")
if (m_valueSet == false) {
ESP_LOGD(LOG_TAG, "<< Return of un-initialized UUID!");
log_v("<< Return of un-initialized UUID!");
return nullptr;
}
//ESP_LOGD(TAG, "<< getNative()");
//log_d("<< getNative()");
return &m_uuid;
} // getNative
@ -296,7 +288,7 @@ esp_bt_uuid_t* BLEUUID::getNative() {
* will convert 16 or 32 bit representations to the full 128bit.
*/
BLEUUID BLEUUID::to128() {
//ESP_LOGD(LOG_TAG, ">> toFull() - %s", toString().c_str());
//log_v(">> toFull() - %s", toString().c_str());
// If we either don't have a value or are already a 128 bit UUID, nothing further to do.
if (!m_valueSet || m_uuid.len == ESP_UUID_LEN_128) {
@ -338,7 +330,7 @@ BLEUUID BLEUUID::to128() {
m_uuid.uuid.uuid128[0] = 0xfb;
m_uuid.len = ESP_UUID_LEN_128;
//ESP_LOGD(TAG, "<< toFull <- %s", toString().c_str());
//log_d("<< toFull <- %s", toString().c_str());
return *this;
} // to128