CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::serial::ICommandRegistry Class Referenceabstract

#include <ICommandRegistry.h>

Inheritance diagram for cdc::serial::ICommandRegistry:
cdc::serial::CommandRegistry

Public Types

using LineInterceptor = bool (*)(const char* line)
using ByteInterceptor = void (*)(uint8_t byte)

Public Member Functions

virtual ~ICommandRegistry ()=default
virtual bool registerCommand (const Command &cmd)=0
virtual void unregisterModule (const char *moduleName)=0
virtual bool processCommand (const char *line)=0
virtual void showHelp ()=0
virtual size_t getCommandCount () const =0
virtual void setAuthProvider (bool(*authCheck)())=0
virtual void setOnCommandExecuted (void(*callback)())=0
virtual void setLineInterceptor (LineInterceptor interceptor)
virtual void setByteInterceptor (ByteInterceptor interceptor)
virtual ByteInterceptor getByteInterceptor () const

Detailed Description

Command Registry Interface

Modules register their commands here. The registry handles:

  • Command lookup and dispatch
  • Help text generation
  • Optional authentication requirements

Definition at line 51 of file ICommandRegistry.h.

Member Typedef Documentation

◆ ByteInterceptor

using cdc::serial::ICommandRegistry::ByteInterceptor = void (*)(uint8_t byte)

Byte interceptor for binary streaming modes (e.g. raw plugin upload).

While installed, every byte received from serial is passed directly to the handler instead of being echoed, accumulated in the line buffer or dispatched as a command. The interceptor decides when to remove itself (typically once the expected payload size has been received) by calling setByteInterceptor(nullptr).

Definition at line 119 of file ICommandRegistry.h.

◆ LineInterceptor

using cdc::serial::ICommandRegistry::LineInterceptor = bool (*)(const char* line)

Line interceptor for multiline input modes (e.g., vCard paste). When set, called before normal command dispatch. Return true to consume the line, false for normal processing.

Definition at line 102 of file ICommandRegistry.h.

Constructor & Destructor Documentation

◆ ~ICommandRegistry()

virtual cdc::serial::ICommandRegistry::~ICommandRegistry ( )
virtualdefault

Member Function Documentation

◆ getByteInterceptor()

virtual ByteInterceptor cdc::serial::ICommandRegistry::getByteInterceptor ( ) const
inlinevirtual

Reimplemented in cdc::serial::CommandRegistry.

Definition at line 126 of file ICommandRegistry.h.

◆ getCommandCount()

virtual size_t cdc::serial::ICommandRegistry::getCommandCount ( ) const
pure virtual

Get number of registered commands

Implemented in cdc::serial::CommandRegistry.

◆ processCommand()

virtual bool cdc::serial::ICommandRegistry::processCommand ( const char * line)
pure virtual

Process a command line

Parameters
lineFull command line (command + arguments)
Returns
true if command was found and executed

Implemented in cdc::serial::CommandRegistry.

◆ registerCommand()

virtual bool cdc::serial::ICommandRegistry::registerCommand ( const Command & cmd)
pure virtual

Register a command

Parameters
Plugin command channelCommand definition
Returns
true if registered successfully

Implemented in cdc::serial::CommandRegistry.

Referenced by cdc::ui::registerBackupSerialCommand().

◆ setAuthProvider()

virtual void cdc::serial::ICommandRegistry::setAuthProvider ( bool(* authCheck )())
pure virtual

Set authentication provider callback

Parameters
authCheckFunction that returns true if session is authenticated

Implemented in cdc::serial::CommandRegistry.

Referenced by cdc::serial::SerialCmd::init().

◆ setByteInterceptor()

virtual void cdc::serial::ICommandRegistry::setByteInterceptor ( ByteInterceptor interceptor)
inlinevirtual

Set or clear the byte interceptor. While set, line-based parsing is fully bypassed.

Reimplemented in cdc::serial::CommandRegistry.

Definition at line 125 of file ICommandRegistry.h.

◆ setLineInterceptor()

virtual void cdc::serial::ICommandRegistry::setLineInterceptor ( LineInterceptor interceptor)
inlinevirtual

Set or clear the line interceptor

Parameters
interceptorCallback, or nullptr to clear

Reimplemented in cdc::serial::CommandRegistry.

Definition at line 108 of file ICommandRegistry.h.

Referenced by cdc::mod_vcard::cmdVcardSet(), and cdc::mod_vcard::vcard_session_clear().

◆ setOnCommandExecuted()

virtual void cdc::serial::ICommandRegistry::setOnCommandExecuted ( void(* callback )())
pure virtual

Set callback for successful command execution Used to reset auth timer when FEATURE_SECURE_SERIAL is enabled

Implemented in cdc::serial::CommandRegistry.

Referenced by cdc::serial::SerialCmd::init().

◆ showHelp()

virtual void cdc::serial::ICommandRegistry::showHelp ( )
pure virtual

Show help for all commands

Implemented in cdc::serial::CommandRegistry.

Referenced by cdc::serial::cmdHelp().

◆ unregisterModule()

virtual void cdc::serial::ICommandRegistry::unregisterModule ( const char * moduleName)
pure virtual

Unregister all commands from a module

Parameters
moduleNameModule name used in registration

Implemented in cdc::serial::CommandRegistry.


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