8#include <hardware/adc.h>
9#include <pico/cyw43_arch.h>
44 { res.
send(
"Welcome to PicoFramework!"); });
47 std::vector<FileInfo> files;
62 std::cout <<
"[App] Initializing application..." << std::endl;
65 gpioController.
start();
67 dashboardController.
start();
80 gpioEventManager->
enableInterrupt(16, GPIO_IRQ_EDGE_RISE | GPIO_IRQ_EDGE_FALL);
81 gpioEventManager->
enableInterrupt(17, GPIO_IRQ_EDGE_RISE | GPIO_IRQ_EDGE_FALL);
85 std::cout <<
"[App] Waiting for network..." << std::endl;
125 printf(
"[App] GpioChange received\n");
129 printf(
"[App] GPIO changed - pin %u: %s\n",
131 (data.
edge & GPIO_IRQ_EDGE_RISE) ?
"rising" : (data.
edge & GPIO_IRQ_EDGE_FALL) ?
"falling" :
"unknown");
136 std::cout <<
"[App] Network ready. Starting services..." << std::endl;
138 printf(
"[App] Network ready. Starting HTTP server...\n");
143 std::cout <<
"[App] Time is valid." << std::endl;
148 printf(
"[App] UTC time: %s\n", localTime.c_str());
156 std::cout <<
"[App] Local Time is valid." << std::endl;
158 printf(
"[App] Local time: %s\n", localTime.c_str());
163 std::cout <<
"[App] SNTP Time Sync event." << std::endl;
171 std::cout <<
"[App] Time is invalid. Running in degraded mode." << std::endl;
183 printf(
"[App] Heartbeat user event received\n");
190 static int count = 0;
192 printf(
"[App] Starting main polling loop...\n");
195 vTaskDelay(pdMS_TO_TICKS(100));
201 printf(
"[App] Running main polling loop...\n");
205 vTaskDelay(pdMS_TO_TICKS(1)); },
"logLoop");
Event pub/sub manager for embedded applications using FreeRTOS.
Posts GPIO change events (rising/falling edge) via EventManager.
HTTP file server and file handling helpers for static content.
Utility functions to send standard JSON responses using nlohmann::json.
constexpr uint32_t eventMask(Enum e)
Helper function to create an event mask from an enum value.
HTTP routing with middleware and optional JWT-based authorization. Part of the PicoFramework HTTP ser...
Abstract interface for file and directory storage backends.
static constexpr std::uintptr_t getTypeKey()
void initRoutes() override
Define the application's HTTP routes.
void onEvent(const Event &e) override
Called when an event is dispatched to this controller.
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.
Manages the system-wide event queue and subscriptions.
void subscribe(uint32_t eventMask, FrameworkController *controller)
Subscribe a task to specific event types.
Base class for applications using the framework.
HttpServer server
Embedded HTTP server instance.
Router router
Router instance for handling HTTP routes.
void onStart() override
Starts the Framework Manager.
void runEvery(uint32_t intervalMs, const std::function< void()> &fn, const char *id)
Run a function periodically with millisecond resolution.
bool start()
Starts the task via FreeRTOS.
GpioEventManager registers interrupts and posts GpioChange events to multiple listeners per pin.
void enableInterrupt(uint pin, uint32_t edgeMask)
Enable GPIO interrupts for a specific pin and edge mask.
Forward declaration for potential routing needs.
Represents an HTTP response object.
HttpResponse & json(const std::string &jsonString)
Send a JSON string/object with correct content type.
void send(const std::string &body)
Send a full response including headers and body.
bool start()
Start the HTTP server as a FreeRTOS task.
void addRoute(const std::string &method, const std::string &path, RouteHandler handler, std::vector< Middleware > middleware={})
Register a route with optional middleware.
Represents a framework event, optionally carrying payload data.
Notification notification
Notification identifier (system or user)
GpioEvent gpioEvent
Inline data if GpioChange.
Structure representing a GPIO event.
SystemNotification system