Replaced Logger usage with LOG_x (#548)

This commit is contained in:
Ken Van Hoeylandt
2026-07-04 23:49:19 +02:00
committed by GitHub
parent ecad2248d9
commit 9d5993930d
162 changed files with 1776 additions and 1842 deletions
+10 -10
View File
@@ -7,18 +7,18 @@
#include <Tactility/service/espnow/EspNow.h>
#include <Tactility/service/espnow/EspNowService.h>
#include <Tactility/Logger.h>
#include <tactility/log.h>
namespace tt::service::espnow {
static const auto LOGGER = Logger("EspNow");
constexpr auto* TAG = "EspNow";
void enable(const EspNowConfig& config) {
auto service = findService();
if (service != nullptr) {
service->enable(config);
} else {
LOGGER.error("Service not found");
LOG_E(TAG, "Service not found");
}
}
@@ -27,7 +27,7 @@ void disable() {
if (service != nullptr) {
service->disable();
} else {
LOGGER.error("Service not found");
LOG_E(TAG, "Service not found");
}
}
@@ -36,7 +36,7 @@ bool isEnabled() {
if (service != nullptr) {
return service->isEnabled();
} else {
LOGGER.error("Service not found");
LOG_E(TAG, "Service not found");
return false;
}
}
@@ -46,7 +46,7 @@ bool addPeer(const esp_now_peer_info_t& peer) {
if (service != nullptr) {
return service->addPeer(peer);
} else {
LOGGER.error("Service not found");
LOG_E(TAG, "Service not found");
return false;
}
}
@@ -56,7 +56,7 @@ bool send(const uint8_t* address, const uint8_t* buffer, size_t bufferLength) {
if (service != nullptr) {
return service->send(address, buffer, bufferLength);
} else {
LOGGER.error("Service not found");
LOG_E(TAG, "Service not found");
return false;
}
}
@@ -66,7 +66,7 @@ ReceiverSubscription subscribeReceiver(std::function<void(const esp_now_recv_inf
if (service != nullptr) {
return service->subscribeReceiver(onReceive);
} else {
LOGGER.error("Service not found");
LOG_E(TAG, "Service not found");
return -1;
}
}
@@ -76,7 +76,7 @@ void unsubscribeReceiver(ReceiverSubscription subscription) {
if (service != nullptr) {
service->unsubscribeReceiver(subscription);
} else {
LOGGER.error("Service not found");
LOG_E(TAG, "Service not found");
}
}
@@ -85,7 +85,7 @@ uint32_t getVersion() {
if (service != nullptr) {
return service->getVersion();
}
LOGGER.error("Service not found");
LOG_E(TAG, "Service not found");
return 0;
}
@@ -4,7 +4,6 @@
#if defined(CONFIG_SOC_WIFI_SUPPORTED) && !defined(CONFIG_SLAVE_SOC_WIFI_SUPPORTED)
#include <Tactility/Logger.h>
#include <Tactility/Tactility.h>
#include <Tactility/service/espnow/EspNowService.h>
#include <Tactility/service/ServiceManifest.h>
@@ -15,11 +14,13 @@
#include <esp_now.h>
#include <esp_random.h>
#include <tactility/log.h>
namespace tt::service::espnow {
extern const ServiceManifest manifest;
static const auto LOGGER = Logger("EspNowService");
constexpr auto* TAG = "EspNowService";
static uint8_t BROADCAST_MAC[ESP_NOW_ETH_ALEN];
constexpr TickType_t MAX_DELAY = 1000U / portTICK_PERIOD_MS;
@@ -60,17 +61,17 @@ void EspNowService::enableFromDispatcher(const EspNowConfig& config) {
}
if (!initWifi(config)) {
LOGGER.error("initWifi() failed");
LOG_E(TAG,"initWifi() failed");
return;
}
if (esp_now_init() != ESP_OK) {
LOGGER.error("esp_now_init() failed");
LOG_E(TAG,"esp_now_init() failed");
return;
}
if (esp_now_register_recv_cb(receiveCallback) != ESP_OK) {
LOGGER.error("esp_now_register_recv_cb() failed");
LOG_E(TAG,"esp_now_register_recv_cb() failed");
return;
}
@@ -80,15 +81,15 @@ void EspNowService::enableFromDispatcher(const EspNowConfig& config) {
//#endif
if (esp_now_set_pmk(config.masterKey) != ESP_OK) {
LOGGER.error("esp_now_set_pmk() failed");
LOG_E(TAG,"esp_now_set_pmk() failed");
return;
}
espnowVersion = 0;
if (esp_now_get_version(&espnowVersion) == ESP_OK) {
LOGGER.info("ESP-NOW version: {}.0", espnowVersion);
LOG_I(TAG, "ESP-NOW version: %u.0", (unsigned)espnowVersion);
} else {
LOGGER.warn("Failed to get ESP-NOW version");
LOG_W(TAG, "Failed to get ESP-NOW version");
}
// Add default unencrypted broadcast peer
@@ -119,11 +120,11 @@ void EspNowService::disableFromDispatcher() {
}
if (esp_now_deinit() != ESP_OK) {
LOGGER.error("esp_now_deinit() failed");
LOG_E(TAG,"esp_now_deinit() failed");
}
if (!deinitWifi()) {
LOGGER.error("deinitWifi() failed");
LOG_E(TAG,"deinitWifi() failed");
}
espnowVersion = 0;
@@ -137,7 +138,7 @@ void EspNowService::disableFromDispatcher() {
void EspNowService::receiveCallback(const esp_now_recv_info_t* receiveInfo, const uint8_t* data, int length) {
auto service = findService();
if (service == nullptr) {
LOGGER.error("Service not running");
LOG_E(TAG,"Service not running");
return;
}
service->onReceive(receiveInfo, data, length);
@@ -147,7 +148,7 @@ void EspNowService::onReceive(const esp_now_recv_info_t* receiveInfo, const uint
auto lock = mutex.asScopedLock();
lock.lock();
LOGGER.debug("Received {} bytes", length);
LOG_D(TAG, "Received %d bytes", length);
for (const auto& item: subscriptions) {
item.onReceive(receiveInfo, data, length);
@@ -164,10 +165,10 @@ bool EspNowService::isEnabled() const {
bool EspNowService::addPeer(const esp_now_peer_info_t& peer) {
if (esp_now_add_peer(&peer) != ESP_OK) {
LOGGER.error("Failed to add peer");
LOG_E(TAG,"Failed to add peer");
return false;
} else {
LOGGER.info("Peer added");
LOG_I(TAG, "Peer added");
return true;
}
}
+12 -11
View File
@@ -4,16 +4,17 @@
#if defined(CONFIG_SOC_WIFI_SUPPORTED) && !defined(CONFIG_SLAVE_SOC_WIFI_SUPPORTED)
#include <Tactility/Logger.h>
#include <Tactility/service/espnow/EspNow.h>
#include <Tactility/service/wifi/Wifi.h>
#include <esp_now.h>
#include <esp_wifi.h>
#include <tactility/log.h>
namespace tt::service::espnow {
static const auto LOGGER = Logger("EspNowService");
constexpr auto* TAG = "EspNowService";
static bool wifiStartedByEspNow = false;
bool initWifi(const EspNowConfig& config) {
@@ -32,27 +33,27 @@ bool initWifi(const EspNowConfig& config) {
if (wifiStartedByEspNow) {
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
if (esp_wifi_init(&cfg) != ESP_OK) {
LOGGER.error("esp_wifi_init() failed");
LOG_E(TAG,"esp_wifi_init() failed");
return false;
}
if (esp_wifi_set_storage(WIFI_STORAGE_RAM) != ESP_OK) {
LOGGER.error("esp_wifi_set_storage() failed");
LOG_E(TAG,"esp_wifi_set_storage() failed");
return false;
}
if (esp_wifi_set_mode(mode) != ESP_OK) {
LOGGER.error("esp_wifi_set_mode() failed");
LOG_E(TAG,"esp_wifi_set_mode() failed");
return false;
}
if (esp_wifi_start() != ESP_OK) {
LOGGER.error("esp_wifi_start() failed");
LOG_E(TAG,"esp_wifi_start() failed");
return false;
}
if (esp_wifi_set_channel(config.channel, WIFI_SECOND_CHAN_NONE) != ESP_OK) {
LOGGER.error("esp_wifi_set_channel() failed");
LOG_E(TAG,"esp_wifi_set_channel() failed");
return false;
}
}
@@ -66,11 +67,11 @@ bool initWifi(const EspNowConfig& config) {
}
if (esp_wifi_set_protocol(wifi_interface, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N | WIFI_PROTOCOL_LR) != ESP_OK) {
LOGGER.warn("esp_wifi_set_protocol() for long range failed");
LOG_W(TAG,"esp_wifi_set_protocol() for long range failed");
}
}
LOGGER.info("WiFi initialized for ESP-NOW (wifi already running: {})", wifi_already_running ? "yes" : "no");
LOG_I(TAG, "WiFi initialized for ESP-NOW (wifi already running: %s)", wifi_already_running ? "yes" : "no");
return true;
}
@@ -79,9 +80,9 @@ bool deinitWifi() {
esp_wifi_stop();
esp_wifi_deinit();
wifiStartedByEspNow = false;
LOGGER.info("WiFi stopped (was started by ESP-NOW)");
LOG_I(TAG, "WiFi stopped (was started by ESP-NOW)");
} else {
LOGGER.info("WiFi left running (managed by WiFi service)");
LOG_I(TAG, "WiFi left running (managed by WiFi service)");
}
return true;
}