|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
#include <PinChangeView.h>
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 |
PinChangeView - PIN change wizard
Three-step flow:
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.
| using cdc::ui::PinChangeView::BlockedCallback = bool(*)() |
Definition at line 42 of file PinChangeView.h.
| using cdc::ui::PinChangeView::ChangeCallback = bool(*)(const char* currentPin, const char* newPin) |
Definition at line 40 of file PinChangeView.h.
| using cdc::ui::PinChangeView::CompleteCallback = void(*)(bool success) |
Callback when PIN change is complete
| success | true if PIN was changed successfully |
Definition at line 38 of file PinChangeView.h.
| using cdc::ui::PinChangeView::RetriesCallback = uint8_t(*)() |
Definition at line 41 of file PinChangeView.h.
| using cdc::ui::PinChangeView::VerifyCallback = bool(*)(const char* pin) |
Definition at line 39 of file PinChangeView.h.
|
strong |
| Enumerator | |
|---|---|
| CURRENT_PIN | |
| NEW_PIN | |
| CONFIRM_PIN | |
Definition at line 28 of file PinChangeView.h.
|
overridevirtual |
Returns localized footer hint text.
Reimplemented from cdc::ui::IView.
Definition at line 308 of file PinChangeView.cpp.
References cdc::ui::tr().
Referenced by render().
|
inlineoverridevirtual |
Get view name for debugging
Implements cdc::ui::IView.
Definition at line 76 of file PinChangeView.h.
| uint8_t cdc::ui::PinChangeView::getRetriesRemaining | ( | ) | const |
Returns remaining retry count for current PIN verification.
Get retries remaining (from PinManager)
Definition at line 104 of file PinChangeView.cpp.
References cdc::core::PinManager::getBadgeRetries(), and cdc::core::PinManager::instance().
Referenced by render().
|
inline |
Get current step
Definition at line 64 of file PinChangeView.h.
| void cdc::ui::PinChangeView::init | ( | uint8_t | minLength = 4, |
| uint8_t | maxLength = 16 ) |
Initializes PIN-change wizard state.
Initialize PIN change view
| minLength | Minimum PIN length (default 4) |
| maxLength | Maximum PIN length (default 16) |
| minLength | Minimum required PIN length. |
| maxLength | Maximum allowed PIN length. |
Definition at line 38 of file PinChangeView.cpp.
References CURRENT_PIN, cdc::ui::ViewBase::dirty_, and MAX_PIN_LENGTH.
Referenced by onEnter().
|
overridevirtual |
Resets wizard state when entering the view.
| context | Optional view context (unused). |
Implements cdc::ui::IView.
Definition at line 57 of file PinChangeView.cpp.
References init().
|
overridevirtual |
Handles key input for PIN-change flow.
| key | Pressed key code. |
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.
|
overridevirtual |
Handles message timeout and completion callbacks.
| nowMs | Current monotonic time in milliseconds. |
Reimplemented from cdc::ui::IView.
Definition at line 237 of file PinChangeView.cpp.
References cdc::ui::ViewBase::dirty_, and MESSAGE_DISPLAY_MS.
|
overridevirtual |
Renders PIN-change wizard UI.
| partial | Indicates partial/full redraw mode. |
Implements cdc::ui::IView.
Definition at line 317 of file PinChangeView.cpp.
References CURRENT_PIN, cdc::ui::ViewBase::dirty_, cdc::ui::display, cdc::ui::render::drawFooterBar(), cdc::ui::render::drawHeaderCentered(), cdc::hal::getDisplayInstance(), getFooterHint(), getRetriesRemaining(), MESSAGE_Y, PIN_DOT_SIZE, PIN_DOT_SPACING, PIN_Y, cdc::ui::render::printText(), STEP_Y, cdc::ui::TITLE_Y, and cdc::ui::tr().
|
inline |
Definition at line 58 of file PinChangeView.h.
|
inline |
Definition at line 56 of file PinChangeView.h.
|
inline |
Set completion callback
Definition at line 54 of file PinChangeView.h.
|
inline |
Definition at line 57 of file PinChangeView.h.
|
inline |
Definition at line 59 of file PinChangeView.h.
|
inline |
Definition at line 55 of file PinChangeView.h.
|
staticconstexpr |
Definition at line 25 of file PinChangeView.h.
Referenced by init().
|
staticconstexpr |
Definition at line 26 of file PinChangeView.h.
Referenced by onTick().