224 void cleanupOrphanedModuleData();
229 void saveModuleList();
235 uint8_t initCount_ = 0;
238 bool hasError =
false;
239 char message[96] = {0};
246 static constexpr size_t MAX_DISABLED_LIST_SIZE = 128;
247 char disabledModules_[MAX_DISABLED_LIST_SIZE] = {0};
252 void loadDisabledList();
257 void saveDisabledList();
259 void setModuleError(uint8_t index,
const char* message);
260 void clearModuleError(uint8_t index);
261 bool applySlotRequest(IModule* module, uint8_t index);
264 bool validateSlotMap(
const char* moduleName);
265 bool validateEccRange(
const char* mapName,
const char* moduleName,
266 uint16_t minSlots, IModule::SlotRange& range,
268 bool validateRmemRange(
const char* mapName,
const char* moduleName,
269 uint16_t minSlots, IModule::SlotRange& range,
271 static void buildSlotErrorMessage(
char* buffer,
size_t bufSize,
272 const char* errorType,
const char* mapName);
276#define CDC_MODULE(name) cdc::core::ModuleRegistry::instance().getModule(name)
char name[cdc::hal::ISecureElement::RMEM_NAME_LEN]
Module interface that extends IService with module-specific features.
void runAllInitializers()
Executes all registered initializers and post-registration housekeeping.
bool retryModule(uint8_t index)
Attempts to recover a failed module by re-initializing and restarting it.
void reportModuleError(const char *name, const char *message)
Records and publishes an operational module error by module name.
bool registerModule(IModule *module)
Registers a module instance in the runtime registry.
void dispatchUnlock()
Dispatches unlock lifecycle event to started modules.
void dispatchUsbConnect()
Dispatches USB-connect lifecycle event to started modules.
const char * getModuleSlotError(uint8_t index) const
Returns stored slot-error message for module index.
void dispatchUsbDisconnect()
Dispatches USB-disconnect lifecycle event to started modules.
const char * getModuleStatusLabel(uint8_t index) const
Returns a short status marker combining enabled flag and run state.
bool startAll()
Starts all enabled modules.
static constexpr const char * NVS_PREFIX
bool hasModuleSlotError(uint8_t index) const
Reports whether a module currently has a slot-validation error.
bool isModuleEnabledByName(const char *name) const
Checks whether a module name is currently enabled.
uint8_t getModuleCount() const
IModule * getModuleAt(uint8_t index)
Returns module pointer at registry index.
void stopAll()
Stops all currently started modules.
static ModuleRegistry & instance()
Returns the singleton module registry instance.
bool initAll()
Calls init() on all registered modules.
static constexpr uint8_t MAX_MODULES
uint8_t getLockScreenContextItems(LockScreenContextItem *items, uint8_t maxItems)
Collects lock-screen context actions from started modules.
bool isModuleEnabled(uint8_t index) const
Checks whether module at index is enabled.
void registerInitializer(ModuleInitFunc initFunc)
Registers a deferred module initializer callback.
bool toggleModuleEnabled(uint8_t index)
Toggles enabled state for a module.
bool startModule(uint8_t index)
Starts a single module by index.
static constexpr uint8_t MAX_INITIALIZERS
uint8_t getMenuItems(MenuLocation location, ModuleMenuItem *items, uint8_t maxItems)
Collects menu items from started modules for a given location.
void setModuleEnabled(uint8_t index, bool enabled)
Enables or disables a module by updating persisted disabled list.
static constexpr uint8_t MAX_MENU_ITEMS
void unregisterModule(const char *name)
Unregisters a module by name.
void clearModuleErrorByName(const char *name)
Clears stored module error by module name.
ModuleStartFailure classifyStartFailure(uint8_t index) const
Classifies why a preceding startModule() call failed.
void dispatchTick(uint32_t nowMs)
Dispatches periodic tick callback to started modules.
IModule * getModule(const char *name)
Looks up a module by name.
void dispatchLock()
Dispatches lock lifecycle event to started modules.
MenuLocation
Menu location for module registration.
ModuleStartFailure
Classified cause of a failed startModule() call.
@ UsbBudgetFull
HID interface budget is exhausted.
@ Generic
Start failed for an unspecified reason.
@ SlotError
Module reported a slot-map error.
Lock screen context menu item registered by a module.