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

#include <UsbManager.h>

Inheritance diagram for cdc::core::UsbManager:
cdc::core::IService

Public Member Functions

const char * getName () const override
bool init () override
 Initializes USB manager service state.
bool start () override
 Starts USB manager service state.
void stop () override
 Stops USB manager service state.
ServiceState getState () const override
bool registerInterface (UsbHidInterface type, const char *moduleName, const UsbInterfaceSpec &def)
 Registers a HID interface request from a module.
void unregisterInterface (UsbHidInterface type, const char *moduleName)
 Unregisters a previously registered HID interface.
uint8_t activeInterfaceMask () const
bool applyConfiguration ()
 Applies current interface set to USB HID stack.
bool needsReplug () const
bool hidSlotsFull () const
 Reports whether the HID interface budget is exhausted.
bool newlyRequiresReplug (bool wasNeededBefore) const
 Tests whether a toggle newly introduced a replug requirement.
Public Member Functions inherited from cdc::core::IService
virtual ~IService ()=default

Static Public Member Functions

static UsbManagerinstance ()
 Returns singleton USB manager instance.

Detailed Description

UsbManager - HID interface arbitration

CDC is always enabled (handled by usb_badge). HID interfaces are optional and registered by modules at runtime.

Definition at line 52 of file UsbManager.h.

Member Function Documentation

◆ activeInterfaceMask()

uint8_t cdc::core::UsbManager::activeInterfaceMask ( ) const
inline

Definition at line 67 of file UsbManager.h.

◆ applyConfiguration()

bool cdc::core::UsbManager::applyConfiguration ( )

Applies current interface set to USB HID stack.

Returns
true when configuration call succeeded.

Definition at line 130 of file UsbManager.cpp.

References cdc::core::Ccid, cdc::core::Fido, cdc::core::Keyboard, and usb_hid_apply_config().

Referenced by registerInterface(), and unregisterInterface().

◆ getName()

const char * cdc::core::UsbManager::getName ( ) const
inlineoverridevirtual

Get service name (for logging/debugging)

Implements cdc::core::IService.

Definition at line 56 of file UsbManager.h.

◆ getState()

ServiceState cdc::core::UsbManager::getState ( ) const
inlineoverridevirtual

Get current service state

Implements cdc::core::IService.

Definition at line 61 of file UsbManager.h.

◆ hidSlotsFull()

bool cdc::core::UsbManager::hidSlotsFull ( ) const
inline

Reports whether the HID interface budget is exhausted.

Returns
true when active HID interfaces reached MAX_ACTIVE_HID.

Definition at line 75 of file UsbManager.h.

◆ init()

bool cdc::core::UsbManager::init ( )
overridevirtual

Initializes USB manager service state.

Returns
Always true.

Implements cdc::core::IService.

Definition at line 23 of file UsbManager.cpp.

References cdc::core::INITIALIZED.

◆ instance()

◆ needsReplug()

bool cdc::core::UsbManager::needsReplug ( ) const
inline

◆ newlyRequiresReplug()

bool cdc::core::UsbManager::newlyRequiresReplug ( bool wasNeededBefore) const
inline

Tests whether a toggle newly introduced a replug requirement.

Callers snapshot needsReplug() before performing a module toggle and pass it here afterwards; returns true only on a false-to-true transition.

Parameters
wasNeededBeforeneedsReplug() value captured before the toggle.
Returns
true if a replug is now required but was not before.

Definition at line 85 of file UsbManager.h.

◆ registerInterface()

bool cdc::core::UsbManager::registerInterface ( UsbHidInterface type,
const char * moduleName,
const UsbInterfaceSpec & def )

Registers a HID interface request from a module.

Parameters
typeHID interface slot.
moduleNameOwning module name.
defInterface descriptor definition.
Returns
true on successful registration.

Definition at line 73 of file UsbManager.cpp.

References applyConfiguration(), LOG_I, LOG_W, and TAG.

◆ start()

bool cdc::core::UsbManager::start ( )
overridevirtual

Starts USB manager service state.

Returns
Always true.

Implements cdc::core::IService.

Definition at line 32 of file UsbManager.cpp.

References cdc::core::STARTED.

◆ stop()

void cdc::core::UsbManager::stop ( )
overridevirtual

Stops USB manager service state.

Implements cdc::core::IService.

Definition at line 40 of file UsbManager.cpp.

References cdc::core::STOPPED.

◆ unregisterInterface()

void cdc::core::UsbManager::unregisterInterface ( UsbHidInterface type,
const char * moduleName )

Unregisters a previously registered HID interface.

Parameters
typeHID interface slot.
moduleNameRequesting module name.

Definition at line 106 of file UsbManager.cpp.

References applyConfiguration(), LOG_I, LOG_W, and TAG.

Referenced by cdc::mod_fido2::Fido2Module::start(), cdc::mod_fido2::Fido2Module::stop(), and cdc::mod_gpg::GpgModule::stop().


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