App hub and more (#383)
- Added `AppHub` app - Added `AppHubDetails` app - Added `cJSON` dependency - Renamed `AppSim` module to `FirmwareSim` - Added extra `tt::app::alertdialg::start()` - Renamed `addApp()`, `removeApp()`, `findAppById()` and `getApps()` to `addAppManifest()`, `removeAppManifest()`, `findAppManifestById()` and `getAppManifests()` - Added `tt::lvgl::toolbar_clear_actions()` - Added `tt::network::EspHttpClient` as a thread-safe wrapper around `esp_http_client` - Added `tt::network::http::download()` to download files - Added `tt::network::ntp::isSynced()` - When time is synced, the timestamp is stored in NVS flash. On boot, it is restored. This helps SSL connections when doing a quick reset: when WiFi reconnects, the user doesn't have to wait for NTP sync before SSL works. - Added `tt::json::Reader` as a `cJSON` wrapper - Added `int64_t` support for `Preferences` - Added `int64_t` support for `Bundle` - Added dependencies: `cJSON`, `esp-tls` - When time is synced via NTP, disable time sync. - Added docs to 'tt::file::` functions - Added `tt::string::join()` that works with `std::vector<const char*>` - Fixed `tt::file::getLastPathSegment()` for the scenario when a path was passed with only a single segment - Set `CONFIG_ESP_MAIN_TASK_STACK_SIZE=5120` (from about 3k) for all boards - Set `CONFIG_MBEDTLS_SSL_PROTO_TLS1_3=y` for all boards
This commit is contained in:
committed by
GitHub
parent
e9384e0c11
commit
f660550f86
@@ -1,14 +1,14 @@
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include "nvs_flash.h"
|
||||
#include "Tactility/Preferences.h"
|
||||
|
||||
#include <Tactility/Preferences.h>
|
||||
#include <Tactility/TactilityCore.h>
|
||||
|
||||
#define TAG "preferences"
|
||||
#include <nvs_flash.h>
|
||||
|
||||
namespace tt {
|
||||
|
||||
constexpr auto* TAG = "Preferences";
|
||||
|
||||
bool Preferences::optBool(const std::string& key, bool& out) const {
|
||||
nvs_handle_t handle;
|
||||
if (nvs_open(namespace_, NVS_READWRITE, &handle) != ESP_OK) {
|
||||
@@ -37,6 +37,18 @@ bool Preferences::optInt32(const std::string& key, int32_t& out) const {
|
||||
}
|
||||
}
|
||||
|
||||
bool Preferences::optInt64(const std::string& key, int64_t& out) const {
|
||||
nvs_handle_t handle;
|
||||
if (nvs_open(namespace_, NVS_READWRITE, &handle) != ESP_OK) {
|
||||
TT_LOG_E(TAG, "Failed to open namespace %s", namespace_);
|
||||
return false;
|
||||
} else {
|
||||
bool success = nvs_get_i64(handle, key.c_str(), &out) == ESP_OK;
|
||||
nvs_close(handle);
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
||||
bool Preferences::optString(const std::string& key, std::string& out) const {
|
||||
nvs_handle_t handle;
|
||||
if (nvs_open(namespace_, NVS_READWRITE, &handle) != ESP_OK) {
|
||||
@@ -63,6 +75,11 @@ bool Preferences::hasInt32(const std::string& key) const {
|
||||
return optInt32(key, temp);
|
||||
}
|
||||
|
||||
bool Preferences::hasInt64(const std::string& key) const {
|
||||
int64_t temp;
|
||||
return optInt64(key, temp);
|
||||
}
|
||||
|
||||
bool Preferences::hasString(const std::string& key) const {
|
||||
std::string temp;
|
||||
return optString(key, temp);
|
||||
@@ -92,6 +109,18 @@ void Preferences::putInt32(const std::string& key, int32_t value) {
|
||||
}
|
||||
}
|
||||
|
||||
void Preferences::putInt64(const std::string& key, int64_t value) {
|
||||
nvs_handle_t handle;
|
||||
if (nvs_open(namespace_, NVS_READWRITE, &handle) == ESP_OK) {
|
||||
if (nvs_set_i64(handle, key.c_str(), value) != ESP_OK) {
|
||||
TT_LOG_E(TAG, "Failed to write %s:%s", namespace_, key.c_str());
|
||||
}
|
||||
nvs_close(handle);
|
||||
} else {
|
||||
TT_LOG_E(TAG, "Failed to open namespace %s", namespace_);
|
||||
}
|
||||
}
|
||||
|
||||
void Preferences::putString(const std::string& key, const std::string& text) {
|
||||
nvs_handle_t handle;
|
||||
if (nvs_open(namespace_, NVS_READWRITE, &handle) == ESP_OK) {
|
||||
|
||||
Reference in New Issue
Block a user