Various improvements (#264)

- Replace C function pointers with C++ `std::function` in `Thread`, `Timer` and `DispatcherThread`
- Rename `SystemEvent`-related functions
- WiFi: fix auto-connect when WiFi disconnects from bad signal
- WiFi: fix auto-connect when WiFi fails to auto-connect
- WiFi: implement disconnect() when tapping connected WiFi ap in WiFi management app
This commit is contained in:
Ken Van Hoeylandt
2025-03-30 21:59:31 +02:00
committed by GitHub
parent d72852a6e2
commit 3f1bfee3f5
37 changed files with 239 additions and 322 deletions
+3 -3
View File
@@ -55,7 +55,7 @@ static const char* getEventName(SystemEvent event) {
tt_crash(); // Missing case above
}
void systemEventPublish(SystemEvent event) {
void publishSystemEvent(SystemEvent event) {
TT_LOG_I(TAG, "%s", getEventName(event));
if (mutex.lock(portMAX_DELAY)) {
@@ -69,7 +69,7 @@ void systemEventPublish(SystemEvent event) {
}
}
SystemEventSubscription systemEventAddListener(SystemEvent event, std::function<void(SystemEvent)> handler) {
SystemEventSubscription subscribeSystemEvent(SystemEvent event, OnSystemEvent handler) {
if (mutex.lock(portMAX_DELAY)) {
auto id = ++subscriptionCounter;
@@ -86,7 +86,7 @@ SystemEventSubscription systemEventAddListener(SystemEvent event, std::function<
}
}
void systemEventRemoveListener(SystemEventSubscription subscription) {
void unsubscribeSystemEvent(SystemEventSubscription subscription) {
if (mutex.lock(portMAX_DELAY)) {
std::erase_if(subscriptions, [subscription](auto& item) {
return (item.id == subscription);