|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
#include <PinEntryView.h>
Public Types | |
| using | VerifyCallback = bool(*)(const char* pin) |
| using | SuccessCallback = void(*)() |
| using | CancelCallback = void(*)() |
| using | FailureCallback = void(*)(bool lockedOut) |
Public Member Functions | |
| void | init (const char *title, uint8_t maxPinLength=6, uint8_t maxAttempts=3) |
| Initializes PIN entry configuration and clears current input. | |
| void | setOnVerify (VerifyCallback callback) |
| void | setOnSuccess (SuccessCallback callback) |
| void | setOnCancel (CancelCallback callback) |
| void | setOnFailure (FailureCallback callback) |
| void | setShowMessages (bool enabled) |
| const char * | getPin () const |
| uint8_t | getAttempts () const |
| bool | isLockedOut () const |
| void | clear () |
| Clears the internal PIN buffer. | |
| void | resetAttempts () |
| void | setMinLength (uint8_t minLen) |
| uint32_t | getLockoutRemaining () const |
| Returns remaining lockout time. | |
| void | onEnter (void *context) override |
| Resets entry state when the view is entered. | |
| void | onTick (uint32_t nowMs) override |
| Updates lockout state and periodic countdown refresh. | |
| void | render (bool partial) override |
| Renders PIN dots, status text, and footer hint. | |
| InputResult | onKey (char key) override |
| Handles key input for PIN entry and actions. | |
| 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 = 8 |
| static constexpr uint32_t | LOCKOUT_DURATION_MS = 60000 |
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 |
PinEntryView - Secure PIN code input
Displays PIN entry with masked digits. Supports configurable length and max attempts. Errors are shown via MessageBox overlay.
Keys: 0-9 = Add digit N = Backspace (short) / Cancel (empty) Y = Confirm and verify PIN
Definition at line 20 of file PinEntryView.h.
| using cdc::ui::PinEntryView::CancelCallback = void(*)() |
Cancel callback (called when N is pressed with empty PIN)
Definition at line 40 of file PinEntryView.h.
| using cdc::ui::PinEntryView::FailureCallback = void(*)(bool lockedOut) |
Failure callback (called after invalid PIN)
| lockedOut | True if device is now locked out |
Definition at line 46 of file PinEntryView.h.
| using cdc::ui::PinEntryView::SuccessCallback = void(*)() |
PIN success callback
Definition at line 35 of file PinEntryView.h.
| using cdc::ui::PinEntryView::VerifyCallback = bool(*)(const char* pin) |
PIN complete callback
| pin | The entered PIN |
Definition at line 30 of file PinEntryView.h.
| void cdc::ui::PinEntryView::clear | ( | ) |
Clears the internal PIN buffer.
Clear PIN and reset state
Definition at line 71 of file PinEntryView.cpp.
|
inline |
Get current attempt count
Definition at line 89 of file PinEntryView.h.
|
overridevirtual |
Returns localized footer hint text.
Reimplemented from cdc::ui::IView.
Definition at line 226 of file PinEntryView.cpp.
References cdc::ui::tr().
Referenced by render().
| uint32_t cdc::ui::PinEntryView::getLockoutRemaining | ( | ) | const |
Returns remaining lockout time.
Get remaining lockout time in seconds (0 if not locked)
Definition at line 130 of file PinEntryView.cpp.
References cdc::core::PinManager::getLockoutRemainingMs(), and cdc::core::PinManager::instance().
|
inlineoverridevirtual |
Get view name for debugging
Implements cdc::ui::IView.
Definition at line 122 of file PinEntryView.h.
|
inline |
Get current PIN
Definition at line 84 of file PinEntryView.h.
| void cdc::ui::PinEntryView::init | ( | const char * | title, |
| uint8_t | maxPinLength = 6, | ||
| uint8_t | maxAttempts = 3 ) |
Initializes PIN entry configuration and clears current input.
Initialize PIN entry view
| title | Title text |
| maxPinLength | Maximum PIN length (default 6) |
| maxAttempts | Maximum attempts before lockout (0 = unlimited) |
| title | Title text shown in the view. |
| maxPinLength | Maximum accepted PIN length. |
| maxAttempts | Maximum allowed attempts before lockout handling. |
Definition at line 47 of file PinEntryView.cpp.
References cdc::core::PinManager::BADGE_PIN_MIN, clear(), cdc::ui::ViewBase::dirty_, and MAX_PIN_LENGTH.
|
inline |
Check if locked out
Definition at line 94 of file PinEntryView.h.
|
overridevirtual |
Resets entry state when the view is entered.
| context | Optional view context (unused). |
Implements cdc::ui::IView.
Definition at line 61 of file PinEntryView.cpp.
References clear(), and cdc::ui::ViewBase::dirty_.
|
overridevirtual |
Handles key input for PIN entry and actions.
| key | Pressed key code. |
Implements cdc::ui::IView.
Definition at line 189 of file PinEntryView.cpp.
References cdc::ui::CONSUMED, cdc::ui::IGNORED, cdc::ui::KEY_NO, cdc::ui::KEY_YES, and cdc::ui::REQUEST_POP.
|
overridevirtual |
Updates lockout state and periodic countdown refresh.
| nowMs | Current monotonic time in milliseconds. |
Reimplemented from cdc::ui::IView.
Definition at line 105 of file PinEntryView.cpp.
References cdc::ui::ViewBase::dirty_, cdc::core::PinManager::instance(), and LOCKOUT_REFRESH_MS.
|
overridevirtual |
Renders PIN dots, status text, and footer hint.
| partial | Indicates partial/full redraw mode. |
Implements cdc::ui::IView.
Definition at line 235 of file PinEntryView.cpp.
References cdc::ui::ViewBase::dirty_, cdc::ui::display, cdc::ui::render::drawFooterBar(), cdc::ui::render::drawHeaderCentered(), cdc::hal::getDisplayInstance(), getFooterHint(), cdc::core::PinManager::instance(), LOG_E, PIN_DOT_SIZE, PIN_DOT_SPACING, PIN_Y, cdc::ui::render::printText(), RETRIES_Y, cdc::ui::TAG, cdc::ui::TITLE_Y, and cdc::ui::tr().
|
inline |
Reset attempt counter
Definition at line 104 of file PinEntryView.h.
|
inline |
Set minimum PIN length required (default 1) Y will only work if length >= minLength
Definition at line 110 of file PinEntryView.h.
|
inline |
Set cancel callback (optional)
Definition at line 69 of file PinEntryView.h.
|
inline |
Set failure callback (optional)
Definition at line 74 of file PinEntryView.h.
|
inline |
Set success callback (called after successful verify)
Definition at line 64 of file PinEntryView.h.
|
inline |
Set verify callback (called when Y is pressed)
Definition at line 59 of file PinEntryView.h.
|
inline |
Suppress internal error messages (caller handles feedback)
Definition at line 79 of file PinEntryView.h.
|
staticconstexpr |
Definition at line 23 of file PinEntryView.h.
|
staticconstexpr |
Definition at line 22 of file PinEntryView.h.
Referenced by init().