Create TactilityFreertos subproject (#440)
This commit is contained in:
committed by
GitHub
parent
a4dc633063
commit
7283920def
@@ -5,15 +5,15 @@
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/TactilityConfig.h>
|
||||
|
||||
#include <Tactility/DispatcherThread.h>
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/app/AppManifestParsing.h>
|
||||
#include <Tactility/app/AppRegistration.h>
|
||||
#include <Tactility/DispatcherThread.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/file/FileLock.h>
|
||||
#include <Tactility/file/PropertiesFile.h>
|
||||
#include <Tactility/hal/HalPrivate.h>
|
||||
#include <Tactility/lvgl/LvglPrivate.h>
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/network/NtpPrivate.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <Tactility/app/AppManifestParsing.h>
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <regex>
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/lvgl/Lvgl.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
@@ -9,8 +11,6 @@
|
||||
#include <Tactility/service/development/DevelopmentSettings.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
#include <Tactility/service/wifi/Wifi.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/Timer.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <lvgl.h>
|
||||
@@ -27,7 +27,7 @@ class DevelopmentApp final : public App {
|
||||
lv_obj_t* statusLabel = nullptr;
|
||||
std::shared_ptr<service::development::DevelopmentService> service;
|
||||
|
||||
Timer timer = Timer(Timer::Type::Periodic, [this] {
|
||||
Timer timer = Timer(Timer::Type::Periodic, pdMS_TO_TICKS(1000), [this] {
|
||||
auto lock = lvgl::getSyncLock()->asScopedLock();
|
||||
// TODO: There's a crash when this is called when the app is being destroyed
|
||||
if (lock.lock(lvgl::defaultLockTime) && lvgl::isStarted()) {
|
||||
@@ -148,7 +148,7 @@ public:
|
||||
|
||||
updateViewState();
|
||||
|
||||
timer.start(1000);
|
||||
timer.start();
|
||||
}
|
||||
|
||||
void onHide(AppContext& appContext) override {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <Tactility/hal/sdcard/SdCardDevice.h>
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
#include <Tactility/kernel/Platform.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
#include <Tactility/app/files/View.h>
|
||||
#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/lvgl/Toolbar.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/StringUtils.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <Tactility/file/FileLock.h>
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "Tactility/hal/sdcard/SdCardDevice.h"
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
#include <Tactility/kernel/Platform.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
#include "Tactility/app/fileselection/View.h"
|
||||
#include <Tactility/app/fileselection/View.h>
|
||||
|
||||
#include "Tactility/app/alertdialog/AlertDialog.h"
|
||||
#include "Tactility/lvgl/Toolbar.h"
|
||||
#include "Tactility/lvgl/LvglSync.h"
|
||||
#include <Tactility/app/alertdialog/AlertDialog.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
|
||||
#include <Tactility/Tactility.h>
|
||||
#include "Tactility/file/File.h"
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/StringUtils.h>
|
||||
|
||||
#include <Tactility/kernel/Platform.h>
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "Tactility/service/loader/Loader.h"
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
#endif
|
||||
|
||||
namespace tt::app::fileselection {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <Tactility/Tactility.h>
|
||||
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/app/alertdialog/AlertDialog.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
@@ -7,7 +8,6 @@
|
||||
#include <Tactility/service/gps/GpsService.h>
|
||||
#include <Tactility/service/gps/GpsState.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
#include <Tactility/Timer.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
@@ -62,7 +62,7 @@ class GpsSettingsApp final : public App {
|
||||
}
|
||||
|
||||
void startReceivingUpdates() {
|
||||
timer->start(kernel::secondsToTicks(1));
|
||||
timer->start();
|
||||
updateViews();
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ class GpsSettingsApp final : public App {
|
||||
public:
|
||||
|
||||
GpsSettingsApp() {
|
||||
timer = std::make_unique<Timer>(Timer::Type::Periodic, [this] {
|
||||
timer = std::make_unique<Timer>(Timer::Type::Periodic, kernel::secondsToTicks(1), [this] {
|
||||
updateViews();
|
||||
});
|
||||
service = service::gps::findGpsService();
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/Assets.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/Timer.h>
|
||||
|
||||
#include <format>
|
||||
|
||||
@@ -278,10 +278,10 @@ void I2cScannerApp::startScanning() {
|
||||
lv_obj_clean(scanListWidget);
|
||||
|
||||
scanState = ScanStateScanning;
|
||||
scanTimer = std::make_unique<Timer>(Timer::Type::Once, [this]{
|
||||
scanTimer = std::make_unique<Timer>(Timer::Type::Once, 10, [this]{
|
||||
onScanTimer();
|
||||
});
|
||||
scanTimer->start(10);
|
||||
scanTimer->start();
|
||||
mutex.unlock();
|
||||
} else {
|
||||
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "startScanning");
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#include "Tactility/app/AppContext.h"
|
||||
#include "Tactility/lvgl/LvglSync.h"
|
||||
#include "Tactility/lvgl/Style.h"
|
||||
#include "Tactility/lvgl/Toolbar.h"
|
||||
#include "Tactility/service/loader/Loader.h"
|
||||
#include <Tactility/app/AppContext.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/lvgl/Style.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
|
||||
#include "Tactility/hal/power/PowerDevice.h"
|
||||
#include <Tactility/Assets.h>
|
||||
#include <Tactility/hal/power/PowerDevice.h>
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/Assets.h>
|
||||
#include <Tactility/hal/Device.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
@@ -31,7 +31,7 @@ std::shared_ptr<PowerApp> _Nullable optApp() {
|
||||
|
||||
class PowerApp : public App {
|
||||
|
||||
Timer update_timer = Timer(Timer::Type::Periodic, []() { onTimer(); });
|
||||
Timer update_timer = Timer(Timer::Type::Periodic, kernel::millisToTicks(1000),[]() { onTimer(); });
|
||||
|
||||
std::shared_ptr<hal::power::PowerDevice> power;
|
||||
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
|
||||
updateUi();
|
||||
|
||||
update_timer.start(kernel::millisToTicks(1000));
|
||||
update_timer.start();
|
||||
}
|
||||
|
||||
void onHide(TT_UNUSED AppContext& app) override {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <Tactility/app/App.h>
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/kernel/Platform.h>
|
||||
#include <Tactility/lvgl/Lvgl.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
@@ -71,7 +72,7 @@ static void onModeSetCallback(TT_UNUSED lv_event_t* event) {
|
||||
}
|
||||
|
||||
ScreenshotApp::ScreenshotApp() {
|
||||
updateTimer = std::make_unique<Timer>(Timer::Type::Periodic, [this]() {
|
||||
updateTimer = std::make_unique<Timer>(Timer::Type::Periodic, 500 / portTICK_PERIOD_MS, [this] {
|
||||
onTimerTick();
|
||||
});
|
||||
}
|
||||
@@ -274,7 +275,7 @@ void ScreenshotApp::onShow(AppContext& appContext, lv_obj_t* parent) {
|
||||
updateScreenshotMode();
|
||||
|
||||
if (!updateTimer->isRunning()) {
|
||||
updateTimer->start(500 / portTICK_PERIOD_MS);
|
||||
updateTimer->start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -283,7 +283,7 @@ static std::shared_ptr<SystemInfoApp> _Nullable optApp() {
|
||||
}
|
||||
|
||||
class SystemInfoApp final : public App {
|
||||
Timer memoryTimer = Timer(Timer::Type::Periodic, []() {
|
||||
Timer memoryTimer = Timer(Timer::Type::Periodic, kernel::millisToTicks(10000), [] {
|
||||
auto app = optApp();
|
||||
if (app) {
|
||||
auto lock = lvgl::getSyncLock()->asScopedLock();
|
||||
@@ -293,7 +293,7 @@ class SystemInfoApp final : public App {
|
||||
}
|
||||
});
|
||||
|
||||
Timer tasksTimer = Timer(Timer::Type::Periodic, []() {
|
||||
Timer tasksTimer = Timer(Timer::Type::Periodic, kernel::millisToTicks(15000), [] {
|
||||
auto app = optApp();
|
||||
if (app) {
|
||||
auto lock = lvgl::getSyncLock()->asScopedLock();
|
||||
@@ -688,8 +688,8 @@ class SystemInfoApp final : public App {
|
||||
updatePsram(); // PSRAM: detailed breakdown
|
||||
|
||||
// Start timers (only run while app is visible, stopped in onHide)
|
||||
memoryTimer.start(kernel::millisToTicks(10000)); // Memory & PSRAM: every 10s
|
||||
tasksTimer.start(kernel::millisToTicks(15000)); // Tasks/CPU: every 15s
|
||||
memoryTimer.start(); // Memory & PSRAM: every 10s
|
||||
tasksTimer.start(); // Tasks/CPU: every 15s
|
||||
}
|
||||
|
||||
void onHide(TT_UNUSED AppContext& app) override {
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/StringUtils.h>
|
||||
#include <Tactility/Timer.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <memory>
|
||||
@@ -82,7 +82,7 @@ class TimeZoneApp final : public App {
|
||||
updateTimer->stop();
|
||||
}
|
||||
|
||||
updateTimer->start(500 / portTICK_PERIOD_MS);
|
||||
updateTimer->start();
|
||||
|
||||
mutex.unlock();
|
||||
}
|
||||
@@ -220,7 +220,7 @@ public:
|
||||
}
|
||||
|
||||
void onCreate(AppContext& app) override {
|
||||
updateTimer = std::make_unique<Timer>(Timer::Type::Once, [this] {
|
||||
updateTimer = std::make_unique<Timer>(Timer::Type::Once, 500 / portTICK_PERIOD_MS, [this] {
|
||||
updateList();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "Tactility/hal/Device.h"
|
||||
#include <Tactility/hal/Device.h>
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -9,7 +10,7 @@ std::vector<std::shared_ptr<Device>> devices;
|
||||
RecursiveMutex mutex;
|
||||
static Device::Id nextId = 0;
|
||||
|
||||
#define TAG "devices"
|
||||
constexpr auto TAG = "devices";
|
||||
|
||||
Device::Device() : id(nextId++) {}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "Tactility/hal/gps/GpsDevice.h"
|
||||
#include "Tactility/hal/gps/GpsInit.h"
|
||||
#include "Tactility/hal/gps/Probe.h"
|
||||
#include "Tactility/hal/uart/Uart.h"
|
||||
#include <Tactility/hal/gps/GpsDevice.h>
|
||||
#include <Tactility/hal/gps/GpsInit.h>
|
||||
#include <Tactility/hal/gps/Probe.h>
|
||||
#include <Tactility/hal/uart/Uart.h>
|
||||
#include <Tactility/Log.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <minmea.h>
|
||||
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
#include "Tactility/hal/gps/Cas.h"
|
||||
#include "Tactility/hal/gps/GpsDevice.h"
|
||||
#include "Tactility/hal/gps/Ublox.h"
|
||||
#include <Tactility/Check.h>
|
||||
#include <Tactility/hal/gps/Cas.h>
|
||||
#include <Tactility/hal/gps/GpsDevice.h>
|
||||
#include <Tactility/hal/gps/Ublox.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
#include <Tactility/Log.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#define TAG "gps"
|
||||
|
||||
namespace tt::hal::gps {
|
||||
|
||||
constexpr auto TAG = "gps";
|
||||
|
||||
bool initMtk(uart::Uart& uart);
|
||||
bool initMtkL76b(uart::Uart& uart);
|
||||
bool initMtkPa1616s(uart::Uart& uart);
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
#include "Tactility/hal/gps/Satellites.h"
|
||||
#include <Tactility/hal/gps/Satellites.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
#include <Tactility/Log.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#define TAG "satellites"
|
||||
|
||||
namespace tt::hal::gps {
|
||||
|
||||
constexpr inline bool hasTimeElapsed(TickType_t now, TickType_t timeInThePast, TickType_t expireTimeInTicks) {
|
||||
constexpr auto TAG = "Satellites";
|
||||
|
||||
constexpr bool hasTimeElapsed(TickType_t now, TickType_t timeInThePast, TickType_t expireTimeInTicks) {
|
||||
return (TickType_t)(now - timeInThePast) >= expireTimeInTicks;
|
||||
}
|
||||
|
||||
@@ -45,7 +47,7 @@ SatelliteStorage::SatelliteRecord* SatelliteStorage::findRecordToRecycle() {
|
||||
lock.lock();
|
||||
|
||||
int candidate_index = -1;
|
||||
auto candidate_age = portMAX_DELAY;
|
||||
auto candidate_age = kernel::MAX_TICKS;
|
||||
TickType_t expire_duration = kernel::secondsToTicks(recycleTimeSeconds);
|
||||
TickType_t now = kernel::getTicks();
|
||||
for (int i = 0; i < records.size(); ++i) {
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
#include "Tactility/hal/gps/Ublox.h"
|
||||
#include "Tactility/hal/gps/UbloxMessages.h"
|
||||
#include "Tactility/hal/uart/Uart.h"
|
||||
#include <Tactility/hal/gps/Ublox.h>
|
||||
#include <Tactility/hal/gps/UbloxMessages.h>
|
||||
#include <Tactility/hal/uart/Uart.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
#include <Tactility/Log.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#define TAG "ublox"
|
||||
|
||||
namespace tt::hal::gps::ublox {
|
||||
|
||||
constexpr auto TAG = "ublox";
|
||||
|
||||
bool initUblox6(uart::Uart& uart);
|
||||
bool initUblox789(uart::Uart& uart, GpsModel model);
|
||||
bool initUblox10(uart::Uart& uart);
|
||||
|
||||
@@ -2,15 +2,12 @@
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include <esp_check.h>
|
||||
#endif // ESP_PLATFORM
|
||||
|
||||
#define TAG "i2c"
|
||||
#include <Tactility/Check.h>
|
||||
|
||||
namespace tt::hal::i2c {
|
||||
|
||||
constexpr auto TAG = "i2c";
|
||||
|
||||
struct Data {
|
||||
Mutex mutex;
|
||||
bool isConfigured = false;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "Tactility/hal/spi/Spi.h"
|
||||
#include <Tactility/hal/spi/Spi.h>
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
|
||||
namespace tt::hal::spi {
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include "Tactility/hal/uart/UartEsp.h"
|
||||
#include <Tactility/hal/uart/UartEsp.h>
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <esp_check.h>
|
||||
|
||||
#define TAG "uart"
|
||||
#include <sstream>
|
||||
|
||||
namespace tt::hal::uart {
|
||||
|
||||
constexpr auto TAG = "uart";
|
||||
|
||||
bool UartEsp::start() {
|
||||
TT_LOG_I(TAG, "[%s] Starting", configuration.name.c_str());
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef ESP_PLATFORM
|
||||
|
||||
#include "Tactility/hal/uart/UartPosix.h"
|
||||
#include "Tactility/hal/uart/Uart.h"
|
||||
|
||||
#include <Tactility/hal/uart/UartPosix.h>
|
||||
#include <Tactility/hal/uart/Uart.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
#include <Tactility/Log.h>
|
||||
|
||||
#include <cstring>
|
||||
@@ -10,10 +10,10 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define TAG "uart"
|
||||
|
||||
namespace tt::hal::uart {
|
||||
|
||||
constexpr auto TAG = "uart";
|
||||
|
||||
bool UartPosix::start() {
|
||||
auto lock = mutex.asScopedLock();
|
||||
lock.lock();
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "Tactility/kernel/SystemEvents.h"
|
||||
#include <Tactility/kernel/SystemEvents.h>
|
||||
|
||||
#include <Tactility/Check.h>
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace tt::kernel {
|
||||
@@ -56,7 +59,7 @@ static const char* getEventName(SystemEvent event) {
|
||||
void publishSystemEvent(SystemEvent event) {
|
||||
TT_LOG_I(TAG, "%s", getEventName(event));
|
||||
|
||||
if (mutex.lock(portMAX_DELAY)) {
|
||||
if (mutex.lock(kernel::MAX_TICKS)) {
|
||||
for (auto& subscription : subscriptions) {
|
||||
if (subscription.event == event) {
|
||||
subscription.handler(event);
|
||||
@@ -68,7 +71,7 @@ void publishSystemEvent(SystemEvent event) {
|
||||
}
|
||||
|
||||
SystemEventSubscription subscribeSystemEvent(SystemEvent event, OnSystemEvent handler) {
|
||||
if (mutex.lock(portMAX_DELAY)) {
|
||||
if (mutex.lock(kernel::MAX_TICKS)) {
|
||||
auto id = ++subscriptionCounter;
|
||||
|
||||
subscriptions.push_back({
|
||||
@@ -85,7 +88,7 @@ SystemEventSubscription subscribeSystemEvent(SystemEvent event, OnSystemEvent ha
|
||||
}
|
||||
|
||||
void unsubscribeSystemEvent(SystemEventSubscription subscription) {
|
||||
if (mutex.lock(portMAX_DELAY)) {
|
||||
if (mutex.lock(kernel::MAX_TICKS)) {
|
||||
std::erase_if(subscriptions, [subscription](auto& item) {
|
||||
return (item.id == subscription);
|
||||
});
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <esp_lvgl_port.h>
|
||||
#include <Tactility/Thread.h>
|
||||
#include <Tactility/CpuAffinity.h>
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
|
||||
#include <esp_lvgl_port.h>
|
||||
|
||||
// LVGL
|
||||
// The minimum task stack seems to be about 3500, but that crashes the wifi app in some scenarios
|
||||
|
||||
@@ -22,14 +22,14 @@ void syncSet(LvglLock lock, LvglUnlock unlock) {
|
||||
auto old_unlock = unlock_singleton;
|
||||
|
||||
// Ensure the old lock is not engaged when changing locks
|
||||
old_lock((uint32_t)portMAX_DELAY);
|
||||
old_lock((uint32_t)kernel::MAX_TICKS);
|
||||
lock_singleton = lock;
|
||||
unlock_singleton = unlock;
|
||||
old_unlock();
|
||||
}
|
||||
|
||||
bool lock(TickType_t timeout) {
|
||||
return lock_singleton(pdMS_TO_TICKS(timeout == 0 ? portMAX_DELAY : timeout));
|
||||
return lock_singleton(pdMS_TO_TICKS(timeout == 0 ? kernel::MAX_TICKS : timeout));
|
||||
}
|
||||
|
||||
void unlock() {
|
||||
@@ -44,9 +44,8 @@ public:
|
||||
return lvgl::lock(timeoutTicks);
|
||||
}
|
||||
|
||||
bool unlock() const override {
|
||||
void unlock() const override {
|
||||
lvgl::unlock();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/TactilityCore.h>
|
||||
|
||||
#include <Tactility/PubSub.h>
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/kernel/SystemEvents.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/lvgl/Statusbar.h>
|
||||
#include <Tactility/lvgl/Style.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/PubSub.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/settings/Time.h>
|
||||
#include <Tactility/Timer.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
@@ -30,7 +30,7 @@ struct StatusbarData {
|
||||
RecursiveMutex mutex;
|
||||
std::shared_ptr<PubSub<void*>> pubsub = std::make_shared<PubSub<void*>>();
|
||||
StatusbarIcon icons[STATUSBAR_ICON_LIMIT] = {};
|
||||
Timer* time_update_timer = new Timer(Timer::Type::Once, [] { onUpdateTime(); });
|
||||
Timer* time_update_timer = new Timer(Timer::Type::Once, 200 / portTICK_PERIOD_MS, [] { onUpdateTime(); });
|
||||
uint8_t time_hours = 0;
|
||||
uint8_t time_minutes = 0;
|
||||
bool time_set = false;
|
||||
@@ -73,12 +73,12 @@ static void onUpdateTime() {
|
||||
statusbar_data.time_set = true;
|
||||
|
||||
// Reschedule
|
||||
statusbar_data.time_update_timer->start(getNextUpdateTime());
|
||||
statusbar_data.time_update_timer->reset(getNextUpdateTime());
|
||||
|
||||
// Notify widget
|
||||
statusbar_data.pubsub->publish(nullptr);
|
||||
} else {
|
||||
statusbar_data.time_update_timer->start(pdMS_TO_TICKS(60000U));
|
||||
statusbar_data.time_update_timer->reset(pdMS_TO_TICKS(60000U));
|
||||
}
|
||||
|
||||
statusbar_data.mutex.unlock();
|
||||
@@ -113,9 +113,7 @@ static void statusbar_pubsub_event(Statusbar* statusbar) {
|
||||
|
||||
static void onTimeChanged(TT_UNUSED kernel::SystemEvent event) {
|
||||
if (statusbar_data.mutex.lock()) {
|
||||
statusbar_data.time_update_timer->stop();
|
||||
statusbar_data.time_update_timer->start(5);
|
||||
|
||||
statusbar_data.time_update_timer->reset(5);
|
||||
statusbar_data.mutex.unlock();
|
||||
}
|
||||
}
|
||||
@@ -131,7 +129,7 @@ static void statusbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj)
|
||||
});
|
||||
|
||||
if (!statusbar_data.time_update_timer->isRunning()) {
|
||||
statusbar_data.time_update_timer->start(200 / portTICK_PERIOD_MS);
|
||||
statusbar_data.time_update_timer->start();
|
||||
statusbar_data.systemEventSubscription = kernel::subscribeSystemEvent(
|
||||
kernel::SystemEvent::Time,
|
||||
onTimeChanged
|
||||
@@ -177,7 +175,7 @@ lv_obj_t* statusbar_create(lv_obj_t* parent) {
|
||||
obj_set_style_bg_invisible(left_spacer);
|
||||
lv_obj_set_flex_grow(left_spacer, 1);
|
||||
|
||||
statusbar_data.mutex.lock(portMAX_DELAY);
|
||||
statusbar_data.mutex.lock(kernel::MAX_TICKS);
|
||||
for (int i = 0; i < STATUSBAR_ICON_LIMIT; ++i) {
|
||||
auto* image = lv_image_create(obj);
|
||||
lv_obj_set_size(image, STATUSBAR_ICON_SIZE, STATUSBAR_ICON_SIZE);
|
||||
|
||||
@@ -31,6 +31,7 @@ void download(
|
||||
|
||||
auto certificate_length = strlen(reinterpret_cast<const char*>(certificate.get())) + 1;
|
||||
|
||||
// TODO: Fix for missing initializer warnings
|
||||
auto config = std::make_unique<esp_http_client_config_t>(esp_http_client_config_t {
|
||||
.url = url.c_str(),
|
||||
.auth_type = HTTP_AUTH_TYPE_NONE,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include <Tactility/network/HttpServer.h>
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/service/wifi/Wifi.h>
|
||||
|
||||
namespace tt::network {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/service/ServiceInstance.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
|
||||
#include <Tactility/Mutex.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace tt::service {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
#include <Tactility/service/ServiceContext.h>
|
||||
#include <Tactility/CoreDefines.h>
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/settings/DisplaySettings.h>
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/service/ServiceContext.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
#include <Tactility/settings/DisplaySettings.h>
|
||||
|
||||
namespace tt::service::displayidle {
|
||||
|
||||
@@ -61,9 +62,9 @@ public:
|
||||
// Note: Settings changes require service restart to take effect
|
||||
// TODO: Add DisplaySettingsChanged events for dynamic updates
|
||||
|
||||
timer = std::make_unique<Timer>(Timer::Type::Periodic, [this]{ this->tick(); });
|
||||
timer->setThreadPriority(Thread::Priority::Lower);
|
||||
timer->start(250); // check 4x per second for snappy restore
|
||||
timer = std::make_unique<Timer>(Timer::Type::Periodic, kernel::millisToTicks(250), [this]{ this->tick(); });
|
||||
timer->setCallbackPriority(Thread::Priority::Lower);
|
||||
timer->start();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
|
||||
#ifdef CONFIG_ESP_WIFI_ENABLED
|
||||
|
||||
#include "Tactility/service/espnow/EspNow.h"
|
||||
#include "Tactility/service/wifi/Wifi.h"
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/service/espnow/EspNow.h>
|
||||
#include <Tactility/service/wifi/Wifi.h>
|
||||
|
||||
#include <esp_now.h>
|
||||
#include <esp_wifi.h>
|
||||
|
||||
@@ -25,27 +25,30 @@ void GuiService::onLoaderEvent(LoaderService::Event event) {
|
||||
}
|
||||
|
||||
int32_t GuiService::guiMain() {
|
||||
auto service = findServiceById<GuiService>(manifest.id);
|
||||
|
||||
while (true) {
|
||||
uint32_t flags = Thread::awaitFlags(GUI_THREAD_FLAG_ALL, EventFlag::WaitAny, portMAX_DELAY);
|
||||
|
||||
// When service not started or starting -> exit
|
||||
State service_state = getState(manifest.id);
|
||||
if (service_state != State::Started && service_state != State::Starting) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Process and dispatch draw call
|
||||
if (flags & GUI_THREAD_FLAG_DRAW) {
|
||||
Thread::clearFlags(GUI_THREAD_FLAG_DRAW);
|
||||
auto service = findService();
|
||||
if (service != nullptr) {
|
||||
service->redraw();
|
||||
uint32_t flags = 0;
|
||||
if (service->threadFlags.wait(GUI_THREAD_FLAG_ALL, false, true, portMAX_DELAY, &flags)) {
|
||||
// When service not started or starting -> exit
|
||||
State service_state = getState(manifest.id);
|
||||
if (service_state != State::Started && service_state != State::Starting) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & GUI_THREAD_FLAG_EXIT) {
|
||||
Thread::clearFlags(GUI_THREAD_FLAG_EXIT);
|
||||
break;
|
||||
// Process and dispatch draw call
|
||||
if (flags & GUI_THREAD_FLAG_DRAW) {
|
||||
service->threadFlags.clear(GUI_THREAD_FLAG_DRAW);
|
||||
auto service = findService();
|
||||
if (service != nullptr) {
|
||||
service->redraw();
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & GUI_THREAD_FLAG_EXIT) {
|
||||
service->threadFlags.clear(GUI_THREAD_FLAG_EXIT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,8 +180,8 @@ void GuiService::onStop(TT_UNUSED ServiceContext& service) {
|
||||
appToRender = nullptr;
|
||||
isStarted = false;
|
||||
|
||||
ThreadId thread_id = thread->getId();
|
||||
Thread::setFlags(thread_id, GUI_THREAD_FLAG_EXIT);
|
||||
auto task_handle = thread->getTaskHandle();
|
||||
threadFlags.set(GUI_THREAD_FLAG_EXIT);
|
||||
thread->join();
|
||||
delete thread;
|
||||
|
||||
@@ -190,8 +193,8 @@ void GuiService::onStop(TT_UNUSED ServiceContext& service) {
|
||||
}
|
||||
|
||||
void GuiService::requestDraw() {
|
||||
ThreadId thread_id = thread->getId();
|
||||
Thread::setFlags(thread_id, GUI_THREAD_FLAG_DRAW);
|
||||
auto task_handle = thread->getTaskHandle();
|
||||
threadFlags.set(GUI_THREAD_FLAG_DRAW);
|
||||
}
|
||||
|
||||
void GuiService::showApp(std::shared_ptr<app::AppInstance> app) {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
#include <Tactility/service/ServiceContext.h>
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/settings/KeyboardSettings.h>
|
||||
#include <Tactility/CoreDefines.h>
|
||||
#include <Tactility/hal/keyboard/KeyboardDevice.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/service/ServiceContext.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
#include <Tactility/settings/KeyboardSettings.h>
|
||||
#include <Tactility/Timer.h>
|
||||
|
||||
namespace keyboardbacklight {
|
||||
bool setBrightness(uint8_t brightness);
|
||||
@@ -67,9 +68,9 @@ public:
|
||||
// Note: Settings changes require service restart to take effect
|
||||
// TODO: Add KeyboardSettingsChanged events for dynamic updates
|
||||
|
||||
timer = std::make_unique<Timer>(Timer::Type::Periodic, [this]{ this->tick(); });
|
||||
timer->setThreadPriority(Thread::Priority::Lower);
|
||||
timer->start(250); // check 4x per second for snappy restore
|
||||
timer = std::make_unique<Timer>(Timer::Type::Periodic, kernel::millisToTicks(250), [this]{ this->tick(); });
|
||||
timer->setCallbackPriority(Thread::Priority::Lower);
|
||||
timer->start();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
namespace tt::service::memorychecker {
|
||||
|
||||
constexpr const char* TAG = "MemoryChecker";
|
||||
constexpr TickType_t TIMER_UPDATE_INTERVAL = 2000U / portTICK_PERIOD_MS;
|
||||
|
||||
// Total memory (in bytes) that should be free before warnings occur
|
||||
constexpr auto TOTAL_FREE_THRESHOLD = 10'000;
|
||||
@@ -58,8 +57,8 @@ bool MemoryCheckerService::onStart(ServiceContext& service) {
|
||||
statusbarIconId = lvgl::statusbar_icon_add(icon_path, false);
|
||||
lvgl::statusbar_icon_set_visibility(statusbarIconId, false);
|
||||
|
||||
timer.setThreadPriority(Thread::Priority::Lower);
|
||||
timer.start(TIMER_UPDATE_INTERVAL);
|
||||
timer.setCallbackPriority(Thread::Priority::Lower);
|
||||
timer.start();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
#if TT_FEATURE_SCREENSHOT_ENABLED
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <Tactility/service/screenshot/Screenshot.h>
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
|
||||
#include <memory>
|
||||
#include <lvgl.h>
|
||||
#include <memory>
|
||||
|
||||
namespace tt::service::screenshot {
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ void ScreenshotTask::stop() {
|
||||
if (thread != nullptr) {
|
||||
if (mutex.lock(50 / portTICK_PERIOD_MS)) {
|
||||
interrupted = true;
|
||||
tt_check(mutex.unlock());
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
thread->join();
|
||||
@@ -167,7 +167,7 @@ void ScreenshotTask::stop() {
|
||||
if (mutex.lock(50 / portTICK_PERIOD_MS)) {
|
||||
delete thread;
|
||||
thread = nullptr;
|
||||
tt_check(mutex.unlock());
|
||||
mutex.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <Tactility/service/ServiceContext.h>
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/hal/sdcard/SdCardDevice.h>
|
||||
|
||||
namespace tt::service::sdcard {
|
||||
@@ -60,12 +60,12 @@ public:
|
||||
}
|
||||
|
||||
auto service = findServiceById<SdCardService>(manifest.id);
|
||||
updateTimer = std::make_unique<Timer>(Timer::Type::Periodic, [service]() {
|
||||
updateTimer = std::make_unique<Timer>(Timer::Type::Periodic, 1000, [service] {
|
||||
service->update();
|
||||
});
|
||||
|
||||
// We want to try and scan more often in case of startup or scan lock failure
|
||||
updateTimer->start(1000);
|
||||
updateTimer->start();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#include <Tactility/lvgl/Statusbar.h>
|
||||
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/hal/power/PowerDevice.h>
|
||||
#include <Tactility/hal/sdcard/SdCardDevice.h>
|
||||
#include <Tactility/lvgl/Lvgl.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/service/gps/GpsService.h>
|
||||
#include <Tactility/service/ServiceContext.h>
|
||||
#include <Tactility/service/ServicePaths.h>
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
#include <Tactility/service/gps/GpsService.h>
|
||||
#include <Tactility/service/wifi/Wifi.h>
|
||||
#include <Tactility/Timer.h>
|
||||
|
||||
namespace tt::service::statusbar {
|
||||
|
||||
@@ -265,14 +265,14 @@ public:
|
||||
assert(service);
|
||||
service->update();
|
||||
|
||||
updateTimer = std::make_unique<Timer>(Timer::Type::Periodic, [service] {
|
||||
updateTimer = std::make_unique<Timer>(Timer::Type::Periodic, pdMS_TO_TICKS(1000), [service] {
|
||||
service->update();
|
||||
});
|
||||
|
||||
updateTimer->setThreadPriority(Thread::Priority::Lower);
|
||||
updateTimer->setCallbackPriority(Thread::Priority::Lower);
|
||||
|
||||
// We want to try and scan more often in case of startup or scan lock failure
|
||||
updateTimer->start(1000);
|
||||
updateTimer->start();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "Tactility/service/wifi/Wifi.h"
|
||||
#include <Tactility/service/wifi/Wifi.h>
|
||||
|
||||
#include <Tactility/Check.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
|
||||
|
||||
@@ -6,15 +6,15 @@
|
||||
|
||||
#include <Tactility/service/wifi/Wifi.h>
|
||||
|
||||
#include <Tactility/EventFlag.h>
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/EventGroup.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/kernel/SystemEvents.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/service/ServiceContext.h>
|
||||
#include <Tactility/service/wifi/WifiBootSplashInit.h>
|
||||
#include <Tactility/service/wifi/WifiGlobals.h>
|
||||
#include <Tactility/service/wifi/WifiSettings.h>
|
||||
#include <Tactility/service/wifi/WifiBootSplashInit.h>
|
||||
#include <Tactility/Timer.h>
|
||||
|
||||
#include <lwip/esp_netif_net_stack.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
@@ -66,10 +66,10 @@ public:
|
||||
/** @brief Maximum amount of records to scan (value > 0) */
|
||||
uint16_t scan_list_limit = TT_WIFI_SCAN_RECORD_LIMIT;
|
||||
/** @brief when we last requested a scan. Loops around every 50 days. */
|
||||
TickType_t last_scan_time = portMAX_DELAY;
|
||||
TickType_t last_scan_time = kernel::MAX_TICKS;
|
||||
esp_event_handler_instance_t event_handler_any_id = nullptr;
|
||||
esp_event_handler_instance_t event_handler_got_ip = nullptr;
|
||||
EventFlag connection_wait_flags;
|
||||
EventGroup connection_wait_flags;
|
||||
settings::WifiApSettings connection_target;
|
||||
bool pause_auto_connect = false; // Pause when manually disconnecting until manually connecting again
|
||||
bool connection_target_remember = false; // Whether to store the connection_target on successful connection or not
|
||||
@@ -792,32 +792,34 @@ static void dispatchConnect(std::shared_ptr<Wifi> wifi) {
|
||||
/* Waiting until either the connection is established (WIFI_CONNECTED_BIT)
|
||||
* or connection failed for the maximum number of re-tries (WIFI_FAIL_BIT).
|
||||
* The bits are set by wifi_event_handler() */
|
||||
uint32_t bits = wifi_singleton->connection_wait_flags.wait(WIFI_FAIL_BIT | WIFI_CONNECTED_BIT);
|
||||
TT_LOG_I(TAG, "Waiting for EventFlag by event_handler()");
|
||||
uint32_t bits;
|
||||
if (wifi_singleton->connection_wait_flags.wait(WIFI_FAIL_BIT | WIFI_CONNECTED_BIT, false, true, kernel::MAX_TICKS, &bits)) {
|
||||
TT_LOG_I(TAG, "Waiting for EventGroup by event_handler()");
|
||||
|
||||
if (bits & WIFI_CONNECTED_BIT) {
|
||||
wifi->setSecureConnection(config.sta.password[0] != 0x00U);
|
||||
wifi->setRadioState(RadioState::ConnectionActive);
|
||||
publish_event(wifi, WifiEvent::ConnectionSuccess);
|
||||
TT_LOG_I(TAG, "Connected to %s", wifi->connection_target.ssid.c_str());
|
||||
if (wifi->connection_target_remember) {
|
||||
if (!settings::save(wifi->connection_target)) {
|
||||
TT_LOG_E(TAG, "Failed to store credentials");
|
||||
} else {
|
||||
TT_LOG_I(TAG, "Stored credentials");
|
||||
if (bits & WIFI_CONNECTED_BIT) {
|
||||
wifi->setSecureConnection(config.sta.password[0] != 0x00U);
|
||||
wifi->setRadioState(RadioState::ConnectionActive);
|
||||
publish_event(wifi, WifiEvent::ConnectionSuccess);
|
||||
TT_LOG_I(TAG, "Connected to %s", wifi->connection_target.ssid.c_str());
|
||||
if (wifi->connection_target_remember) {
|
||||
if (!settings::save(wifi->connection_target)) {
|
||||
TT_LOG_E(TAG, "Failed to store credentials");
|
||||
} else {
|
||||
TT_LOG_I(TAG, "Stored credentials");
|
||||
}
|
||||
}
|
||||
} else if (bits & WIFI_FAIL_BIT) {
|
||||
wifi->setRadioState(RadioState::On);
|
||||
publish_event(wifi, WifiEvent::ConnectionFailed);
|
||||
TT_LOG_I(TAG, "Failed to connect to %s", wifi->connection_target.ssid.c_str());
|
||||
} else {
|
||||
wifi->setRadioState(RadioState::On);
|
||||
publish_event(wifi, WifiEvent::ConnectionFailed);
|
||||
TT_LOG_E(TAG, "UNEXPECTED EVENT");
|
||||
}
|
||||
} else if (bits & WIFI_FAIL_BIT) {
|
||||
wifi->setRadioState(RadioState::On);
|
||||
publish_event(wifi, WifiEvent::ConnectionFailed);
|
||||
TT_LOG_I(TAG, "Failed to connect to %s", wifi->connection_target.ssid.c_str());
|
||||
} else {
|
||||
wifi->setRadioState(RadioState::On);
|
||||
publish_event(wifi, WifiEvent::ConnectionFailed);
|
||||
TT_LOG_E(TAG, "UNEXPECTED EVENT");
|
||||
}
|
||||
|
||||
wifi_singleton->connection_wait_flags.clear(WIFI_FAIL_BIT | WIFI_CONNECTED_BIT);
|
||||
wifi_singleton->connection_wait_flags.clear(WIFI_FAIL_BIT | WIFI_CONNECTED_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
static void dispatchDisconnectButKeepActive(std::shared_ptr<Wifi> wifi) {
|
||||
@@ -920,9 +922,10 @@ public:
|
||||
bootSplashInit();
|
||||
});
|
||||
|
||||
wifi_singleton->autoConnectTimer = std::make_unique<Timer>(Timer::Type::Periodic, []() { onAutoConnectTimer(); });
|
||||
auto timer_interval = std::min(2000, AUTO_SCAN_INTERVAL);
|
||||
wifi_singleton->autoConnectTimer = std::make_unique<Timer>(Timer::Type::Periodic, timer_interval, [] { onAutoConnectTimer(); });
|
||||
// We want to try and scan more often in case of startup or scan lock failure
|
||||
wifi_singleton->autoConnectTimer->start(std::min(2000, AUTO_SCAN_INTERVAL));
|
||||
wifi_singleton->autoConnectTimer->start();
|
||||
|
||||
if (settings::shouldEnableOnBoot()) {
|
||||
TT_LOG_I(TAG, "Auto-enabling due to setting");
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
#include <Tactility/service/wifi/Wifi.h>
|
||||
|
||||
#include <Tactility/PubSub.h>
|
||||
#include <Tactility/Check.h>
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/PubSub.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/service/Service.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
@@ -81,26 +81,31 @@ std::vector<ApRecord> getScanResults() {
|
||||
records.push_back((ApRecord) {
|
||||
.ssid = "Home Wifi",
|
||||
.rssi = -30,
|
||||
.channel = 0,
|
||||
.auth_mode = WIFI_AUTH_WPA2_PSK
|
||||
});
|
||||
records.push_back((ApRecord) {
|
||||
.ssid = "No place like 127.0.0.1",
|
||||
.rssi = -67,
|
||||
.channel = 0,
|
||||
.auth_mode = WIFI_AUTH_WPA2_PSK
|
||||
});
|
||||
records.push_back((ApRecord) {
|
||||
.ssid = "Pretty fly for a Wi-Fi",
|
||||
.rssi = -70,
|
||||
.channel = 0,
|
||||
.auth_mode = WIFI_AUTH_WPA2_PSK
|
||||
});
|
||||
records.push_back((ApRecord) {
|
||||
.ssid = "An AP with a really, really long name",
|
||||
.rssi = -80,
|
||||
.channel = 0,
|
||||
.auth_mode = WIFI_AUTH_WPA2_PSK
|
||||
});
|
||||
records.push_back((ApRecord) {
|
||||
.ssid = "Bad Reception",
|
||||
.rssi = -90,
|
||||
.channel = 0,
|
||||
.auth_mode = WIFI_AUTH_OPEN
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user