CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
BleSerialModule.h
Go to the documentation of this file.
1#pragma once
2
3#include "cdc_core/IModule.h"
4#include <cstddef>
5
7
17class BleSerialModule : public core::IModule {
18public:
19 // === IService ===
20 const char* getName() const override { return "mod_ble_serial"; }
21 core::ServiceState getState() const override { return state_; }
22 bool init() override;
23 bool start() override;
24 void stop() override;
25
26 // === IModule ===
27 const char* getVersion() const override { return "1.0"; }
28 uint8_t getMenuItems(core::ModuleMenuItem* items, uint8_t maxItems) override;
29 void onTick(uint32_t nowMs) override;
30
31 // === BLE Serial Specific ===
32
36 bool isEnabled() const { return enabled_; }
37
41 void toggle();
42
46 static BleSerialModule& instance();
47
48private:
49 BleSerialModule() = default;
50
52 bool enabled_ = false;
53
54 // Menu label buffer
55 static constexpr size_t LABEL_BUF_SIZE = 32;
56 char labelBuf_[LABEL_BUF_SIZE] = {};
57
58 // NVS namespace
59 static constexpr const char* NVS_NAMESPACE = "mod_ble_serial";
60
61 // I18n
62 void registerStrings();
63
64 // Console hooks
65 void registerConsoleHooks();
66 void unregisterConsoleHooks();
67
68 // Pairing UI is centralized in AppUi (see ui_init). Kept as a no-op
69 // for ABI stability of the .cpp call sites.
70 void registerPairingCallback();
71
72 // Settings
73 void loadSettings();
74 void saveSettings();
75};
76
77} // namespace cdc::mod_ble_serial
78
79// C registration function
80extern "C" void mod_ble_serial_register();
void mod_ble_serial_register()
Registers BLE serial module initializer.
Module interface that extends IService with module-specific features.
Definition IModule.h:55
static BleSerialModule & instance()
BLE serial module lifecycle implementation.
uint8_t getMenuItems(core::ModuleMenuItem *items, uint8_t maxItems) override
Provides Bluetooth-menu item for BLE serial toggle.
bool start() override
Starts BLE serial module and optionally auto-enables service.
core::ServiceState getState() const override
void onTick(uint32_t nowMs) override
Periodic module tick hook.
void stop() override
Stops BLE serial module and deinitializes UART service when enabled.
bool init() override
Initializes BLE serial module resources and settings.
void toggle()
Toggles BLE serial service state and updates persisted setting.
const char * getVersion() const override
Returns the module version string.
const char * getName() const override
#define NVS_NAMESPACE
Menu item registered by a module.
Definition IModule.h:29