CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::mod_ble_serial::BleSerialModule Class Reference

#include <BleSerialModule.h>

Inheritance diagram for cdc::mod_ble_serial::BleSerialModule:
cdc::core::IModule cdc::core::IService

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::IViewgetEntryView ()
 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.

Detailed Description

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.

Member Function Documentation

◆ getMenuItems()

uint8_t cdc::mod_ble_serial::BleSerialModule::getMenuItems ( core::ModuleMenuItem * items,
uint8_t maxItems )
overridevirtual

Provides Bluetooth-menu item for BLE serial toggle.

Parameters
itemsOutput menu item array.
maxItemsMaximum writable entries.
Returns
Number of populated menu items.

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().

◆ getName()

const char * cdc::mod_ble_serial::BleSerialModule::getName ( ) const
inlineoverridevirtual

Get service name (for logging/debugging)

Implements cdc::core::IService.

Definition at line 20 of file BleSerialModule.h.

Referenced by getMenuItems().

◆ getState()

core::ServiceState cdc::mod_ble_serial::BleSerialModule::getState ( ) const
inlineoverridevirtual

Get current service state

Implements cdc::core::IService.

Definition at line 21 of file BleSerialModule.h.

◆ getVersion()

const char * cdc::mod_ble_serial::BleSerialModule::getVersion ( ) const
inlineoverridevirtual

Returns the module version string.

Returns
Pointer to a null-terminated version string.

Implements cdc::core::IModule.

Definition at line 27 of file BleSerialModule.h.

◆ init()

bool cdc::mod_ble_serial::BleSerialModule::init ( )
overridevirtual

Initializes BLE serial module resources and settings.

Returns
true on successful initialization.

Implements cdc::core::IService.

Definition at line 131 of file BleSerialModule.cpp.

References cdc::core::INITIALIZED, LOG_I, and TAG.

◆ instance()

BleSerialModule & cdc::mod_ble_serial::BleSerialModule::instance ( )
static

BLE serial module lifecycle implementation.

Singleton access

Returns singleton BLE serial module instance.

Returns
Module singleton reference.

Definition at line 122 of file BleSerialModule.cpp.

Referenced by getMenuItems().

◆ isEnabled()

bool cdc::mod_ble_serial::BleSerialModule::isEnabled ( ) const
inline

Check if BLE Serial is enabled

Definition at line 36 of file BleSerialModule.h.

◆ onTick()

void cdc::mod_ble_serial::BleSerialModule::onTick ( uint32_t nowMs)
overridevirtual

Periodic module tick hook.

Parameters
nowMsCurrent uptime in milliseconds.

Reimplemented from cdc::core::IModule.

Definition at line 244 of file BleSerialModule.cpp.

◆ start()

bool cdc::mod_ble_serial::BleSerialModule::start ( )
overridevirtual

Starts BLE serial module and optionally auto-enables service.

Returns
true if start transition succeeded.

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.

◆ stop()

void cdc::mod_ble_serial::BleSerialModule::stop ( )
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.

◆ toggle()

void cdc::mod_ble_serial::BleSerialModule::toggle ( )

The documentation for this class was generated from the following files: