Merge develop into main (#150)
- Update `Configuration` to use C++ vector instead of C arrays - Rename `Desktop` app to `Launcher` - Fix for hard-coded app start of `Launcher` and `CrashDiagnostics` apps. - Ensure `Launcher` icons are clickable, even if they're not loading. - Don't show error scenario for SD card in statusbar when SD card status is unknown (this happens during Mutex timeout due to LVGL rendering delays) - Cleanup deprecated `Mutex` methods. - `hal::getConfiguration()` now returns a pointer instead of a reference, just like `tt:getConfiguration()`
This commit is contained in:
committed by
GitHub
parent
415096c3b2
commit
4f360741a1
@@ -50,9 +50,8 @@ Dispatcher& getMainDispatcher() {
|
||||
|
||||
namespace hal {
|
||||
|
||||
const Configuration& getConfiguration() {
|
||||
tt_assert(hardwareConfig != nullptr);
|
||||
return *hardwareConfig;
|
||||
const Configuration* getConfiguration() {
|
||||
return hardwareConfig;
|
||||
}
|
||||
|
||||
} // namespace hal
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "TactilityCore.h"
|
||||
#include "hal/Configuration.h"
|
||||
#include "TactilityHeadlessConfig.h"
|
||||
#include "Dispatcher.h"
|
||||
|
||||
namespace tt {
|
||||
@@ -20,7 +19,7 @@ Dispatcher& getMainDispatcher();
|
||||
|
||||
namespace tt::hal {
|
||||
|
||||
/** Can be called after initHeadless() is called. Will crash otherwise. */
|
||||
const Configuration& getConfiguration();
|
||||
/** While technically this configuration is nullable, it's never null after initHeadless() is called. */
|
||||
const Configuration* _Nullable getConfiguration();
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define TT_CONFIG_SERVICES_LIMIT 32
|
||||
@@ -1,4 +1,5 @@
|
||||
#ifdef ESP_TARGET
|
||||
|
||||
#include "TactilityCore.h"
|
||||
#include "EspPartitions_i.h"
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ static Mode currentMode = ModeDefault;
|
||||
static RTC_NOINIT_ATTR BootMode bootMode;
|
||||
|
||||
sdmmc_card_t* _Nullable getCard() {
|
||||
auto sdcard = getConfiguration().sdcard;
|
||||
auto sdcard = getConfiguration()->sdcard;
|
||||
if (sdcard == nullptr) {
|
||||
TT_LOG_W(TAG, "No SD card configuration found");
|
||||
return nullptr;
|
||||
|
||||
@@ -30,7 +30,7 @@ struct ServiceData {
|
||||
|
||||
|
||||
static void onUpdate(std::shared_ptr<void> context) {
|
||||
auto sdcard = tt::hal::getConfiguration().sdcard;
|
||||
auto sdcard = tt::hal::getConfiguration()->sdcard;
|
||||
if (sdcard == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -57,7 +57,7 @@ static void onUpdate(std::shared_ptr<void> context) {
|
||||
}
|
||||
|
||||
static void onStart(ServiceContext& service) {
|
||||
if (hal::getConfiguration().sdcard != nullptr) {
|
||||
if (hal::getConfiguration()->sdcard != nullptr) {
|
||||
auto data = std::make_shared<ServiceData>();
|
||||
service.setData(data);
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#include "Mutex.h"
|
||||
#include "Pubsub.h"
|
||||
#include "service/ServiceContext.h"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
namespace tt::service::wifi {
|
||||
|
||||
@@ -17,25 +15,23 @@ namespace tt::service::wifi {
|
||||
#define WIFI_CONNECTED_BIT BIT0
|
||||
#define WIFI_FAIL_BIT BIT1
|
||||
|
||||
typedef struct {
|
||||
struct Wifi {
|
||||
Wifi() = default;
|
||||
~Wifi() = default;
|
||||
|
||||
/** @brief Locking mechanism for modifying the Wifi instance */
|
||||
Mutex* mutex;
|
||||
Mutex mutex = Mutex(Mutex::TypeRecursive);
|
||||
/** @brief The public event bus */
|
||||
std::shared_ptr<PubSub> pubsub;
|
||||
std::shared_ptr<PubSub> pubsub = std::make_shared<PubSub>();
|
||||
/** @brief The internal message queue */
|
||||
MessageQueue queue;
|
||||
bool scan_active;
|
||||
bool secure_connection;
|
||||
WifiRadioState radio_state;
|
||||
} Wifi;
|
||||
bool scan_active = false;
|
||||
bool secure_connection = false;
|
||||
WifiRadioState radio_state = WIFI_RADIO_CONNECTION_ACTIVE;
|
||||
};
|
||||
|
||||
|
||||
static Wifi* wifi = nullptr;
|
||||
|
||||
// Forward declarations
|
||||
static void wifi_lock(Wifi* wifi);
|
||||
static void wifi_unlock(Wifi* wifi);
|
||||
|
||||
// region Static
|
||||
|
||||
static void publish_event_simple(Wifi* wifi, WifiEventType type) {
|
||||
@@ -45,25 +41,6 @@ static void publish_event_simple(Wifi* wifi, WifiEventType type) {
|
||||
|
||||
// endregion Static
|
||||
|
||||
// region Alloc
|
||||
|
||||
static Wifi* wifi_alloc() {
|
||||
auto* instance = static_cast<Wifi*>(malloc(sizeof(Wifi)));
|
||||
instance->mutex = tt_mutex_alloc(Mutex::TypeRecursive);
|
||||
instance->pubsub = std::make_shared<PubSub>();
|
||||
instance->scan_active = false;
|
||||
instance->radio_state = WIFI_RADIO_CONNECTION_ACTIVE;
|
||||
instance->secure_connection = false;
|
||||
return instance;
|
||||
}
|
||||
|
||||
static void wifi_free(Wifi* instance) {
|
||||
tt_mutex_free(instance->mutex);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
// endregion Alloc
|
||||
|
||||
// region Public functions
|
||||
|
||||
std::shared_ptr<PubSub> getPubsub() {
|
||||
@@ -160,29 +137,14 @@ int getRssi() {
|
||||
|
||||
// endregion Public functions
|
||||
|
||||
static void lock(Wifi* wifi) {
|
||||
tt_crash("this fails for now");
|
||||
tt_assert(wifi);
|
||||
tt_assert(wifi->mutex);
|
||||
tt_mutex_acquire(wifi->mutex, 100);
|
||||
}
|
||||
|
||||
static void unlock(Wifi* wifi) {
|
||||
tt_assert(wifi);
|
||||
tt_assert(wifi->mutex);
|
||||
tt_mutex_release(wifi->mutex);
|
||||
}
|
||||
|
||||
|
||||
static void service_start(TT_UNUSED ServiceContext& service) {
|
||||
tt_check(wifi == nullptr);
|
||||
wifi = wifi_alloc();
|
||||
wifi = new Wifi();
|
||||
}
|
||||
|
||||
static void service_stop(TT_UNUSED ServiceContext& service) {
|
||||
tt_check(wifi != nullptr);
|
||||
|
||||
wifi_free(wifi);
|
||||
delete wifi;
|
||||
wifi = nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user