feat: integrate NetworkHandler and WifiHandler for network initialization
This commit is contained in:
@@ -23,6 +23,10 @@
|
|||||||
#include "display/display.h"
|
#include "display/display.h"
|
||||||
#include "touch/touch.h"
|
#include "touch/touch.h"
|
||||||
#include <tick/lv_tick.h>
|
#include <tick/lv_tick.h>
|
||||||
|
#include "network.h"
|
||||||
|
|
||||||
|
#define DEFAULT_STORAGE_NAMESPACE "storage"
|
||||||
|
#define WIFI_CREDENTIALS_STORAGE_NAMESPACE "wifi_credentials"
|
||||||
|
|
||||||
extern "C" void app_main(void);
|
extern "C" void app_main(void);
|
||||||
|
|
||||||
@@ -50,12 +54,17 @@ void app_main(void) {
|
|||||||
throw std::runtime_error("Failed to create LVGL mutex");
|
throw std::runtime_error("Failed to create LVGL mutex");
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
WifiHandler wifi_handler(
|
||||||
|
new NVSStorageHandler(WIFI_CREDENTIALS_STORAGE_NAMESPACE)
|
||||||
|
);
|
||||||
|
NetworkHandler* network_handler = new NetworkHandler(std::move(wifi_handler));
|
||||||
KVStorageHandler* kv_storage_handler = new NVSStorageHandler(
|
KVStorageHandler* kv_storage_handler = new NVSStorageHandler(
|
||||||
"storage"
|
DEFAULT_STORAGE_NAMESPACE
|
||||||
);
|
);
|
||||||
DisplayHandler* display_handler = new EInkDisplayHandler(touch_event_queue, lvgl_mutex);
|
DisplayHandler* display_handler = new EInkDisplayHandler(touch_event_queue, lvgl_mutex);
|
||||||
TouchHandler* touch_handler = new EInkTouchHandler(touch_event_queue);
|
TouchHandler* touch_handler = new EInkTouchHandler(touch_event_queue);
|
||||||
//
|
//
|
||||||
|
network_handler->init(system_event_group);
|
||||||
kv_storage_handler->init(system_event_group);
|
kv_storage_handler->init(system_event_group);
|
||||||
display_handler->init(system_event_group);
|
display_handler->init(system_event_group);
|
||||||
touch_handler->init(system_event_group);
|
touch_handler->init(system_event_group);
|
||||||
@@ -80,7 +89,7 @@ void app_main(void) {
|
|||||||
printf("Waiting for system to be ready...\n");
|
printf("Waiting for system to be ready...\n");
|
||||||
xEventGroupWaitBits(
|
xEventGroupWaitBits(
|
||||||
system_event_group,
|
system_event_group,
|
||||||
DISPLAY_READY_BIT | TOUCH_CALIBRATED_BIT | STORAGE_READY_BIT,
|
DISPLAY_READY_BIT | TOUCH_CALIBRATED_BIT | STORAGE_READY_BIT | NETWORK_READY_BIT,
|
||||||
// do not clear on exit, require explicit reset
|
// do not clear on exit, require explicit reset
|
||||||
pdFALSE,
|
pdFALSE,
|
||||||
pdTRUE,
|
pdTRUE,
|
||||||
@@ -109,7 +118,6 @@ void app_main(void) {
|
|||||||
vSemaphoreDelete(lvgl_mutex);
|
vSemaphoreDelete(lvgl_mutex);
|
||||||
vEventGroupDelete(system_event_group);
|
vEventGroupDelete(system_event_group);
|
||||||
vQueueDelete(touch_event_queue);
|
vQueueDelete(touch_event_queue);
|
||||||
|
|
||||||
printf("Cleanup complete.\n");
|
printf("Cleanup complete.\n");
|
||||||
|
|
||||||
// handle shutdown or restart
|
// handle shutdown or restart
|
||||||
@@ -130,6 +138,14 @@ void app_main(void) {
|
|||||||
pdFALSE,
|
pdFALSE,
|
||||||
portMAX_DELAY
|
portMAX_DELAY
|
||||||
);
|
);
|
||||||
|
if (bits & SYSTEM_START_BIT) {
|
||||||
|
printf("SYSTEM_START_BIT received, restarting system.\n");
|
||||||
|
} else {
|
||||||
|
printf("No restart signal received, waiting for manual power cycle.\n");
|
||||||
|
while (true) {
|
||||||
|
vTaskDelay(portMAX_DELAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (bits & SYSTEM_RESTART_BIT) {
|
} else if (bits & SYSTEM_RESTART_BIT) {
|
||||||
if (restart_display_handler != nullptr) {
|
if (restart_display_handler != nullptr) {
|
||||||
printf("Calling display restart handler...\n");
|
printf("Calling display restart handler...\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user