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

#include <SerialCmd.h>

Static Public Member Functions

static void init ()
 Public SerialCmd interface implementation.
static bool process ()
 Processes one pending input character from the serial console.
static ICommandRegistrygetRegistry ()
 Returns the shared command registry instance.
static void setTextCallback (TextChangeCallback callback)
 Sets the callback used by text-setting commands.
static void setTimeCallback (TimeChangeCallback callback)
 Sets the callback invoked after successful date/time updates.
static bool isAuthenticated ()
 Returns whether the serial session is currently authenticated.
static bool authenticate (const char *pin)
 Attempts to authenticate the serial session with a PIN.
static void logout ()
 Logs out the current serial session.
static void touchAuthSession ()
 Keeps the auth session alive during a long-running serial activity.
static void registerBuiltinCommands ()
 Registers all built-in serial commands.

Static Public Attributes

static constexpr size_t CMD_BUFFER_SIZE = 256
static constexpr uint32_t AUTH_TIMEOUT_MS = 5 * 60 * 1000

Detailed Description

Serial Command Processor

Main entry point for serial command handling. Handles:

  • Input buffering and line editing
  • Command dispatching via ICommandRegistry
  • Optional authentication (FEATURE_SECURE_SERIAL)
  • Special input modes (vCard, CSR, etc.)

Definition at line 23 of file SerialCmd.h.

Member Function Documentation

◆ authenticate()

bool cdc::serial::SerialCmd::authenticate ( const char * pin)
static

Attempts to authenticate the serial session with a PIN.

Authenticate with PIN

Returns
true if PIN is correct
Parameters
pinCandidate PIN string.
Returns
true on successful authentication, otherwise false.

Definition at line 1787 of file SerialCmd.cpp.

References cdc::core::PinManager::instance(), LOG_I, log_set_level(), LOG_W, cdc::serial::s_authenticated, cdc::serial::s_authTimestamp, and TAG.

◆ getRegistry()

ICommandRegistry & cdc::serial::SerialCmd::getRegistry ( )
static

Returns the shared command registry instance.

Get command registry for module registration

Returns
Reference to the command registry.

Definition at line 1738 of file SerialCmd.cpp.

References cdc::serial::getCommandRegistry().

◆ init()

◆ isAuthenticated()

bool cdc::serial::SerialCmd::isAuthenticated ( )
static

Returns whether the serial session is currently authenticated.

Check if currently authenticated

Returns
true when authenticated (and not timed out), otherwise false.

Definition at line 1762 of file SerialCmd.cpp.

References AUTH_TIMEOUT_MS, LOG_I, log_set_level(), cdc::serial::s_authenticated, cdc::serial::s_authTimestamp, and TAG.

Referenced by init().

◆ logout()

void cdc::serial::SerialCmd::logout ( )
static

Logs out the current serial session.

Logout (clear authentication)

Definition at line 1833 of file SerialCmd.cpp.

References LOG_I, log_set_level(), cdc::serial::s_authenticated, cdc::serial::s_authTimestamp, and TAG.

◆ process()

bool cdc::serial::SerialCmd::process ( )
static

Processes one pending input character from the serial console.

Process one character from input Call this regularly from main loop

Returns
true if a complete command was executed
true if a command line was completed, otherwise false.

Definition at line 1716 of file SerialCmd.cpp.

References cdc::serial::Console::getchar().

Referenced by runMainLoopIteration().

◆ registerBuiltinCommands()

◆ setTextCallback()

void cdc::serial::SerialCmd::setTextCallback ( TextChangeCallback callback)
static

Sets the callback used by text-setting commands.

Set callback for text changes (name, info, info2)

Parameters
callbackCallback receiving field key and new value.

Definition at line 1746 of file SerialCmd.cpp.

References cdc::serial::s_textCallback.

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

◆ setTimeCallback()

void cdc::serial::SerialCmd::setTimeCallback ( TimeChangeCallback callback)
static

Sets the callback invoked after successful date/time updates.

Set callback for time changes

Parameters
callbackCallback triggered on time change.

Definition at line 1754 of file SerialCmd.cpp.

References cdc::serial::s_timeCallback.

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

◆ touchAuthSession()

void cdc::serial::SerialCmd::touchAuthSession ( )
static

Keeps the auth session alive during a long-running serial activity.

Refresh the authentication-timeout timestamp so a long-running serial activity (binary upload, multi-line paste) can keep the session alive without having to execute periodic dummy commands.

Definition at line 1822 of file SerialCmd.cpp.

References cdc::serial::s_authenticated, and cdc::serial::s_authTimestamp.

Member Data Documentation

◆ AUTH_TIMEOUT_MS

uint32_t cdc::serial::SerialCmd::AUTH_TIMEOUT_MS = 5 * 60 * 1000
staticconstexpr

Definition at line 26 of file SerialCmd.h.

Referenced by isAuthenticated().

◆ CMD_BUFFER_SIZE

size_t cdc::serial::SerialCmd::CMD_BUFFER_SIZE = 256
staticconstexpr

Definition at line 25 of file SerialCmd.h.

Referenced by cdc::serial::historyAdd(), and cdc::serial::redrawLine().


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