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

#include <PinChangeView.h>

Inheritance diagram for cdc::ui::PinChangeView:
cdc::ui::ViewBase cdc::ui::IView

Public Types

enum class  Step : uint8_t { CURRENT_PIN , NEW_PIN , CONFIRM_PIN }
using CompleteCallback = void(*)(bool success)
using VerifyCallback = bool(*)(const char* pin)
using ChangeCallback = bool(*)(const char* currentPin, const char* newPin)
using RetriesCallback = uint8_t(*)()
using BlockedCallback = bool(*)()

Public Member Functions

void init (uint8_t minLength=4, uint8_t maxLength=16)
 Initializes PIN-change wizard state.
void setOnComplete (CompleteCallback callback)
void setVerifyCallback (VerifyCallback callback)
void setChangeCallback (ChangeCallback callback)
void setRetriesCallback (RetriesCallback callback)
void setBlockedCallback (BlockedCallback callback)
void setTitle (const char *title)
Step getStep () const
uint8_t getRetriesRemaining () const
 Returns remaining retry count for current PIN verification.
void onEnter (void *context) override
 Resets wizard state when entering the view.
void render (bool partial) override
 Renders PIN-change wizard UI.
InputResult onKey (char key) override
 Handles key input for PIN-change flow.
void onTick (uint32_t nowMs) override
 Handles message timeout and completion callbacks.
const char * getName () const override
const char * getFooterHint () const override
 Returns localized footer hint text.
Public Member Functions inherited from cdc::ui::ViewBase
virtual ~ViewBase ()=default
void onEnter (void *context) override
void onExit () override
void onResume () override
void onPause () override
void setLifecycleHooks (void(*onHide)(void *), void(*onShow)(void *), void *userData) override
bool needsRender () const override
void markDirty () override
void clearDirty () override
void setFooterHint (const char *hint) override
const char * getFooterHint () const override
Public Member Functions inherited from cdc::ui::IView
virtual ~IView ()=default
virtual bool prefersLightRefresh () const
virtual InputResult onLongPress (char key)

Static Public Attributes

static constexpr uint8_t MAX_PIN_LENGTH = 16
static constexpr uint32_t MESSAGE_DISPLAY_MS = 2000

Additional Inherited Members

Protected Member Functions inherited from cdc::ui::ViewBase
void setTitle (const char *title)
const char * getTitle () const
Protected Attributes inherited from cdc::ui::ViewBase
bool dirty_ = true
const char * title_ = nullptr
const char * customFooter_ = nullptr
void(* onHide_ )(void *) = nullptr
void(* onShow_ )(void *) = nullptr
void * lifecycleUserData_ = nullptr

Detailed Description

PinChangeView - PIN change wizard

Three-step flow:

  1. Enter current PIN (verification)
  2. Enter new PIN
  3. Confirm new PIN

Validates PIN length and calls PinManager on success.

Keys: 0-9 = Add digit N = Backspace/Cancel Y = Confirm step

Definition at line 23 of file PinChangeView.h.

Member Typedef Documentation

◆ BlockedCallback

Definition at line 42 of file PinChangeView.h.

◆ ChangeCallback

using cdc::ui::PinChangeView::ChangeCallback = bool(*)(const char* currentPin, const char* newPin)

Definition at line 40 of file PinChangeView.h.

◆ CompleteCallback

using cdc::ui::PinChangeView::CompleteCallback = void(*)(bool success)

Callback when PIN change is complete

Parameters
successtrue if PIN was changed successfully

Definition at line 38 of file PinChangeView.h.

◆ RetriesCallback

Definition at line 41 of file PinChangeView.h.

◆ VerifyCallback

using cdc::ui::PinChangeView::VerifyCallback = bool(*)(const char* pin)

Definition at line 39 of file PinChangeView.h.

Member Enumeration Documentation

◆ Step

enum class cdc::ui::PinChangeView::Step : uint8_t
strong
Enumerator
CURRENT_PIN 
NEW_PIN 
CONFIRM_PIN 

Definition at line 28 of file PinChangeView.h.

Member Function Documentation

◆ getFooterHint()

const char * cdc::ui::PinChangeView::getFooterHint ( ) const
overridevirtual

Returns localized footer hint text.

Returns
Footer hint string.

Reimplemented from cdc::ui::IView.

Definition at line 308 of file PinChangeView.cpp.

References cdc::ui::tr().

Referenced by render().

◆ getName()

const char * cdc::ui::PinChangeView::getName ( ) const
inlineoverridevirtual

Get view name for debugging

Implements cdc::ui::IView.

Definition at line 76 of file PinChangeView.h.

◆ getRetriesRemaining()

uint8_t cdc::ui::PinChangeView::getRetriesRemaining ( ) const

Returns remaining retry count for current PIN verification.

Get retries remaining (from PinManager)

Returns
Remaining retries.

Definition at line 104 of file PinChangeView.cpp.

References cdc::core::PinManager::getBadgeRetries(), and cdc::core::PinManager::instance().

Referenced by render().

◆ getStep()

Step cdc::ui::PinChangeView::getStep ( ) const
inline

Get current step

Definition at line 64 of file PinChangeView.h.

◆ init()

void cdc::ui::PinChangeView::init ( uint8_t minLength = 4,
uint8_t maxLength = 16 )

Initializes PIN-change wizard state.

Initialize PIN change view

Parameters
minLengthMinimum PIN length (default 4)
maxLengthMaximum PIN length (default 16)
minLengthMinimum required PIN length.
maxLengthMaximum allowed PIN length.
Returns
void

Definition at line 38 of file PinChangeView.cpp.

References CURRENT_PIN, cdc::ui::ViewBase::dirty_, and MAX_PIN_LENGTH.

Referenced by onEnter().

◆ onEnter()

void cdc::ui::PinChangeView::onEnter ( void * context)
overridevirtual

Resets wizard state when entering the view.

Parameters
contextOptional view context (unused).
Returns
void

Implements cdc::ui::IView.

Definition at line 57 of file PinChangeView.cpp.

References init().

◆ onKey()

InputResult cdc::ui::PinChangeView::onKey ( char key)
overridevirtual

Handles key input for PIN-change flow.

Parameters
keyPressed key code.
Returns
Input handling result for the view stack.

Implements cdc::ui::IView.

Definition at line 257 of file PinChangeView.cpp.

References CONFIRM_PIN, cdc::ui::CONSUMED, CURRENT_PIN, cdc::ui::ViewBase::dirty_, cdc::ui::IGNORED, cdc::core::PinManager::instance(), cdc::core::PinManager::isBadgeBlocked(), cdc::ui::KEY_NO, cdc::ui::KEY_YES, NEW_PIN, and cdc::ui::REQUEST_POP.

◆ onTick()

void cdc::ui::PinChangeView::onTick ( uint32_t nowMs)
overridevirtual

Handles message timeout and completion callbacks.

Parameters
nowMsCurrent monotonic time in milliseconds.
Returns
void

Reimplemented from cdc::ui::IView.

Definition at line 237 of file PinChangeView.cpp.

References cdc::ui::ViewBase::dirty_, and MESSAGE_DISPLAY_MS.

◆ render()

void cdc::ui::PinChangeView::render ( bool partial)
overridevirtual

◆ setBlockedCallback()

void cdc::ui::PinChangeView::setBlockedCallback ( BlockedCallback callback)
inline

Definition at line 58 of file PinChangeView.h.

◆ setChangeCallback()

void cdc::ui::PinChangeView::setChangeCallback ( ChangeCallback callback)
inline

Definition at line 56 of file PinChangeView.h.

◆ setOnComplete()

void cdc::ui::PinChangeView::setOnComplete ( CompleteCallback callback)
inline

Set completion callback

Definition at line 54 of file PinChangeView.h.

◆ setRetriesCallback()

void cdc::ui::PinChangeView::setRetriesCallback ( RetriesCallback callback)
inline

Definition at line 57 of file PinChangeView.h.

◆ setTitle()

void cdc::ui::PinChangeView::setTitle ( const char * title)
inline

Definition at line 59 of file PinChangeView.h.

◆ setVerifyCallback()

void cdc::ui::PinChangeView::setVerifyCallback ( VerifyCallback callback)
inline

Definition at line 55 of file PinChangeView.h.

Member Data Documentation

◆ MAX_PIN_LENGTH

uint8_t cdc::ui::PinChangeView::MAX_PIN_LENGTH = 16
staticconstexpr

Definition at line 25 of file PinChangeView.h.

Referenced by init().

◆ MESSAGE_DISPLAY_MS

uint32_t cdc::ui::PinChangeView::MESSAGE_DISPLAY_MS = 2000
staticconstexpr

Definition at line 26 of file PinChangeView.h.

Referenced by onTick().


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