Starts and coordinates core system services like networking and time sync. More...
#include <FrameworkManager.h>
Public Member Functions | |
FrameworkManager (FrameworkApp *app, Router &router) | |
Constructor. | |
![]() | |
FrameworkController (const char *name, Router &sharedRouter, uint16_t stackSize=1024, UBaseType_t priority=tskIDLE_PRIORITY+1) | |
Constructor. | |
void | run () override final |
Main task loop. | |
const char * | getName () const |
Get the name of this controller. | |
void | enableEventQueue (size_t depth=8) |
Enable the event queue for this controller. | |
QueueHandle_t | getEventQueue () const |
Get the event queue for this controller. | |
bool | getNextEvent (Event &event, uint32_t timeoutMs) |
Check if there are any pending events in the queue. | |
![]() | |
FrameworkTask (const char *name, uint16_t stackSize=1024, UBaseType_t priority=1) | |
Constructor. | |
virtual | ~FrameworkTask () |
Destructor. | |
bool | start () |
Starts the task via FreeRTOS. | |
void | suspend () |
Suspends the task using vTaskSuspend() . | |
void | resume () |
Resumes the task using vTaskResume() . | |
TaskHandle_t | getHandle () const |
Returns the FreeRTOS task handle. | |
const char * | getName () const |
Returns the task name. | |
void | notify (uint8_t index, uint32_t value=1) |
Sends a notification to this task using an index. | |
void | notify (Notification n, uint32_t value=1) |
Sends a notification using a framework-defined enum. | |
void | notifyFromISR (uint8_t index, uint32_t value=1, BaseType_t *pxHigherPriorityTaskWoken=nullptr) |
Sends a notification from an ISR (by index). | |
void | notifyFromISR (Notification n, uint32_t value=1, BaseType_t *pxHigherPriorityTaskWoken=nullptr) |
Sends a notification from ISR using enum identifier. | |
bool | waitFor (uint8_t index, TickType_t timeout=portMAX_DELAY) |
Waits for a notification (by index). | |
bool | waitFor (Notification n, TickType_t timeout=portMAX_DELAY) |
Waits for a notification (by enum identifier). | |
Notification | waitForAny (uint8_t index, uint32_t mask, TickType_t timeout=portMAX_DELAY) |
waits for any notification matching the given mask. | |
Private Member Functions | |
void | setupTraceFromConfig () |
Sets up debug tracing from configuration. | |
void | onStart () |
Initializes the network and application tasks. | |
void | warmUp () |
void | poll () |
Polling function for the FrameworkManager. | |
void | onEvent (const Event &event) |
Handles events posted to the FrameworkManager. | |
Static Private Member Functions | |
static void | app_task (void *params) |
Placeholder for an application-level task, if used. | |
Private Attributes | |
FrameworkApp * | app |
Pointer to the application task. | |
TaskHandle_t | networkTaskHandle |
Handle for the network task. | |
TaskHandle_t | applicationTaskHandle |
(Unused) optional handle for app task | |
Network | network |
Network management. | |
Additional Inherited Members | |
![]() | |
virtual void | initRoutes () |
Initialize routes for this controller. | |
virtual TickType_t | getPollIntervalTicks () |
Returns the polling interval in ticks used in run(). | |
void | runEvery (uint32_t intervalMs, const std::function< void()> &fn, const char *id) |
Run a function periodically with millisecond resolution. | |
![]() | |
uint32_t | waitFor (TickType_t timeout=portMAX_DELAY) |
Wait for any notification (default index). | |
bool | createQueue (size_t itemSize, size_t length) |
Creates an internal FreeRTOS queue. | |
bool | sendToQueue (const void *item, TickType_t timeout=0) |
Sends an item to the internal queue. | |
bool | receiveFromQueue (void *item, TickType_t timeout=portMAX_DELAY) |
Receives an item from the internal queue. | |
![]() | |
Router & | router |
Handles path-to-handler mapping - reference to shared Router instance. | |
![]() | |
const char * | _name |
uint16_t | _stackSize |
UBaseType_t | _priority |
TaskHandle_t | _handle = nullptr |
QueueHandle_t | _queue = nullptr |
Responsible for launching the network task, waiting for connection, and notifying the application via FrameworkNotification::NetworkReady
.
Definition at line 38 of file FrameworkManager.h.
FrameworkManager::FrameworkManager | ( | FrameworkApp * | app, |
Router & | router | ||
) |
Constructor.
app | Pointer to the application, which will be notified when the network is ready. |
app | Pointer to the application, which will be notified when the network is ready. |
Definition at line 45 of file FrameworkManager.cpp.
|
staticprivate |
Placeholder for an application-level task, if used.
Definition at line 127 of file FrameworkManager.cpp.
|
privatevirtual |
This function is called by the EventManager when an event is posted to the FrameworkManager's event queue.
Reimplemented from FrameworkController.
Definition at line 133 of file FrameworkManager.cpp.
References AppContext::getTypeKey(), HttpServerStarted, Notification::kind, Event::notification, System, and Notification::system.
|
privatevirtual |
Initializes the network and application tasks.
This function is called to set up the network and application tasks with the appropriate stack sizes and priorities.
This function is called to set up the network and application tasks with the appropriate stack sizes and priorities.
Reimplemented from FrameworkController.
Definition at line 53 of file FrameworkManager.cpp.
References app, configASSERT, eventMask(), AppContext::getInstance(), AppContext::getTypeKey(), HttpServerStarted, AppContext::initFrameworkServices(), Network::initialize(), network, NetworkReady, Event::notification, TimeManager::onNetworkReady(), setupTraceFromConfig(), FrameworkApp::start(), TimeManager::start(), Network::startWifiWithResilience(), and warmUp().
|
privatevirtual |
This function checks the Wi-Fi connection status at regular intervals and attempts to reconnect if the connection is lost.
Reimplemented from FrameworkController.
Definition at line 148 of file FrameworkManager.cpp.
References Network::checkAndReconnect(), AppContext::getTypeKey(), NetworkDown, NetworkReady, rebootSystem(), Network::restart_wifi(), WIFI_MONITOR_INTERVAL_MS, and WIFI_REBOOT_ON_FAILURE.
|
private |
Sets up debug tracing from configuration.
Uses framework_config to set up tracing options, including file output if enabled. This function should be called after the framework is initialized and before any trace calls are made.
Uses framework_config to set up tracing options, including file output if enabled. This function should be called after the framework is initialized and before any trace calls are made.
Definition at line 195 of file FrameworkManager.cpp.
References AppContext::getTypeKey(), setTraceOutputToFile(), TRACE, TRACE_INIT, and TRACE_LOG_PATH.
Referenced by onStart().
|
private |
Definition at line 102 of file FrameworkManager.cpp.
References HttpRequest::getHeader(), HttpRequest::setHeader(), HttpRequest::setMethod(), and HttpRequest::setPath().
Referenced by onStart().
|
private |
Definition at line 50 of file FrameworkManager.h.
Referenced by onStart().
|
private |
Definition at line 52 of file FrameworkManager.h.
|
private |
Definition at line 54 of file FrameworkManager.h.
Referenced by onStart().
|
private |
Definition at line 51 of file FrameworkManager.h.