Logo Pico-Framework A web-first embedded framework for C++
Loading...
Searching...
No Matches
AppContext.cpp
Go to the documentation of this file.
2#include "time/TimeManager.h"
7#include "utility/logger.h"
8// Right now its mandatory to have one StorageManager interface
9#if PICO_HTTP_ENABLE_LITTLEFS
11 #include "storage/JsonService.h"
12#else
13 #include "storage/JsonService.h"
15#endif
16#include "framework_config.h"
17#include "DebugTrace.h"
19
20SemaphoreHandle_t AppContext::mutex = xSemaphoreCreateMutex();
21
23 static AppContext instance;
24 return instance;
25}
26
28 printf("[AppContext] Initializing framework services...\n");
29 #if PICO_HTTP_ENABLE_LITTLEFS
30 TRACE("[AppContext] Initializing LittleFS storage manager.\n");
33 TRACE("[AppContext] LittleFS storage manager registered.\n");
34 static JsonService jsonService(&littlefs);
35 registerService<JsonService>(&jsonService);
36 TRACE("[AppContext] Registered JsonService.\n");
37
38 #else
41 static JsonService jsonService(&fatfs);
42 registerService<JsonService>(&jsonService);
43 TRACE("[AppContext] Registered FatFsStorageManager.\n");
44 #endif
45 // Time manager (always present)
46 static TimeManager timeMgr;
48 TRACE("[AppContext] Registered TimeManager.\n");
49 // Event manager (always present)
52 TRACE("[AppContext] Registered EventManager.\n");
53 // Timer service (always present)
56 TRACE("[AppContext] Registered TimerService.\n");
57 static Logger logger;
59 TRACE("[AppContext] Registered Logger.\n");
60 #if defined(ENABLE_GPIO_EVENTS)
63 TRACE("[AppContext] Registered GpioEventManager.\n");
64 #endif
65
66 #if PICO_HTTP_ENABLE_JWT
67 static JwtAuthenticator jwt;
69 TRACE("[AppContext] Registered JwtAuthenticator.\n");
70 #endif
71 }
72
73// No need to define ServiceHolder instances explicitly unless you want
74// to force-instantiation for linker visibility in rare cases.
Macro-based debug trace system with optional SD file logging.
#define TRACE_INIT(MODULE_NAME)
Declare trace usage in a source file for a given module.
Definition DebugTrace.h:170
#define TRACE(...)
Default trace (INFO level).
Definition DebugTrace.h:187
Event pub/sub manager for embedded applications using FreeRTOS.
FatFs-based implementation of the StorageManager interface for SD card access.
Posts GPIO change events (rising/falling edge) via EventManager.
Lightweight JSON wrapper for persistent config management using StorageManager.
Stateless singleton class for creating and validating JWTs using HMAC-SHA256.
Flash-backed implementation of the StorageManager interface using LittleFS.
Time-of-day and interval-based scheduler for embedded events.
static SemaphoreHandle_t mutex
Definition AppContext.h:88
static AppContext & getInstance()
void initFrameworkServices()
static constexpr std::uintptr_t getTypeKey()
Definition AppContext.h:91
Manages the system-wide event queue and subscriptions.
Concrete implementation of StorageManager using FatFs.
GpioEventManager registers interrupts and posts GpioChange events to multiple listeners per pin.
static GpioEventManager & getInstance()
Get the singleton instance of GpioEventManager.
Manages loading and saving of a single JSON document using StorageManager.
Definition JsonService.h:28
JWT JwtAuthenticator for embedded applications.
A LittleFS-based implementation of StorageManager, storing files in flash memory.
Basic timestamped logger with optional SD file logging.
Definition Logger.h:50
Central service for time-driven scheduling of framework events.
Delegates to user or system configuration.