#include <app.h>
Public Types | |
enum class | UserNotification : uint8_t { Heartbeat = 0 } |
Public Member Functions | |
App (int port) | |
void | initRoutes () override |
Define the application's HTTP routes. | |
void | onStart () override |
Called once at task start before entering the main loop. | |
void | poll () override |
Called during every loop iteration for non-blocking background logic. | |
void | onEvent (const Event &e) override |
Called when an event is dispatched to this controller. | |
![]() | |
FrameworkApp (int port, const char *name="AppTask", uint16_t stackSize=2048, UBaseType_t priority=tskIDLE_PRIORITY+1) | |
Constructor. | |
virtual | ~FrameworkApp ()=default |
Virtual destructor. | |
virtual void | start () |
Initializes the application and its framework services. | |
void | onStart () override |
Starts the Framework Manager. | |
![]() | |
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 Attributes | |
PicoModel | pico |
Additional Inherited Members | |
![]() | |
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 |
Router instance for handling HTTP routes. | |
HttpServer | server |
Embedded HTTP server instance. | |
FrameworkManager | manager |
Responsible for launching system services and networking. | |
![]() | |
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 |
|
strong |
|
overridevirtual |
You must implement this method in your subclass. Define your routes here using router.addRoute(...)
. This centralizes route logic and ensures all endpoints are registered before the server runs.
Example:
Or bind member functions:
Reimplemented from FrameworkApp.
Definition at line 33 of file app.cpp.
References Router::addRoute(), AppContext::getTypeKey(), HttpResponse::json(), FrameworkApp::router, and HttpResponse::send().
|
overridevirtual |
Called when an event is dispatched to this controller.
Override to implement your event-driven logic.
Override to implement your event-driven logic.
Reimplemented from FrameworkController.
Definition at line 108 of file app.cpp.
References GpioEvent::edge, AppContext::getTypeKey(), GpioChange, Event::gpioEvent, Heartbeat, Notification::kind, LocalTimeValid, NetworkReady, Event::notification, PicoModel::onNetworkReady(), pico, GpioEvent::pin, FrameworkApp::server, HttpServer::start(), System, Notification::system, TimeInvalid, TimeSync, TimeValid, User, and Notification::user_code.
|
overridevirtual |
Called once at task start before entering the main loop.
Override this to initialize controller state.
Override this to initialize controller state.
Reimplemented from FrameworkController.
Definition at line 53 of file app.cpp.
References GpioEventManager::enableInterrupt(), eventMask(), AppContext::getTypeKey(), GpioChange, Heartbeat, LocalTimeValid, NetworkReady, PicoModel::onStart(), FrameworkApp::onStart(), pico, FrameworkApp::router, FrameworkTask::start(), EventManager::subscribe(), TimeInvalid, TimeSync, and TimeValid.
|
overridevirtual |
Called during every loop iteration for non-blocking background logic.
Runs after waitAndDispatch() — useful for polling sensors or internal FSMs.
Runs after waitAndDispatch() — useful for polling sensors or internal FSMs.
Reimplemented from FrameworkController.
Definition at line 188 of file app.cpp.
References AppContext::getTypeKey(), Heartbeat, and FrameworkController::runEvery().
|
private |