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

#include <VcardModule.h>

Inheritance diagram for cdc::mod_vcard::VcardModule:
cdc::core::IModule cdc::core::IService

Public Member Functions

const char * getName () const override
const char * getVersion () const override
 Returns the module version string.
core::ServiceState getState () const override
bool init () override
 Initializes module UI strings, serial commands, and BLE service hooks.
bool start () override
 Starts vCard module service.
void stop () override
 Stops vCard BLE service and module runtime.
uint8_t getMenuItems (core::ModuleMenuItem *items, uint8_t maxItems) override
 Provides tools-menu entry for vCard module.
uint8_t getLockScreenContextItems (core::LockScreenContextItem *items, uint8_t maxItems) override
 Provides the lock-screen quick action that shows the owner vCard as a QR code.
void onTick (uint32_t nowMs) override
 Periodic vCard module tick forwarding BLE state machine.
bool exportBackup (cJSON *out) override
 Exports the own vCard and all received vCards into the backup section.
core::IModule::BackupResult importBackup (const cJSON *in) override
 Restores the own vCard and received vCards from the backup section.
Public Member Functions inherited from cdc::core::IModule
virtual ui::IViewgetEntryView ()
 Returns the module's entry view (main view when selected from menu).
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 VcardModuleinstance ()
 Returns singleton vCard module instance.

Detailed Description

Definition at line 9 of file VcardModule.h.

Member Function Documentation

◆ exportBackup()

bool cdc::mod_vcard::VcardModule::exportBackup ( cJSON * out)
overridevirtual

Exports the own vCard and all received vCards into the backup section.

Writes schema_ver, an optional own string, and a received array of raw vCard texts. Returns false only when there is nothing to export.

Parameters
outcJSON object that forms the module's section in the backup file.
Returns
true if any vCard data was exported.

Reimplemented from cdc::core::IModule.

Definition at line 884 of file VcardModule.cpp.

References cdc::mod_vcard::kSchemaVer, VCARD_MAX_CARDS, VCARD_MAX_LEN, vcard_store_get(), vcard_store_get_own(), and vcard_store_get_sorted().

◆ getLockScreenContextItems()

uint8_t cdc::mod_vcard::VcardModule::getLockScreenContextItems ( core::LockScreenContextItem * items,
uint8_t maxItems )
overridevirtual

Provides the lock-screen quick action that shows the owner vCard as a QR code.

Parameters
itemsOutput array for context items.
maxItemsMaximum writable entries.
Returns
Number of populated entries.

Reimplemented from cdc::core::IModule.

Definition at line 853 of file VcardModule.cpp.

References cdc::mod_vcard::getMyVcardLockscreenLabel(), and cdc::mod_vcard::onMyVcardLockscreenSelect().

◆ getMenuItems()

uint8_t cdc::mod_vcard::VcardModule::getMenuItems ( core::ModuleMenuItem * items,
uint8_t maxItems )
overridevirtual

Provides tools-menu entry for vCard module.

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

Reimplemented from cdc::core::IModule.

Definition at line 824 of file VcardModule.cpp.

References getName(), cdc::mod_vcard::mstr(), cdc::mod_vcard::onMainMenuSelect(), cdc::mod_vcard::rebuildMainMenu(), cdc::mod_vcard::s_mainMenu, cdc::mod_vcard::s_viewsInitialized, cdc::mod_vcard::STR_VCARD, and cdc::core::TOOLS_MENU.

◆ getName()

const char * cdc::mod_vcard::VcardModule::getName ( ) const
inlineoverridevirtual

Get service name (for logging/debugging)

Implements cdc::core::IService.

Definition at line 13 of file VcardModule.h.

Referenced by getMenuItems().

◆ getState()

core::ServiceState cdc::mod_vcard::VcardModule::getState ( ) const
inlineoverridevirtual

Get current service state

Implements cdc::core::IService.

Definition at line 15 of file VcardModule.h.

◆ getVersion()

const char * cdc::mod_vcard::VcardModule::getVersion ( ) const
inlineoverridevirtual

Returns the module version string.

Returns
Pointer to a null-terminated version string.

Implements cdc::core::IModule.

Definition at line 14 of file VcardModule.h.

◆ importBackup()

core::IModule::BackupResult cdc::mod_vcard::VcardModule::importBackup ( const cJSON * in)
overridevirtual

Restores the own vCard and received vCards from the backup section.

The own vCard overwrites the current one; received vCards are upserted by exact text. Best-effort: failures are tallied, never aborting the restore.

Parameters
incJSON object holding the previously exported section.
Returns
Tally of imported and failed records.

Reimplemented from cdc::core::IModule.

Definition at line 947 of file VcardModule.cpp.

References cdc::core::IModule::BackupResult::failed, cdc::core::IModule::BackupResult::imported, cdc::ui::importJsonArray(), cdc::mod_vcard::importReceivedVcard(), cdc::mod_vcard::kSchemaVer, LOG_W, TAG, and vcard_store_set_own().

◆ init()

◆ instance()

VcardModule & cdc::mod_vcard::VcardModule::instance ( )
static

Returns singleton vCard module instance.

Returns
Module singleton reference.

Definition at line 773 of file VcardModule.cpp.

◆ onTick()

void cdc::mod_vcard::VcardModule::onTick ( uint32_t nowMs)
overridevirtual

Periodic vCard module tick forwarding BLE state machine.

Parameters
nowMsCurrent uptime in milliseconds.

Reimplemented from cdc::core::IModule.

Definition at line 868 of file VcardModule.cpp.

◆ start()

bool cdc::mod_vcard::VcardModule::start ( )
overridevirtual

Starts vCard module service.

Returns
true if start transition succeeded.

Implements cdc::core::IService.

Definition at line 802 of file VcardModule.cpp.

References cdc::core::INITIALIZED, cdc::core::STARTED, and cdc::core::STOPPED.

◆ stop()

void cdc::mod_vcard::VcardModule::stop ( )
overridevirtual

Stops vCard BLE service and module runtime.

Implements cdc::core::IService.

Definition at line 813 of file VcardModule.cpp.

References cdc::core::STOPPED.


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