New logging and more (#446)
- `TT_LOG_*` macros are replaced by `Logger` via `#include<Tactility/Logger.h>` - Changed default timezone to Europe/Amsterdam - Fix for logic bug in unPhone hardware - Fix for init/deinit in DRV2605 driver - Other fixes - Removed optimization that broke unPhone (disabled the moving of heap-related functions to flash)
This commit is contained in:
committed by
GitHub
parent
719f7bcece
commit
f620255c41
@@ -6,35 +6,32 @@
|
||||
#include <Tactility/file/FileLock.h>
|
||||
#include <Tactility/file/PropertiesFile.h>
|
||||
#include <Tactility/hal/Device.h>
|
||||
#include <Tactility/hal/sdcard/SdCardDevice.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/Paths.h>
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fcntl.h>
|
||||
#include <format>
|
||||
#include <libgen.h>
|
||||
#include <map>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <minitar.h>
|
||||
|
||||
constexpr auto* TAG = "App";
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
static const auto LOGGER = Logger("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)) {
|
||||
TT_LOG_E(TAG, "Can't find or create directory %s", destinationPath.c_str());
|
||||
LOGGER.error("Can't find or create directory {}", 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())) {
|
||||
TT_LOG_E(TAG, "Failed to write data to %s", absolute_path.c_str());
|
||||
LOGGER.error("Failed to write data to {}", absolute_path.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -63,32 +60,32 @@ static bool untar(const std::string& tarPath, const std::string& destinationPath
|
||||
|
||||
do {
|
||||
if (minitar_read_entry(&mp, &entry) == 0) {
|
||||
TT_LOG_I(TAG, "Extracting %s", entry.metadata.path);
|
||||
LOGGER.info("Extracting {}", 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)) {
|
||||
TT_LOG_E(TAG, "Failed to create directory %s/%s: %s", destinationPath.c_str(), entry.metadata.name, strerror(errno));
|
||||
LOGGER.error("Failed to create directory {}/{}: {}", destinationPath, entry.metadata.name, strerror(errno));
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
} else if (entry.metadata.type == MTAR_REGULAR) {
|
||||
if (!untarFile(&mp, &entry, destinationPath)) {
|
||||
TT_LOG_E(TAG, "Failed to extract file %s: %s", entry.metadata.path, strerror(errno));
|
||||
LOGGER.error("Failed to extract file {}: {}", entry.metadata.path, strerror(errno));
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
} else if (entry.metadata.type == MTAR_SYMLINK) {
|
||||
TT_LOG_E(TAG, "SYMLINK not supported");
|
||||
LOGGER.error("SYMLINK not supported");
|
||||
} else if (entry.metadata.type == MTAR_HARDLINK) {
|
||||
TT_LOG_E(TAG, "HARDLINK not supported");
|
||||
LOGGER.error("HARDLINK not supported");
|
||||
} else if (entry.metadata.type == MTAR_FIFO) {
|
||||
TT_LOG_E(TAG, "FIFO not supported");
|
||||
LOGGER.error("FIFO not supported");
|
||||
} else if (entry.metadata.type == MTAR_BLKDEV) {
|
||||
TT_LOG_E(TAG, "BLKDEV not supported");
|
||||
LOGGER.error("BLKDEV not supported");
|
||||
} else if (entry.metadata.type == MTAR_CHRDEV) {
|
||||
TT_LOG_E(TAG, "CHRDEV not supported");
|
||||
LOGGER.error("CHRDEV not supported");
|
||||
} else {
|
||||
TT_LOG_E(TAG, "Unknown entry type: %d", entry.metadata.type);
|
||||
LOGGER.error("Unknown entry type: {}", static_cast<int>(entry.metadata.type));
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
@@ -100,7 +97,7 @@ static bool untar(const std::string& tarPath, const std::string& destinationPath
|
||||
|
||||
void cleanupInstallDirectory(const std::string& path) {
|
||||
if (!file::deleteRecursively(path)) {
|
||||
TT_LOG_W(TAG, "Failed to delete existing installation at %s", path.c_str());
|
||||
LOGGER.warn("Failed to delete existing installation at {}", path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,16 +106,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();
|
||||
TT_LOG_I(TAG, "Installing app %s to %s", path.c_str(), app_parent_path.c_str());
|
||||
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);
|
||||
if (file::isDirectory(app_target_path) && !file::deleteRecursively(app_target_path)) {
|
||||
TT_LOG_W(TAG, "Failed to delete %s", app_target_path.c_str());
|
||||
LOGGER.warn("Failed to delete {}", app_target_path);
|
||||
}
|
||||
|
||||
if (!file::findOrCreateDirectory(app_target_path, 0777)) {
|
||||
TT_LOG_I(TAG, "Failed to create directory %s", app_target_path.c_str());
|
||||
LOGGER.info("Failed to create directory {}", app_target_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -126,9 +123,9 @@ bool install(const std::string& path) {
|
||||
auto source_path_lock = file::getLock(path)->asScopedLock();
|
||||
target_path_lock.lock();
|
||||
source_path_lock.lock();
|
||||
TT_LOG_I(TAG, "Extracting app from %s to %s", path.c_str(), app_target_path.c_str());
|
||||
LOGGER.info("Extracting app from {} to {}", path, app_target_path);
|
||||
if (!untar(path, app_target_path)) {
|
||||
TT_LOG_E(TAG, "Failed to extract");
|
||||
LOGGER.error("Failed to extract");
|
||||
return false;
|
||||
}
|
||||
source_path_lock.unlock();
|
||||
@@ -136,21 +133,21 @@ bool install(const std::string& path) {
|
||||
|
||||
auto manifest_path = app_target_path + "/manifest.properties";
|
||||
if (!file::isFile(manifest_path)) {
|
||||
TT_LOG_E(TAG, "Manifest not found at %s", manifest_path.c_str());
|
||||
LOGGER.error("Manifest not found at {}", manifest_path);
|
||||
cleanupInstallDirectory(app_target_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> properties;
|
||||
if (!file::loadPropertiesFile(manifest_path, properties)) {
|
||||
TT_LOG_E(TAG, "Failed to load manifest at %s", manifest_path.c_str());
|
||||
LOGGER.error("Failed to load manifest at {}", manifest_path);
|
||||
cleanupInstallDirectory(app_target_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
AppManifest manifest;
|
||||
if (!parseManifest(properties, manifest)) {
|
||||
TT_LOG_W(TAG, "Invalid manifest");
|
||||
LOGGER.warn("Invalid manifest");
|
||||
cleanupInstallDirectory(app_target_path);
|
||||
return false;
|
||||
}
|
||||
@@ -163,7 +160,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)) {
|
||||
TT_LOG_W(TAG, "Failed to delete existing installation at %s", renamed_target_path.c_str());
|
||||
LOGGER.warn("Failed to delete existing installation at {}", renamed_target_path);
|
||||
cleanupInstallDirectory(app_target_path);
|
||||
return false;
|
||||
}
|
||||
@@ -174,7 +171,7 @@ bool install(const std::string& path) {
|
||||
target_path_lock.unlock();
|
||||
|
||||
if (!rename_success) {
|
||||
TT_LOG_E(TAG, "Failed to rename \"%s\" to \"%s\"", app_target_path.c_str(), manifest.appId.c_str());
|
||||
LOGGER.error(R"(Failed to rename "{}" to "{}")", app_target_path, manifest.appId);
|
||||
cleanupInstallDirectory(app_target_path);
|
||||
return false;
|
||||
}
|
||||
@@ -187,7 +184,7 @@ bool install(const std::string& path) {
|
||||
}
|
||||
|
||||
bool uninstall(const std::string& appId) {
|
||||
TT_LOG_I(TAG, "Uninstalling app %s", appId.c_str());
|
||||
LOGGER.info("Uninstalling app {}", appId);
|
||||
|
||||
// If the app was running, then stop it
|
||||
if (isRunning(appId)) {
|
||||
@@ -196,7 +193,7 @@ bool uninstall(const std::string& appId) {
|
||||
|
||||
auto app_path = getAppInstallPath(appId);
|
||||
if (!file::isDirectory(app_path)) {
|
||||
TT_LOG_E(TAG, "App %s not found at %s", appId.c_str(), app_path.c_str());
|
||||
LOGGER.error("App {} not found at {}", appId, app_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -205,7 +202,7 @@ bool uninstall(const std::string& appId) {
|
||||
}
|
||||
|
||||
if (!removeAppManifest(appId)) {
|
||||
TT_LOG_W(TAG, "Failed to remove app %s from registry", appId.c_str());
|
||||
LOGGER.warn("Failed to remove app {} from registry", appId);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
#define TAG "app"
|
||||
|
||||
void AppInstance::setState(State newState) {
|
||||
mutex.lock();
|
||||
state = newState;
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
#include <Tactility/app/AppManifestParsing.h>
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <algorithm>
|
||||
#include <regex>
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
constexpr auto* TAG = "App";
|
||||
static const auto LOGGER = Logger("AppManifest");
|
||||
|
||||
static bool validateString(const std::string& value, const std::function<bool(const char)>& isValidChar) {
|
||||
for (const auto& c : value) {
|
||||
if (!isValidChar(c)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
constexpr bool validateString(const std::string& value, const std::function<bool(char)>& isValidChar) {
|
||||
return std::ranges::all_of(value, isValidChar);
|
||||
}
|
||||
|
||||
static 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()) {
|
||||
TT_LOG_E(TAG, "Failed to find %s in manifest", key.c_str());
|
||||
LOGGER.error("Failed to find {} in manifest", key);
|
||||
return false;
|
||||
}
|
||||
output = iterator->second;
|
||||
@@ -33,19 +29,19 @@ bool isValidId(const std::string& id) {
|
||||
}
|
||||
|
||||
static bool isValidManifestVersion(const std::string& version) {
|
||||
return version.size() > 0 && validateString(version, [](const char c) {
|
||||
return !version.empty() && validateString(version, [](const char c) {
|
||||
return std::isalnum(c) != 0 || c == '.';
|
||||
});
|
||||
}
|
||||
|
||||
static bool isValidAppVersionName(const std::string& version) {
|
||||
return version.size() > 0 && validateString(version, [](const char c) {
|
||||
return !version.empty() && validateString(version, [](const char c) {
|
||||
return std::isalnum(c) != 0 || c == '.' || c == '-' || c == '_';
|
||||
});
|
||||
}
|
||||
|
||||
static bool isValidAppVersionCode(const std::string& version) {
|
||||
return version.size() > 0 && validateString(version, [](const char c) {
|
||||
return !version.empty() && validateString(version, [](const char c) {
|
||||
return std::isdigit(c) != 0;
|
||||
});
|
||||
}
|
||||
@@ -57,7 +53,7 @@ static bool isValidName(const std::string& name) {
|
||||
}
|
||||
|
||||
bool parseManifest(const std::map<std::string, std::string>& map, AppManifest& manifest) {
|
||||
TT_LOG_I(TAG, "Parsing manifest");
|
||||
LOGGER.info("Parsing manifest");
|
||||
|
||||
// [manifest]
|
||||
|
||||
@@ -67,7 +63,7 @@ bool parseManifest(const std::map<std::string, std::string>& map, AppManifest& m
|
||||
}
|
||||
|
||||
if (!isValidManifestVersion(manifest_version)) {
|
||||
TT_LOG_E(TAG, "Invalid version");
|
||||
LOGGER.error("Invalid version");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -78,7 +74,7 @@ bool parseManifest(const std::map<std::string, std::string>& map, AppManifest& m
|
||||
}
|
||||
|
||||
if (!isValidId(manifest.appId)) {
|
||||
TT_LOG_E(TAG, "Invalid app id");
|
||||
LOGGER.error("Invalid app id");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -87,7 +83,7 @@ bool parseManifest(const std::map<std::string, std::string>& map, AppManifest& m
|
||||
}
|
||||
|
||||
if (!isValidName(manifest.appName)) {
|
||||
TT_LOG_I(TAG, "Invalid app name");
|
||||
LOGGER.error("Invalid app name");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -96,7 +92,7 @@ bool parseManifest(const std::map<std::string, std::string>& map, AppManifest& m
|
||||
}
|
||||
|
||||
if (!isValidAppVersionName(manifest.appVersionName)) {
|
||||
TT_LOG_E(TAG, "Invalid app version name");
|
||||
LOGGER.error("Invalid app version name");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -106,7 +102,7 @@ bool parseManifest(const std::map<std::string, std::string>& map, AppManifest& m
|
||||
}
|
||||
|
||||
if (!isValidAppVersionCode(version_code_string)) {
|
||||
TT_LOG_E(TAG, "Invalid app version code");
|
||||
LOGGER.error("Invalid app version code");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,28 @@
|
||||
#include "Tactility/app/AppRegistration.h"
|
||||
#include "Tactility/app/AppManifest.h"
|
||||
#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>
|
||||
|
||||
#define TAG "app"
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
static const auto LOGGER = Logger("AppRegistration");
|
||||
|
||||
typedef std::unordered_map<std::string, std::shared_ptr<AppManifest>> AppManifestMap;
|
||||
|
||||
static AppManifestMap app_manifest_map;
|
||||
static Mutex hash_mutex;
|
||||
|
||||
void addAppManifest(const AppManifest& manifest) {
|
||||
TT_LOG_I(TAG, "Registering manifest %s", manifest.appId.c_str());
|
||||
LOGGER.info("Registering manifest {}", manifest.appId);
|
||||
|
||||
hash_mutex.lock();
|
||||
|
||||
if (app_manifest_map.contains(manifest.appId)) {
|
||||
TT_LOG_W(TAG, "Overwriting existing manifest for %s", manifest.appId.c_str());
|
||||
LOGGER.warn("Overwriting existing manifest for {}", manifest.appId);
|
||||
}
|
||||
|
||||
app_manifest_map[manifest.appId] = std::make_shared<AppManifest>(manifest);
|
||||
@@ -30,7 +31,7 @@ void addAppManifest(const AppManifest& manifest) {
|
||||
}
|
||||
|
||||
bool removeAppManifest(const std::string& id) {
|
||||
TT_LOG_I(TAG, "Removing manifest for %s", id.c_str());
|
||||
LOGGER.info("Removing manifest for {}", id);
|
||||
|
||||
auto lock = hash_mutex.asScopedLock();
|
||||
lock.lock();
|
||||
|
||||
@@ -4,18 +4,17 @@
|
||||
#include <Tactility/app/ElfApp.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/file/FileLock.h>
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
#include <Tactility/StringUtils.h>
|
||||
|
||||
#include <esp_elf.h>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
constexpr auto* TAG = "ElfApp";
|
||||
static auto LOGGER = Logger("ElfApp");
|
||||
|
||||
static std::string getErrorCodeString(int error_code) {
|
||||
switch (error_code) {
|
||||
@@ -72,7 +71,7 @@ private:
|
||||
|
||||
bool startElf() {
|
||||
const std::string elf_path = std::format("{}/elf/{}.elf", appPath, CONFIG_IDF_TARGET);
|
||||
TT_LOG_I(TAG, "Starting ELF %s", elf_path.c_str());
|
||||
LOGGER.info("Starting ELF {}", elf_path);
|
||||
assert(elfFileData == nullptr);
|
||||
|
||||
size_t size = 0;
|
||||
@@ -86,7 +85,7 @@ private:
|
||||
|
||||
if (esp_elf_init(&elf) != ESP_OK) {
|
||||
lastError = "Failed to initialize";
|
||||
TT_LOG_E(TAG, "%s", lastError.c_str());
|
||||
LOGGER.error("{}", lastError);
|
||||
elfFileData = nullptr;
|
||||
return false;
|
||||
}
|
||||
@@ -95,7 +94,7 @@ private:
|
||||
if (relocate_result != 0) {
|
||||
// Note: the result code maps to values from cstdlib's errno.h
|
||||
lastError = getErrorCodeString(-relocate_result);
|
||||
TT_LOG_E(TAG, "Application failed to load: %s", lastError.c_str());
|
||||
LOGGER.error("Application failed to load: {}", lastError);
|
||||
elfFileData = nullptr;
|
||||
return false;
|
||||
}
|
||||
@@ -105,7 +104,7 @@ private:
|
||||
|
||||
if (esp_elf_request(&elf, 0, argc, argv) != ESP_OK) {
|
||||
lastError = "Executable returned error code";
|
||||
TT_LOG_E(TAG, "%s", lastError.c_str());
|
||||
LOGGER.error("{}", lastError);
|
||||
esp_elf_deinit(&elf);
|
||||
elfFileData = nullptr;
|
||||
return false;
|
||||
@@ -116,7 +115,7 @@ private:
|
||||
}
|
||||
|
||||
void stopElf() {
|
||||
TT_LOG_I(TAG, "Cleaning up ELF");
|
||||
LOGGER.info("Cleaning up ELF");
|
||||
|
||||
if (shouldCleanupElf) {
|
||||
esp_elf_deinit(&elf);
|
||||
@@ -164,7 +163,7 @@ public:
|
||||
}
|
||||
|
||||
void onDestroy(AppContext& appContext) override {
|
||||
TT_LOG_I(TAG, "Cleaning up app");
|
||||
LOGGER.info("Cleaning up app");
|
||||
if (manifest != nullptr) {
|
||||
if (manifest->onDestroy != nullptr) {
|
||||
manifest->onDestroy(&appContext, data);
|
||||
@@ -223,7 +222,7 @@ void setElfAppParameters(
|
||||
}
|
||||
|
||||
std::shared_ptr<App> createElfApp(const std::shared_ptr<AppManifest>& manifest) {
|
||||
TT_LOG_I(TAG, "createElfApp");
|
||||
LOGGER.info("createElfApp");
|
||||
assert(manifest != nullptr);
|
||||
assert(manifest->appLocation.isExternal());
|
||||
return std::make_shared<ElfApp>(manifest->appLocation.getPath());
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
#include "Tactility/StringUtils.h"
|
||||
#include "Tactility/app/AppManifest.h"
|
||||
#include "Tactility/app/alertdialog/AlertDialog.h"
|
||||
#include "Tactility/hal/gps/GpsDevice.h"
|
||||
#include "Tactility/hal/uart/Uart.h"
|
||||
#include "Tactility/lvgl/Style.h"
|
||||
#include "Tactility/lvgl/Toolbar.h"
|
||||
#include "Tactility/service/gps/GpsService.h"
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/StringUtils.h>
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/app/alertdialog/AlertDialog.h>
|
||||
#include <Tactility/hal/gps/GpsDevice.h>
|
||||
#include <Tactility/hal/uart/Uart.h>
|
||||
#include <Tactility/lvgl/Style.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/service/gps/GpsService.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <lvgl.h>
|
||||
|
||||
namespace tt::app::addgps {
|
||||
|
||||
constexpr const char* TAG = "AddGps";
|
||||
static const auto LOGGER = Logger("AddGps");
|
||||
|
||||
class AddGpsApp final : public App {
|
||||
|
||||
private:
|
||||
|
||||
lv_obj_t* uartDropdown = nullptr;
|
||||
lv_obj_t* modelDropdown = nullptr;
|
||||
lv_obj_t* baudDropdown = nullptr;
|
||||
@@ -48,7 +47,7 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
TT_LOG_I(TAG, "Saving: uart=%s, model=%lu, baud=%lu", new_configuration.uartName, (uint32_t)new_configuration.model, new_configuration.baudRate);
|
||||
LOGGER.info("Saving: uart={}, model={}, baud={}", new_configuration.uartName, (uint32_t)new_configuration.model, new_configuration.baudRate);
|
||||
|
||||
auto service = service::gps::findGpsService();
|
||||
std::vector<tt::hal::gps::GpsConfiguration> configurations;
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include "Tactility/lvgl/Toolbar.h"
|
||||
#include "Tactility/service/loader/Loader.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/StringUtils.h>
|
||||
#include <Tactility/TactilityCore.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
@@ -16,9 +16,9 @@ namespace tt::app::alertdialog {
|
||||
#define RESULT_BUNDLE_KEY_INDEX "index"
|
||||
|
||||
#define PARAMETER_ITEM_CONCATENATION_TOKEN ";;"
|
||||
#define DEFAULT_TITLE "Select..."
|
||||
#define DEFAULT_TITLE ""
|
||||
|
||||
#define TAG "selection_dialog"
|
||||
static const auto LOGGER = Logger("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));
|
||||
TT_LOG_I(TAG, "Selected item at index %d", index);
|
||||
LOGGER.info("Selected item at index {}", index);
|
||||
|
||||
auto bundle = std::make_unique<Bundle>();
|
||||
bundle->putInt32(RESULT_BUNDLE_KEY_INDEX, (int32_t)index);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#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>
|
||||
@@ -16,7 +17,7 @@
|
||||
|
||||
namespace tt::app::apphub {
|
||||
|
||||
constexpr auto* TAG = "AppHub";
|
||||
static const auto LOGGER = Logger("AppHub");
|
||||
|
||||
extern const AppManifest manifest;
|
||||
|
||||
@@ -55,7 +56,7 @@ class AppHubApp final : public App {
|
||||
}
|
||||
|
||||
void onRefreshSuccess() {
|
||||
TT_LOG_I(TAG, "Request success");
|
||||
LOGGER.info("Request success");
|
||||
auto lock = lvgl::getSyncLock()->asScopedLock();
|
||||
lock.lock();
|
||||
|
||||
@@ -63,7 +64,7 @@ class AppHubApp final : public App {
|
||||
}
|
||||
|
||||
void onRefreshError(const char* error) {
|
||||
TT_LOG_E(TAG, "Request failed: %s", error);
|
||||
LOGGER.error("Request failed: {}", error);
|
||||
auto lock = lvgl::getSyncLock()->asScopedLock();
|
||||
lock.lock();
|
||||
|
||||
@@ -106,7 +107,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];
|
||||
TT_LOG_I(TAG, "Adding %s", entry.appName.c_str());
|
||||
LOGGER.info("Adding {}", 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);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include <Tactility/app/apphub/AppHubEntry.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/json/Reader.h>
|
||||
#include <Tactility/Logger.h>
|
||||
|
||||
namespace tt::app::apphub {
|
||||
|
||||
constexpr auto* TAG = "AppHubJson";
|
||||
static const auto LOGGER = Logger("AppHubJson");
|
||||
|
||||
static bool parseEntry(const cJSON* object, AppHubEntry& entry) {
|
||||
const json::Reader reader(object);
|
||||
@@ -24,21 +25,21 @@ bool parseJson(const std::string& filePath, std::vector<AppHubEntry>& entries) {
|
||||
|
||||
auto data = file::readString(filePath);
|
||||
if (data == nullptr) {
|
||||
TT_LOG_E(TAG, "Failed to read %s", filePath.c_str());
|
||||
LOGGER.error("Failed to read {}", filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto data_ptr = reinterpret_cast<const char*>(data.get());
|
||||
auto* json = cJSON_Parse(data_ptr);
|
||||
if (json == nullptr) {
|
||||
TT_LOG_E(TAG, "Failed to parse %s", filePath.c_str());
|
||||
LOGGER.error("Failed to parse {}", filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
const cJSON* apps_json = cJSON_GetObjectItemCaseSensitive(json, "apps");
|
||||
if (!cJSON_IsArray(apps_json)) {
|
||||
cJSON_Delete(json);
|
||||
TT_LOG_E(TAG, "apps is not an array");
|
||||
LOGGER.error("apps is not an array");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -48,7 +49,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)) {
|
||||
TT_LOG_E(TAG, "Failed to read entry");
|
||||
LOGGER.error("Failed to read entry");
|
||||
cJSON_Delete(json);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#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>
|
||||
@@ -15,8 +16,9 @@
|
||||
|
||||
namespace tt::app::apphubdetails {
|
||||
|
||||
static const auto LOGGER = Logger("AppHubDetails");
|
||||
|
||||
extern const AppManifest manifest;
|
||||
constexpr auto* TAG = "AppHubDetails";
|
||||
|
||||
static std::shared_ptr<Bundle> toBundle(const apphub::AppHubEntry& entry) {
|
||||
auto bundle = std::make_shared<Bundle>();
|
||||
@@ -83,7 +85,7 @@ class AppHubDetailsApp final : public App {
|
||||
}
|
||||
|
||||
void uninstallApp() {
|
||||
TT_LOG_I(TAG, "Uninstall");
|
||||
LOGGER.info("Uninstall");
|
||||
|
||||
lvgl::getSyncLock()->lock();
|
||||
lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN);
|
||||
@@ -107,10 +109,10 @@ class AppHubDetailsApp final : public App {
|
||||
[this, temp_file_path] {
|
||||
install(temp_file_path);
|
||||
|
||||
if (!file::deleteFile(temp_file_path.c_str())) {
|
||||
TT_LOG_W(TAG, "Failed to remove %s", temp_file_path.c_str());
|
||||
if (!file::deleteFile(temp_file_path)) {
|
||||
LOGGER.warn("Failed to remove {}", temp_file_path);
|
||||
} else {
|
||||
TT_LOG_I(TAG, "Deleted temporary file %s", temp_file_path.c_str());
|
||||
LOGGER.info("Deleted temporary file {}", temp_file_path);
|
||||
}
|
||||
|
||||
lvgl::getSyncLock()->lock();
|
||||
@@ -118,18 +120,18 @@ class AppHubDetailsApp final : public App {
|
||||
lvgl::getSyncLock()->unlock();
|
||||
},
|
||||
[temp_file_path](const char* errorMessage) {
|
||||
TT_LOG_E(TAG, "Download failed: %s", errorMessage);
|
||||
LOGGER.error("Download failed: {}", errorMessage);
|
||||
alertdialog::start("Error", "Failed to install app");
|
||||
|
||||
if (file::isFile(temp_file_path) && !file::deleteFile(temp_file_path.c_str())) {
|
||||
TT_LOG_W(TAG, "Failed to remove %s", temp_file_path.c_str());
|
||||
LOGGER.warn("Failed to remove {}", temp_file_path);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void installApp() {
|
||||
TT_LOG_I(TAG, "Install");
|
||||
LOGGER.info("Install");
|
||||
|
||||
lvgl::getSyncLock()->lock();
|
||||
lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN);
|
||||
@@ -139,15 +141,15 @@ class AppHubDetailsApp final : public App {
|
||||
}
|
||||
|
||||
void updateApp() {
|
||||
TT_LOG_I(TAG, "Update");
|
||||
LOGGER.info("Update");
|
||||
|
||||
lvgl::getSyncLock()->lock();
|
||||
lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN);
|
||||
lvgl::getSyncLock()->unlock();
|
||||
|
||||
TT_LOG_I(TAG, "Removing previous version");
|
||||
LOGGER.info("Removing previous version");
|
||||
uninstall(entry.appId);
|
||||
TT_LOG_I(TAG, "Installing new version");
|
||||
LOGGER.info("Installing new version");
|
||||
doInstall();
|
||||
}
|
||||
|
||||
@@ -173,13 +175,13 @@ public:
|
||||
void onCreate(AppContext& appContext) override {
|
||||
auto parameters = appContext.getParameters();
|
||||
if (parameters == nullptr) {
|
||||
TT_LOG_E(TAG, "No parameters");
|
||||
LOGGER.error("No parameters");
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fromBundle(*parameters.get(), entry)) {
|
||||
TT_LOG_E(TAG, "Invalid parameters");
|
||||
LOGGER.error("Invalid parameters");
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#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/service/loader/Loader.h>
|
||||
#include <Tactility/settings/BootSettings.h>
|
||||
@@ -25,7 +26,8 @@
|
||||
|
||||
namespace tt::app::boot {
|
||||
|
||||
constexpr auto* TAG = "Boot";
|
||||
static const auto LOGGER = Logger("Boot");
|
||||
|
||||
extern const AppManifest manifest;
|
||||
|
||||
static std::shared_ptr<hal::display::DisplayDevice> getHalDisplay() {
|
||||
@@ -51,17 +53,17 @@ class BootApp : public App {
|
||||
if (settings::display::load(settings)) {
|
||||
if (hal_display->getGammaCurveCount() > 0) {
|
||||
hal_display->setGammaCurve(settings.gammaCurve);
|
||||
TT_LOG_I(TAG, "Gamma curve %du", settings.gammaCurve);
|
||||
LOGGER.info("Gamma curve {}", settings.gammaCurve);
|
||||
}
|
||||
} else {
|
||||
settings = settings::display::getDefault();
|
||||
}
|
||||
|
||||
if (hal_display->supportsBacklightDuty()) {
|
||||
TT_LOG_I(TAG, "Backlight %du", settings.backlightDuty);
|
||||
LOGGER.info("Backlight {}", settings.backlightDuty);
|
||||
hal_display->setBacklightDuty(settings.backlightDuty);
|
||||
} else {
|
||||
TT_LOG_I(TAG, "no backlight");
|
||||
LOGGER.info("No backlight");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,17 +72,17 @@ class BootApp : public App {
|
||||
return false;
|
||||
}
|
||||
|
||||
TT_LOG_I(TAG, "Rebooting into mass storage device mode");
|
||||
LOGGER.info("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()) {
|
||||
TT_LOG_E(TAG, "Unable to start flash mass storage");
|
||||
LOGGER.error("Unable to start flash mass storage");
|
||||
return false;
|
||||
}
|
||||
} else if (mode == hal::usb::BootMode::Sdmmc) {
|
||||
if (!hal::usb::startMassStorageWithSdmmc()) {
|
||||
TT_LOG_E(TAG, "Unable to start SD mass storage");
|
||||
LOGGER.error("Unable to start SD mass storage");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -98,23 +100,22 @@ class BootApp : public App {
|
||||
}
|
||||
|
||||
static int32_t bootThreadCallback() {
|
||||
TT_LOG_I(TAG, "Starting boot thread");
|
||||
LOGGER.info("Starting boot thread");
|
||||
const auto start_time = kernel::getTicks();
|
||||
|
||||
// Give the UI some time to redraw
|
||||
// If we don't do this, various init calls will read files and block SPI IO for the display
|
||||
// This would result in a blank/black screen being shown during this phase of the boot process
|
||||
// This works with 5 ms on a T-Lora Pager, so we give it 10 ms to be safe
|
||||
TT_LOG_I(TAG, "Delay");
|
||||
kernel::delayMillis(10);
|
||||
|
||||
// TODO: Support for multiple displays
|
||||
TT_LOG_I(TAG, "Setup display");
|
||||
LOGGER.info("Setup display");
|
||||
setupDisplay(); // Set backlight
|
||||
prepareFileSystems();
|
||||
|
||||
if (!setupUsbBootMode()) {
|
||||
TT_LOG_I(TAG, "initFromBootApp");
|
||||
LOGGER.info("initFromBootApp");
|
||||
registerApps();
|
||||
waitForMinimalSplashDuration(start_time);
|
||||
stop(manifest.appId);
|
||||
@@ -123,7 +124,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
|
||||
TT_LOG_I(TAG, "Publish event");
|
||||
LOGGER.info("Publish event");
|
||||
kernel::publishSystemEvent(kernel::SystemEvent::BootSplash);
|
||||
|
||||
return 0;
|
||||
@@ -140,7 +141,7 @@ class BootApp : public App {
|
||||
settings::BootSettings boot_properties;
|
||||
std::string launcher_app_id;
|
||||
if (settings::loadBootSettings(boot_properties) && boot_properties.launcherAppId.empty()) {
|
||||
TT_LOG_E(TAG, "Failed to load launcher configuration, or launcher not configured");
|
||||
LOGGER.error("Failed to load launcher configuration, or launcher not configured");
|
||||
launcher_app_id = boot_properties.launcherAppId;
|
||||
} else {
|
||||
launcher_app_id = "Launcher";
|
||||
@@ -187,7 +188,7 @@ public:
|
||||
logo = hal::usb::isUsbBootMode() ? "logo_usb.png" : "logo.png";
|
||||
}
|
||||
const auto logo_path = lvgl::PATH_PREFIX + paths->getAssetsPath(logo);
|
||||
TT_LOG_I(TAG, "%s", logo_path.c_str());
|
||||
LOGGER.info("{}", logo_path);
|
||||
lv_image_set_src(image, logo_path.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/Assets.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/service/espnow/EspNow.h>
|
||||
|
||||
#include "Tactility/lvgl/LvglSync.h"
|
||||
@@ -18,7 +19,7 @@
|
||||
|
||||
namespace tt::app::chat {
|
||||
|
||||
constexpr const char* TAG = "ChatApp";
|
||||
static const auto LOGGER = Logger("ChatApp");
|
||||
constexpr uint8_t BROADCAST_ADDRESS[ESP_NOW_ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
|
||||
class ChatApp : public App {
|
||||
@@ -46,7 +47,7 @@ class ChatApp : public App {
|
||||
self->addMessage(msg);
|
||||
|
||||
if (!service::espnow::send(BROADCAST_ADDRESS, reinterpret_cast<const uint8_t*>(msg), msg_len)) {
|
||||
TT_LOG_E(TAG, "Failed to send message");
|
||||
LOGGER.error("Failed to send message");
|
||||
}
|
||||
|
||||
lv_textarea_set_text(self->input_field, "");
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include "Tactility/hal/Device.h"
|
||||
|
||||
#include <Tactility/app/crashdiagnostics/QrHelpers.h>
|
||||
#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>
|
||||
|
||||
#define TAG "CrashDiagnostics"
|
||||
|
||||
namespace tt::app::crashdiagnostics {
|
||||
|
||||
static const auto LOGGER = Logger("CrashDiagnostics");
|
||||
|
||||
extern const AppManifest manifest;
|
||||
|
||||
void onContinuePressed(TT_UNUSED lv_event_t* event) {
|
||||
@@ -44,38 +44,38 @@ public:
|
||||
lv_obj_align(bottom_label, LV_ALIGN_BOTTOM_MID, 0, -2);
|
||||
|
||||
std::string url = getUrlFromCrashData();
|
||||
TT_LOG_I(TAG, "%s", url.c_str());
|
||||
LOGGER.info("{}", url);
|
||||
size_t url_length = url.length();
|
||||
|
||||
int qr_version;
|
||||
if (!getQrVersionForBinaryDataLength(url_length, qr_version)) {
|
||||
TT_LOG_E(TAG, "QR is too large");
|
||||
LOGGER.error("QR is too large");
|
||||
stop(manifest.appId);
|
||||
return;
|
||||
}
|
||||
|
||||
TT_LOG_I(TAG, "QR version %d (length: %d)", qr_version, url_length);
|
||||
LOGGER.info("QR version {} (length: {})", qr_version, url_length);
|
||||
auto qrcodeData = std::make_shared<uint8_t[]>(qrcode_getBufferSize(qr_version));
|
||||
if (qrcodeData == nullptr) {
|
||||
TT_LOG_E(TAG, "Failed to allocate QR buffer");
|
||||
stop();
|
||||
LOGGER.error("Failed to allocate QR buffer");
|
||||
stop(manifest.appId);
|
||||
return;
|
||||
}
|
||||
|
||||
QRCode qrcode;
|
||||
TT_LOG_I(TAG, "QR init text");
|
||||
LOGGER.info("QR init text");
|
||||
if (qrcode_initText(&qrcode, qrcodeData.get(), qr_version, ECC_LOW, url.c_str()) != 0) {
|
||||
TT_LOG_E(TAG, "QR init text failed");
|
||||
LOGGER.error("QR init text failed");
|
||||
stop(manifest.appId);
|
||||
return;
|
||||
}
|
||||
|
||||
TT_LOG_I(TAG, "QR size: %d", qrcode.size);
|
||||
LOGGER.info("QR size: {}", 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;
|
||||
TT_LOG_I(TAG, "Create canvas");
|
||||
LOGGER.info("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 {
|
||||
TT_LOG_E(TAG, "QR code won't fit screen");
|
||||
LOGGER.error("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);
|
||||
|
||||
TT_LOG_I(TAG, "Create draw buffer");
|
||||
LOGGER.info("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) {
|
||||
TT_LOG_E(TAG, "Draw buffer alloc");
|
||||
LOGGER.error("Failed to allocate draw buffer");
|
||||
stop(manifest.appId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#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>
|
||||
@@ -17,7 +18,7 @@
|
||||
|
||||
namespace tt::app::development {
|
||||
|
||||
constexpr const char* TAG = "Development";
|
||||
static const auto LOGGER = Logger("Development");
|
||||
extern const AppManifest manifest;
|
||||
|
||||
class DevelopmentApp final : public App {
|
||||
@@ -84,7 +85,7 @@ public:
|
||||
void onCreate(AppContext& appContext) override {
|
||||
service = service::development::findService();
|
||||
if (service == nullptr) {
|
||||
TT_LOG_E(TAG, "Service not found");
|
||||
LOGGER.error("Service not found");
|
||||
stop(manifest.appId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
#include <Tactility/settings/DisplaySettings.h>
|
||||
#include <Tactility/Assets.h>
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
namespace tt::app::display {
|
||||
|
||||
constexpr auto* TAG = "Display";
|
||||
static const auto LOGGER = Logger("Display");
|
||||
|
||||
static std::shared_ptr<hal::display::DisplayDevice> getHalDisplay() {
|
||||
return hal::findFirstDevice<hal::display::DisplayDevice>(hal::Device::Type::Display);
|
||||
@@ -54,7 +55,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);
|
||||
TT_LOG_I(TAG, "Selected %ld", selected_index);
|
||||
LOGGER.info("Selected {}", selected_index);
|
||||
auto selected_orientation = static_cast<settings::display::Orientation>(selected_index);
|
||||
if (selected_orientation != app->displaySettings.orientation) {
|
||||
app->displaySettings.orientation = selected_orientation;
|
||||
|
||||
@@ -3,18 +3,19 @@
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/file/FileLock.h>
|
||||
#include <Tactility/hal/sdcard/SdCardDevice.h>
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/kernel/Platform.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
#include <dirent.h>
|
||||
|
||||
namespace tt::app::files {
|
||||
|
||||
constexpr auto* TAG = "Files";
|
||||
static const auto LOGGER = Logger("Files");
|
||||
|
||||
State::State() {
|
||||
if (kernel::getPlatform() == kernel::PlatformSimulator) {
|
||||
@@ -22,7 +23,7 @@ State::State() {
|
||||
if (getcwd(cwd, sizeof(cwd)) != nullptr) {
|
||||
setEntriesForPath(cwd);
|
||||
} else {
|
||||
TT_LOG_E(TAG, "Failed to get current work directory files");
|
||||
LOGGER.error("Failed to get current work directory files");
|
||||
setEntriesForPath("/");
|
||||
}
|
||||
} else {
|
||||
@@ -37,11 +38,11 @@ std::string State::getSelectedChildPath() const {
|
||||
bool State::setEntriesForPath(const std::string& path) {
|
||||
auto lock = mutex.asScopedLock();
|
||||
if (!lock.lock(100)) {
|
||||
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "setEntriesForPath");
|
||||
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "setEntriesForPath");
|
||||
return false;
|
||||
}
|
||||
|
||||
TT_LOG_I(TAG, "Changing path: %s -> %s", current_path.c_str(), path.c_str());
|
||||
LOGGER.info("Changing path: {} -> {}", current_path, path);
|
||||
|
||||
/**
|
||||
* On PC, the root entry point ("/") is a folder.
|
||||
@@ -49,7 +50,7 @@ bool State::setEntriesForPath(const std::string& path) {
|
||||
*/
|
||||
bool get_mount_points = (kernel::getPlatform() == kernel::PlatformEsp) && (path == "/");
|
||||
if (get_mount_points) {
|
||||
TT_LOG_I(TAG, "Setting custom root");
|
||||
LOGGER.info("Setting custom root");
|
||||
dir_entries = file::getMountPoints();
|
||||
current_path = path;
|
||||
selected_child_entry = "";
|
||||
@@ -59,13 +60,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) {
|
||||
TT_LOG_I(TAG, "%s has %u entries", path.c_str(), count);
|
||||
LOGGER.info("{} has {} entries", path, count);
|
||||
current_path = path;
|
||||
selected_child_entry = "";
|
||||
action = ActionNone;
|
||||
return true;
|
||||
} else {
|
||||
TT_LOG_E(TAG, "Failed to fetch entries for %s", path.c_str());
|
||||
LOGGER.error("Failed to fetch entries for {}", path);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -73,7 +74,7 @@ bool State::setEntriesForPath(const std::string& path) {
|
||||
|
||||
bool State::setEntriesForChildPath(const std::string& childPath) {
|
||||
auto path = file::getChildPath(current_path, childPath);
|
||||
TT_LOG_I(TAG, "Navigating from %s to %s", current_path.c_str(), path.c_str());
|
||||
LOGGER.info("Navigating from {} to {}", current_path, path);
|
||||
return setEntriesForPath(path);
|
||||
}
|
||||
|
||||
@@ -90,4 +91,5 @@ bool State::getDirent(uint32_t index, dirent& dirent) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,21 +2,21 @@
|
||||
#include <Tactility/app/files/SupportedFiles.h>
|
||||
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/file/FileLock.h>
|
||||
#include <Tactility/app/alertdialog/AlertDialog.h>
|
||||
#include <Tactility/app/imageviewer/ImageViewer.h>
|
||||
#include <Tactility/app/inputdialog/InputDialog.h>
|
||||
#include <Tactility/app/notes/Notes.h>
|
||||
#include <Tactility/app/ElfApp.h>
|
||||
#include <Tactility/kernel/Platform.h>
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/StringUtils.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
namespace tt::app::files {
|
||||
|
||||
constexpr auto* TAG = "Files";
|
||||
static const auto LOGGER = Logger("Files");
|
||||
|
||||
// region Callbacks
|
||||
|
||||
@@ -84,11 +84,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) {
|
||||
TT_LOG_E(TAG, "Failed to get current working directory");
|
||||
LOGGER.error("Failed to get current working directory");
|
||||
return;
|
||||
}
|
||||
if (!file_path.starts_with(cwd)) {
|
||||
TT_LOG_E(TAG, "Can only work with files in working directory %s", cwd);
|
||||
LOGGER.error("Can only work with files in working directory {}", cwd);
|
||||
return;
|
||||
}
|
||||
processed_filepath = file_path.substr(strlen(cwd));
|
||||
@@ -96,7 +96,7 @@ void View::viewFile(const std::string& path, const std::string& filename) {
|
||||
processed_filepath = file_path;
|
||||
}
|
||||
|
||||
TT_LOG_I(TAG, "Clicked %s", file_path.c_str());
|
||||
LOGGER.info("Clicked {}", file_path);
|
||||
|
||||
if (isSupportedAppFile(filename)) {
|
||||
#ifdef ESP_PLATFORM
|
||||
@@ -116,7 +116,7 @@ void View::viewFile(const std::string& path, const std::string& filename) {
|
||||
notes::start(processed_filepath.substr(1));
|
||||
}
|
||||
} else {
|
||||
TT_LOG_W(TAG, "opening files of this type is not supported");
|
||||
LOGGER.warn("Opening files of this type is not supported");
|
||||
}
|
||||
|
||||
onNavigate();
|
||||
@@ -125,7 +125,7 @@ void View::viewFile(const std::string& path, const std::string& filename) {
|
||||
void View::onDirEntryPressed(uint32_t index) {
|
||||
dirent dir_entry;
|
||||
if (state->getDirent(index, dir_entry)) {
|
||||
TT_LOG_I(TAG, "Pressed %s %d", dir_entry.d_name, dir_entry.d_type);
|
||||
LOGGER.info("Pressed {} {}", dir_entry.d_name, dir_entry.d_type);
|
||||
state->setSelectedChildEntry(dir_entry.d_name);
|
||||
using namespace tt::file;
|
||||
switch (dir_entry.d_type) {
|
||||
@@ -136,7 +136,7 @@ void View::onDirEntryPressed(uint32_t index) {
|
||||
update();
|
||||
break;
|
||||
case TT_DT_LNK:
|
||||
TT_LOG_W(TAG, "opening links is not supported");
|
||||
LOGGER.warn("opening links is not supported");
|
||||
break;
|
||||
case TT_DT_REG:
|
||||
viewFile(state->getCurrentPath(), dir_entry.d_name);
|
||||
@@ -155,7 +155,7 @@ void View::onDirEntryPressed(uint32_t index) {
|
||||
void View::onDirEntryLongPressed(int32_t index) {
|
||||
dirent dir_entry;
|
||||
if (state->getDirent(index, dir_entry)) {
|
||||
TT_LOG_I(TAG, "Pressed %s %d", dir_entry.d_name, dir_entry.d_type);
|
||||
LOGGER.info("Pressed {} {}", dir_entry.d_name, dir_entry.d_type);
|
||||
state->setSelectedChildEntry(dir_entry.d_name);
|
||||
using namespace file;
|
||||
switch (dir_entry.d_type) {
|
||||
@@ -164,7 +164,7 @@ void View::onDirEntryLongPressed(int32_t index) {
|
||||
showActionsForDirectory();
|
||||
break;
|
||||
case TT_DT_LNK:
|
||||
TT_LOG_W(TAG, "opening links is not supported");
|
||||
LOGGER.warn("Opening links is not supported");
|
||||
break;
|
||||
case TT_DT_REG:
|
||||
showActionsForFile();
|
||||
@@ -228,7 +228,7 @@ void View::createDirEntryWidget(lv_obj_t* list, dirent& dir_entry) {
|
||||
|
||||
void View::onNavigateUpPressed() {
|
||||
if (state->getCurrentPath() != "/") {
|
||||
TT_LOG_I(TAG, "Navigating upwards");
|
||||
LOGGER.info("Navigating upwards");
|
||||
std::string new_absolute_path;
|
||||
if (string::getPathParent(state->getCurrentPath(), new_absolute_path)) {
|
||||
state->setEntriesForPath(new_absolute_path);
|
||||
@@ -240,14 +240,14 @@ void View::onNavigateUpPressed() {
|
||||
|
||||
void View::onRenamePressed() {
|
||||
std::string entry_name = state->getSelectedChildEntry();
|
||||
TT_LOG_I(TAG, "Pending rename %s", entry_name.c_str());
|
||||
LOGGER.info("Pending rename {}", entry_name);
|
||||
state->setPendingAction(State::ActionRename);
|
||||
inputdialog::start("Rename", "", entry_name);
|
||||
}
|
||||
|
||||
void View::onDeletePressed() {
|
||||
std::string file_path = state->getSelectedChildPath();
|
||||
TT_LOG_I(TAG, "Pending delete %s", file_path.c_str());
|
||||
LOGGER.info("Pending delete {}", file_path);
|
||||
state->setPendingAction(State::ActionDelete);
|
||||
std::string message = "Do you want to delete this?\n" + file_path;
|
||||
const std::vector<std::string> choices = { "Yes", "No" };
|
||||
@@ -255,13 +255,13 @@ void View::onDeletePressed() {
|
||||
}
|
||||
|
||||
void View::onNewFilePressed() {
|
||||
TT_LOG_I(TAG, "Creating new file");
|
||||
LOGGER.info("Creating new file");
|
||||
state->setPendingAction(State::ActionCreateFile);
|
||||
inputdialog::start("New File", "Enter filename:", "");
|
||||
}
|
||||
|
||||
void View::onNewFolderPressed() {
|
||||
TT_LOG_I(TAG, "Creating new folder");
|
||||
LOGGER.info("Creating new folder");
|
||||
state->setPendingAction(State::ActionCreateFolder);
|
||||
inputdialog::start("New Folder", "Enter folder name:", "");
|
||||
}
|
||||
@@ -295,7 +295,7 @@ void View::update() {
|
||||
|
||||
state->withEntries([this](const std::vector<dirent>& entries) {
|
||||
for (auto entry : entries) {
|
||||
TT_LOG_D(TAG, "Entry: %s %d", entry.d_name, entry.d_type);
|
||||
LOGGER.debug("Entry: {} {}", entry.d_name, entry.d_type);
|
||||
createDirEntryWidget(dir_entry_list, entry);
|
||||
}
|
||||
});
|
||||
@@ -306,7 +306,7 @@ void View::update() {
|
||||
lv_obj_remove_flag(navigate_up_button, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
} else {
|
||||
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "lvgl");
|
||||
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "lvgl");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,20 +369,20 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
|
||||
}
|
||||
|
||||
std::string filepath = state->getSelectedChildPath();
|
||||
TT_LOG_I(TAG, "Result for %s", filepath.c_str());
|
||||
LOGGER.info("Result for {}", filepath);
|
||||
|
||||
switch (state->getPendingAction()) {
|
||||
case State::ActionDelete: {
|
||||
if (alertdialog::getResultIndex(*bundle) == 0) {
|
||||
if (file::isDirectory(filepath)) {
|
||||
if (!file::deleteRecursively(filepath)) {
|
||||
TT_LOG_W(TAG, "Failed to delete %s", filepath.c_str());
|
||||
LOGGER.warn("Failed to delete {}", filepath);
|
||||
}
|
||||
} else if (file::isFile(filepath)) {
|
||||
auto lock = file::getLock(filepath);
|
||||
lock->lock();
|
||||
if (remove(filepath.c_str()) <= 0) {
|
||||
TT_LOG_W(TAG, "Failed to delete %s", filepath.c_str());
|
||||
LOGGER.warn("Failed to delete {}", filepath);
|
||||
}
|
||||
lock->unlock();
|
||||
}
|
||||
@@ -399,9 +399,9 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
|
||||
lock->lock();
|
||||
std::string rename_to = file::getChildPath(state->getCurrentPath(), new_name);
|
||||
if (rename(filepath.c_str(), rename_to.c_str())) {
|
||||
TT_LOG_I(TAG, "Renamed \"%s\" to \"%s\"", filepath.c_str(), rename_to.c_str());
|
||||
LOGGER.info("Renamed \"{}\" to \"{}\"", filepath, rename_to);
|
||||
} else {
|
||||
TT_LOG_E(TAG, "Failed to rename \"%s\" to \"%s\"", filepath.c_str(), rename_to.c_str());
|
||||
LOGGER.error("Failed to rename \"{}\" to \"{}\"", filepath, rename_to);
|
||||
}
|
||||
lock->unlock();
|
||||
|
||||
@@ -420,7 +420,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) {
|
||||
TT_LOG_W(TAG, "File already exists: \"%s\"", new_file_path.c_str());
|
||||
LOGGER.warn("File already exists: \"{}\"", new_file_path);
|
||||
lock->unlock();
|
||||
break;
|
||||
}
|
||||
@@ -428,9 +428,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);
|
||||
TT_LOG_I(TAG, "Created file \"%s\"", new_file_path.c_str());
|
||||
LOGGER.info("Created file \"{}\"", new_file_path);
|
||||
} else {
|
||||
TT_LOG_E(TAG, "Failed to create file \"%s\"", new_file_path.c_str());
|
||||
LOGGER.error("Failed to create file \"{}\"", new_file_path);
|
||||
}
|
||||
lock->unlock();
|
||||
|
||||
@@ -449,15 +449,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) {
|
||||
TT_LOG_W(TAG, "Folder already exists: \"%s\"", new_folder_path.c_str());
|
||||
LOGGER.warn("Folder already exists: \"{}\"", new_folder_path);
|
||||
lock->unlock();
|
||||
break;
|
||||
}
|
||||
|
||||
if (mkdir(new_folder_path.c_str(), 0755) == 0) {
|
||||
TT_LOG_I(TAG, "Created folder \"%s\"", new_folder_path.c_str());
|
||||
LOGGER.info("Created folder \"{}\"", new_folder_path);
|
||||
} else {
|
||||
TT_LOG_E(TAG, "Failed to create folder \"%s\"", new_folder_path.c_str());
|
||||
LOGGER.error("Failed to create folder \"{}\"", new_folder_path);
|
||||
}
|
||||
lock->unlock();
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <Tactility/file/File.h>
|
||||
#include "Tactility/hal/sdcard/SdCardDevice.h"
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/kernel/Platform.h>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace tt::app::fileselection {
|
||||
|
||||
constexpr auto* TAG = "FileSelection";
|
||||
static const auto LOGGER = Logger("FileSelection");
|
||||
|
||||
State::State() {
|
||||
if (kernel::getPlatform() == kernel::PlatformSimulator) {
|
||||
@@ -21,7 +21,7 @@ State::State() {
|
||||
if (getcwd(cwd, sizeof(cwd)) != nullptr) {
|
||||
setEntriesForPath(cwd);
|
||||
} else {
|
||||
TT_LOG_E(TAG, "Failed to get current work directory files");
|
||||
LOGGER.error("Failed to get current work directory files");
|
||||
setEntriesForPath("/");
|
||||
}
|
||||
} else {
|
||||
@@ -34,7 +34,7 @@ std::string State::getSelectedChildPath() const {
|
||||
}
|
||||
|
||||
bool State::setEntriesForPath(const std::string& path) {
|
||||
TT_LOG_I(TAG, "Changing path: %s -> %s", current_path.c_str(), path.c_str());
|
||||
LOGGER.info("Changing path: {} -> {}", current_path, path);
|
||||
|
||||
/**
|
||||
* ESP32 does not have a root directory, so we have to create it manually.
|
||||
@@ -42,7 +42,7 @@ bool State::setEntriesForPath(const std::string& path) {
|
||||
*/
|
||||
bool show_custom_root = (kernel::getPlatform() == kernel::PlatformEsp) && (path == "/");
|
||||
if (show_custom_root) {
|
||||
TT_LOG_I(TAG, "Setting custom root");
|
||||
LOGGER.info("Setting custom root");
|
||||
dir_entries = file::getMountPoints();
|
||||
current_path = path;
|
||||
selected_child_entry = "";
|
||||
@@ -51,12 +51,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) {
|
||||
TT_LOG_I(TAG, "%s has %u entries", path.c_str(), count);
|
||||
LOGGER.info("{} has {} entries", path, count);
|
||||
current_path = path;
|
||||
selected_child_entry = "";
|
||||
return true;
|
||||
} else {
|
||||
TT_LOG_E(TAG, "Failed to fetch entries for %s", path.c_str());
|
||||
LOGGER.error("Failed to fetch entries for {}", path);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ bool State::setEntriesForPath(const std::string& path) {
|
||||
|
||||
bool State::setEntriesForChildPath(const std::string& childPath) {
|
||||
auto path = file::getChildPath(current_path, childPath);
|
||||
TT_LOG_I(TAG, "Navigating from %s to %s", current_path.c_str(), path.c_str());
|
||||
LOGGER.info("Navigating from {} to {}", current_path, path);
|
||||
return setEntriesForPath(path);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
#include <Tactility/app/fileselection/View.h>
|
||||
|
||||
#include <Tactility/app/alertdialog/AlertDialog.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/StringUtils.h>
|
||||
|
||||
#include <Tactility/kernel/Platform.h>
|
||||
#include <Tactility/StringUtils.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -18,7 +19,7 @@
|
||||
|
||||
namespace tt::app::fileselection {
|
||||
|
||||
constexpr auto* TAG = "FileSelection";
|
||||
const static Logger LOGGER = Logger("FileSelection");
|
||||
|
||||
// region Callbacks
|
||||
|
||||
@@ -45,11 +46,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) {
|
||||
TT_LOG_E(TAG, "Failed to get current working directory");
|
||||
LOGGER.error("Failed to get current working directory");
|
||||
return;
|
||||
}
|
||||
if (!file_path.starts_with(cwd)) {
|
||||
TT_LOG_E(TAG, "Can only work with files in working directory %s", cwd);
|
||||
LOGGER.error("Can only work with files in working directory {}", cwd);
|
||||
return;
|
||||
}
|
||||
processed_filepath = file_path.substr(strlen(cwd));
|
||||
@@ -57,7 +58,7 @@ void View::onTapFile(const std::string& path, const std::string& filename) {
|
||||
processed_filepath = file_path;
|
||||
}
|
||||
|
||||
TT_LOG_I(TAG, "Clicked %s", processed_filepath.c_str());
|
||||
LOGGER.info("Clicked {}", processed_filepath);
|
||||
|
||||
lv_textarea_set_text(path_textarea, processed_filepath.c_str());
|
||||
}
|
||||
@@ -65,7 +66,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)) {
|
||||
TT_LOG_I(TAG, "Pressed %s %d", dir_entry.d_name, dir_entry.d_type);
|
||||
LOGGER.info("Pressed {} {}", dir_entry.d_name, dir_entry.d_type);
|
||||
state->setSelectedChildEntry(dir_entry.d_name);
|
||||
using namespace tt::file;
|
||||
switch (dir_entry.d_type) {
|
||||
@@ -76,7 +77,7 @@ void View::onDirEntryPressed(uint32_t index) {
|
||||
update();
|
||||
break;
|
||||
case TT_DT_LNK:
|
||||
TT_LOG_W(TAG, "opening links is not supported");
|
||||
LOGGER.warn("Opening links is not supported");
|
||||
break;
|
||||
case TT_DT_REG:
|
||||
onTapFile(state->getCurrentPath(), dir_entry.d_name);
|
||||
@@ -94,7 +95,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) {
|
||||
TT_LOG_W(TAG, "Select pressed, but not path found in textarea");
|
||||
LOGGER.warn("Select pressed, but not path found in textarea");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -138,7 +139,7 @@ void View::createDirEntryWidget(lv_obj_t* list, dirent& dir_entry) {
|
||||
|
||||
void View::onNavigateUpPressed() {
|
||||
if (state->getCurrentPath() != "/") {
|
||||
TT_LOG_I(TAG, "Navigating upwards");
|
||||
LOGGER.info("Navigating upwards");
|
||||
std::string new_absolute_path;
|
||||
if (string::getPathParent(state->getCurrentPath(), new_absolute_path)) {
|
||||
state->setEntriesForPath(new_absolute_path);
|
||||
@@ -159,7 +160,7 @@ void View::update() {
|
||||
|
||||
state->withEntries([this](const std::vector<dirent>& entries) {
|
||||
for (auto entry : entries) {
|
||||
TT_LOG_D(TAG, "Entry: %s %d", entry.d_name, entry.d_type);
|
||||
LOGGER.debug("Entry: {} {}", entry.d_name, entry.d_type);
|
||||
createDirEntryWidget(dir_entry_list, entry);
|
||||
}
|
||||
});
|
||||
@@ -170,7 +171,7 @@ void View::update() {
|
||||
lv_obj_remove_flag(navigate_up_button, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
} else {
|
||||
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "lvgl");
|
||||
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "lvgl");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#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>
|
||||
@@ -23,7 +24,7 @@ extern const AppManifest manifest;
|
||||
|
||||
class GpsSettingsApp final : public App {
|
||||
|
||||
static constexpr auto* TAG = "GpsSettings";
|
||||
const Logger logger = Logger("GpsSettings");
|
||||
|
||||
std::unique_ptr<Timer> timer;
|
||||
std::shared_ptr<GpsSettingsApp*> appReference = std::make_shared<GpsSettingsApp*>(this);
|
||||
@@ -92,8 +93,8 @@ 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)) {
|
||||
TT_LOG_I(TAG, "Found service and configs %d %d", index, configurations.size());
|
||||
if (index <= configurations.size()) {
|
||||
Logger("GpsSettings").info("Found service and configs {} {}", index, configurations.size());
|
||||
if (index < configurations.size()) {
|
||||
if (gps_service->removeGpsConfiguration(configurations[index])) {
|
||||
app->updateViews();
|
||||
} else {
|
||||
@@ -154,7 +155,7 @@ class GpsSettingsApp final : public App {
|
||||
// Update toolbar
|
||||
switch (state) {
|
||||
case service::gps::State::OnPending:
|
||||
TT_LOG_D(TAG, "OnPending");
|
||||
logger.debug("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);
|
||||
@@ -163,7 +164,7 @@ class GpsSettingsApp final : public App {
|
||||
lv_obj_add_flag(addGpsWrapper, LV_OBJ_FLAG_HIDDEN);
|
||||
break;
|
||||
case service::gps::State::On:
|
||||
TT_LOG_D(TAG, "On");
|
||||
logger.debug("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);
|
||||
@@ -172,7 +173,7 @@ class GpsSettingsApp final : public App {
|
||||
lv_obj_add_flag(addGpsWrapper, LV_OBJ_FLAG_HIDDEN);
|
||||
break;
|
||||
case service::gps::State::OffPending:
|
||||
TT_LOG_D(TAG, "OffPending");
|
||||
logger.debug("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);
|
||||
@@ -181,7 +182,7 @@ class GpsSettingsApp final : public App {
|
||||
lv_obj_remove_flag(addGpsWrapper, LV_OBJ_FLAG_HIDDEN);
|
||||
break;
|
||||
case service::gps::State::Off:
|
||||
TT_LOG_D(TAG, "Off");
|
||||
logger.debug("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);
|
||||
@@ -254,11 +255,11 @@ class GpsSettingsApp final : public App {
|
||||
if (wants_on != is_on) {
|
||||
// start/stop are potentially blocking calls, so we use a dispatcher to not block the UI
|
||||
if (wants_on) {
|
||||
getMainDispatcher().dispatch([this]() {
|
||||
getMainDispatcher().dispatch([this] {
|
||||
service->startReceiving();
|
||||
});
|
||||
} else {
|
||||
getMainDispatcher().dispatch([this]() {
|
||||
getMainDispatcher().dispatch([this] {
|
||||
service->stopReceiving();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
#include <Tactility/app/i2cscanner/I2cScannerPrivate.h>
|
||||
#include <Tactility/app/i2cscanner/I2cHelpers.h>
|
||||
|
||||
#include <Tactility/Preferences.h>
|
||||
#include <Tactility/Assets.h>
|
||||
#include <Tactility/app/AppContext.h>
|
||||
#include <Tactility/hal/i2c/I2cDevice.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/Assets.h>
|
||||
#include <Tactility/Preferences.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/Timer.h>
|
||||
|
||||
#include <format>
|
||||
|
||||
@@ -21,6 +22,8 @@ extern const AppManifest manifest;
|
||||
|
||||
class I2cScannerApp final : public App {
|
||||
|
||||
const Logger logger = Logger("I2cScanner");
|
||||
|
||||
static constexpr auto* START_SCAN_TEXT = "Scan";
|
||||
static constexpr auto* STOP_SCAN_TEXT = "Stop scan";
|
||||
|
||||
@@ -189,7 +192,7 @@ bool I2cScannerApp::getPort(i2c_port_t* outPort) {
|
||||
mutex.unlock();
|
||||
return true;
|
||||
} else {
|
||||
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "getPort");
|
||||
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "getPort");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -200,7 +203,7 @@ bool I2cScannerApp::addAddressToList(uint8_t address) {
|
||||
mutex.unlock();
|
||||
return true;
|
||||
} else {
|
||||
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "addAddressToList");
|
||||
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "addAddressToList");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -216,24 +219,24 @@ bool I2cScannerApp::shouldStopScanTimer() {
|
||||
}
|
||||
|
||||
void I2cScannerApp::onScanTimer() {
|
||||
TT_LOG_I(TAG, "Scan thread started");
|
||||
logger.info("Scan thread started");
|
||||
|
||||
i2c_port_t safe_port;
|
||||
if (!getPort(&safe_port)) {
|
||||
TT_LOG_E(TAG, "Failed to get I2C port");
|
||||
logger.error("Failed to get I2C port");
|
||||
onScanTimerFinished();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hal::i2c::isStarted(safe_port)) {
|
||||
TT_LOG_E(TAG, "I2C port not started");
|
||||
logger.error("I2C port not started");
|
||||
onScanTimerFinished();
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint8_t address = 0; address < 128; ++address) {
|
||||
if (hal::i2c::masterHasDeviceAtAddress(port, address, 10 / portTICK_PERIOD_MS)) {
|
||||
TT_LOG_I(TAG, "Found device at address 0x%02X", address);
|
||||
if (hal::i2c::masterHasDeviceAtAddress(safe_port, address, 10 / portTICK_PERIOD_MS)) {
|
||||
logger.info("Found device at address 0x{:02X}", address);
|
||||
if (!shouldStopScanTimer()) {
|
||||
addAddressToList(address);
|
||||
} else {
|
||||
@@ -246,11 +249,11 @@ void I2cScannerApp::onScanTimer() {
|
||||
}
|
||||
}
|
||||
|
||||
TT_LOG_I(TAG, "Scan thread finalizing");
|
||||
logger.info("Scan thread finalizing");
|
||||
|
||||
onScanTimerFinished();
|
||||
|
||||
TT_LOG_I(TAG, "Scan timer done");
|
||||
logger.info("Scan timer done");
|
||||
}
|
||||
|
||||
bool I2cScannerApp::hasScanThread() {
|
||||
@@ -261,7 +264,7 @@ bool I2cScannerApp::hasScanThread() {
|
||||
return has_thread;
|
||||
} else {
|
||||
// Unsafe way
|
||||
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "hasScanTimer");
|
||||
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "hasScanTimer");
|
||||
return scanTimer != nullptr;
|
||||
}
|
||||
}
|
||||
@@ -284,7 +287,7 @@ void I2cScannerApp::startScanning() {
|
||||
scanTimer->start();
|
||||
mutex.unlock();
|
||||
} else {
|
||||
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "startScanning");
|
||||
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "startScanning");
|
||||
}
|
||||
}
|
||||
void I2cScannerApp::stopScanning() {
|
||||
@@ -293,7 +296,7 @@ void I2cScannerApp::stopScanning() {
|
||||
scanState = ScanStateStopped;
|
||||
mutex.unlock();
|
||||
} else {
|
||||
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED);
|
||||
logger.error(LOG_MESSAGE_MUTEX_LOCK_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +317,7 @@ void I2cScannerApp::selectBus(int32_t selected) {
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
TT_LOG_I(TAG, "Selected %ld", selected);
|
||||
logger.info("Selected {}", selected);
|
||||
setLastBusIndex(selected);
|
||||
|
||||
startScanning();
|
||||
@@ -377,7 +380,7 @@ void I2cScannerApp::updateViews() {
|
||||
|
||||
mutex.unlock();
|
||||
} else {
|
||||
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "updateViews");
|
||||
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "updateViews");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,7 +389,7 @@ void I2cScannerApp::updateViewsSafely() {
|
||||
updateViews();
|
||||
lvgl::unlock();
|
||||
} else {
|
||||
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "updateViewsSafely");
|
||||
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "updateViewsSafely");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,7 +402,7 @@ void I2cScannerApp::onScanTimerFinished() {
|
||||
|
||||
updateViewsSafely();
|
||||
} else {
|
||||
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "onScanTimerFinished");
|
||||
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "onScanTimerFinished");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <Tactility/lvgl/Style.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/StringUtils.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
@@ -11,7 +11,7 @@ namespace tt::app::imageviewer {
|
||||
|
||||
extern const AppManifest manifest;
|
||||
|
||||
constexpr auto* TAG = "ImageViewer";
|
||||
static const auto LOGGER = Logger("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;
|
||||
TT_LOG_I(TAG, "Opening %s", prefixed_path.c_str());
|
||||
LOGGER.info("Opening {}", prefixed_path);
|
||||
lv_img_set_src(image, prefixed_path.c_str());
|
||||
auto path = string::getLastPathSegment(file_argument);
|
||||
lv_label_set_text(file_label, path.c_str());
|
||||
|
||||
@@ -15,7 +15,7 @@ constexpr auto* RESULT_BUNDLE_KEY_RESULT = "result";
|
||||
|
||||
constexpr auto* DEFAULT_TITLE = "Input";
|
||||
|
||||
constexpr auto* TAG = "InputDialog";
|
||||
static const auto LOGGER = Logger("InputDialog");
|
||||
|
||||
extern const AppManifest manifest;
|
||||
class InputDialogApp;
|
||||
@@ -62,7 +62,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;
|
||||
TT_LOG_I(TAG, "Selected item at index %d", index);
|
||||
LOGGER.info("Selected item at index {}", index);
|
||||
if (index == 0) {
|
||||
auto bundle = std::make_unique<Bundle>();
|
||||
const char* text = lv_textarea_get_text((lv_obj_t*)user_data);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace tt::app::launcher {
|
||||
|
||||
constexpr auto* TAG = "Launcher";
|
||||
static const auto LOGGER = Logger("Launcher");
|
||||
|
||||
static int getButtonSize(hal::UiScale scale) {
|
||||
if (scale == hal::UiScale::Smallest) {
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
void onCreate(TT_UNUSED AppContext& app) override {
|
||||
settings::BootSettings boot_properties;
|
||||
if (settings::loadBootSettings(boot_properties) && !boot_properties.autoStartAppId.empty()) {
|
||||
TT_LOG_I(TAG, "Starting %s", boot_properties.autoStartAppId.c_str());
|
||||
LOGGER.info("Starting {}", boot_properties.autoStartAppId);
|
||||
start(boot_properties.autoStartAppId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace tt::app::notes {
|
||||
|
||||
constexpr auto* TAG = "Notes";
|
||||
static const auto LOGGER = Logger("Notes");
|
||||
constexpr auto* NOTES_FILE_ARGUMENT = "file";
|
||||
|
||||
class NotesApp final : public App {
|
||||
@@ -52,11 +52,11 @@ class NotesApp final : public App {
|
||||
saveBuffer = lv_textarea_get_text(uiNoteText);
|
||||
lvgl::getSyncLock()->unlock();
|
||||
saveFileLaunchId = fileselection::startForExistingOrNewFile();
|
||||
TT_LOG_I(TAG, "launched with id %d", loadFileLaunchId);
|
||||
LOGGER.info("launched with id {}", saveFileLaunchId);
|
||||
break;
|
||||
case 3: // Load
|
||||
loadFileLaunchId = fileselection::startForExistingFile();
|
||||
TT_LOG_I(TAG, "launched with id %d", loadFileLaunchId);
|
||||
LOGGER.info("launched with id {}", loadFileLaunchId);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -64,7 +64,7 @@ class NotesApp final : public App {
|
||||
if (obj == cont) return;
|
||||
if (lv_obj_get_child(cont, 1)) {
|
||||
saveFileLaunchId = fileselection::startForExistingOrNewFile();
|
||||
TT_LOG_I(TAG, "launched with id %d", loadFileLaunchId);
|
||||
LOGGER.info("launched with id {}", saveFileLaunchId);
|
||||
} else { //Reset
|
||||
resetFileContent();
|
||||
}
|
||||
@@ -91,7 +91,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;
|
||||
TT_LOG_I(TAG, "Loaded from %s", path.c_str());
|
||||
LOGGER.info("Loaded from {}", path);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -101,7 +101,7 @@ class NotesApp final : public App {
|
||||
bool result = false;
|
||||
file::getLock(path)->withLock([&result, this, path] {
|
||||
if (file::writeString(path, saveBuffer.c_str())) {
|
||||
TT_LOG_I(TAG, "Saved to %s", path.c_str());
|
||||
LOGGER.info("Saved to {}", path);
|
||||
filePath = path;
|
||||
result = true;
|
||||
}
|
||||
@@ -186,7 +186,7 @@ class NotesApp final : public App {
|
||||
}
|
||||
|
||||
void onResult(AppContext& appContext, LaunchId launchId, Result result, std::unique_ptr<Bundle> resultData) override {
|
||||
TT_LOG_I(TAG, "Result for launch id %d", launchId);
|
||||
LOGGER.info("Result for launch id {}", launchId);
|
||||
if (launchId == loadFileLaunchId) {
|
||||
loadFileLaunchId = 0;
|
||||
if (result == Result::Ok && resultData != nullptr) {
|
||||
|
||||
@@ -9,15 +9,16 @@
|
||||
#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>
|
||||
#include <Tactility/service/screenshot/Screenshot.h>
|
||||
|
||||
constexpr auto* TAG = "Screenshot";
|
||||
|
||||
namespace tt::app::screenshot {
|
||||
|
||||
static const auto LOGGER = Logger("Screenshot");
|
||||
|
||||
extern const AppManifest manifest;
|
||||
|
||||
class ScreenshotApp final : public App {
|
||||
@@ -97,27 +98,27 @@ void ScreenshotApp::onModeSet() {
|
||||
void ScreenshotApp::onStartPressed() {
|
||||
auto service = service::screenshot::optScreenshotService();
|
||||
if (service == nullptr) {
|
||||
TT_LOG_E(TAG, "Service not found/running");
|
||||
LOGGER.error("Service not found/running");
|
||||
return;
|
||||
}
|
||||
|
||||
if (service->isTaskStarted()) {
|
||||
TT_LOG_I(TAG, "Stop screenshot");
|
||||
LOGGER.info("Stop screenshot");
|
||||
service->stop();
|
||||
} else {
|
||||
uint32_t selected = lv_dropdown_get_selected(modeDropdown);
|
||||
const char* path = lv_textarea_get_text(pathTextArea);
|
||||
if (selected == 0) {
|
||||
TT_LOG_I(TAG, "Start timed screenshots");
|
||||
LOGGER.info("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 {
|
||||
TT_LOG_W(TAG, "Ignored screenshot start because delay was 0");
|
||||
LOGGER.warn("Ignored screenshot start because delay was 0");
|
||||
}
|
||||
} else {
|
||||
TT_LOG_I(TAG, "Start app screenshots");
|
||||
LOGGER.info("Start app screenshots");
|
||||
service->startApps(path);
|
||||
}
|
||||
}
|
||||
@@ -128,7 +129,7 @@ void ScreenshotApp::onStartPressed() {
|
||||
void ScreenshotApp::updateScreenshotMode() {
|
||||
auto service = service::screenshot::optScreenshotService();
|
||||
if (service == nullptr) {
|
||||
TT_LOG_E(TAG, "Service not found/running");
|
||||
LOGGER.error("Service not found/running");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -151,7 +152,7 @@ void ScreenshotApp::updateScreenshotMode() {
|
||||
void ScreenshotApp::createModeSettingWidgets(lv_obj_t* parent) {
|
||||
auto service = service::screenshot::optScreenshotService();
|
||||
if (service == nullptr) {
|
||||
TT_LOG_E(TAG, "Service not found/running");
|
||||
LOGGER.error("Service not found/running");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -203,7 +204,7 @@ void ScreenshotApp::createFilePathWidgets(lv_obj_t* parent) {
|
||||
if (kernel::getPlatform() == kernel::PlatformEsp) {
|
||||
auto sdcard_devices = tt::hal::findDevices<tt::hal::sdcard::SdCardDevice>(tt::hal::Device::Type::SdCard);
|
||||
if (sdcard_devices.size() > 1) {
|
||||
TT_LOG_W(TAG, "Found multiple SD card devices - picking first");
|
||||
LOGGER.warn("Found multiple SD card devices - picking first");
|
||||
}
|
||||
if (!sdcard_devices.empty() && sdcard_devices.front()->isMounted()) {
|
||||
std::string lvgl_mount_path = lvgl::PATH_PREFIX + sdcard_devices.front()->getMountPath();
|
||||
|
||||
@@ -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/TactilityCore.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...";
|
||||
|
||||
constexpr auto* TAG = "SelectionDialog";
|
||||
static const auto LOGGER = Logger("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));
|
||||
TT_LOG_I(TAG, "Selected item at index %d", index);
|
||||
LOGGER.info("Selected item at index {}", 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()) {
|
||||
TT_LOG_E(TAG, "No items provided");
|
||||
LOGGER.error("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);
|
||||
TT_LOG_W(TAG, "Auto-selecting single item");
|
||||
LOGGER.warn("Auto-selecting single item");
|
||||
} else {
|
||||
size_t index = 0;
|
||||
for (const auto& item: items) {
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
}
|
||||
}
|
||||
} else {
|
||||
TT_LOG_E(TAG, "No items provided");
|
||||
LOGGER.error("No items provided");
|
||||
setResult(Result::Error);
|
||||
stop(manifest.appId);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include <Tactility/Assets.h>
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/app/timezone/TimeZone.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
#include <Tactility/settings/Time.h>
|
||||
#include <Tactility/settings/SystemSettings.h>
|
||||
@@ -12,7 +13,7 @@
|
||||
|
||||
namespace tt::app::timedatesettings {
|
||||
|
||||
constexpr auto* TAG = "TimeDate";
|
||||
static const auto LOGGER = Logger("TimeDate");
|
||||
|
||||
extern const AppManifest manifest;
|
||||
|
||||
@@ -137,7 +138,7 @@ public:
|
||||
if (result == Result::Ok && bundle != nullptr) {
|
||||
const auto name = timezone::getResultName(*bundle);
|
||||
const auto code = timezone::getResultCode(*bundle);
|
||||
TT_LOG_I(TAG, "Result name=%s code=%s", name.c_str(), code.c_str());
|
||||
LOGGER.info("Result name={} code={}", name, code);
|
||||
settings::setTimeZone(name, code);
|
||||
|
||||
if (!name.empty()) {
|
||||
|
||||
@@ -2,21 +2,23 @@
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/app/AppPaths.h>
|
||||
#include <Tactility/app/timezone/TimeZone.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <Tactility/lvgl/Lvgl.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
#include <Tactility/StringUtils.h>
|
||||
#include <Tactility/Timer.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <memory>
|
||||
|
||||
namespace tt::app::timezone {
|
||||
|
||||
constexpr auto* TAG = "TimeZone";
|
||||
static const auto LOGGER = Logger("TimeZone");
|
||||
|
||||
constexpr auto* RESULT_BUNDLE_CODE_INDEX = "code";
|
||||
constexpr auto* RESULT_BUNDLE_NAME_INDEX = "name";
|
||||
|
||||
@@ -96,7 +98,7 @@ class TimeZoneApp final : public App {
|
||||
}
|
||||
|
||||
void onListItemSelected(std::size_t index) {
|
||||
TT_LOG_I(TAG, "Selected item at index %zu", index);
|
||||
LOGGER.info("Selected item at index {}", index);
|
||||
|
||||
auto& entry = entries[index];
|
||||
|
||||
@@ -117,7 +119,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) {
|
||||
TT_LOG_E(TAG, "Failed to open %s", path.c_str());
|
||||
LOGGER.error("Failed to open {}", path);
|
||||
return;
|
||||
}
|
||||
char line[96];
|
||||
@@ -138,7 +140,7 @@ class TimeZoneApp final : public App {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
TT_LOG_E(TAG, "Parse error at line %lu", count);
|
||||
LOGGER.error("Parse error at line {}", count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,10 +150,10 @@ class TimeZoneApp final : public App {
|
||||
entries = std::move(new_entries);
|
||||
mutex.unlock();
|
||||
} else {
|
||||
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED);
|
||||
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED);
|
||||
}
|
||||
|
||||
TT_LOG_I(TAG, "Processed %lu entries", count);
|
||||
LOGGER.info("Processed {} entries", count);
|
||||
}
|
||||
|
||||
void updateList() {
|
||||
@@ -160,7 +162,7 @@ class TimeZoneApp final : public App {
|
||||
readTimeZones(filter);
|
||||
lvgl::unlock();
|
||||
} else {
|
||||
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
|
||||
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,15 +6,16 @@
|
||||
#include <Tactility/app/AppContext.h>
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/app/alertdialog/AlertDialog.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <Tactility/lvgl/Style.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/TactilityCore.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
namespace tt::app::wifiapsettings {
|
||||
|
||||
constexpr auto* TAG = "WifiApSettings";
|
||||
static const auto LOGGER = Logger("WifiApSettings");
|
||||
|
||||
extern const AppManifest manifest;
|
||||
|
||||
@@ -50,10 +51,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)) {
|
||||
TT_LOG_E(TAG, "Failed to save settings");
|
||||
LOGGER.error("Failed to save settings");
|
||||
}
|
||||
} else {
|
||||
TT_LOG_E(TAG, "Failed to load settings");
|
||||
LOGGER.error("Failed to load settings");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +90,7 @@ class WifiApSettings : public App {
|
||||
updateViews();
|
||||
lvgl::unlock();
|
||||
} else {
|
||||
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
|
||||
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,7 +193,7 @@ public:
|
||||
lv_obj_remove_state(auto_connect_switch, LV_STATE_CHECKED);
|
||||
}
|
||||
} else {
|
||||
TT_LOG_W(TAG, "No settings found");
|
||||
LOGGER.warn("No settings found");
|
||||
lv_obj_add_flag(forget_button, LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(auto_connect_wrapper, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
@@ -223,11 +224,11 @@ public:
|
||||
|
||||
std::string ssid = parameters->getString("ssid");
|
||||
if (!service::wifi::settings::remove(ssid.c_str())) {
|
||||
TT_LOG_E(TAG, "Failed to remove SSID");
|
||||
LOGGER.error("Failed to remove SSID");
|
||||
return;
|
||||
}
|
||||
|
||||
TT_LOG_I(TAG, "Removed SSID");
|
||||
LOGGER.info("Removed SSID");
|
||||
if (
|
||||
service::wifi::getRadioState() == service::wifi::RadioState::ConnectionActive &&
|
||||
service::wifi::getConnectionTarget() == ssid
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#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>
|
||||
@@ -12,7 +13,7 @@
|
||||
|
||||
namespace tt::app::wificonnect {
|
||||
|
||||
constexpr auto* TAG = "WifiConnect";
|
||||
static const auto LOGGER = Logger("WifiConnect");
|
||||
|
||||
void View::resetErrors() {
|
||||
lv_obj_add_flag(password_error, LV_OBJ_FLAG_HIDDEN);
|
||||
@@ -30,7 +31,7 @@ static void onConnect(TT_UNUSED 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) {
|
||||
TT_LOG_E(TAG, "SSID too long");
|
||||
LOGGER.error("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;
|
||||
@@ -39,7 +40,7 @@ static void onConnect(TT_UNUSED 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) {
|
||||
TT_LOG_E(TAG, "Password too long");
|
||||
LOGGER.error("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;
|
||||
@@ -199,7 +200,7 @@ void View::init(AppContext& app, lv_obj_t* parent) {
|
||||
}
|
||||
|
||||
std::string password;
|
||||
if (optPasswordParameter(bundle, ssid)) {
|
||||
if (optPasswordParameter(bundle, password)) {
|
||||
lv_textarea_set_text(password_textarea, password.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#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/lvgl/LvglSync.h>
|
||||
|
||||
namespace tt::app::wificonnect {
|
||||
|
||||
constexpr auto* TAG = "WifiConnect";
|
||||
static const auto LOGGER = Logger("WifiConnect");
|
||||
constexpr auto* WIFI_CONNECT_PARAM_SSID = "ssid"; // String
|
||||
constexpr auto* WIFI_CONNECT_PARAM_PASSWORD = "password"; // String
|
||||
|
||||
@@ -72,7 +74,7 @@ void WifiConnect::requestViewUpdate() {
|
||||
view.update();
|
||||
lvgl::unlock();
|
||||
} else {
|
||||
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
|
||||
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
|
||||
}
|
||||
}
|
||||
unlock();
|
||||
|
||||
@@ -1,24 +1,20 @@
|
||||
#include <Tactility/network/HttpdReq.h>
|
||||
|
||||
#include <Tactility/app/wifimanage/View.h>
|
||||
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/app/wifimanage/WifiManagePrivate.h>
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/lvgl/Style.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/service/wifi/Wifi.h>
|
||||
#include <Tactility/service/wifi/WifiSettings.h>
|
||||
|
||||
#include <format>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <Tactility/service/wifi/WifiSettings.h>
|
||||
|
||||
namespace tt::app::wifimanage {
|
||||
|
||||
constexpr auto* TAG = "WifiManageView";
|
||||
static const auto LOGGER = Logger("WifiManageView");
|
||||
|
||||
std::shared_ptr<WifiManage> _Nullable optWifiManage();
|
||||
|
||||
@@ -70,16 +66,16 @@ static void onConnectToHiddenClicked(lv_event_t* event) {
|
||||
// region Secondary updates
|
||||
|
||||
void View::connect(lv_event_t* event) {
|
||||
TT_LOG_D(TAG, "connect()");
|
||||
LOGGER.debug("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()) {
|
||||
TT_LOG_I(TAG, "Clicked %d/%d", index, ap_records.size() - 1);
|
||||
LOGGER.info("Clicked {}/{}", index, ap_records.size() - 1);
|
||||
auto& ssid = ap_records[index].ssid;
|
||||
TT_LOG_I(TAG, "Clicked AP: %s", ssid.c_str());
|
||||
LOGGER.info("Clicked AP: {}", ssid);
|
||||
std::string connection_target = service::wifi::getConnectionTarget();
|
||||
if (connection_target == ssid) {
|
||||
self->bindings->onDisconnect();
|
||||
@@ -87,12 +83,12 @@ void View::connect(lv_event_t* event) {
|
||||
self->bindings->onConnectSsid(ssid);
|
||||
}
|
||||
} else {
|
||||
TT_LOG_W(TAG, "Clicked AP: record %d/%d does not exist", index, ap_records.size() - 1);
|
||||
LOGGER.warn("Clicked AP: record {}/{} does not exist", index, ap_records.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void View::showDetails(lv_event_t* event) {
|
||||
TT_LOG_D(TAG, "showDetails()");
|
||||
LOGGER.debug("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));
|
||||
@@ -100,10 +96,10 @@ void View::showDetails(lv_event_t* event) {
|
||||
|
||||
if (index < ap_records.size()) {
|
||||
auto& ssid = ap_records[index].ssid;
|
||||
TT_LOG_I(TAG, "Clicked AP: %s", ssid.c_str());
|
||||
LOGGER.info("Clicked AP: {}", ssid);
|
||||
self->bindings->onShowApSettings(ssid);
|
||||
} else {
|
||||
TT_LOG_W(TAG, "Clicked AP: record %d/%d does not exist", index, ap_records.size() - 1);
|
||||
LOGGER.warn("Clicked AP: record {}/{} does not exist", index, ap_records.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,22 +4,24 @@
|
||||
#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>
|
||||
|
||||
namespace tt::app::wifimanage {
|
||||
|
||||
constexpr auto TAG = "WifiManage";
|
||||
static const auto LOGGER = Logger("WifiManage");
|
||||
|
||||
extern const AppManifest manifest;
|
||||
|
||||
static void onConnect(const std::string& ssid) {
|
||||
service::wifi::settings::WifiApSettings settings;
|
||||
if (service::wifi::settings::load(ssid, settings)) {
|
||||
TT_LOG_I(TAG, "Connecting with known credentials");
|
||||
LOGGER.info("Connecting with known credentials");
|
||||
service::wifi::connect(settings, false);
|
||||
} else {
|
||||
TT_LOG_I(TAG, "Starting connection dialog");
|
||||
LOGGER.info("Starting connection dialog");
|
||||
wificonnect::start(ssid);
|
||||
}
|
||||
}
|
||||
@@ -65,7 +67,7 @@ void WifiManage::requestViewUpdate() {
|
||||
view.update();
|
||||
lvgl::unlock();
|
||||
} else {
|
||||
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
|
||||
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
|
||||
}
|
||||
}
|
||||
unlock();
|
||||
@@ -73,7 +75,7 @@ void WifiManage::requestViewUpdate() {
|
||||
|
||||
void WifiManage::onWifiEvent(service::wifi::WifiEvent event) {
|
||||
auto radio_state = service::wifi::getRadioState();
|
||||
TT_LOG_I(TAG, "Update with state %s", service::wifi::radioStateToString(radio_state));
|
||||
LOGGER.info("Update with state {}", service::wifi::radioStateToString(radio_state));
|
||||
getState().setRadioState(radio_state);
|
||||
switch (event) {
|
||||
using enum service::wifi::WifiEvent;
|
||||
@@ -118,7 +120,7 @@ void WifiManage::onShow(AppContext& app, lv_obj_t* parent) {
|
||||
bool can_scan = radio_state == service::wifi::RadioState::On ||
|
||||
radio_state == service::wifi::RadioState::ConnectionPending ||
|
||||
radio_state == service::wifi::RadioState::ConnectionActive;
|
||||
TT_LOG_I(TAG, "%s %d", service::wifi::radioStateToString(radio_state), (int)service::wifi::isScanning());
|
||||
LOGGER.info("{} {}", service::wifi::radioStateToString(radio_state), service::wifi::isScanning());
|
||||
if (can_scan && !service::wifi::isScanning()) {
|
||||
service::wifi::scan();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user