35#include <unordered_map>
72 FrameworkController(
const char* name,
Router& sharedRouter, uint16_t stackSize = 1024, UBaseType_t priority = tskIDLE_PRIORITY + 1);
82 void run()
override final;
120 return pdMS_TO_TICKS(100);
137 void runEvery(uint32_t intervalMs,
const std::function<
void()> &fn,
const char *
id);
178 std::unordered_map<std::string, TickType_t>
_timers;
199#define STRINGIFY_DETAIL(x) #x
200#define STRINGIFY(x) STRINGIFY_DETAIL(x)
201#define RUN_EVERY(ms, fn) runEvery(ms, fn, __FUNCTION__ ":" STRINGIFY(__LINE__))
Defines the Event structure and related utilities for event messaging.
FreeRTOS-aware task abstraction with built-in notification and queue support.
HTTP routing with middleware and optional JWT-based authorization. Part of the PicoFramework HTTP ser...
Base class for event-driven control logic in embedded applications.
void runEvery(uint32_t intervalMs, const std::function< void()> &fn, const char *id)
Run a function periodically with millisecond resolution.
virtual TickType_t getPollIntervalTicks()
Returns the polling interval in ticks used in run().
Router & router
Handles path-to-handler mapping - reference to shared Router instance.
bool getNextEvent(Event &event, uint32_t timeoutMs)
Check if there are any pending events in the queue.
virtual void onStart()
Called once at task start before entering the main loop.
virtual void onEvent(const Event &event)
Called when an event is dispatched to this controller.
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.
void run() override final
Main task loop.
virtual void initRoutes()
Initialize routes for this controller.
virtual void poll()
Called during every loop iteration for non-blocking background logic.
void waitAndDispatch(uint32_t timeoutMs=portMAX_DELAY)
Waits for an event and dispatches it to onEvent() if applicable.
QueueHandle_t eventQueue_
std::unordered_map< std::string, TickType_t > _timers
Stores last-execution timestamps per ID.
Base class for FreeRTOS-aware tasks in the framework.
const char * getName() const
Returns the task name.
The central router for handling HTTP requests and middleware.
Represents a framework event, optionally carrying payload data.