Merge develop into main (#312)

- Move various settings to `/data/settings` and `/sdcard/settings`
- Fix for `Gui` and `Statusbar` errors on startup (LVGL start)
- Implement Development service settings as properties file
- Rename `service::findManifestId()` to `service::findManifestById()`
- Renamed various classes like `BootProperties` to `BootSettings`
- Renamed `settings.properties` to `system.properties`. Code was moved to `settings` namespace/folder
- `DevelopmentSettings` is now in `settings` namespace/folder (moved from service)
This commit is contained in:
Ken Van Hoeylandt
2025-08-31 20:31:31 +02:00
committed by GitHub
parent 5dfc6d70da
commit 5cc5b50694
30 changed files with 449 additions and 331 deletions
@@ -1,24 +1,24 @@
#ifdef ESP_PLATFORM
#include "Tactility/service/development/DevelopmentService.h"
#include <Tactility/service/development/DevelopmentService.h>
#include "Tactility/network/HttpdReq.h"
#include "Tactility/network/Url.h"
#include "Tactility/TactilityHeadless.h"
#include "Tactility/service/ServiceManifest.h"
#include "Tactility/service/ServiceRegistration.h"
#include "Tactility/service/wifi/Wifi.h"
#include <Tactility/app/App.h>
#include <Tactility/app/AppRegistration.h>
#include <Tactility/app/ElfApp.h>
#include <Tactility/file/File.h>
#include <Tactility/network/HttpdReq.h>
#include <Tactility/network/Url.h>
#include <Tactility/service/development/DevelopmentSettings.h>
#include <Tactility/service/ServiceManifest.h>
#include <Tactility/service/ServiceRegistration.h>
#include <Tactility/service/wifi/Wifi.h>
#include <Tactility/StringUtils.h>
#include <Tactility/TactilityHeadless.h>
#include <cstring>
#include <esp_wifi.h>
#include <ranges>
#include <sstream>
#include <Tactility/Preferences.h>
#include <Tactility/StringUtils.h>
#include <Tactility/app/App.h>
#include <Tactility/app/ElfApp.h>
#include <Tactility/app/AppRegistration.h>
#include <Tactility/file/File.h>
namespace tt::service::development {
@@ -39,7 +39,7 @@ void DevelopmentService::onStart(ServiceContext& service) {
[this](kernel::SystemEvent) { onNetworkDisconnected(); }
);
setEnabled(isEnabledOnStart());
setEnabled(shouldEnableOnBoot());
}
void DevelopmentService::onStop(ServiceContext& service) {
@@ -76,18 +76,6 @@ bool DevelopmentService::isEnabled() const {
return enabled;
}
bool DevelopmentService::isEnabledOnStart() const {
Preferences preferences = Preferences(manifest.id.c_str());
bool enabled_on_boot = false;
preferences.optBool("enabledOnBoot", enabled_on_boot);
return enabled_on_boot;
}
void DevelopmentService::setEnabledOnStart(bool enabled) {
Preferences preferences = Preferences(manifest.id.c_str());
preferences.putBool("enabledOnBoot", enabled);
}
// region Enable/disable
void DevelopmentService::startServer() {
@@ -0,0 +1,55 @@
#ifdef ESP_PLATFORM
#include <Tactility/file/PropertiesFile.h>
#include <Tactility/Log.h>
#include <Tactility/service/development/DevelopmentSettings.h>
#include <map>
#include <string>
namespace tt::service::development {
constexpr auto* TAG = "DevSettings";
constexpr auto* SETTINGS_FILE = "/data/settings/development.properties";
constexpr auto* SETTINGS_KEY_ENABLE_ON_BOOT = "enableOnBoot";
struct DevelopmentSettings {
bool enableOnBoot;
};
static bool load(DevelopmentSettings& settings) {
std::map<std::string, std::string> map;
if (!file::loadPropertiesFile(SETTINGS_FILE, map)) {
return false;
}
if (!map.contains(SETTINGS_KEY_ENABLE_ON_BOOT)) {
return false;
}
auto enable_on_boot_string = map[SETTINGS_KEY_ENABLE_ON_BOOT];
settings.enableOnBoot = (enable_on_boot_string == "true");
return true;
}
static bool save(const DevelopmentSettings& settings) {
std::map<std::string, std::string> map;
map[SETTINGS_KEY_ENABLE_ON_BOOT] = settings.enableOnBoot ? "true" : "false";
return file::savePropertiesFile(SETTINGS_FILE, map);
}
void setEnableOnBoot(bool enable) {
DevelopmentSettings properties { .enableOnBoot = enable };
if (!save(properties)) {
TT_LOG_E(TAG, "Failed to save %s", SETTINGS_FILE);
}
}
bool shouldEnableOnBoot() {
DevelopmentSettings settings;
if (!load(settings)) {
return false;
}
return settings.enableOnBoot;
}
}
#endif // ESP_PLATFORM