|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
#include <BleSerialModule.h>
Public Member Functions | |
| const char * | getName () const override |
| core::ServiceState | getState () const override |
| bool | init () override |
| Initializes BLE serial module resources and settings. | |
| bool | start () override |
| Starts BLE serial module and optionally auto-enables service. | |
| void | stop () override |
| Stops BLE serial module and deinitializes UART service when enabled. | |
| const char * | getVersion () const override |
| Returns the module version string. | |
| uint8_t | getMenuItems (core::ModuleMenuItem *items, uint8_t maxItems) override |
| Provides Bluetooth-menu item for BLE serial toggle. | |
| void | onTick (uint32_t nowMs) override |
| Periodic module tick hook. | |
| bool | isEnabled () const |
| void | toggle () |
| Toggles BLE serial service state and updates persisted setting. | |
| Public Member Functions inherited from cdc::core::IModule | |
| virtual bool | exportBackup (cJSON *out) |
| Exports this module's data as a JSON section for the backup file. | |
| virtual BackupResult | importBackup (const cJSON *in) |
| Restores this module's data from its JSON backup section. | |
| virtual ui::IView * | getEntryView () |
| Returns the module's entry view (main view when selected from menu). | |
| virtual uint8_t | getLockScreenContextItems (LockScreenContextItem *items, uint8_t maxItems) |
| Returns the module's lock screen context menu items. | |
| virtual void | onUnlock () |
| Called when device is unlocked. | |
| virtual void | onLock () |
| Called when device is locked. | |
| virtual void | onUsbConnect () |
| Called when USB is connected. | |
| virtual void | onUsbDisconnect () |
| Called when USB is disconnected. | |
| virtual void | setSlotRange (const SlotRange &range) |
| Sets the slot range assigned by the module registry (from compile-time memory map). | |
| virtual SlotRequest | getSlotRequest () const |
| Returns slot requirements for this module (from compile-time memory map). | |
| Public Member Functions inherited from cdc::core::IService | |
| virtual | ~IService ()=default |
Static Public Member Functions | |
| static BleSerialModule & | instance () |
| BLE serial module lifecycle implementation. | |
BLE Serial Module
Provides serial command interface over Bluetooth Low Energy using Nordic UART Service (NUS).
Registers in the Bluetooth menu as a toggle item. When enabled, serial commands work over BLE just like over USB.
Definition at line 17 of file BleSerialModule.h.
|
overridevirtual |
Provides Bluetooth-menu item for BLE serial toggle.
| items | Output menu item array. |
| maxItems | Maximum writable entries. |
Reimplemented from cdc::core::IModule.
Definition at line 221 of file BleSerialModule.cpp.
References cdc::core::BLUETOOTH_MENU, getName(), cdc::core::ModuleMenuItem::getView, instance(), cdc::core::ModuleMenuItem::isVisible, cdc::core::ModuleMenuItem::label, cdc::core::ModuleMenuItem::location, cdc::core::ModuleMenuItem::moduleName, cdc::core::ModuleMenuItem::onSelect, cdc::core::ModuleMenuItem::priority, toggle(), and cdc::ui::tr().
|
inlineoverridevirtual |
Get service name (for logging/debugging)
Implements cdc::core::IService.
Definition at line 20 of file BleSerialModule.h.
Referenced by getMenuItems().
|
inlineoverridevirtual |
Get current service state
Implements cdc::core::IService.
Definition at line 21 of file BleSerialModule.h.
|
inlineoverridevirtual |
Returns the module version string.
Implements cdc::core::IModule.
Definition at line 27 of file BleSerialModule.h.
|
overridevirtual |
Initializes BLE serial module resources and settings.
Implements cdc::core::IService.
Definition at line 131 of file BleSerialModule.cpp.
References cdc::core::INITIALIZED, LOG_I, and TAG.
|
static |
BLE serial module lifecycle implementation.
Singleton access
Returns singleton BLE serial module instance.
Definition at line 122 of file BleSerialModule.cpp.
Referenced by getMenuItems().
|
inline |
Check if BLE Serial is enabled
Definition at line 36 of file BleSerialModule.h.
|
overridevirtual |
Periodic module tick hook.
| nowMs | Current uptime in milliseconds. |
Reimplemented from cdc::core::IModule.
Definition at line 244 of file BleSerialModule.cpp.
|
overridevirtual |
Starts BLE serial module and optionally auto-enables service.
Implements cdc::core::IService.
Definition at line 145 of file BleSerialModule.cpp.
References cdc::hal::getBluetoothControllerInstance(), cdc::core::INITIALIZED, cdc::mod_ble_serial::BleUartService::instance(), LOG_I, cdc::core::STARTED, cdc::core::STOPPED, and TAG.
|
overridevirtual |
Stops BLE serial module and deinitializes UART service when enabled.
Implements cdc::core::IService.
Definition at line 171 of file BleSerialModule.cpp.
References cdc::mod_ble_serial::BleUartService::deinit(), cdc::mod_ble_serial::BleUartService::instance(), and cdc::core::STOPPED.
| void cdc::mod_ble_serial::BleSerialModule::toggle | ( | ) |
Toggles BLE serial service state and updates persisted setting.
Toggle BLE Serial on/off
Definition at line 182 of file BleSerialModule.cpp.
References cdc::mod_ble_serial::BleUartService::deinit(), cdc::hal::getBluetoothControllerInstance(), cdc::mod_ble_serial::BleUartService::instance(), cdc::ui::showToastError(), cdc::ui::showToastInfo(), cdc::ui::showToastSuccess(), and cdc::ui::tr().
Referenced by getMenuItems().