New logging and more (#446)
- `TT_LOG_*` macros are replaced by `Logger` via `#include<Tactility/Logger.h>` - Changed default timezone to Europe/Amsterdam - Fix for logic bug in unPhone hardware - Fix for init/deinit in DRV2605 driver - Other fixes - Removed optimization that broke unPhone (disabled the moving of heap-related functions to flash)
This commit is contained in:
committed by
GitHub
parent
719f7bcece
commit
f620255c41
@@ -5,7 +5,7 @@
|
||||
#ifdef CONFIG_ESP_WIFI_ENABLED
|
||||
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/service/espnow/EspNow.h>
|
||||
#include <Tactility/service/wifi/Wifi.h>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
namespace tt::service::espnow {
|
||||
|
||||
constexpr const char* TAG = "EspNowService";
|
||||
static const auto LOGGER = Logger("EspNowService");
|
||||
|
||||
static bool disableWifiService() {
|
||||
auto wifi_state = wifi::getRadioState();
|
||||
@@ -43,7 +43,7 @@ bool initWifi(const EspNowConfig& config) {
|
||||
// If WiFi is already connected, keep it running and just add ESP-NOW on top
|
||||
if (!wifi_was_connected && wifi_state != wifi::RadioState::Off && wifi_state != wifi::RadioState::OffPending) {
|
||||
if (!disableWifiService()) {
|
||||
TT_LOG_E(TAG, "Failed to disable wifi");
|
||||
LOGGER.error("Failed to disable wifi");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -60,28 +60,28 @@ bool initWifi(const EspNowConfig& config) {
|
||||
if (wifi::getRadioState() == wifi::RadioState::Off) {
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
if (esp_wifi_init(&cfg) != ESP_OK) {
|
||||
TT_LOG_E(TAG, "esp_wifi_init() failed");
|
||||
LOGGER.error("esp_wifi_init() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_wifi_set_storage(WIFI_STORAGE_RAM) != ESP_OK) {
|
||||
TT_LOG_E(TAG, "esp_wifi_set_storage() failed");
|
||||
LOGGER.error("esp_wifi_set_storage() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_wifi_set_mode(mode) != ESP_OK) {
|
||||
TT_LOG_E(TAG, "esp_wifi_set_mode() failed");
|
||||
LOGGER.error("esp_wifi_set_mode() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_wifi_start() != ESP_OK) {
|
||||
TT_LOG_E(TAG, "esp_wifi_start() failed");
|
||||
LOGGER.error("esp_wifi_start() failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (esp_wifi_set_channel(config.channel, WIFI_SECOND_CHAN_NONE) != ESP_OK) {
|
||||
TT_LOG_E(TAG, "esp_wifi_set_channel() failed");
|
||||
LOGGER.error("esp_wifi_set_channel() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -94,11 +94,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) {
|
||||
TT_LOG_W(TAG, "esp_wifi_set_protocol() for long range failed");
|
||||
LOGGER.warn("esp_wifi_set_protocol() for long range failed");
|
||||
}
|
||||
}
|
||||
|
||||
TT_LOG_I(TAG, "WiFi initialized for ESP-NOW (preserved existing connection: %s)", wifi_was_connected ? "yes" : "no");
|
||||
LOGGER.info("WiFi initialized for ESP-NOW (preserved existing connection: {})", wifi_was_connected ? "yes" : "no");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ bool deinitWifi() {
|
||||
// Since we're only using WiFi for ESP-NOW, we can safely keep it in a minimal state
|
||||
// or shut it down. For now, keep it running to support STA + ESP-NOW coexistence.
|
||||
|
||||
TT_LOG_I(TAG, "ESP-NOW WiFi deinitialized (WiFi service continues independently)");
|
||||
LOGGER.info("ESP-NOW WiFi deinitialized (WiFi service continues independently)");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user