From f6dfc04cb80aed9016ce583344e22f586bf3d8a3 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 4 Jan 2026 23:25:13 +0100 Subject: [PATCH] Fixes --- .../Source/KeyboardBacklight/KeyboardBacklight.cpp | 2 +- Tactility/Include/Tactility/network/EspHttpClient.h | 4 ++-- Tactility/Private/Tactility/json/Reader.h | 2 +- Tactility/Source/PartitionsEsp.cpp | 4 ++-- Tactility/Source/app/AppInstall.cpp | 2 +- Tactility/Source/file/ObjectFileWriter.cpp | 2 +- Tactility/Source/hal/sdcard/SdCardMounting.cpp | 2 +- Tactility/Source/hal/uart/Uart.cpp | 2 +- Tactility/Source/hal/uart/UartEsp.cpp | 2 +- Tactility/Source/network/HttpdReq.cpp | 2 +- Tactility/Source/service/gps/GpsConfiguration.cpp | 2 +- Tactility/Source/service/gps/GpsService.cpp | 2 +- Tactility/Source/service/wifi/WifiEsp.cpp | 10 +++++----- TactilityCore/Include/Tactility/LoggerAdapterGeneric.h | 7 +++++-- TactilityCore/Source/Check.cpp | 4 ++-- 15 files changed, 26 insertions(+), 23 deletions(-) diff --git a/Devices/lilygo-tdeck/Source/KeyboardBacklight/KeyboardBacklight.cpp b/Devices/lilygo-tdeck/Source/KeyboardBacklight/KeyboardBacklight.cpp index e5fb19d7..185216cf 100644 --- a/Devices/lilygo-tdeck/Source/KeyboardBacklight/KeyboardBacklight.cpp +++ b/Devices/lilygo-tdeck/Source/KeyboardBacklight/KeyboardBacklight.cpp @@ -65,7 +65,7 @@ bool setBrightness(uint8_t brightness) { LOGGER.info("Successfully set brightness to {}", brightness); return true; } else { - LOGGER.error("Failed to set brightness: {} (0x%x)", esp_err_to_name(ret), ret); + LOGGER.error("Failed to set brightness: {} (0x{:02X})", esp_err_to_name(ret), ret); return false; } } diff --git a/Tactility/Include/Tactility/network/EspHttpClient.h b/Tactility/Include/Tactility/network/EspHttpClient.h index 8b7bdd14..c8d4b421 100644 --- a/Tactility/Include/Tactility/network/EspHttpClient.h +++ b/Tactility/Include/Tactility/network/EspHttpClient.h @@ -28,7 +28,7 @@ public: } bool init(std::unique_ptr inConfig) { - logger.info("init(%s)", inConfig->url); + logger.info("init({})", inConfig->url); assert(this->config == nullptr); config = std::move(inConfig); client = esp_http_client_init(config.get()); @@ -41,7 +41,7 @@ public: auto result = esp_http_client_open(client, 0); if (result != ESP_OK) { - logger.error("open() failed: %s", esp_err_to_name(result)); + logger.error("open() failed: {}", esp_err_to_name(result)); return false; } diff --git a/Tactility/Private/Tactility/json/Reader.h b/Tactility/Private/Tactility/json/Reader.h index 40ff7ccb..0b2ad1fc 100644 --- a/Tactility/Private/Tactility/json/Reader.h +++ b/Tactility/Private/Tactility/json/Reader.h @@ -67,7 +67,7 @@ public: for (int i = 0; i < size; ++i) { const auto string_json = cJSON_GetArrayItem(child, i); if (!cJSON_IsString(string_json)) { - logger.error("array child of %s is not a string", key); + logger.error("Array child of {} is not a string", key); return false; } output[i] = cJSON_GetStringValue(string_json); diff --git a/Tactility/Source/PartitionsEsp.cpp b/Tactility/Source/PartitionsEsp.cpp index bc6fd22d..b1b79a5a 100644 --- a/Tactility/Source/PartitionsEsp.cpp +++ b/Tactility/Source/PartitionsEsp.cpp @@ -53,14 +53,14 @@ esp_err_t initPartitionsEsp() { auto system_result = esp_vfs_fat_spiflash_mount_ro("/system", "system", &mount_config); if (system_result != ESP_OK) { - LOGGER.error("Failed to mount /system (%s)", esp_err_to_name(system_result)); + LOGGER.error("Failed to mount /system ({})", esp_err_to_name(system_result)); } else { LOGGER.info("Mounted /system"); } auto data_result = esp_vfs_fat_spiflash_mount_rw_wl("/data", "data", &mount_config, &data_wl_handle); if (data_result != ESP_OK) { - LOGGER.error("Failed to mount /data (%s)", esp_err_to_name(data_result)); + LOGGER.error("Failed to mount /data ({})", esp_err_to_name(data_result)); } else { LOGGER.info("Mounted /data"); } diff --git a/Tactility/Source/app/AppInstall.cpp b/Tactility/Source/app/AppInstall.cpp index 22e45caa..f3b87815 100644 --- a/Tactility/Source/app/AppInstall.cpp +++ b/Tactility/Source/app/AppInstall.cpp @@ -106,7 +106,7 @@ bool install(const std::string& path) { // the lock with the display. We don't want to lock the display for very long. auto app_parent_path = getAppInstallPath(); - LOGGER.info("Installing app %s to {}", path, app_parent_path); + LOGGER.info("Installing app {} to {}", path, app_parent_path); auto filename = file::getLastPathSegment(path); const std::string app_target_path = std::format("{}/{}", app_parent_path, filename); diff --git a/Tactility/Source/file/ObjectFileWriter.cpp b/Tactility/Source/file/ObjectFileWriter.cpp index ceb3f3ba..c94a34eb 100644 --- a/Tactility/Source/file/ObjectFileWriter.cpp +++ b/Tactility/Source/file/ObjectFileWriter.cpp @@ -39,7 +39,7 @@ bool ObjectFileWriter::open() { } if (file_header.version != OBJECT_FILE_VERSION) { - LOGGER.error("Unknown version for {}: {}", filePath, file_header.identifier); + LOGGER.error("Unknown version for {}: {}", filePath, file_header.version); return false; } diff --git a/Tactility/Source/hal/sdcard/SdCardMounting.cpp b/Tactility/Source/hal/sdcard/SdCardMounting.cpp index 61b6c33f..b7152117 100644 --- a/Tactility/Source/hal/sdcard/SdCardMounting.cpp +++ b/Tactility/Source/hal/sdcard/SdCardMounting.cpp @@ -7,7 +7,7 @@ namespace tt::hal::sdcard { -static const auto LOGGER = Logger("EspLcdDisplay"); +static const auto LOGGER = Logger("SdCardMounting"); constexpr auto* TT_SDCARD_MOUNT_POINT = "/sdcard"; static void mount(const std::shared_ptr& sdcard, const std::string& path) { diff --git a/Tactility/Source/hal/uart/Uart.cpp b/Tactility/Source/hal/uart/Uart.cpp index 8e415583..46a20089 100644 --- a/Tactility/Source/hal/uart/Uart.cpp +++ b/Tactility/Source/hal/uart/Uart.cpp @@ -17,7 +17,7 @@ namespace tt::hal::uart { -static const auto LOGGER = Logger("SPI"); +static const auto LOGGER = Logger("UART"); constexpr uint32_t uartIdNotInUse = 0; diff --git a/Tactility/Source/hal/uart/UartEsp.cpp b/Tactility/Source/hal/uart/UartEsp.cpp index 5c487377..6b6fb2bc 100644 --- a/Tactility/Source/hal/uart/UartEsp.cpp +++ b/Tactility/Source/hal/uart/UartEsp.cpp @@ -33,7 +33,7 @@ bool UartEsp::start() { esp_err_t result = uart_param_config(configuration.port, &configuration.config); if (result != ESP_OK) { - LOGGER.error("[{}] Starting: Failed to configure: %s", configuration.name, esp_err_to_name(result)); + LOGGER.error("[{}] Starting: Failed to configure: {}", configuration.name, esp_err_to_name(result)); return false; } diff --git a/Tactility/Source/network/HttpdReq.cpp b/Tactility/Source/network/HttpdReq.cpp index 09df8320..8388322f 100644 --- a/Tactility/Source/network/HttpdReq.cpp +++ b/Tactility/Source/network/HttpdReq.cpp @@ -22,7 +22,7 @@ bool getHeaderOrSendError(httpd_req_t* request, const std::string& name, std::st auto header_buffer = std::make_unique(header_size + 1); if (header_buffer == nullptr) { - LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED); + LOGGER.error( LOG_MESSAGE_ALLOC_FAILED); httpd_resp_send_500(request); return false; } diff --git a/Tactility/Source/service/gps/GpsConfiguration.cpp b/Tactility/Source/service/gps/GpsConfiguration.cpp index ec58e262..aa278373 100644 --- a/Tactility/Source/service/gps/GpsConfiguration.cpp +++ b/Tactility/Source/service/gps/GpsConfiguration.cpp @@ -39,7 +39,7 @@ bool GpsService::getGpsConfigurations(std::vector& c return true; } - LOGGER.info("Reading configuration file %s", path.c_str()); + LOGGER.info("Reading configuration file {}", path); auto reader = file::ObjectFileReader(path, sizeof(hal::gps::GpsConfiguration)); if (!reader.open()) { LOGGER.error("Failed to open configuration file"); diff --git a/Tactility/Source/service/gps/GpsService.cpp b/Tactility/Source/service/gps/GpsService.cpp index 305f7e2c..69cc251c 100644 --- a/Tactility/Source/service/gps/GpsService.cpp +++ b/Tactility/Source/service/gps/GpsService.cpp @@ -195,7 +195,7 @@ void GpsService::onGgaSentence(hal::Device::Id deviceId, const minmea_sentence_g } void GpsService::onRmcSentence(hal::Device::Id deviceId, const minmea_sentence_rmc& rmc) { - LOGGER.debug("[device {}] LAT {} LON %f, speed: {}", deviceId, minmea_tocoord(&rmc.latitude), minmea_tocoord(&rmc.longitude), minmea_tofloat(&rmc.speed)); + LOGGER.debug("[device {}] LAT {} LON {}, speed: {}", deviceId, minmea_tocoord(&rmc.latitude), minmea_tocoord(&rmc.longitude), minmea_tofloat(&rmc.speed)); } State GpsService::getState() const { diff --git a/Tactility/Source/service/wifi/WifiEsp.cpp b/Tactility/Source/service/wifi/WifiEsp.cpp index d39339d2..9b109c38 100644 --- a/Tactility/Source/service/wifi/WifiEsp.cpp +++ b/Tactility/Source/service/wifi/WifiEsp.cpp @@ -459,7 +459,7 @@ static void dispatchAutoConnect(std::shared_ptr wifi) { settings::WifiApSettings settings; if (find_auto_connect_ap(wifi, settings)) { - LOGGER.info("Auto-connecting to %s", settings.ssid.c_str()); + LOGGER.info("Auto-connecting to {}", settings.ssid); connect(settings, false); // TODO: We currently have to manually reset it because connect() sets it. // connect() assumes it's only being called by the user and not internally, so it disables auto-connect @@ -475,18 +475,18 @@ static void eventHandler(TT_UNUSED void* arg, esp_event_base_t event_base, int32 } if (event_base == WIFI_EVENT) { - LOGGER.info("eventHandler: WIFI_EVENT ({})", event_id); + LOGGER.info("eventHandler: WIFI_EVENT {}", event_id); } else if (event_base == IP_EVENT) { - LOGGER.info("eventHandler: IP_EVENT ({})", event_id); + LOGGER.info("eventHandler: IP_EVENT {}", event_id); } if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) { - LOGGER.info("eventHandler: sta start"); + LOGGER.info("eventHandler: STA_START"); if (wifi->getRadioState() == RadioState::ConnectionPending) { esp_wifi_connect(); } } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { - LOGGER.info("eventHandler: disconnected"); + LOGGER.info("eventHandler: STA_DISCONNECTED"); clearIp(); switch (wifi->getRadioState()) { case RadioState::ConnectionPending: diff --git a/TactilityCore/Include/Tactility/LoggerAdapterGeneric.h b/TactilityCore/Include/Tactility/LoggerAdapterGeneric.h index b5b8e78e..4f62bfcc 100644 --- a/TactilityCore/Include/Tactility/LoggerAdapterGeneric.h +++ b/TactilityCore/Include/Tactility/LoggerAdapterGeneric.h @@ -3,6 +3,8 @@ #include "LoggerAdapter.h" #include "LoggerAdapterShared.h" +#include +#include #include #include @@ -10,12 +12,13 @@ namespace tt { static uint64_t getLogTimestamp() { static uint64_t base = 0U; + static std::once_flag init_flag; timeval time {}; gettimeofday(&time, nullptr); uint64_t now = ((uint64_t)time.tv_sec * 1000U) + (time.tv_usec / 1000U); - if (base == 0U) { + std::call_once(init_flag, [now]() { base = now; - } + }); return now - base; } diff --git a/TactilityCore/Source/Check.cpp b/TactilityCore/Source/Check.cpp index f928335c..07a57e7a 100644 --- a/TactilityCore/Source/Check.cpp +++ b/TactilityCore/Source/Check.cpp @@ -21,8 +21,8 @@ static void logMemoryInfo() { static void logTaskInfo() { const char* name = pcTaskGetName(nullptr); const char* safe_name = name ? name : "main"; - LOGGER.error("Task: %s", safe_name); - LOGGER.error("Stack watermark: %u", uxTaskGetStackHighWaterMark(NULL) * 4); + LOGGER.error("Task: {}", safe_name); + LOGGER.error("Stack watermark: {}", uxTaskGetStackHighWaterMark(NULL) * 4); } namespace tt {