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
+26 -26
View File
@@ -5,7 +5,6 @@
#include <Tactility/file/File.h>
#include <Tactility/file/FileLock.h>
#include <tactility/hal/Device.h>
#include <Tactility/Logger.h>
#include <Tactility/Paths.h>
#include <cerrno>
@@ -16,21 +15,22 @@
#include <unistd.h>
#include <minitar.h>
#include <tactility/log.h>
namespace tt::app {
static const auto LOGGER = Logger("App");
constexpr auto* TAG = "App";
static bool untarFile(minitar* mp, const minitar_entry* entry, const std::string& destinationPath) {
const auto absolute_path = destinationPath + "/" + entry->metadata.path;
if (!file::findOrCreateDirectory(destinationPath, 0777)) {
LOGGER.error("Can't find or create directory {}", destinationPath.c_str());
LOG_E(TAG, "Can't find or create directory %s", destinationPath.c_str());
return false;
}
// minitar_read_contents(&mp, &entry, file_buffer, entry.metadata.size);
if (!minitar_read_contents_to_file(mp, entry, absolute_path.c_str())) {
LOGGER.error("Failed to write data to {}", absolute_path.c_str());
LOG_E(TAG, "Failed to write data to %s", absolute_path.c_str());
return false;
}
@@ -59,32 +59,32 @@ static bool untar(const std::string& tarPath, const std::string& destinationPath
do {
if (minitar_read_entry(&mp, &entry) == 0) {
LOGGER.info("Extracting {}", entry.metadata.path);
LOG_I(TAG, "Extracting %s", entry.metadata.path);
if (entry.metadata.type == MTAR_DIRECTORY) {
if (!strcmp(entry.metadata.name, ".") || !strcmp(entry.metadata.name, "..") || !strcmp(entry.metadata.name, "/")) continue;
if (!untarDirectory(&entry, destinationPath)) {
LOGGER.error("Failed to create directory {}/{}: {}", destinationPath, entry.metadata.name, strerror(errno));
LOG_E(TAG, "Failed to create directory %s/%s: %s", destinationPath.c_str(), entry.metadata.name, strerror(errno));
success = false;
break;
}
} else if (entry.metadata.type == MTAR_REGULAR) {
if (!untarFile(&mp, &entry, destinationPath)) {
LOGGER.error("Failed to extract file {}: {}", entry.metadata.path, strerror(errno));
LOG_E(TAG, "Failed to extract file %s: %s", entry.metadata.path, strerror(errno));
success = false;
break;
}
} else if (entry.metadata.type == MTAR_SYMLINK) {
LOGGER.error("SYMLINK not supported");
LOG_E(TAG, "SYMLINK not supported");
} else if (entry.metadata.type == MTAR_HARDLINK) {
LOGGER.error("HARDLINK not supported");
LOG_E(TAG, "HARDLINK not supported");
} else if (entry.metadata.type == MTAR_FIFO) {
LOGGER.error("FIFO not supported");
LOG_E(TAG, "FIFO not supported");
} else if (entry.metadata.type == MTAR_BLKDEV) {
LOGGER.error("BLKDEV not supported");
LOG_E(TAG, "BLKDEV not supported");
} else if (entry.metadata.type == MTAR_CHRDEV) {
LOGGER.error("CHRDEV not supported");
LOG_E(TAG, "CHRDEV not supported");
} else {
LOGGER.error("Unknown entry type: {}", static_cast<int>(entry.metadata.type));
LOG_E(TAG, "Unknown entry type: %d", static_cast<int>(entry.metadata.type));
success = false;
break;
}
@@ -96,7 +96,7 @@ static bool untar(const std::string& tarPath, const std::string& destinationPath
void cleanupInstallDirectory(const std::string& path) {
if (!file::deleteRecursively(path)) {
LOGGER.warn("Failed to delete existing installation at {}", path);
LOG_W(TAG, "Failed to delete existing installation at %s", path.c_str());
}
}
@@ -105,16 +105,16 @@ 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 {} to {}", path, app_parent_path);
LOG_I(TAG, "Installing app %s to %s", path.c_str(), app_parent_path.c_str());
auto filename = file::getLastPathSegment(path);
const std::string app_target_path = std::format("{}/{}", app_parent_path, filename);
if (file::isDirectory(app_target_path) && !file::deleteRecursively(app_target_path)) {
LOGGER.warn("Failed to delete {}", app_target_path);
LOG_W(TAG, "Failed to delete %s", app_target_path.c_str());
}
if (!file::findOrCreateDirectory(app_target_path, 0777)) {
LOGGER.info("Failed to create directory {}", app_target_path);
LOG_I(TAG, "Failed to create directory %s", app_target_path.c_str());
return false;
}
@@ -122,9 +122,9 @@ bool install(const std::string& path) {
auto source_path_lock = file::getLock(path)->asScopedLock();
target_path_lock.lock();
source_path_lock.lock();
LOGGER.info("Extracting app from {} to {}", path, app_target_path);
LOG_I(TAG, "Extracting app from %s to %s", path.c_str(), app_target_path.c_str());
if (!untar(path, app_target_path)) {
LOGGER.error("Failed to extract");
LOG_E(TAG, "Failed to extract");
return false;
}
source_path_lock.unlock();
@@ -132,14 +132,14 @@ bool install(const std::string& path) {
auto manifest_path = app_target_path + "/manifest.properties";
if (!file::isFile(manifest_path)) {
LOGGER.error("Manifest not found at {}", manifest_path);
LOG_E(TAG, "Manifest not found at %s", manifest_path.c_str());
cleanupInstallDirectory(app_target_path);
return false;
}
AppManifest manifest;
if (!parseManifest(manifest_path, manifest)) {
LOGGER.warn("Invalid manifest");
LOG_W(TAG, "Invalid manifest");
cleanupInstallDirectory(app_target_path);
return false;
}
@@ -152,7 +152,7 @@ bool install(const std::string& path) {
const std::string renamed_target_path = std::format("{}/{}", app_parent_path, manifest.appId);
if (file::isDirectory(renamed_target_path)) {
if (!file::deleteRecursively(renamed_target_path)) {
LOGGER.warn("Failed to delete existing installation at {}", renamed_target_path);
LOG_W(TAG, "Failed to delete existing installation at %s", renamed_target_path.c_str());
cleanupInstallDirectory(app_target_path);
return false;
}
@@ -163,7 +163,7 @@ bool install(const std::string& path) {
target_path_lock.unlock();
if (!rename_success) {
LOGGER.error(R"(Failed to rename "{}" to "{}")", app_target_path, manifest.appId);
LOG_E(TAG, R"(Failed to rename "%s" to "%s")", app_target_path.c_str(), manifest.appId.c_str());
cleanupInstallDirectory(app_target_path);
return false;
}
@@ -176,7 +176,7 @@ bool install(const std::string& path) {
}
bool uninstall(const std::string& appId) {
LOGGER.info("Uninstalling app {}", appId);
LOG_I(TAG, "Uninstalling app %s", appId.c_str());
// If the app was running, then stop it
if (isRunning(appId)) {
@@ -185,7 +185,7 @@ bool uninstall(const std::string& appId) {
auto app_path = getAppInstallPath(appId);
if (!file::isDirectory(app_path)) {
LOGGER.error("App {} not found at {}", appId, app_path);
LOG_E(TAG, "App %s not found at %s", appId.c_str(), app_path.c_str());
return false;
}
@@ -194,7 +194,7 @@ bool uninstall(const std::string& appId) {
}
if (!removeAppManifest(appId)) {
LOGGER.warn("Failed to remove app {} from registry", appId);
LOG_W(TAG, "Failed to remove app %s from registry", appId.c_str());
}
return true;
+5 -5
View File
@@ -1,16 +1,16 @@
#include <Tactility/app/AppManifestParsing.h>
#include <Tactility/app/AppManifestParsingInternal.h>
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h>
#include <Tactility/file/File.h>
#include <Tactility/file/PropertiesFile.h>
#include <algorithm>
#include <tactility/log.h>
namespace tt::app {
static const auto LOGGER = Logger("AppManifest");
constexpr auto* TAG = "AppManifest";
constexpr bool validateString(const std::string& value, const std::function<bool(char)>& isValidChar) {
return std::ranges::all_of(value, isValidChar);
@@ -19,7 +19,7 @@ constexpr bool validateString(const std::string& value, const std::function<bool
bool getValueFromManifest(const std::map<std::string, std::string>& map, const std::string& key, std::string& output) {
const auto iterator = map.find(key);
if (iterator == map.end()) {
LOGGER.error("Failed to find {} in manifest", key);
LOG_E(TAG, "Failed to find %s in manifest", key.c_str());
return false;
}
output = iterator->second;
@@ -70,13 +70,13 @@ static bool detectIsV1Format(const std::string& filePath) {
}
bool parseManifest(const std::string& filePath, AppManifest& manifest) {
LOGGER.info("Parsing manifest {}", filePath);
LOG_I(TAG, "Parsing manifest %s", filePath.c_str());
bool is_v1_format = detectIsV1Format(filePath);
std::map<std::string, std::string> properties;
if (!file::loadPropertiesFile(filePath, properties)) {
LOGGER.error("Failed to load manifest at {}", filePath);
LOG_E(TAG, "Failed to load manifest at %s", filePath.c_str());
return false;
}
@@ -1,11 +1,11 @@
#include <Tactility/app/AppManifestParsing.h>
#include <Tactility/app/AppManifestParsingInternal.h>
#include <Tactility/Logger.h>
#include <tactility/log.h>
namespace tt::app {
static const auto LOGGER = Logger("AppManifestV1");
constexpr auto* TAG = "AppManifestV1";
bool parseManifestV1(const std::map<std::string, std::string>& map, AppManifest& manifest) {
// [manifest]
@@ -16,7 +16,7 @@ bool parseManifestV1(const std::map<std::string, std::string>& map, AppManifest&
}
if (!isValidManifestVersion(manifest_version)) {
LOGGER.error("Invalid version");
LOG_E(TAG, "Invalid version");
return false;
}
@@ -27,7 +27,7 @@ bool parseManifestV1(const std::map<std::string, std::string>& map, AppManifest&
}
if (!isValidId(manifest.appId)) {
LOGGER.error("Invalid app id");
LOG_E(TAG, "Invalid app id");
return false;
}
@@ -36,7 +36,7 @@ bool parseManifestV1(const std::map<std::string, std::string>& map, AppManifest&
}
if (!isValidName(manifest.appName)) {
LOGGER.error("Invalid app name");
LOG_E(TAG, "Invalid app name");
return false;
}
@@ -45,7 +45,7 @@ bool parseManifestV1(const std::map<std::string, std::string>& map, AppManifest&
}
if (!isValidAppVersionName(manifest.appVersionName)) {
LOGGER.error("Invalid app version name");
LOG_E(TAG, "Invalid app version name");
return false;
}
@@ -55,7 +55,7 @@ bool parseManifestV1(const std::map<std::string, std::string>& map, AppManifest&
}
if (!isValidAppVersionCode(version_code_string)) {
LOGGER.error("Invalid app version code");
LOG_E(TAG, "Invalid app version code");
return false;
}
@@ -1,11 +1,11 @@
#include <Tactility/app/AppManifestParsing.h>
#include <Tactility/app/AppManifestParsingInternal.h>
#include <Tactility/Logger.h>
#include <tactility/log.h>
namespace tt::app {
static const auto LOGGER = Logger("AppManifestV2");
constexpr auto* TAG = "AppManifestV2";
bool parseManifestV2(const std::map<std::string, std::string>& map, AppManifest& manifest) {
// manifest
@@ -16,7 +16,7 @@ bool parseManifestV2(const std::map<std::string, std::string>& map, AppManifest&
}
if (!isValidManifestVersion(manifest_version)) {
LOGGER.error("Invalid version");
LOG_E(TAG, "Invalid version");
return false;
}
@@ -27,7 +27,7 @@ bool parseManifestV2(const std::map<std::string, std::string>& map, AppManifest&
}
if (!isValidId(manifest.appId)) {
LOGGER.error("Invalid app id");
LOG_E(TAG, "Invalid app id");
return false;
}
@@ -36,7 +36,7 @@ bool parseManifestV2(const std::map<std::string, std::string>& map, AppManifest&
}
if (!isValidName(manifest.appName)) {
LOGGER.error("Invalid app name");
LOG_E(TAG, "Invalid app name");
return false;
}
@@ -45,7 +45,7 @@ bool parseManifestV2(const std::map<std::string, std::string>& map, AppManifest&
}
if (!isValidAppVersionName(manifest.appVersionName)) {
LOGGER.error("Invalid app version name");
LOG_E(TAG, "Invalid app version name");
return false;
}
@@ -55,7 +55,7 @@ bool parseManifestV2(const std::map<std::string, std::string>& map, AppManifest&
}
if (!isValidAppVersionCode(version_code_string)) {
LOGGER.error("Invalid app version code");
LOG_E(TAG, "Invalid app version code");
return false;
}
+5 -5
View File
@@ -1,15 +1,15 @@
#include <Tactility/app/AppRegistration.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/Logger.h>
#include <Tactility/Mutex.h>
#include <unordered_map>
#include <Tactility/file/File.h>
#include <tactility/log.h>
namespace tt::app {
static const auto LOGGER = Logger("AppRegistration");
constexpr auto* TAG = "AppRegistration";
typedef std::unordered_map<std::string, std::shared_ptr<AppManifest>> AppManifestMap;
@@ -17,12 +17,12 @@ static AppManifestMap app_manifest_map;
static Mutex hash_mutex;
void addAppManifest(const AppManifest& manifest) {
LOGGER.info("Registering manifest {}", manifest.appId);
LOG_I(TAG, "Registering manifest %s", manifest.appId.c_str());
hash_mutex.lock();
if (app_manifest_map.contains(manifest.appId)) {
LOGGER.warn("Overwriting existing manifest for {}", manifest.appId);
LOG_W(TAG, "Overwriting existing manifest for %s", manifest.appId.c_str());
}
app_manifest_map[manifest.appId] = std::make_shared<AppManifest>(manifest);
@@ -31,7 +31,7 @@ void addAppManifest(const AppManifest& manifest) {
}
bool removeAppManifest(const std::string& id) {
LOGGER.info("Removing manifest for {}", id);
LOG_I(TAG, "Removing manifest for %s", id.c_str());
auto lock = hash_mutex.asScopedLock();
lock.lock();
+9 -9
View File
@@ -4,17 +4,17 @@
#include <Tactility/app/ElfApp.h>
#include <Tactility/file/File.h>
#include <Tactility/file/FileLock.h>
#include <Tactility/Logger.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/StringUtils.h>
#include <esp_elf.h>
#include <string>
#include <tactility/log.h>
#include <utility>
namespace tt::app {
static auto LOGGER = Logger("ElfApp");
constexpr auto* TAG = "ElfApp";
static std::string getErrorCodeString(int error_code) {
switch (error_code) {
@@ -71,7 +71,7 @@ private:
bool startElf() {
const std::string elf_path = std::format("{}/elf/{}.elf", appPath, CONFIG_IDF_TARGET);
LOGGER.info("Starting ELF {}", elf_path);
LOG_I(TAG, "Starting ELF %s", elf_path.c_str());
assert(elfFileData == nullptr);
size_t size = 0;
@@ -85,7 +85,7 @@ private:
if (esp_elf_init(&elf) != ESP_OK) {
lastError = "Failed to initialize";
LOGGER.error("{}", lastError);
LOG_E(TAG, "%s", lastError.c_str());
elfFileData = nullptr;
return false;
}
@@ -94,7 +94,7 @@ private:
if (relocate_result != 0) {
// Note: the result code maps to values from cstdlib's errno.h
lastError = getErrorCodeString(-relocate_result);
LOGGER.error("Application failed to load: {}", lastError);
LOG_E(TAG, "Application failed to load: %s", lastError.c_str());
elfFileData = nullptr;
return false;
}
@@ -104,7 +104,7 @@ private:
if (esp_elf_request(&elf, 0, argc, argv) != ESP_OK) {
lastError = "Executable returned error code";
LOGGER.error("{}", lastError);
LOG_E(TAG, "%s", lastError.c_str());
esp_elf_deinit(&elf);
elfFileData = nullptr;
return false;
@@ -115,7 +115,7 @@ private:
}
void stopElf() {
LOGGER.info("Cleaning up ELF");
LOG_I(TAG, "Cleaning up ELF");
if (shouldCleanupElf) {
esp_elf_deinit(&elf);
@@ -163,7 +163,7 @@ public:
}
void onDestroy(AppContext& appContext) override {
LOGGER.info("Cleaning up app");
LOG_I(TAG, "Cleaning up app");
if (manifest != nullptr) {
if (manifest->onDestroy != nullptr) {
manifest->onDestroy(&appContext, data);
@@ -222,7 +222,7 @@ void setElfAppParameters(
}
std::shared_ptr<App> createElfApp(const std::shared_ptr<AppManifest>& manifest) {
LOGGER.info("createElfApp");
LOG_I(TAG, "createElfApp");
assert(manifest != nullptr);
assert(manifest->appLocation.isExternal());
return std::make_shared<ElfApp>(manifest->appLocation.getPath());
+3 -3
View File
@@ -1,4 +1,3 @@
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
@@ -10,11 +9,12 @@
#include "tactility/drivers/uart_controller.h"
#include <cstring>
#include <lvgl.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h>
namespace tt::app::addgps {
static const auto LOGGER = Logger("AddGps");
constexpr auto* TAG = "AddGps";
class AddGpsApp final : public App {
@@ -50,7 +50,7 @@ class AddGpsApp final : public App {
return;
}
LOGGER.info("Saving: uart={}, model={}, baud={}", new_configuration.uartName, (uint32_t)new_configuration.model, new_configuration.baudRate);
LOG_I(TAG, "Saving: uart=%s, model=%d, baud=%u", new_configuration.uartName, (int)new_configuration.model, (unsigned)new_configuration.baudRate);
auto service = service::gps::findGpsService();
std::vector<tt::hal::gps::GpsConfiguration> configurations;
@@ -3,10 +3,10 @@
#include "Tactility/lvgl/Toolbar.h"
#include "Tactility/service/loader/Loader.h"
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h>
#include <lvgl.h>
#include <tactility/log.h>
namespace tt::app::alertdialog {
@@ -18,7 +18,7 @@ namespace tt::app::alertdialog {
#define PARAMETER_ITEM_CONCATENATION_TOKEN ";;"
#define DEFAULT_TITLE ""
static const auto LOGGER = Logger("AlertDialog");
constexpr auto* TAG = "AlertDialog";
extern const AppManifest manifest;
@@ -74,7 +74,7 @@ class AlertDialogApp : public App {
void onButtonClicked(lv_event_t* e) {
auto index = reinterpret_cast<std::size_t>(lv_event_get_user_data(e));
LOGGER.info("Selected item at index {}", index);
LOG_I(TAG, "Selected item at index %d", (int)index);
auto bundle = std::make_unique<Bundle>();
bundle->putInt32(RESULT_BUNDLE_KEY_INDEX, (int32_t)index);
+5 -5
View File
@@ -5,20 +5,20 @@
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Spinner.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Logger.h>
#include <Tactility/network/Http.h>
#include <Tactility/Paths.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/service/wifi/Wifi.h>
#include <lvgl.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h>
#include <algorithm>
#include <format>
namespace tt::app::apphub {
static const auto LOGGER = Logger("AppHub");
constexpr auto* TAG = "AppHub";
extern const AppManifest manifest;
@@ -57,7 +57,7 @@ class AppHubApp final : public App {
}
void onRefreshSuccess() {
LOGGER.info("Request success");
LOG_I(TAG, "Request success");
auto lock = lvgl::getSyncLock()->asScopedLock();
lock.lock();
@@ -65,7 +65,7 @@ class AppHubApp final : public App {
}
void onRefreshError(const char* error) {
LOGGER.error("Request failed: {}", error);
LOG_E(TAG, "Request failed: %s", error);
auto lock = lvgl::getSyncLock()->asScopedLock();
lock.lock();
@@ -108,7 +108,7 @@ class AppHubApp final : public App {
lv_obj_set_size(list, LV_PCT(100), LV_SIZE_CONTENT);
for (int i = 0; i < entries.size(); i++) {
auto& entry = entries[i];
LOGGER.info("Adding {}", entry.appName.c_str());
LOG_I(TAG, "Adding %s", entry.appName.c_str());
const char* icon = findAppManifestById(entry.appId) != nullptr ? LV_SYMBOL_OK : nullptr;
auto* entry_button = lv_list_add_button(list, icon, entry.appName.c_str());
auto int_as_voidptr = reinterpret_cast<void*>(i);
+7 -6
View File
@@ -1,11 +1,12 @@
#include <Tactility/app/apphub/AppHubEntry.h>
#include <Tactility/file/File.h>
#include <Tactility/json/Reader.h>
#include <Tactility/Logger.h>
#include <tactility/log.h>
namespace tt::app::apphub {
static const auto LOGGER = Logger("AppHubJson");
constexpr auto* TAG = "AppHubJson";
static bool parseEntry(const cJSON* object, AppHubEntry& entry) {
const json::Reader reader(object);
@@ -25,21 +26,21 @@ bool parseJson(const std::string& filePath, std::vector<AppHubEntry>& entries) {
auto data = file::readString(filePath);
if (data == nullptr) {
LOGGER.error("Failed to read {}", filePath);
LOG_E(TAG, "Failed to read %s", filePath.c_str());
return false;
}
auto data_ptr = reinterpret_cast<const char*>(data.get());
auto* json = cJSON_Parse(data_ptr);
if (json == nullptr) {
LOGGER.error("Failed to parse {}", filePath);
LOG_E(TAG, "Failed to parse %s", filePath.c_str());
return false;
}
const cJSON* apps_json = cJSON_GetObjectItemCaseSensitive(json, "apps");
if (!cJSON_IsArray(apps_json)) {
cJSON_Delete(json);
LOGGER.error("apps is not an array");
LOG_E(TAG, "apps is not an array");
return false;
}
@@ -49,7 +50,7 @@ bool parseJson(const std::string& filePath, std::vector<AppHubEntry>& entries) {
auto& entry = entries.at(i);
auto* entry_json = cJSON_GetArrayItem(apps_json, i);
if (!parseEntry(entry_json, entry)) {
LOGGER.error("Failed to read entry");
LOG_E(TAG, "Failed to read entry");
cJSON_Delete(json);
return false;
}
@@ -5,18 +5,18 @@
#include <Tactility/file/File.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Logger.h>
#include <Tactility/network/Http.h>
#include <Tactility/Paths.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/StringUtils.h>
#include <lvgl.h>
#include <tactility/log.h>
#include <format>
namespace tt::app::apphubdetails {
static const auto LOGGER = Logger("AppHubDetails");
constexpr auto* TAG = "AppHubDetails";
extern const AppManifest manifest;
@@ -85,7 +85,7 @@ class AppHubDetailsApp final : public App {
}
void uninstallApp() {
LOGGER.info("Uninstall");
LOG_I(TAG, "Uninstall");
lvgl::getSyncLock()->lock();
lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN);
@@ -110,9 +110,9 @@ class AppHubDetailsApp final : public App {
install(temp_file_path);
if (!file::deleteFile(temp_file_path)) {
LOGGER.warn("Failed to remove {}", temp_file_path);
LOG_W(TAG, "Failed to remove %s", temp_file_path.c_str());
} else {
LOGGER.info("Deleted temporary file {}", temp_file_path);
LOG_I(TAG, "Deleted temporary file %s", temp_file_path.c_str());
}
lvgl::getSyncLock()->lock();
@@ -120,18 +120,18 @@ class AppHubDetailsApp final : public App {
lvgl::getSyncLock()->unlock();
},
[temp_file_path](const char* errorMessage) {
LOGGER.error("Download failed: {}", errorMessage);
LOG_E(TAG, "Download failed: %s", errorMessage);
alertdialog::start("Error", "Failed to install app");
if (file::isFile(temp_file_path) && !file::deleteFile(temp_file_path.c_str())) {
LOGGER.warn("Failed to remove {}", temp_file_path);
LOG_W(TAG, "Failed to remove %s", temp_file_path.c_str());
}
}
);
}
void installApp() {
LOGGER.info("Install");
LOG_I(TAG, "Install");
lvgl::getSyncLock()->lock();
lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN);
@@ -141,15 +141,15 @@ class AppHubDetailsApp final : public App {
}
void updateApp() {
LOGGER.info("Update");
LOG_I(TAG, "Update");
lvgl::getSyncLock()->lock();
lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN);
lvgl::getSyncLock()->unlock();
LOGGER.info("Removing previous version");
LOG_I(TAG, "Removing previous version");
uninstall(entry.appId);
LOGGER.info("Installing new version");
LOG_I(TAG, "Installing new version");
doInstall();
}
@@ -175,13 +175,13 @@ public:
void onCreate(AppContext& appContext) override {
auto parameters = appContext.getParameters();
if (parameters == nullptr) {
LOGGER.error("No parameters");
LOG_E(TAG, "No parameters");
stop();
return;
}
if (!fromBundle(*parameters.get(), entry)) {
LOGGER.error("Invalid parameters");
LOG_E(TAG, "Invalid parameters");
stop();
}
}
@@ -1,6 +1,5 @@
#ifdef ESP_PLATFORM
#include <Tactility/Logger.h>
#include <Tactility/Tactility.h>
#include <Tactility/app/App.h>
#include <Tactility/lvgl/Toolbar.h>
@@ -8,10 +7,11 @@
#include <Tactility/settings/WebServerSettings.h>
#include <lvgl.h>
#include <tactility/log.h>
namespace tt::app::apwebserver {
static const auto LOGGER = tt::Logger("ApWebServerApp");
constexpr auto* TAG = "ApWebServerApp";
class ApWebServerApp final : public App {
lv_obj_t* labelSsidValue = nullptr;
@@ -91,7 +91,7 @@ public:
// Apply settings and start services
getMainDispatcher().dispatch([apSettings] {
if (!settings::webserver::save(apSettings)) {
LOGGER.error("Failed to save AP settings");
LOG_E(TAG, "Failed to save AP settings");
return;
}
service::webserver::getPubsub()->publish(service::webserver::WebServerEvent::WebServerSettingsChanged);
@@ -106,13 +106,13 @@ public:
getMainDispatcher().dispatch([copy, webServerChanged] {
if (!settings::webserver::save(copy)) {
LOGGER.warn("Failed to persist WebServer settings; changes may be lost on reboot");
LOG_W(TAG, "Failed to persist WebServer settings; changes may be lost on reboot");
}
service::webserver::getPubsub()->publish(service::webserver::WebServerEvent::WebServerSettingsChanged);
if (webServerChanged) {
LOGGER.info("WebServer {}", copy.webServerEnabled ? "enabling..." : "disabling...");
LOG_I(TAG, "WebServer %s", copy.webServerEnabled ? "enabling..." : "disabling...");
service::webserver::setWebServerEnabled(copy.webServerEnabled);
}
});
+16 -16
View File
@@ -9,7 +9,6 @@
#include <Tactility/hal/display/DisplayDevice.h>
#include <Tactility/hal/usb/Usb.h>
#include <Tactility/kernel/SystemEvents.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/Paths.h>
#include <Tactility/service/loader/Loader.h>
@@ -17,6 +16,7 @@
#include <Tactility/settings/DisplaySettings.h>
#include <lvgl.h>
#include <tactility/log.h>
#include <atomic>
@@ -31,7 +31,7 @@
namespace tt::app::boot {
static const auto LOGGER = Logger("Boot");
constexpr auto* TAG = "Boot";
extern const AppManifest manifest;
@@ -67,17 +67,17 @@ class BootApp : public App {
if (settings::display::load(settings)) {
if (hal_display->getGammaCurveCount() > 0) {
hal_display->setGammaCurve(settings.gammaCurve);
LOGGER.info("Gamma curve {}", settings.gammaCurve);
LOG_I(TAG, "Gamma curve %d", settings.gammaCurve);
}
} else {
settings = settings::display::getDefault();
}
if (hal_display->supportsBacklightDuty()) {
LOGGER.info("Backlight {}", settings.backlightDuty);
LOG_I(TAG, "Backlight %d", settings.backlightDuty);
hal_display->setBacklightDuty(settings.backlightDuty);
} else {
LOGGER.info("No backlight");
LOG_I(TAG, "No backlight");
}
}
@@ -86,17 +86,17 @@ class BootApp : public App {
return false;
}
LOGGER.info("Rebooting into mass storage device mode");
LOG_I(TAG, "Rebooting into mass storage device mode");
auto mode = hal::usb::getUsbBootMode(); // Get mode before reset
hal::usb::resetUsbBootMode();
if (mode == hal::usb::BootMode::Flash) {
if (!hal::usb::startMassStorageWithFlash(true)) {
LOGGER.error("Unable to start flash mass storage");
LOG_E(TAG, "Unable to start flash mass storage");
return false;
}
} else if (mode == hal::usb::BootMode::Sdmmc) {
if (!hal::usb::startMassStorageWithSdmmc(true)) {
LOGGER.error("Unable to start SD mass storage");
LOG_E(TAG, "Unable to start SD mass storage");
return false;
}
}
@@ -114,7 +114,7 @@ class BootApp : public App {
}
static int32_t bootThreadCallback() {
LOGGER.info("Starting boot thread");
LOG_I(TAG, "Starting boot thread");
const auto start_time = kernel::getTicks();
// Give the UI some time to redraw
@@ -124,20 +124,20 @@ class BootApp : public App {
kernel::delayMillis(10);
// TODO: Support for multiple displays
LOGGER.info("Setup display");
LOG_I(TAG, "Setup display");
setupDisplay(); // Set backlight
prepareFileSystems();
#ifdef CONFIG_TT_USER_DATA_LOCATION_SD
std::string sd_path;
if (!findFirstMountedSdCardPath(sd_path)) {
LOGGER.error("SD card not found");
LOG_E(TAG, "SD card not found");
sdCardMissing = true;
}
#endif
if (!setupUsbBootMode()) {
LOGGER.info("initFromBootApp");
LOG_I(TAG, "initFromBootApp");
registerApps();
waitForMinimalSplashDuration(start_time);
// When SD card is missing, wait for dialog result
@@ -147,7 +147,7 @@ class BootApp : public App {
// This event will likely block as other systems are initialized
// e.g. Wi-Fi reads AP configs from SD card
LOGGER.info("Publish event");
LOG_I(TAG, "Publish event");
kernel::publishSystemEvent(kernel::SystemEvent::BootSplash);
return 0;
@@ -162,13 +162,13 @@ class BootApp : public App {
// When boot properties didn't specify an override, return default
if (boot_properties.launcherAppId.empty()) {
LOGGER.error("Failed to load launcher configuration, or launcher not configured");
LOG_E(TAG, "Failed to load launcher configuration, or launcher not configured");
return CONFIG_TT_LAUNCHER_APP_ID;
}
// If the app in the boot.properties does not exist, return default
if (findAppManifestById(boot_properties.launcherAppId) == nullptr) {
LOGGER.error("Launcher app {} not found", boot_properties.launcherAppId);
LOG_E(TAG, "Launcher app %s not found", boot_properties.launcherAppId.c_str());
return CONFIG_TT_LAUNCHER_APP_ID;
}
@@ -239,7 +239,7 @@ public:
logo = isUsbBootSplash ? "logo_usb.png" : "logo.png";
}
const auto logo_path = lvgl::PATH_PREFIX + paths->getAssetsPath(logo);
LOGGER.info("{}", logo_path);
LOG_I(TAG, "%s", logo_path.c_str());
lv_image_set_src(image, logo_path.c_str());
#ifdef ESP_PLATFORM
+9 -9
View File
@@ -1,18 +1,18 @@
#include <Tactility/app/btmanage/BtManagePrivate.h>
#include <Tactility/app/btmanage/View.h>
#include <Tactility/LogMessages.h>
#include <Tactility/Tactility.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/Tactility.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h>
namespace tt::app::btmanage {
static const auto LOGGER = Logger("BtManage");
constexpr auto* TAG = "BtManage";
extern const AppManifest manifest;
@@ -83,7 +83,7 @@ void BtManage::requestViewUpdate() {
view.update();
lvgl::unlock();
} else {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
}
}
unlock();
@@ -91,7 +91,7 @@ void BtManage::requestViewUpdate() {
void BtManage::onBtEvent(const struct BtEvent& event) {
auto radio_state = bluetooth::getRadioState();
LOGGER.info("Update with state {}", bluetooth::radioStateToString(radio_state));
LOG_I(TAG, "Update with state %s", bluetooth::radioStateToString(radio_state));
getState().setRadioState(radio_state);
switch (event.type) {
case BT_EVENT_SCAN_STARTED:
@@ -162,10 +162,10 @@ void BtManage::onShow(AppContext& app, lv_obj_t* parent) {
auto radio_state = bluetooth::getRadioState();
bool can_scan = radio_state == bluetooth::RadioState::On;
LOGGER.info("Radio: {}, Scanning: {}, Can scan: {}",
LOG_I(TAG, "Radio: %s, Scanning: %d, Can scan: %d",
bluetooth::radioStateToString(radio_state),
dev ? bluetooth_is_scanning(dev) : false,
can_scan);
(int)(dev ? bluetooth_is_scanning(dev) : false),
(int)can_scan);
if (can_scan && dev && !bluetooth_is_scanning(dev)) {
bluetooth_scan_start(dev);
}
-1
View File
@@ -6,7 +6,6 @@
#include <Tactility/app/btmanage/View.h>
#include <Tactility/app/btmanage/BtManagePrivate.h>
#include <Tactility/app/btpeersettings/BtPeerSettings.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/bluetooth/Bluetooth.h>
@@ -3,7 +3,6 @@
#include "tactility/device.h"
#include <Tactility/LogMessages.h>
#include <Tactility/Logger.h>
#include <Tactility/app/App.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/app/AppManifest.h>
@@ -15,12 +14,13 @@
#include <Tactility/lvgl/Toolbar.h>
#include <tactility/check.h>
#include <tactility/drivers/bluetooth.h>
#include <tactility/log.h>
#include <lvgl.h>
namespace tt::app::btpeersettings {
static const auto LOGGER = Logger("BtPeerSettings");
constexpr auto* TAG = "BtPeerSettings";
extern const AppManifest manifest;
@@ -77,7 +77,7 @@ class BtPeerSettings : public App {
if (bluetooth::settings::load(self->addrHex, device)) {
device.autoConnect = is_on;
if (!bluetooth::settings::save(device)) {
LOGGER.error("Failed to save auto-connect setting");
LOG_E(TAG, "Failed to save auto-connect setting");
}
}
}
@@ -88,7 +88,7 @@ class BtPeerSettings : public App {
updateViews();
lvgl::unlock();
} else {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
}
}
}
+6 -6
View File
@@ -8,18 +8,18 @@
#include <Tactility/app/chat/ChatProtocol.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/LvglSync.h>
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h>
#include <vector>
namespace tt::app::chat {
static const auto LOGGER = Logger("ChatApp");
constexpr auto* TAG = "ChatApp";
static constexpr uint8_t BROADCAST_ADDRESS[ESP_NOW_ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
void ChatApp::enableEspNow() {
@@ -98,12 +98,12 @@ void ChatApp::sendMessage(const std::string& text) {
std::vector<uint8_t> wireMsg;
if (!serializeTextMessage(settings.senderId, BROADCAST_ID, nickname, channel, text, wireMsg)) {
LOGGER.error("Failed to serialize message");
LOG_E(TAG, "Failed to serialize message");
return;
}
if (!service::espnow::send(BROADCAST_ADDRESS, wireMsg.data(), wireMsg.size())) {
LOGGER.error("Failed to send message");
LOG_E(TAG, "Failed to send message");
return;
}
@@ -144,7 +144,7 @@ void ChatApp::applySettings(const std::string& nickname, const std::string& keyH
}
settings.hasEncryptionKey = true;
} else {
LOGGER.warn("Invalid hex characters in encryption key");
LOG_W(TAG, "Invalid hex characters in encryption key");
}
} else if (keyHex.empty()) {
if (settings.hasEncryptionKey) {
@@ -153,7 +153,7 @@ void ChatApp::applySettings(const std::string& nickname, const std::string& keyH
needRestart = true;
}
} else {
LOGGER.warn("Key must be exactly {} hex characters, got {}", ESP_NOW_KEY_LEN * 2, keyHex.size());
LOG_W(TAG, "Key must be exactly %d hex characters, got %d", (int)(ESP_NOW_KEY_LEN * 2), (int)keyHex.size());
}
state.setLocalNickname(settings.nickname);
+7 -7
View File
@@ -10,7 +10,6 @@
#include <Tactility/crypt/Crypt.h>
#include <Tactility/file/File.h>
#include <Tactility/file/PropertiesFile.h>
#include <Tactility/Logger.h>
#include <Tactility/Paths.h>
#include <esp_random.h>
@@ -20,11 +19,12 @@
#include <iomanip>
#include <map>
#include <sstream>
#include <tactility/log.h>
#include <unistd.h>
namespace tt::app::chat {
static const auto LOGGER = Logger("ChatSettings");
constexpr auto* TAG = "ChatSettings";
static std::string getSettingsFilePath() {
return getUserDataPath() + "/settings/chat.properties";
@@ -52,7 +52,7 @@ static std::string toHexString(const uint8_t* data, size_t length) {
static bool readHex(const std::string& input, uint8_t* buffer, size_t length) {
if (input.size() != length * 2) {
LOGGER.error("readHex() length mismatch");
LOG_E(TAG, "readHex() length mismatch");
return false;
}
@@ -63,7 +63,7 @@ static bool readHex(const std::string& input, uint8_t* buffer, size_t length) {
char* endptr;
unsigned long val = strtoul(hex, &endptr, 16);
if (endptr != hex + 2) {
LOGGER.error("readHex() invalid hex character");
LOG_E(TAG, "readHex() invalid hex character");
return false;
}
buffer[i] = static_cast<uint8_t>(val);
@@ -77,7 +77,7 @@ static bool encryptKey(const uint8_t key[ESP_NOW_KEY_LEN], std::string& hexOutpu
uint8_t encrypted[ESP_NOW_KEY_LEN];
if (crypt::encrypt(iv, key, encrypted, ESP_NOW_KEY_LEN) != 0) {
LOGGER.error("Failed to encrypt key");
LOG_E(TAG, "Failed to encrypt key");
return false;
}
@@ -99,7 +99,7 @@ static bool decryptKey(const std::string& hexInput, uint8_t key[ESP_NOW_KEY_LEN]
crypt::getIv(IV_SEED, std::strlen(IV_SEED), iv);
if (crypt::decrypt(iv, encrypted, key, ESP_NOW_KEY_LEN) != 0) {
LOGGER.error("Failed to decrypt key");
LOG_E(TAG, "Failed to decrypt key");
return false;
}
return true;
@@ -188,7 +188,7 @@ bool saveSettings(const ChatSettingsData& settings) {
auto settings_path = getSettingsFilePath();
if (!file::findOrCreateParentDirectory(settings_path, 0755)) {
LOGGER.error("Failed to create parent dir for {}", settings_path);
LOG_E(TAG, "Failed to create parent dir for %s", settings_path.c_str());
return false;
}
return file::savePropertiesFile(settings_path, map);
@@ -4,16 +4,16 @@
#include <Tactility/app/crashdiagnostics/QrUrl.h>
#include <Tactility/app/launcher/Launcher.h>
#include <tactility/hal/Device.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Statusbar.h>
#include <Tactility/service/loader/Loader.h>
#include <lvgl.h>
#include <qrcode.h>
#include <tactility/log.h>
namespace tt::app::crashdiagnostics {
static const auto LOGGER = Logger("CrashDiagnostics");
constexpr auto* TAG = "CrashDiagnostics";
extern const AppManifest manifest;
@@ -44,38 +44,38 @@ public:
lv_obj_align(bottom_label, LV_ALIGN_BOTTOM_MID, 0, -2);
std::string url = getUrlFromCrashData();
LOGGER.info("{}", url);
LOG_I(TAG, "%s", url.c_str());
size_t url_length = url.length();
int qr_version;
if (!getQrVersionForBinaryDataLength(url_length, qr_version)) {
LOGGER.error("QR is too large");
LOG_E(TAG, "QR is too large");
stop(manifest.appId);
return;
}
LOGGER.info("QR version {} (length: {})", qr_version, url_length);
LOG_I(TAG, "QR version %d (length: %d)", qr_version, (int)url_length);
auto qrcodeData = std::make_shared<uint8_t[]>(qrcode_getBufferSize(qr_version));
if (qrcodeData == nullptr) {
LOGGER.error("Failed to allocate QR buffer");
LOG_E(TAG, "Failed to allocate QR buffer");
stop(manifest.appId);
return;
}
QRCode qrcode;
LOGGER.info("QR init text");
LOG_I(TAG, "QR init text");
if (qrcode_initText(&qrcode, qrcodeData.get(), qr_version, ECC_LOW, url.c_str()) != 0) {
LOGGER.error("QR init text failed");
LOG_E(TAG, "QR init text failed");
stop(manifest.appId);
return;
}
LOGGER.info("QR size: {}", qrcode.size);
LOG_I(TAG, "QR size: %d", qrcode.size);
// Calculate QR dot size
int32_t top_label_height = lv_obj_get_height(top_label) + 2;
int32_t bottom_label_height = lv_obj_get_height(bottom_label) + 2;
LOGGER.info("Create canvas");
LOG_I(TAG, "Create canvas");
int32_t available_height = parent_height - top_label_height - bottom_label_height;
int32_t available_width = lv_display_get_horizontal_resolution(display);
int32_t smallest_size = std::min(available_height, available_width);
@@ -85,7 +85,7 @@ public:
} else if (qrcode.size <= smallest_size) {
pixel_size = 1;
} else {
LOGGER.error("QR code won't fit screen");
LOG_E(TAG, "QR code won't fit screen");
stop(manifest.appId);
return;
}
@@ -97,10 +97,10 @@ public:
lv_obj_set_content_height(canvas, qrcode.size * pixel_size);
lv_obj_set_content_width(canvas, qrcode.size * pixel_size);
LOGGER.info("Create draw buffer");
LOG_I(TAG, "Create draw buffer");
auto* draw_buf = lv_draw_buf_create(pixel_size * qrcode.size, pixel_size * qrcode.size, LV_COLOR_FORMAT_RGB565, LV_STRIDE_AUTO);
if (draw_buf == nullptr) {
LOGGER.error("Failed to allocate draw buffer");
LOG_E(TAG, "Failed to allocate draw buffer");
stop(manifest.appId);
return;
}
@@ -7,12 +7,12 @@
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Logger.h>
#include <Tactility/service/development/DevelopmentService.h>
#include <Tactility/service/development/DevelopmentSettings.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/service/wifi/Wifi.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h>
#include <cstring>
@@ -20,7 +20,7 @@
namespace tt::app::development {
static const auto LOGGER = Logger("Development");
constexpr auto* TAG = "Development";
extern const AppManifest manifest;
class DevelopmentApp final : public App {
@@ -87,7 +87,7 @@ public:
void onCreate(AppContext& appContext) override {
service = service::development::findService();
if (service == nullptr) {
LOGGER.error("Service not found");
LOG_E(TAG, "Service not found");
stop(manifest.appId);
}
}
+3 -3
View File
@@ -6,7 +6,6 @@
#include <Tactility/service/displayidle/DisplayIdleService.h>
#endif
#include <Tactility/Logger.h>
#include <Tactility/app/App.h>
#include <Tactility/hal/display/DisplayDevice.h>
#include <Tactility/hal/touch/TouchDevice.h>
@@ -14,11 +13,12 @@
#include <Tactility/settings/DisplaySettings.h>
#include <lvgl.h>
#include <tactility/log.h>
#include <tactility/lvgl_module.h>
namespace tt::app::display {
static const auto LOGGER = Logger("Display");
constexpr auto* TAG = "Display";
static std::shared_ptr<hal::display::DisplayDevice> getHalDisplay() {
return hal::findFirstDevice<hal::display::DisplayDevice>(hal::Device::Type::Display);
@@ -74,7 +74,7 @@ class DisplayApp final : public App {
auto* app = static_cast<DisplayApp*>(lv_event_get_user_data(event));
auto* dropdown = static_cast<lv_obj_t*>(lv_event_get_target(event));
uint32_t selected_index = lv_dropdown_get_selected(dropdown);
LOGGER.info("Selected {}", selected_index);
LOG_I(TAG, "Selected %u", (unsigned)selected_index);
auto selected_orientation = static_cast<settings::display::Orientation>(selected_index);
if (selected_orientation != app->displaySettings.orientation) {
app->displaySettings.orientation = selected_orientation;
+11 -11
View File
@@ -1,11 +1,11 @@
#include <Tactility/app/files/State.h>
#include <Tactility/file/File.h>
#include <Tactility/file/FileLock.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/MountPoints.h>
#include <Tactility/file/File.h>
#include <Tactility/file/FileLock.h>
#include <Tactility/kernel/Platform.h>
#include <tactility/log.h>
#include <cstring>
#include <dirent.h>
@@ -14,7 +14,7 @@
namespace tt::app::files {
static const auto LOGGER = Logger("Files");
constexpr auto* TAG = "Files";
State::State() {
if (kernel::getPlatform() == kernel::PlatformSimulator) {
@@ -22,7 +22,7 @@ State::State() {
if (getcwd(cwd, sizeof(cwd)) != nullptr) {
setEntriesForPath(cwd);
} else {
LOGGER.error("Failed to get current work directory files");
LOG_E(TAG, "Failed to get current work directory files");
setEntriesForPath("/");
}
} else {
@@ -37,11 +37,11 @@ std::string State::getSelectedChildPath() const {
bool State::setEntriesForPath(const std::string& path) {
auto lock = mutex.asScopedLock();
if (!lock.lock(100)) {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "setEntriesForPath");
LOG_E(TAG, "Mutex acquisition timeout (%s)", "setEntriesForPath");
return false;
}
LOGGER.info("Changing path: {} -> {}", current_path, path);
LOG_I(TAG, "Changing path: %s -> %s", current_path.c_str(), path.c_str());
/**
* On PC, the root entry point ("/") is a folder.
@@ -49,7 +49,7 @@ bool State::setEntriesForPath(const std::string& path) {
*/
bool get_mount_points = (kernel::getPlatform() == kernel::PlatformEsp) && (path == "/");
if (get_mount_points) {
LOGGER.info("Setting custom root");
LOG_I(TAG, "Setting custom root");
dir_entries = file::getFileSystemDirents();
current_path = path;
selected_child_entry = "";
@@ -59,13 +59,13 @@ bool State::setEntriesForPath(const std::string& path) {
dir_entries.clear();
int count = file::scandir(path, dir_entries, &file::direntFilterDotEntries, file::direntSortAlphaAndType);
if (count >= 0) {
LOGGER.info("{} has {} entries", path, count);
LOG_I(TAG, "%s has %d entries", path.c_str(), count);
current_path = path;
selected_child_entry = "";
action = ActionNone;
return true;
} else {
LOGGER.error("Failed to fetch entries for {}", path);
LOG_E(TAG, "Failed to fetch entries for %s", path.c_str());
return false;
}
}
@@ -73,7 +73,7 @@ bool State::setEntriesForPath(const std::string& path) {
bool State::setEntriesForChildPath(const std::string& childPath) {
auto path = file::getChildPath(current_path, childPath);
LOGGER.info("Navigating from {} to {}", current_path, path);
LOG_I(TAG, "Navigating from %s to %s", current_path.c_str(), path.c_str());
return setEntriesForPath(path);
}
+37 -37
View File
@@ -2,7 +2,6 @@
#include <Tactility/app/files/View.h>
#include <Tactility/LogMessages.h>
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h>
#include <Tactility/Tactility.h>
#include <Tactility/app/ElfApp.h>
@@ -18,6 +17,7 @@
#include <tactility/device.h>
#include <tactility/drivers/usb_host_msc.h>
#include <tactility/log.h>
#include <cctype>
#include <cstdio>
@@ -30,7 +30,7 @@
namespace tt::app::files {
static const auto LOGGER = Logger("Files");
constexpr auto* TAG = "Files";
// region Callbacks
@@ -202,11 +202,11 @@ void View::viewFile(const std::string& path, const std::string& filename) {
if (kernel::getPlatform() == kernel::PlatformSimulator) {
char cwd[PATH_MAX];
if (getcwd(cwd, sizeof(cwd)) == nullptr) {
LOGGER.error("Failed to get current working directory");
LOG_E(TAG, "Failed to get current working directory");
return;
}
if (!file_path.starts_with(cwd)) {
LOGGER.error("Can only work with files in working directory {}", cwd);
LOG_E(TAG, "Can only work with files in working directory %s", cwd);
return;
}
processed_filepath = file_path.substr(strlen(cwd));
@@ -214,7 +214,7 @@ void View::viewFile(const std::string& path, const std::string& filename) {
processed_filepath = file_path;
}
LOGGER.info("Clicked {}", file_path);
LOG_I(TAG, "Clicked %s", file_path.c_str());
if (isSupportedAppFile(filename)) {
#ifdef ESP_PLATFORM
@@ -234,7 +234,7 @@ void View::viewFile(const std::string& path, const std::string& filename) {
notes::start(processed_filepath.substr(1));
}
} else {
LOGGER.warn("Opening files of this type is not supported");
LOG_W(TAG, "Opening files of this type is not supported");
}
onNavigate();
@@ -260,7 +260,7 @@ void View::onDirEntryPressed(uint32_t index) {
return;
}
LOGGER.info("Pressed {} {}", dir_entry.d_name, dir_entry.d_type);
LOG_I(TAG, "Pressed %s %d", dir_entry.d_name, (int)dir_entry.d_type);
state->setSelectedChildEntry(dir_entry.d_name);
using namespace tt::file;
@@ -273,7 +273,7 @@ void View::onDirEntryPressed(uint32_t index) {
break;
case TT_DT_LNK:
LOGGER.warn("opening links is not supported");
LOG_W(TAG, "opening links is not supported");
break;
default:
@@ -289,7 +289,7 @@ void View::onDirEntryLongPressed(int32_t index) {
return;
}
LOGGER.info("Long-pressed {} {}", dir_entry.d_name, dir_entry.d_type);
LOG_I(TAG, "Long-pressed %s %d", dir_entry.d_name, (int)dir_entry.d_type);
state->setSelectedChildEntry(dir_entry.d_name);
if (state->getCurrentPath() == "/") {
@@ -310,7 +310,7 @@ void View::onDirEntryLongPressed(int32_t index) {
break;
case TT_DT_LNK:
LOGGER.warn("Opening links is not supported");
LOG_W(TAG, "Opening links is not supported");
break;
default:
@@ -369,7 +369,7 @@ void View::createDirEntryWidget(lv_obj_t* list, dirent& dir_entry) {
void View::onNavigateUpPressed() {
if (state->getCurrentPath() != "/") {
LOGGER.info("Navigating upwards");
LOG_I(TAG, "Navigating upwards");
std::string new_absolute_path;
if (string::getPathParent(state->getCurrentPath(), new_absolute_path)) {
state->setEntriesForPath(new_absolute_path);
@@ -381,14 +381,14 @@ void View::onNavigateUpPressed() {
void View::onRenamePressed() {
std::string entry_name = state->getSelectedChildEntry();
LOGGER.info("Pending rename {}", entry_name);
LOG_I(TAG, "Pending rename %s", entry_name.c_str());
state->setPendingAction(State::ActionRename);
inputdialog::start("Rename", "", entry_name);
}
void View::onDeletePressed() {
std::string file_path = state->getSelectedChildPath();
LOGGER.info("Pending delete {}", file_path);
LOG_I(TAG, "Pending delete %s", file_path.c_str());
state->setPendingAction(State::ActionDelete);
std::string message = "Do you want to delete this?\n" + file_path;
const std::vector<std::string> choices = {"Yes", "No"};
@@ -396,13 +396,13 @@ void View::onDeletePressed() {
}
void View::onNewFilePressed() {
LOGGER.info("Creating new file");
LOG_I(TAG, "Creating new file");
state->setPendingAction(State::ActionCreateFile);
inputdialog::start("New File", "Enter filename:", "");
}
void View::onNewFolderPressed() {
LOGGER.info("Creating new folder");
LOG_I(TAG, "Creating new folder");
state->setPendingAction(State::ActionCreateFolder);
inputdialog::start("New Folder", "Enter folder name:", "");
}
@@ -436,11 +436,11 @@ void View::showActionsForMountPoint() {
void View::onEjectPressed() {
std::string mount_path = state->getSelectedChildPath();
LOGGER.info("Ejecting {}", mount_path);
LOG_I(TAG, "Ejecting %s", mount_path.c_str());
struct Device* msc_dev = device_find_first_active_by_type(&USB_HOST_MSC_TYPE);
if (!msc_dev || !usb_msc_eject(msc_dev, mount_path.c_str())) {
LOGGER.warn("usb_msc_eject: {} not found", mount_path);
LOG_W(TAG, "usb_msc_eject: %s not found", mount_path.c_str());
alertdialog::start("Eject failed", "Could not eject \"" + file::getLastPathSegment(mount_path) + "\".");
}
@@ -454,7 +454,7 @@ void View::update(size_t start_index) {
auto scoped_lockable = lvgl::getSyncLock()->asScopedLock();
if (!scoped_lockable.lock(lvgl::defaultLockTime)) {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "lvgl");
LOG_E(TAG, "Mutex acquisition timeout (%s)", "lvgl");
return;
}
@@ -580,20 +580,20 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
}
std::string filepath = state->getSelectedChildPath();
LOGGER.info("Result for {}", filepath);
LOG_I(TAG, "Result for %s", filepath.c_str());
switch (state->getPendingAction()) {
case State::ActionDelete: {
if (alertdialog::getResultIndex(*bundle) == 0) {
if (file::isDirectory(filepath)) {
if (!file::deleteRecursively(filepath)) {
LOGGER.warn("Failed to delete {}", filepath);
LOG_W(TAG, "Failed to delete %s", filepath.c_str());
}
} else if (file::isFile(filepath)) {
auto lock = file::getLock(filepath);
lock->lock();
if (remove(filepath.c_str()) != 0) {
LOGGER.warn("Failed to delete {}", filepath);
LOG_W(TAG, "Failed to delete %s", filepath.c_str());
}
lock->unlock();
}
@@ -611,16 +611,16 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
std::string rename_to = file::getChildPath(state->getCurrentPath(), new_name);
struct stat st;
if (stat(rename_to.c_str(), &st) == 0) {
LOGGER.warn("Rename: destination already exists: \"{}\"", rename_to);
LOG_W(TAG, "Rename: destination already exists: \"%s\"", rename_to.c_str());
lock->unlock();
state->setPendingAction(State::ActionNone);
alertdialog::start("Rename failed", "\"" + new_name + "\" already exists.");
break;
}
if (rename(filepath.c_str(), rename_to.c_str()) == 0) {
LOGGER.info("Renamed \"{}\" to \"{}\"", filepath, rename_to);
LOG_I(TAG, "Renamed \"%s\" to \"%s\"", filepath.c_str(), rename_to.c_str());
} else {
LOGGER.error("Failed to rename \"{}\" to \"{}\"", filepath, rename_to);
LOG_E(TAG, "Failed to rename \"%s\" to \"%s\"", filepath.c_str(), rename_to.c_str());
}
lock->unlock();
@@ -639,7 +639,7 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
struct stat st;
if (stat(new_file_path.c_str(), &st) == 0) {
LOGGER.warn("File already exists: \"{}\"", new_file_path);
LOG_W(TAG, "File already exists: \"%s\"", new_file_path.c_str());
lock->unlock();
break;
}
@@ -647,9 +647,9 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
FILE* new_file = fopen(new_file_path.c_str(), "w");
if (new_file) {
fclose(new_file);
LOGGER.info("Created file \"{}\"", new_file_path);
LOG_I(TAG, "Created file \"%s\"", new_file_path.c_str());
} else {
LOGGER.error("Failed to create file \"{}\"", new_file_path);
LOG_E(TAG, "Failed to create file \"%s\"", new_file_path.c_str());
}
lock->unlock();
@@ -668,15 +668,15 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
struct stat st;
if (stat(new_folder_path.c_str(), &st) == 0) {
LOGGER.warn("Folder already exists: \"{}\"", new_folder_path);
LOG_W(TAG, "Folder already exists: \"%s\"", new_folder_path.c_str());
lock->unlock();
break;
}
if (mkdir(new_folder_path.c_str(), 0755) == 0) {
LOGGER.info("Created folder \"{}\"", new_folder_path);
LOG_I(TAG, "Created folder \"%s\"", new_folder_path.c_str());
} else {
LOGGER.error("Failed to create folder \"{}\"", new_folder_path);
LOG_E(TAG, "Failed to create folder \"%s\"", new_folder_path.c_str());
}
lock->unlock();
@@ -698,7 +698,7 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
if (file::deleteRecursively(dst)) {
doPaste(clipboard->first, clipboard->second, dst);
} else {
LOGGER.error("Overwrite: failed to remove existing destination: \"{}\"", dst);
LOG_E(TAG, "Overwrite: failed to remove existing destination: \"%s\"", dst.c_str());
state->setPendingAction(State::ActionNone);
alertdialog::start(
"Overwrite failed",
@@ -717,7 +717,7 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
void View::onCopyPressed() {
std::string path = state->getSelectedChildPath();
state->setClipboard(path, false);
LOGGER.info("Copied to clipboard: {}", path);
LOG_I(TAG, "Copied to clipboard: %s", path.c_str());
onNavigate();
update();
}
@@ -725,7 +725,7 @@ void View::onCopyPressed() {
void View::onCutPressed() {
std::string path = state->getSelectedChildPath();
state->setClipboard(path, true);
LOGGER.info("Cut to clipboard: {}", path);
LOG_I(TAG, "Cut to clipboard: %s", path.c_str());
onNavigate();
update();
}
@@ -744,7 +744,7 @@ void View::onPastePressed() {
// between this check and the write inside doPaste. Acceptable on a
// single-user embedded device; locking dst instead would be more correct.
if (src == dst) {
LOGGER.info("Paste: source and destination are the same path, skipping");
LOG_I(TAG, "Paste: source and destination are the same path, skipping");
return;
}
auto lock = file::getLock(src);
@@ -783,7 +783,7 @@ void View::doPaste(const std::string& src, bool is_cut, const std::string& dst)
success = true;
} else {
src_delete_failed = true;
LOGGER.error("Cut: copied \"{}\" to \"{}\" but failed to remove source — manual cleanup required", src, dst);
LOG_E(TAG, "Cut: copied \"%s\" to \"%s\" but failed to remove source — manual cleanup required", src.c_str(), dst.c_str());
}
}
}
@@ -793,7 +793,7 @@ void View::doPaste(const std::string& src, bool is_cut, const std::string& dst)
const std::string filename = file::getLastPathSegment(src);
if (success) {
LOGGER.info("{} \"{}\" to \"{}\"", is_cut ? "Moved" : "Copied", src, dst);
LOG_I(TAG, "%s \"%s\" to \"%s\"", is_cut ? "Moved" : "Copied", src.c_str(), dst.c_str());
if (is_cut) {
state->clearClipboard();
}
@@ -801,7 +801,7 @@ void View::doPaste(const std::string& src, bool is_cut, const std::string& dst)
state->setPendingAction(State::ActionNone); // prevent re-trigger on dialog dismiss
alertdialog::start("Move incomplete", "\"" + filename + "\" was copied but the original could not be removed.\nPlease delete it manually.");
} else {
LOGGER.error("Failed to {} \"{}\" to \"{}\"", is_cut ? "move" : "copy", src, dst);
LOG_E(TAG, "Failed to %s \"%s\" to \"%s\"", is_cut ? "move" : "copy", src.c_str(), dst.c_str());
state->setPendingAction(State::ActionNone); // prevent re-trigger on dialog dismiss
alertdialog::start(
std::string("Failed to ") + (is_cut ? "move" : "copy"),
+9 -9
View File
@@ -1,19 +1,19 @@
#include "Tactility/app/fileselection/State.h"
#include <Tactility/file/File.h>
#include <Tactility/Logger.h>
#include <Tactility/MountPoints.h>
#include <Tactility/kernel/Platform.h>
#include <Tactility/LogMessages.h>
#include <cstring>
#include <dirent.h>
#include <tactility/log.h>
#include <unistd.h>
#include <vector>
namespace tt::app::fileselection {
static const auto LOGGER = Logger("FileSelection");
constexpr auto* TAG = "FileSelection";
State::State() {
if (kernel::getPlatform() == kernel::PlatformSimulator) {
@@ -21,7 +21,7 @@ State::State() {
if (getcwd(cwd, sizeof(cwd)) != nullptr) {
setEntriesForPath(cwd);
} else {
LOGGER.error("Failed to get current work directory files");
LOG_E(TAG, "Failed to get current work directory files");
setEntriesForPath("/");
}
} else {
@@ -34,11 +34,11 @@ std::string State::getSelectedChildPath() const {
}
bool State::setEntriesForPath(const std::string& path) {
LOGGER.info("Changing path: {} -> {}", current_path, path);
LOG_I(TAG, "Changing path: %s -> %s", current_path.c_str(), path.c_str());
auto lock = mutex.asScopedLock();
if (!lock.lock(100)) {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "setEntriesForPath");
LOG_E(TAG, "Mutex acquisition timeout (%s)", "setEntriesForPath");
return false;
}
@@ -48,7 +48,7 @@ bool State::setEntriesForPath(const std::string& path) {
*/
bool show_custom_root = (kernel::getPlatform() == kernel::PlatformEsp) && (path == "/");
if (show_custom_root) {
LOGGER.info("Setting custom root");
LOG_I(TAG, "Setting custom root");
dir_entries = file::getFileSystemDirents();
current_path = path;
selected_child_entry = "";
@@ -57,12 +57,12 @@ bool State::setEntriesForPath(const std::string& path) {
dir_entries.clear();
int count = file::scandir(path, dir_entries, &file::direntFilterDotEntries, file::direntSortAlphaAndType);
if (count >= 0) {
LOGGER.info("{} has {} entries", path, count);
LOG_I(TAG, "%s has %d entries", path.c_str(), count);
current_path = path;
selected_child_entry = "";
return true;
} else {
LOGGER.error("Failed to fetch entries for {}", path);
LOG_E(TAG, "Failed to fetch entries for %s", path.c_str());
return false;
}
}
@@ -70,7 +70,7 @@ bool State::setEntriesForPath(const std::string& path) {
bool State::setEntriesForChildPath(const std::string& childPath) {
auto path = file::getChildPath(current_path, childPath);
LOGGER.info("Navigating from {} to {}", current_path, path);
LOG_I(TAG, "Navigating from %s to %s", current_path.c_str(), path.c_str());
return setEntriesForPath(path);
}
+12 -12
View File
@@ -1,15 +1,15 @@
#include <Tactility/app/fileselection/View.h>
#include <Tactility/LogMessages.h>
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h>
#include <Tactility/Tactility.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <tactility/check.h>
#include <Tactility/file/File.h>
#include <Tactility/kernel/Platform.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <tactility/check.h>
#include <tactility/log.h>
#include <cstring>
#include <unistd.h>
@@ -20,7 +20,7 @@
namespace tt::app::fileselection {
const static Logger LOGGER = Logger("FileSelection");
constexpr auto* TAG = "FileSelection";
// region Callbacks
@@ -47,11 +47,11 @@ void View::onTapFile(const std::string& path, const std::string& filename) {
if (kernel::getPlatform() == kernel::PlatformSimulator) {
char cwd[PATH_MAX];
if (getcwd(cwd, sizeof(cwd)) == nullptr) {
LOGGER.error("Failed to get current working directory");
LOG_E(TAG, "Failed to get current working directory");
return;
}
if (!file_path.starts_with(cwd)) {
LOGGER.error("Can only work with files in working directory {}", cwd);
LOG_E(TAG, "Can only work with files in working directory %s", cwd);
return;
}
processed_filepath = file_path.substr(strlen(cwd));
@@ -59,7 +59,7 @@ void View::onTapFile(const std::string& path, const std::string& filename) {
processed_filepath = file_path;
}
LOGGER.info("Clicked {}", processed_filepath);
LOG_I(TAG, "Clicked %s", processed_filepath.c_str());
lv_textarea_set_text(path_textarea, processed_filepath.c_str());
}
@@ -67,7 +67,7 @@ void View::onTapFile(const std::string& path, const std::string& filename) {
void View::onDirEntryPressed(uint32_t index) {
dirent dir_entry;
if (state->getDirent(index, dir_entry)) {
LOGGER.info("Pressed {} {}", dir_entry.d_name, dir_entry.d_type);
LOG_I(TAG, "Pressed %s %d", dir_entry.d_name, (int)dir_entry.d_type);
state->setSelectedChildEntry(dir_entry.d_name);
using namespace tt::file;
switch (dir_entry.d_type) {
@@ -78,7 +78,7 @@ void View::onDirEntryPressed(uint32_t index) {
update();
break;
case TT_DT_LNK:
LOGGER.warn("Opening links is not supported");
LOG_W(TAG, "Opening links is not supported");
break;
case TT_DT_REG:
onTapFile(state->getCurrentPath(), dir_entry.d_name);
@@ -96,7 +96,7 @@ void View::onSelectButtonPressed(lv_event_t* event) {
auto* view = static_cast<View*>(lv_event_get_user_data(event));
const char* path = lv_textarea_get_text(view->path_textarea);
if (path == nullptr || strlen(path) == 0) {
LOGGER.warn("Select pressed, but not path found in textarea");
LOG_W(TAG, "Select pressed, but not path found in textarea");
return;
}
@@ -140,7 +140,7 @@ void View::createDirEntryWidget(lv_obj_t* list, dirent& dir_entry) {
void View::onNavigateUpPressed() {
if (state->getCurrentPath() != "/") {
LOGGER.info("Navigating upwards");
LOG_I(TAG, "Navigating upwards");
std::string new_absolute_path;
if (string::getPathParent(state->getCurrentPath(), new_absolute_path)) {
state->setEntriesForPath(new_absolute_path);
@@ -161,7 +161,7 @@ void View::update() {
state->withEntries([this](const std::vector<dirent>& entries) {
for (auto entry : entries) {
LOGGER.debug("Entry: {} {}", entry.d_name, entry.d_type);
LOG_D(TAG, "Entry: %s %d", entry.d_name, (int)entry.d_type);
createDirEntryWidget(dir_entry_list, entry);
}
});
@@ -172,7 +172,7 @@ void View::update() {
lv_obj_remove_flag(navigate_up_button, LV_OBJ_FLAG_HIDDEN);
}
} else {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "lvgl");
LOG_E(TAG, "Mutex acquisition timeout (%s)", "lvgl");
}
}
@@ -5,11 +5,11 @@
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Logger.h>
#include <Tactility/service/gps/GpsService.h>
#include <Tactility/service/gps/GpsState.h>
#include <Tactility/service/loader/Loader.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h>
#include <cstring>
@@ -26,7 +26,7 @@ extern const AppManifest manifest;
class GpsSettingsApp final : public App {
const Logger logger = Logger("GpsSettings");
static constexpr auto* TAG = "GpsSettings";
std::unique_ptr<Timer> timer;
std::shared_ptr<GpsSettingsApp*> appReference = std::make_shared<GpsSettingsApp*>(this);
@@ -101,7 +101,7 @@ class GpsSettingsApp final : public App {
std::vector<tt::hal::gps::GpsConfiguration> configurations;
auto gps_service = service::gps::findGpsService();
if (gps_service && gps_service->getGpsConfigurations(configurations)) {
Logger("GpsSettings").info("Found service and configs {} {}", index, configurations.size());
LOG_I(TAG, "Found service and configs %d %d", index, (int)configurations.size());
if (index < configurations.size()) {
if (gps_service->removeGpsConfiguration(configurations[index])) {
app->updateViews();
@@ -163,7 +163,7 @@ class GpsSettingsApp final : public App {
// Update toolbar
switch (state) {
case service::gps::State::OnPending:
logger.debug("OnPending");
LOG_D(TAG, "OnPending");
lv_obj_remove_flag(spinnerWidget, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_state(switchWidget, LV_STATE_CHECKED);
lv_obj_add_state(switchWidget, LV_STATE_DISABLED);
@@ -172,7 +172,7 @@ class GpsSettingsApp final : public App {
lv_obj_add_flag(addGpsWrapper, LV_OBJ_FLAG_HIDDEN);
break;
case service::gps::State::On:
logger.debug("On");
LOG_D(TAG, "On");
lv_obj_add_flag(spinnerWidget, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_state(switchWidget, LV_STATE_CHECKED);
lv_obj_remove_state(switchWidget, LV_STATE_DISABLED);
@@ -181,7 +181,7 @@ class GpsSettingsApp final : public App {
lv_obj_add_flag(addGpsWrapper, LV_OBJ_FLAG_HIDDEN);
break;
case service::gps::State::OffPending:
logger.debug("OffPending");
LOG_D(TAG, "OffPending");
lv_obj_remove_flag(spinnerWidget, LV_OBJ_FLAG_HIDDEN);
lv_obj_remove_state(switchWidget, LV_STATE_CHECKED);
lv_obj_add_state(switchWidget, LV_STATE_DISABLED);
@@ -190,7 +190,7 @@ class GpsSettingsApp final : public App {
lv_obj_remove_flag(addGpsWrapper, LV_OBJ_FLAG_HIDDEN);
break;
case service::gps::State::Off:
logger.debug("Off");
LOG_D(TAG, "Off");
lv_obj_add_flag(spinnerWidget, LV_OBJ_FLAG_HIDDEN);
lv_obj_remove_state(switchWidget, LV_STATE_CHECKED);
lv_obj_remove_state(switchWidget, LV_STATE_DISABLED);
+22 -22
View File
@@ -1,19 +1,19 @@
#include <Tactility/app/i2cscanner/I2cScannerPrivate.h>
#include <Tactility/app/i2cscanner/I2cHelpers.h>
#include <Tactility/app/AppContext.h>
#include <tactility/drivers/i2c_controller.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Preferences.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/Timer.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <tactility/drivers/i2c_controller.h>
#include <format>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h>
namespace tt::app::i2cscanner {
@@ -22,7 +22,7 @@ extern const AppManifest manifest;
class I2cScannerApp final : public App {
const Logger logger = Logger("I2cScanner");
static constexpr auto* TAG = "I2cScanner";
static constexpr auto* START_SCAN_TEXT = "Scan";
static constexpr auto* STOP_SCAN_TEXT = "Stop scan";
@@ -190,7 +190,7 @@ bool I2cScannerApp::getPort(struct Device** outPort) {
mutex.unlock();
return true;
} else {
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "getPort");
LOG_W(TAG, "Mutex acquisition timeout (%s)", "getPort");
return false;
}
}
@@ -201,7 +201,7 @@ bool I2cScannerApp::addAddressToList(uint8_t address) {
mutex.unlock();
return true;
} else {
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "addAddressToList");
LOG_W(TAG, "Mutex acquisition timeout (%s)", "addAddressToList");
return false;
}
}
@@ -217,24 +217,24 @@ bool I2cScannerApp::shouldStopScanTimer() {
}
void I2cScannerApp::onScanTimer() {
logger.info("Scan thread started");
LOG_I(TAG, "Scan thread started");
Device* safe_port;
if (!getPort(&safe_port)) {
logger.error("Failed to get I2C port");
LOG_E(TAG, "Failed to get I2C port");
onScanTimerFinished();
return;
}
if (!device_is_ready(safe_port)) {
logger.error("I2C port not started");
LOG_E(TAG, "I2C port not started");
onScanTimerFinished();
return;
}
for (uint8_t address = 1; address < 128; ++address) {
if (i2c_controller_has_device_at_address(safe_port, address, 10 / portTICK_PERIOD_MS) == ERROR_NONE) {
logger.info("Found device at address 0x{:02X}", address);
LOG_I(TAG, "Found device at address 0x%02X", address);
if (!shouldStopScanTimer()) {
addAddressToList(address);
} else {
@@ -247,11 +247,11 @@ void I2cScannerApp::onScanTimer() {
}
}
logger.info("Scan thread finalizing");
LOG_I(TAG, "Scan thread finalizing");
onScanTimerFinished();
logger.info("Scan timer done");
LOG_I(TAG, "Scan timer done");
}
bool I2cScannerApp::hasScanThread() {
@@ -262,7 +262,7 @@ bool I2cScannerApp::hasScanThread() {
return has_thread;
} else {
// Unsafe way
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "hasScanTimer");
LOG_W(TAG, "Mutex acquisition timeout (%s)", "hasScanTimer");
return scanTimer != nullptr;
}
}
@@ -285,7 +285,7 @@ void I2cScannerApp::startScanning() {
scanTimer->start();
mutex.unlock();
} else {
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "startScanning");
LOG_W(TAG, "Mutex acquisition timeout (%s)", "startScanning");
}
}
void I2cScannerApp::stopScanning() {
@@ -294,7 +294,7 @@ void I2cScannerApp::stopScanning() {
scanState = ScanStateStopped;
mutex.unlock();
} else {
logger.error(LOG_MESSAGE_MUTEX_LOCK_FAILED);
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED);
}
}
@@ -317,7 +317,7 @@ void I2cScannerApp::selectBus(int32_t selected) {
mutex.unlock();
}
logger.info("Selected {}", selected);
LOG_I(TAG, "Selected %d", (int)selected);
setLastBusIndex(selected);
startScanning();
@@ -362,7 +362,7 @@ void I2cScannerApp::updateViews() {
mutex.unlock();
} else {
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "updateViews");
LOG_W(TAG, "Mutex acquisition timeout (%s)", "updateViews");
}
}
@@ -371,7 +371,7 @@ void I2cScannerApp::updateViewsSafely() {
updateViews();
lvgl::unlock();
} else {
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "updateViewsSafely");
LOG_W(TAG, "Mutex acquisition timeout (%s)", "updateViewsSafely");
}
}
@@ -384,7 +384,7 @@ void I2cScannerApp::onScanTimerFinished() {
updateViewsSafely();
} else {
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "onScanTimerFinished");
LOG_W(TAG, "Mutex acquisition timeout (%s)", "onScanTimerFinished");
}
}
@@ -2,8 +2,8 @@
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h>
#include <tactility/log.h>
#include <lvgl.h>
@@ -11,7 +11,7 @@ namespace tt::app::imageviewer {
extern const AppManifest manifest;
static const auto LOGGER = Logger("ImageViewer");
constexpr auto* TAG = "ImageViewer";
constexpr auto* IMAGE_VIEWER_FILE_ARGUMENT = "file";
class ImageViewerApp final : public App {
@@ -49,7 +49,7 @@ class ImageViewerApp final : public App {
std::string file_argument;
if (bundle->optString(IMAGE_VIEWER_FILE_ARGUMENT, file_argument)) {
std::string prefixed_path = lvgl::PATH_PREFIX + file_argument;
LOGGER.info("Opening {}", prefixed_path);
LOG_I(TAG, "Opening %s", prefixed_path.c_str());
lv_img_set_src(image, prefixed_path.c_str());
auto path = string::getLastPathSegment(file_argument);
lv_label_set_text(file_label, path.c_str());
@@ -3,6 +3,7 @@
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/TactilityCore.h>
#include <tactility/log.h>
#include <lvgl.h>
@@ -15,7 +16,7 @@ constexpr auto* RESULT_BUNDLE_KEY_RESULT = "result";
constexpr auto* DEFAULT_TITLE = "Input";
static const auto LOGGER = Logger("InputDialog");
constexpr auto* TAG = "InputDialog";
extern const AppManifest manifest;
class InputDialogApp;
@@ -62,7 +63,7 @@ class InputDialogApp final : public App {
void onButtonClicked(lv_event_t* e) {
auto user_data = lv_event_get_user_data(e);
int index = (user_data != 0) ? 0 : 1;
LOGGER.info("Selected item at index {}", index);
LOG_I(TAG, "Selected item at index %d", index);
if (index == 0) {
auto bundle = std::make_unique<Bundle>();
const char* text = lv_textarea_get_text((lv_obj_t*)user_data);
+4 -3
View File
@@ -11,13 +11,14 @@
#include <cstring>
#include <lvgl.h>
#include <tactility/log.h>
#include <tactility/lvgl_fonts.h>
#include <tactility/lvgl_icon_launcher.h>
#include <tactility/lvgl_module.h>
namespace tt::app::launcher {
static const auto LOGGER = Logger("Launcher");
constexpr auto* TAG = "Launcher";
static uint32_t getButtonPadding(UiDensity density, uint32_t buttonSize) {
if (density == LVGL_UI_DENSITY_COMPACT) {
@@ -143,7 +144,7 @@ public:
strcmp(CONFIG_TT_AUTO_START_APP_ID, "") != 0 &&
findAppManifestById(CONFIG_TT_AUTO_START_APP_ID) != nullptr
) {
LOGGER.info("Starting {}", CONFIG_TT_AUTO_START_APP_ID);
LOG_I(TAG, "Starting %s", CONFIG_TT_AUTO_START_APP_ID);
start(CONFIG_TT_AUTO_START_APP_ID);
} else if (
// Auto-start due to user configuration
@@ -151,7 +152,7 @@ public:
!boot_properties.autoStartAppId.empty() &&
findAppManifestById(boot_properties.autoStartAppId) != nullptr
) {
LOGGER.info("Starting {}", boot_properties.autoStartAppId);
LOG_I(TAG, "Starting %s", boot_properties.autoStartAppId.c_str());
start(boot_properties.autoStartAppId);
} else {
// No auto-start, consider running system setup
+8 -7
View File
@@ -8,11 +8,12 @@
#include <Tactility/file/File.h>
#include <lvgl.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h>
namespace tt::app::notes {
static const auto LOGGER = Logger("Notes");
constexpr auto* TAG = "Notes";
constexpr auto* NOTES_FILE_ARGUMENT = "file";
class NotesApp final : public App {
@@ -52,11 +53,11 @@ class NotesApp final : public App {
saveBuffer = lv_textarea_get_text(uiNoteText);
lvgl::getSyncLock()->unlock();
saveFileLaunchId = fileselection::startForExistingOrNewFile();
LOGGER.info("launched with id {}", saveFileLaunchId);
LOG_I(TAG, "launched with id %u", saveFileLaunchId);
break;
case 3: // Load
loadFileLaunchId = fileselection::startForExistingFile();
LOGGER.info("launched with id {}", loadFileLaunchId);
LOG_I(TAG, "launched with id %u", loadFileLaunchId);
break;
}
} else {
@@ -64,7 +65,7 @@ class NotesApp final : public App {
if (obj == cont) return;
if (lv_obj_get_child(cont, 1)) {
saveFileLaunchId = fileselection::startForExistingOrNewFile();
LOGGER.info("launched with id {}", saveFileLaunchId);
LOG_I(TAG, "launched with id %u", saveFileLaunchId);
} else { //Reset
resetFileContent();
}
@@ -91,7 +92,7 @@ class NotesApp final : public App {
lv_textarea_set_text(uiNoteText, reinterpret_cast<const char*>(data.get()));
lv_label_set_text(uiCurrentFileName, path.c_str());
filePath = path;
LOGGER.info("Loaded from {}", path);
LOG_I(TAG, "Loaded from %s", path.c_str());
}
});
}
@@ -101,7 +102,7 @@ class NotesApp final : public App {
bool result = false;
file::getLock(path)->withLock([&result, this, path] {
if (file::writeString(path, saveBuffer.c_str())) {
LOGGER.info("Saved to {}", path);
LOG_I(TAG, "Saved to %s", path.c_str());
filePath = path;
result = true;
}
@@ -193,7 +194,7 @@ class NotesApp final : public App {
}
void onResult(AppContext& appContext, LaunchId launchId, Result result, std::unique_ptr<Bundle> resultData) override {
LOGGER.info("Result for launch id {}", launchId);
LOG_I(TAG, "Result for launch id %u", launchId);
if (launchId == loadFileLaunchId) {
loadFileLaunchId = 0;
if (result == Result::Ok && resultData != nullptr) {
@@ -6,7 +6,6 @@
#include <Tactility/app/App.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/kernel/Platform.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Lvgl.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
@@ -15,11 +14,12 @@
#include <Tactility/Paths.h>
#include <Tactility/Timer.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h>
namespace tt::app::screenshot {
static const auto LOGGER = Logger("Screenshot");
constexpr auto* TAG = "Screenshot";
extern const AppManifest manifest;
@@ -100,27 +100,27 @@ void ScreenshotApp::onModeSet() {
void ScreenshotApp::onStartPressed() {
auto service = service::screenshot::optScreenshotService();
if (service == nullptr) {
LOGGER.error("Service not found/running");
LOG_E(TAG, "Service not found/running");
return;
}
if (service->isTaskStarted()) {
LOGGER.info("Stop screenshot");
LOG_I(TAG, "Stop screenshot");
service->stop();
} else {
uint32_t selected = lv_dropdown_get_selected(modeDropdown);
const char* path = lv_textarea_get_text(pathTextArea);
if (selected == 0) {
LOGGER.info("Start timed screenshots");
LOG_I(TAG, "Start timed screenshots");
const char* delay_text = lv_textarea_get_text(delayTextArea);
int delay = atoi(delay_text);
if (delay > 0) {
service->startTimed(path, delay, 1);
} else {
LOGGER.warn("Ignored screenshot start because delay was 0");
LOG_W(TAG, "Ignored screenshot start because delay was 0");
}
} else {
LOGGER.info("Start app screenshots");
LOG_I(TAG, "Start app screenshots");
service->startApps(path);
}
}
@@ -131,7 +131,7 @@ void ScreenshotApp::onStartPressed() {
void ScreenshotApp::updateScreenshotMode() {
auto service = service::screenshot::optScreenshotService();
if (service == nullptr) {
LOGGER.error("Service not found/running");
LOG_E(TAG, "Service not found/running");
return;
}
@@ -154,7 +154,7 @@ void ScreenshotApp::updateScreenshotMode() {
void ScreenshotApp::createModeSettingWidgets(lv_obj_t* parent) {
auto service = service::screenshot::optScreenshotService();
if (service == nullptr) {
LOGGER.error("Service not found/running");
LOG_E(TAG, "Service not found/running");
return;
}
@@ -1,9 +1,9 @@
#include <Tactility/app/selectiondialog/SelectionDialog.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/StringUtils.h>
#include <tactility/log.h>
#include <lvgl.h>
@@ -16,7 +16,7 @@ constexpr auto* RESULT_BUNDLE_KEY_INDEX = "index";
constexpr auto* PARAMETER_ITEM_CONCATENATION_TOKEN = ";;";
constexpr auto* DEFAULT_TITLE = "Select...";
static const auto LOGGER = Logger("SelectionDialog");
constexpr auto* TAG = "SelectionDialog";
extern const AppManifest manifest;
@@ -53,7 +53,7 @@ class SelectionDialogApp final : public App {
void onListItemSelected(lv_event_t* e) {
auto index = reinterpret_cast<std::size_t>(lv_event_get_user_data(e));
LOGGER.info("Selected item at index {}", index);
LOG_I(TAG, "Selected item at index %d", (int)index);
auto bundle = std::make_unique<Bundle>();
bundle->putInt32(RESULT_BUNDLE_KEY_INDEX, (int32_t)index);
setResult(Result::Ok, std::move(bundle));
@@ -85,7 +85,7 @@ public:
if (parameters->optString(PARAMETER_BUNDLE_KEY_ITEMS, items_concatenated)) {
std::vector<std::string> items = string::split(items_concatenated, PARAMETER_ITEM_CONCATENATION_TOKEN);
if (items.empty() || items.front().empty()) {
LOGGER.error("No items provided");
LOG_E(TAG, "No items provided");
setResult(Result::Error);
stop(manifest.appId);
} else if (items.size() == 1) {
@@ -93,7 +93,7 @@ public:
result_bundle->putInt32(RESULT_BUNDLE_KEY_INDEX, 0);
setResult(Result::Ok, std::move(result_bundle));
stop(manifest.appId);
LOGGER.warn("Auto-selecting single item");
LOG_W(TAG, "Auto-selecting single item");
} else {
size_t index = 0;
for (const auto& item: items) {
@@ -101,7 +101,7 @@ public:
}
}
} else {
LOGGER.error("No items provided");
LOG_E(TAG, "No items provided");
setResult(Result::Error);
stop(manifest.appId);
}
@@ -1,7 +1,6 @@
#include "tactility/lvgl_module.h"
#include <Tactility/Logger.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/timezone/TimeZone.h>
@@ -13,11 +12,12 @@
#include <lvgl.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h>
namespace tt::app::timedatesettings {
static const auto LOGGER = Logger("TimeDate");
constexpr auto* TAG = "TimeDate";
extern const AppManifest manifest;
@@ -149,7 +149,7 @@ public:
if (result == Result::Ok && bundle != nullptr) {
const auto name = timezone::getResultName(*bundle);
const auto code = timezone::getResultCode(*bundle);
LOGGER.info("Result name={} code={}", name, code);
LOG_I(TAG, "Result name=%s code=%s", name.c_str(), code.c_str());
// onShow() may not have (re)created the widgets yet: onResult() runs synchronously
// on the loader thread and can race ahead of the async gui-task redraw.
+8 -8
View File
@@ -6,7 +6,6 @@
#include <Tactility/app/timezone/TimeZone.h>
#include <Tactility/LogMessages.h>
#include <Tactility/Logger.h>
#include <Tactility/MountPoints.h>
#include <Tactility/StringUtils.h>
#include <Tactility/Timer.h>
@@ -14,13 +13,14 @@
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/settings/Time.h>
#include <tactility/log.h>
#include <lvgl.h>
#include <memory>
namespace tt::app::timezone {
static const auto LOGGER = Logger("TimeZone");
constexpr auto* TAG = "TimeZone";
constexpr auto* RESULT_BUNDLE_CODE_INDEX = "code";
constexpr auto* RESULT_BUNDLE_NAME_INDEX = "name";
@@ -103,7 +103,7 @@ class TimeZoneApp final : public App {
}
void onListItemSelected(std::size_t index) {
LOGGER.info("Selected item at index {}", index);
LOG_I(TAG, "Selected item at index %d", (int)index);
auto& entry = entries[index];
@@ -128,7 +128,7 @@ class TimeZoneApp final : public App {
auto path = std::string(file::MOUNT_POINT_SYSTEM) + "/timezones.csv";
auto* file = fopen(path.c_str(), "rb");
if (file == nullptr) {
LOGGER.error("Failed to open {}", path);
LOG_E(TAG, "Failed to open %s", path.c_str());
return;
}
char line[96];
@@ -149,7 +149,7 @@ class TimeZoneApp final : public App {
}
}
} else {
LOGGER.error("Parse error at line {}", count);
LOG_E(TAG, "Parse error at line %llu", count);
}
}
@@ -159,10 +159,10 @@ class TimeZoneApp final : public App {
entries = std::move(new_entries);
mutex.unlock();
} else {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED);
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED);
}
LOGGER.info("Processed {} entries", count);
LOG_I(TAG, "Processed %llu entries", count);
}
void updateList() {
@@ -171,7 +171,7 @@ class TimeZoneApp final : public App {
readTimeZones(filter);
lvgl::unlock();
} else {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
LOG_E(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
return;
}
@@ -2,15 +2,16 @@
#include <Tactility/app/touchcalibration/TouchCalibration.h>
#include <Tactility/Logger.h>
#include <Tactility/settings/TouchCalibrationSettings.h>
#include <tactility/log.h>
#include <algorithm>
#include <lvgl.h>
namespace tt::app::touchcalibration {
static const auto LOGGER = Logger("TouchCalibration");
constexpr auto* TAG = "TouchCalibration";
extern const AppManifest manifest;
@@ -102,7 +103,7 @@ class TouchCalibrationApp final : public App {
return;
}
LOGGER.info("Saved calibration x=[{}, {}] y=[{}, {}]", xMin, xMax, yMin, yMax);
LOG_I(TAG, "Saved calibration x=[%d, %d] y=[%d, %d]", xMin, xMax, yMin, yMax);
lv_label_set_text(titleLabel, "Calibration Complete");
lv_label_set_text(hintLabel, "Touch anywhere to continue.");
lv_obj_add_flag(target, LV_OBJ_FLAG_HIDDEN);
@@ -9,9 +9,9 @@
#include <Tactility/Assets.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/Logger.h>
#include <lvgl.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h>
#include <esp_netif.h>
@@ -21,7 +21,7 @@
namespace tt::app::webserversettings {
static const auto LOGGER = tt::Logger("WebServerSettingsApp");
constexpr auto* TAG = "WebServerSettingsApp";
class WebServerSettingsApp final : public App {
@@ -68,10 +68,10 @@ class WebServerSettingsApp final : public App {
// Apply immediately instead of waiting for app exit
const auto copy = app->wsSettings;
if (!settings::webserver::save(copy)) {
LOGGER.warn("Failed to persist WebServer settings; changes may be lost on reboot");
LOG_W(TAG, "Failed to persist WebServer settings; changes may be lost on reboot");
}
service::webserver::getPubsub()->publish(service::webserver::WebServerEvent::WebServerSettingsChanged);
LOGGER.info("WebServer {}", enabled ? "enabling..." : "disabling...");
LOG_I(TAG, "WebServer %s", enabled ? "enabling..." : "disabling...");
service::webserver::setWebServerEnabled(enabled);
});
}
@@ -360,7 +360,7 @@ public:
getMainDispatcher().dispatch([copy, wifiChanged]{
// Save to flash (fast, low memory pressure)
if (!settings::webserver::save(copy)) {
LOGGER.warn("Failed to persist WebServer settings; changes may be lost on reboot");
LOG_W(TAG, "Failed to persist WebServer settings; changes may be lost on reboot");
}
// Publish event immediately after save so WebServer cache refreshes BEFORE requests arrive
@@ -368,7 +368,7 @@ public:
// Only reconnect WiFi if WiFi settings actually changed
if (wifiChanged) {
LOGGER.info("WiFi mode changed to {}", copy.wifiMode == settings::webserver::WiFiMode::AccessPoint ? "AP" : "Station");
LOG_I(TAG, "WiFi mode changed to %s", copy.wifiMode == settings::webserver::WiFiMode::AccessPoint ? "AP" : "Station");
}
});
}
@@ -1,22 +1,23 @@
#include "Tactility/lvgl/LvglSync.h"
#include <Tactility/LogMessages.h>
#include <Tactility/Logger.h>
#include <Tactility/app/App.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <tactility/check.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/wifi/Wifi.h>
#include <Tactility/service/wifi/WifiApSettings.h>
#include <tactility/check.h>
#include <tactility/log.h>
#include <lvgl.h>
namespace tt::app::wifiapsettings {
static const auto LOGGER = Logger("WifiApSettings");
constexpr auto* TAG = "WifiApSettings";
extern const AppManifest manifest;
@@ -52,10 +53,10 @@ class WifiApSettings : public App {
if (service::wifi::settings::load(self->ssid.c_str(), settings)) {
settings.autoConnect = is_on;
if (!service::wifi::settings::save(settings)) {
LOGGER.error("Failed to save settings");
LOG_E(TAG, "Failed to save settings");
}
} else {
LOGGER.error("Failed to load settings");
LOG_E(TAG, "Failed to load settings");
}
}
@@ -91,7 +92,7 @@ class WifiApSettings : public App {
updateViews();
lvgl::unlock();
} else {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
}
}
}
@@ -194,7 +195,7 @@ public:
lv_obj_remove_state(auto_connect_switch, LV_STATE_CHECKED);
}
} else {
LOGGER.warn("No settings found");
LOG_W(TAG, "No settings found");
lv_obj_add_flag(forget_button, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(auto_connect_wrapper, LV_OBJ_FLAG_HIDDEN);
}
@@ -225,11 +226,11 @@ public:
std::string ssid = parameters->getString("ssid");
if (!service::wifi::settings::remove(ssid.c_str())) {
LOGGER.error("Failed to remove SSID");
LOG_E(TAG, "Failed to remove SSID");
return;
}
LOGGER.info("Removed SSID");
LOG_I(TAG, "Removed SSID");
if (
service::wifi::getRadioState() == service::wifi::RadioState::ConnectionActive &&
service::wifi::getConnectionTarget() == ssid
+5 -4
View File
@@ -2,18 +2,19 @@
#include <Tactility/app/wificonnect/View.h>
#include <Tactility/app/wificonnect/WifiConnect.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/lvgl/Spinner.h>
#include <Tactility/service/wifi/WifiApSettings.h>
#include <Tactility/service/wifi/WifiGlobals.h>
#include <tactility/log.h>
#include <lvgl.h>
#include <cstring>
namespace tt::app::wificonnect {
static const auto LOGGER = Logger("WifiConnect");
constexpr auto* TAG = "WifiConnect";
void View::resetErrors() {
lv_obj_add_flag(password_error, LV_OBJ_FLAG_HIDDEN);
@@ -31,7 +32,7 @@ static void onConnect(lv_event_t* event) {
const char* ssid = lv_textarea_get_text(view.ssid_textarea);
size_t ssid_len = strlen(ssid);
if (ssid_len > TT_WIFI_SSID_LIMIT) {
LOGGER.error("SSID too long");
LOG_E(TAG, "SSID too long");
lv_label_set_text(view.ssid_error, "SSID too long");
lv_obj_remove_flag(view.ssid_error, LV_OBJ_FLAG_HIDDEN);
return;
@@ -40,7 +41,7 @@ static void onConnect(lv_event_t* event) {
const char* password = lv_textarea_get_text(view.password_textarea);
size_t password_len = strlen(password);
if (password_len > TT_WIFI_CREDENTIALS_PASSWORD_LIMIT) {
LOGGER.error("Password too long");
LOG_E(TAG, "Password too long");
lv_label_set_text(view.password_error, "Password too long");
lv_obj_remove_flag(view.password_error, LV_OBJ_FLAG_HIDDEN);
return;
@@ -1,15 +1,16 @@
#include <Tactility/app/wificonnect/WifiConnect.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/service/wifi/Wifi.h>
#include <tactility/log.h>
namespace tt::app::wificonnect {
static const auto LOGGER = Logger("WifiConnect");
constexpr auto* TAG = "WifiConnect";
constexpr auto* WIFI_CONNECT_PARAM_SSID = "ssid"; // String
constexpr auto* WIFI_CONNECT_PARAM_PASSWORD = "password"; // String
@@ -74,7 +75,7 @@ void WifiConnect::requestViewUpdate() {
view.update();
lvgl::unlock();
} else {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
}
}
unlock();
+11 -11
View File
@@ -2,21 +2,21 @@
#include <string>
#include <set>
#include <tactility/lvgl_module.h>
#include <Tactility/network/HttpdReq.h>
#include <Tactility/app/wifimanage/View.h>
#include <Tactility/app/wifimanage/WifiManagePrivate.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/wifi/Wifi.h>
#include <Tactility/service/wifi/WifiSettings.h>
#include <Tactility/Tactility.h>
#include <tactility/log.h>
#include <tactility/lvgl_module.h>
namespace tt::app::wifimanage {
static const auto LOGGER = Logger("WifiManageView");
constexpr auto* TAG = "WifiManageView";
std::shared_ptr<WifiManage> optWifiManage();
@@ -68,16 +68,16 @@ static void onConnectToHiddenClicked(lv_event_t* event) {
// region Secondary updates
void View::connect(lv_event_t* event) {
LOGGER.debug("connect()");
LOG_D(TAG, "connect()");
auto* widget = lv_event_get_current_target_obj(event);
auto index = reinterpret_cast<size_t>(lv_obj_get_user_data(widget));
auto* self = static_cast<View*>(lv_event_get_user_data(event));
auto ap_records = self->state->getApRecords();
if (index < ap_records.size()) {
LOGGER.info("Clicked {}/{}", index, ap_records.size() - 1);
LOG_I(TAG, "Clicked %zu/%zu", index, ap_records.size() - 1);
auto& ssid = ap_records[index].ssid;
LOGGER.info("Clicked AP: {}", ssid);
LOG_I(TAG, "Clicked AP: %s", ssid.c_str());
std::string connection_target = service::wifi::getConnectionTarget();
if (connection_target == ssid) {
self->bindings->onDisconnect();
@@ -85,12 +85,12 @@ void View::connect(lv_event_t* event) {
self->bindings->onConnectSsid(ssid);
}
} else {
LOGGER.warn("Clicked AP: record {}/{} does not exist", index, ap_records.size() - 1);
LOG_W(TAG, "Clicked AP: record %zu/%zu does not exist", index, ap_records.size() - 1);
}
}
void View::showDetails(lv_event_t* event) {
LOGGER.debug("showDetails()");
LOG_D(TAG, "showDetails()");
auto* widget = lv_event_get_current_target_obj(event);
auto index = reinterpret_cast<size_t>(lv_obj_get_user_data(widget));
auto* self = static_cast<View*>(lv_event_get_user_data(event));
@@ -98,10 +98,10 @@ void View::showDetails(lv_event_t* event) {
if (index < ap_records.size()) {
auto& ssid = ap_records[index].ssid;
LOGGER.info("Clicked AP: {}", ssid);
LOG_I(TAG, "Clicked AP: %s", ssid.c_str());
self->bindings->onShowApSettings(ssid);
} else {
LOGGER.warn("Clicked AP: record {}/{} does not exist", index, ap_records.size() - 1);
LOG_W(TAG, "Clicked AP: record %zu/%zu does not exist", index, ap_records.size() - 1);
}
}
+11 -11
View File
@@ -1,29 +1,29 @@
#include <Tactility/app/wifimanage/WifiManagePrivate.h>
#include <Tactility/app/wifimanage/View.h>
#include <Tactility/LogMessages.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/app/wifiapsettings/WifiApSettings.h>
#include <Tactility/app/wificonnect/WifiConnect.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/service/loader/Loader.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h>
namespace tt::app::wifimanage {
static const auto LOGGER = Logger("WifiManage");
constexpr auto* TAG = "WifiManage";
extern const AppManifest manifest;
static void onConnect(const std::string& ssid) {
service::wifi::settings::WifiApSettings settings;
if (service::wifi::settings::load(ssid, settings)) {
LOGGER.info("Connecting with known credentials");
LOG_I(TAG, "Connecting with known credentials");
service::wifi::connect(settings, false);
} else {
LOGGER.info("Starting connection dialog");
LOG_I(TAG, "Starting connection dialog");
wificonnect::start(ssid);
}
}
@@ -69,7 +69,7 @@ void WifiManage::requestViewUpdate() {
view.update();
lvgl::unlock();
} else {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
}
}
unlock();
@@ -77,7 +77,7 @@ void WifiManage::requestViewUpdate() {
void WifiManage::onWifiEvent(service::wifi::WifiEvent event) {
auto radio_state = service::wifi::getRadioState();
LOGGER.info("Update with state {}", service::wifi::radioStateToString(radio_state));
LOG_I(TAG, "Update with state %s", service::wifi::radioStateToString(radio_state));
getState().setRadioState(radio_state);
switch (event) {
using enum service::wifi::WifiEvent;
@@ -123,11 +123,11 @@ void WifiManage::onShow(AppContext& app, lv_obj_t* parent) {
radio_state == service::wifi::RadioState::ConnectionPending ||
radio_state == service::wifi::RadioState::ConnectionActive;
std::string connection_target = service::wifi::getConnectionTarget();
LOGGER.info("Radio: {}, Scanning: {}, Connected to: {}, Can scan: {}",
service::wifi::radioStateToString(radio_state),
service::wifi::isScanning(),
LOG_I(TAG, "Radio: %s, Scanning: %d, Connected to: %s, Can scan: %d",
service::wifi::radioStateToString(radio_state),
(int)service::wifi::isScanning(),
connection_target.empty() ? "(none)" : connection_target.c_str(),
can_scan);
(int)can_scan);
if (can_scan && !service::wifi::isScanning()) {
service::wifi::scan();
}