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
@@ -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