Kleidos API Search

In development. It changes without notice.

Topic

State Rules

The decisions the handlers take, with no screen, no context and no device behind them, and the list of states itself.

Among them: when an idle wait ends and what a timer then does, the order in which a session ends, where a send goes and what it reports, how long the pairing window stays open, and what a wiped or unreadable vault asks at boot. They are tested on a computer.

See also
Application States, State Context & Shared Flows

Files

file src/states/logic/admin_entry.h
What the admin state's first tick does before it serves the portal.
file src/states/logic/app_state.h
The application FSM's state enum and the constants the whole FSM shares.
file src/states/logic/ble_send_report.h
What a Bluetooth typing session says when it ends.
file src/states/logic/ble_type_chooser.h
The BLE "what do I type?" chooser model: its actions, their order and their labels.
file src/states/logic/boot_recovery_logic.h
Which recovery prompt a boot shows, and what it says.
file src/states/logic/compositor_pass.h
When the main loop's last compositor pass composites over the glass.
file src/states/logic/entry_idle_logic.h
When a secret-entry prompt counts as left alone.
file src/states/logic/idle_wait_logic.h
When the main loop may wait out an idle stretch, and for how long.
file src/states/logic/lockout_read_logic.h
When a secret-entry surface reads the brute-force lockout again.
file src/states/logic/pair_window_logic.h
When a pairing page closes its window: the per-tick decision every page that opens the pairing window shares.
file src/states/logic/secret_words.h
Which word names the unlock secret on a surface: "PIN" or "password".
file src/states/logic/send_route.h
Where a send goes before the radio starts: straight out, or through the host picker.
file src/states/logic/session_lock_order.h
The order a session lock takes its steps in: the keys go before the Bluetooth teardown.
file src/states/logic/settings_timer_logic.h
Pure policy for the idle timers (screen-off / auto-lock / deep-sleep): the clamp, the idle predicate, the screen-off step and the relock decision.
file src/states/logic/unlock_shape.h
Whether a secret an entry collected was collected the way the vault on flash takes its secret, so that a wrong one may be counted.
file src/states/logic/unlock_tuning.h
Clock policy for the unlock and write latency changes; the build switches that select it live in perf_switches.h.
file src/states/logic/vault_actions.h
Vault menu action identifiers shared across the vault menu screens.

Classes

struct kleidos::states::blesend::ReportCopy
The notice a report leaves on the glass. More about kleidos::states::blesend::ReportCopy
struct kleidos::states::bletype::ActionList
Resolved chooser action list: first count entries of actions valid. More about kleidos::states::bletype::ActionList
struct kleidos::states::boot_recovery::PromptText
What a prompt says. More about kleidos::states::boot_recovery::PromptText
class kleidos::states::entry_idle::IdleClock
The idle clock of a prompt that owns the loop while it is up. More about kleidos::states::entry_idle::IdleClock
struct kleidos::states::idle_wait::Inputs
What the idle rule reads, gathered by the main loop each tick. More about kleidos::states::idle_wait::Inputs
class kleidos::states::lockout_read::KeptRead
The lockout as an entry surface last read it, and when to read again. More about kleidos::states::lockout_read::KeptRead
struct kleidos::states::pairwin::PairPromptOutcome
What a closed pairing prompt means, and whether the prompt answers the stack. More about kleidos::states::pairwin::PairPromptOutcome
struct kleidos::states::pairwin::PairTick
One tick of a pairing page, as the page reads it. More about kleidos::states::pairwin::PairTick
struct kleidos::states::secret_words::SecretWordIds
One line's two wordings. More about kleidos::states::secret_words::SecretWordIds
struct kleidos::states::secret_words::SecretRowLabel
A settings row whose label names the unlock secret. More about kleidos::states::secret_words::SecretRowLabel
struct kleidos::states::settings::IdleTimers
The three idle timeouts, in milliseconds. More about kleidos::states::settings::IdleTimers

Enumerations

enum class kleidos::states::AdminEntry : uint8_t { kleidos::states::AdminEntry::Serve , kleidos::states::AdminEntry::StartAp , kleidos::states::AdminEntry::HandOver }
What the admin state's first tick does before it serves the portal. More about kleidos::states::AdminEntry
enum class kleidos::AutoLockMode : uint8_t { kleidos::AutoLockMode::AfterSend , kleidos::AutoLockMode::MANUAL , kleidos::AutoLockMode::TIMEOUT }
Auto-lock policy applied after a credential is sent over BLE HID. More about kleidos::AutoLockMode
enum class kleidos::AppState : uint8_t { kleidos::AppState::BootCheck, kleidos::AppState::ONBOARDING, kleidos::AppState::PinEntry, kleidos::AppState::Home, kleidos::AppState::BleHidTyping, kleidos::AppState::AdminMode, kleidos::AppState::HwTest, kleidos::AppState::DeepSleep, kleidos::AppState::ComponentGallery }
Top-level application finite-state-machine states. More about kleidos::AppState
enum class kleidos::states::blesend::Burst : uint8_t { kleidos::states::blesend::Burst::Login , kleidos::states::blesend::Burst::Code }
The burst of a session that ended. More about kleidos::states::blesend::Burst
enum class kleidos::states::blesend::Ending : uint8_t { kleidos::states::blesend::Ending::Landed , kleidos::states::blesend::Ending::Refused , kleidos::states::blesend::Ending::Failed , kleidos::states::blesend::Ending::CapsLock }
How a burst ended. More about kleidos::states::blesend::Ending
enum class kleidos::states::blesend::Report : uint8_t { kleidos::states::blesend::Report::Typed, kleidos::states::blesend::Report::CodeNotTyped, kleidos::states::blesend::Report::NotTyped, kleidos::states::blesend::Report::CapsLockOn, kleidos::states::blesend::Report::CodeCapsLockOn }
What the session says when it ends. More about kleidos::states::blesend::Report
enum class kleidos::states::bletype::Action : uint8_t { kleidos::states::bletype::Action::UserTabPass , kleidos::states::bletype::Action::Totp , kleidos::states::bletype::Action::User , kleidos::states::bletype::Action::Pass }
One action of the BLE "what do I type?" chooser. More about kleidos::states::bletype::Action
enum class kleidos::states::boot_recovery::Prompt : uint8_t { kleidos::states::boot_recovery::Prompt::None, kleidos::states::boot_recovery::Prompt::StorageRefused, kleidos::states::boot_recovery::Prompt::StorageNotSetUp, kleidos::states::boot_recovery::Prompt::OlderLayout, kleidos::states::boot_recovery::Prompt::RecordUnreadable }
The recovery prompt a boot shows. More about kleidos::states::boot_recovery::Prompt
enum class kleidos::states::pairwin::PairPromptResult : uint8_t { kleidos::states::pairwin::PairPromptResult::NotAsked , kleidos::states::pairwin::PairPromptResult::Accepted , kleidos::states::pairwin::PairPromptResult::Rejected , kleidos::states::pairwin::PairPromptResult::Withdrawn }
What the owner answered the numeric-comparison prompt. More about kleidos::states::pairwin::PairPromptResult
enum class kleidos::states::pairwin::AnswerElsewhere : uint8_t { kleidos::states::pairwin::AnswerElsewhere::None , kleidos::states::pairwin::AnswerElsewhere::Accepted , kleidos::states::pairwin::AnswerElsewhere::Rejected }
How the request a closed prompt showed was answered on another surface. More about kleidos::states::pairwin::AnswerElsewhere
enum class kleidos::states::pairwin::PairStep : uint8_t { kleidos::states::pairwin::PairStep::Stay , kleidos::states::pairwin::PairStep::Leave }
What the pairing page does with one tick. More about kleidos::states::pairwin::PairStep
enum class kleidos::states::secret_words::SecretWord : uint8_t { kleidos::states::secret_words::SecretWord::Wrong, kleidos::states::secret_words::SecretWord::WipeBody, kleidos::states::secret_words::SecretWord::FactoryBody, kleidos::states::secret_words::SecretWord::VaultKept, kleidos::states::secret_words::SecretWord::VaultNew, kleidos::states::secret_words::SecretWord::ChangeTitle, kleidos::states::secret_words::SecretWord::ChangeCurrent, kleidos::states::secret_words::SecretWord::ChangeNew, kleidos::states::secret_words::SecretWord::ChangeConfirm, kleidos::states::secret_words::SecretWord::Updated, kleidos::states::secret_words::SecretWord::ReEnter }
A line that names the unlock secret. More about kleidos::states::secret_words::SecretWord
enum class kleidos::states::sendroute::SendRoute : uint8_t { kleidos::states::sendroute::SendRoute::Direct , kleidos::states::sendroute::SendRoute::PickerFirst }
Where a staged credential goes when the owner sends it. More about kleidos::states::sendroute::SendRoute
enum class kleidos::states::settings::TimerField : uint8_t { kleidos::states::settings::TimerField::ScreenOff , kleidos::states::settings::TimerField::AutoLock , kleidos::states::settings::TimerField::DeepSleep }
Which of the three idle timers the user just edited (the authoritative one). More about kleidos::states::settings::TimerField
enum class kleidos::states::settings::RelockAction : uint8_t { kleidos::states::settings::RelockAction::None , kleidos::states::settings::RelockAction::LockFace , kleidos::states::settings::RelockAction::Silent }
What the idle auto-lock timer should do this tick. More about kleidos::states::settings::RelockAction
enum class kleidos::states::settings::ScreenOffStep : uint8_t { kleidos::states::settings::ScreenOffStep::Stay , kleidos::states::settings::ScreenOffStep::Notice , kleidos::states::settings::ScreenOffStep::Sleep }
What the screen-off timer does with the panel on one call. More about kleidos::states::settings::ScreenOffStep
enum class kleidos::VaultAction : uint8_t { kleidos::VaultAction::SETTINGS, kleidos::VaultAction::AddCred, kleidos::VaultAction::WifiAdmin, kleidos::VaultAction::SdExport, kleidos::VaultAction::SdImport, kleidos::VaultAction::SdCsv, kleidos::VaultAction::LOCK, kleidos::VaultAction::PassGen }
Action items available in the vault menu. More about kleidos::VaultAction

Functions

constexpr AdminEntrykleidos::states::adminEntryFor (bool portalOff, bool bleOff)
What the admin state's first tick does, from the radios' state.
constexpr Reportkleidos::states::blesend::reportFor (Burst burst, Ending ending)
The report a session ends with, from its last burst.
constexpr boolkleidos::states::blesend::locksAfterSend (Report report)
Whether the after-send lock applies once the session ends so.
constexpr ReportCopykleidos::states::blesend::copyFor (Report report)
The notice for a report.
constexpr boolkleidos::states::bletype::hasPendingTotp (uint16_t id)
constexpr ActionListkleidos::states::bletype::buildActions (bool hasTotp)
Build the chooser action list in its fixed order.
constexpr i18n::StringIdkleidos::states::bletype::labelFor (Action action)
i18n label id for one chooser action.
constexpr Promptkleidos::states::boot_recovery::promptFor (bool mountRefused, bool formatFailed, bool legacyLayout, bool needsManualRecovery)
Choose the prompt for what the vault's mount reported.
constexpr PromptTextkleidos::states::boot_recovery::textOf (Prompt prompt)
The title and body of prompt.
constexpr boolkleidos::states::compositorPassRuns (bool modalOwnsGlass, bool stateChanged, bool enteredDrew)
Whether the main loop's last compositor pass runs on this tick.
constexpr boolkleidos::states::entry_idle::restsIn (AuthUIState state)
Whether an entry in state is at rest: nothing on it is in motion.
constexpr uint32_tkleidos::states::idle_wait::waitMs (const Inputs &in)
Whether the loop may wait out an idle stretch now, and how long.
constexpr PairPromptOutcomekleidos::states::pairwin::pairPromptOutcome (::kleidos::ui::popup::ConfirmResult closed, AnswerElsewhere elsewhere)
What a closed pairing prompt means, from how its dialog closed.
constexpr boolkleidos::states::pairwin::pairingHolds (bool promptPending, bool linkPairing, bool accepted, uint32_t sinceAnswerMs)
Whether the add-host page's pairing outranks its own clock.
constexpr PairStepkleidos::states::pairwin::decidePairStep (const PairTick &t)
What the pairing page does with t.
constexpr boolkleidos::states::pairwin::newHostLinked (bool connected, uint8_t bondsNow, uint8_t bondsAtOpen)
Whether the add-host page's host is linked: a new bond, on the link.
consteval boolkleidos::states::secret_words::secretWordsInOrder ()
Whether every entry of kSecretWords stands at its line's index.
constexpr boolkleidos::states::secret_words::namesPassword (security::pin_policy::SetSurface surface, security::pin_policy::SecretKind kind)
Whether surface names a secret of kind a password.
constexpr i18n::StringIdkleidos::states::secret_words::secretWord (SecretWord word, security::pin_policy::SetSurface surface, security::pin_policy::SecretKind kind)
The words of word on surface for a secret of kind.
constexpr i18n::StringIdkleidos::states::secret_words::boardSecretWord (SecretWord word, security::pin_policy::SecretKind kind)
The words of word on this board for a secret of kind.
constexpr const kleidos::settings::LabelTiers &kleidos::states::secret_words::rowLabel (const kleidos::settings::SettingsOption &opt, security::pin_policy::SetSurface surface, security::pin_policy::SecretKind kind)
The label opt shows on surface over a secret of kind.
constexpr const kleidos::settings::LabelTiers &kleidos::states::secret_words::boardRowLabel (const kleidos::settings::SettingsOption &opt, security::pin_policy::SecretKind kind)
The label opt shows on this board over a secret of kind.
constexpr SendRoutekleidos::states::sendroute::decideSendRoute (uint8_t bonded)
The route a send takes with bonded hosts in the table.
constexpr boolkleidos::states::settings::idleTimerElapsed (uint32_t idleMs, uint32_t timeoutMs)
Whether an idle timer has run out: the one idle predicate.
constexpr uint32_tkleidos::states::settings::idleTimerRemaining (uint32_t idleMs, uint32_t timeoutMs)
Time left before an idle timer runs out, read through the same rule.
constexpr uint32_tkleidos::states::settings::idleSinceInputOrHold (uint32_t sinceInputMs, bool held, uint32_t sinceHoldMs)
The idle time the auto-lock and the idle sleep count: since the last input, or since the last hold when that came later.
constexpr uint32_tkleidos::states::settings::derivedDimMs (uint32_t screenOffMs)
Derived dim time for a screen-off window (85 %, the final-15 % rule).
constexpr IdleTimerskleidos::states::settings::clampIdleTimers (IdleTimers t, TimerField edited)
Repair the deep-sleep-ceiling invariant after one timer was edited.
constexpr RelockActionkleidos::states::settings::decideRelock (uint32_t idleMs, uint32_t autoLockMs, uint32_t screenOffMs, bool vaultUnlocked, bool panelAsleep=false)
Decide whether idle time has reached the vault auto-lock, and how.
constexpr ScreenOffStepkleidos::states::settings::decideScreenOff (bool due, bool panelAsleep, bool noticed)
Decide what the screen-off timer does with the panel this tick.

Variables

constexpr uint8_tkleidos::states::bletype::kMaxActions
Maximum number of chooser actions (all four present).
constexpr uint16_tkleidos::states::bletype::kNoPendingTotp
constexpr uint32_tkleidos::states::idle_wait::kActiveCadenceMs
The main loop's cadence while anything is going on, ms.
constexpr uint32_tkleidos::states::idle_wait::kLitWaitMs
Longest idle wait while the panel shows a frame, ms.
constexpr uint32_tkleidos::states::idle_wait::kDarkWaitMs
constexpr uint32_tkleidos::states::idle_wait::kInputQuietMs
How long after the last input the loop keeps its cadence, ms.
constexpr uint32_tkleidos::states::idle_wait::kFrameQuietMs
How long after the last frame the loop keeps its cadence, ms.
constexpr uint32_tkleidos::states::lockout_read::kLockedRereadMs
How often a surface reads the guard while a lock holds, in milliseconds.
constexpr uint32_tkleidos::states::pairwin::kPairDwellMs
constexpr uint32_tkleidos::states::pairwin::kSetupPairTimeoutMs
constexpr uint32_tkleidos::states::pairwin::kAddHostPairTimeoutMs
constexpr uint32_tkleidos::states::pairwin::kAcceptedPairingHoldMs
constexpr std::array< SecretWordIds, 11 >kleidos::states::secret_words::kSecretWords
Every line that names the unlock secret, in SecretWord order.
constexpr std::array< SecretRowLabel, 1 >kleidos::states::secret_words::kSecretRowLabels
constexpr uint8_tkleidos::states::sendroute::kPickerMinHosts
Fewest hosts that make a send ask which one.
constexpr uint32_tkleidos::states::settings::kTimerNeverMs
Idle-timer sentinel meaning "this timer never fires".
constexpr uint32_tkleidos::states::settings::kScreenDimPermille
Fraction of the screen-off window at which the display starts dimming.
constexpr uint32_tkleidos::states::unlock::kIdleCpuMhz
constexpr uint32_tkleidos::states::unlock::kIdleCpuMhzBaseline
Core clock the auth screen idles at with the floor off.
constexpr uint32_tkleidos::states::unlock::kIdleCpuMinMhz
Reserved minimum handed to AppContext::configureDFS (no range in use).
constexpr uint32_tkleidos::states::unlock::kAuthCpuMhz
The auth screen's steady-state clock for this build.

Back to the top

Enumeration Type Documentation

Action #

enum class kleidos::states::bletype::Action : uint8_t

One action of the BLE "what do I type?" chooser.

Every action resolves to an existing kleidos::ble::Facade typing entry at staging time: UserTabPass maps to Facade::typeCredential (which already sends username, TAB, password, ENTER); Totp / User / Pass map to Facade::typePassword with the generated code / single field staged in the password slot.

Enumerator
UserTabPass 

Username, TAB, password (the combo the HID stack types).

Totp 

Current TOTP code (offered only when the record embeds one).

User 

Username field alone.

Pass 

Password field alone.

AdminEntry #

enum class kleidos::states::AdminEntry : uint8_t

What the admin state's first tick does before it serves the portal.

Enumerator
Serve 

The portal is up already (HOME brought it up): serve it.

StartAp 

Bring the SoftAP portal up on this tick, then serve it.

HandOver 

BLE is still up: arm the pending-admin routing and restart.

AnswerElsewhere #

enum class kleidos::states::pairwin::AnswerElsewhere : uint8_t

How the request a closed prompt showed was answered on another surface.

Enumerator
None 

Not answered: it was withdrawn (its link ended, a newer request came).

Accepted 

Confirmed elsewhere (the debug console).

Rejected 

Refused elsewhere, or by the stack's own timeout.

AppState #

enum class kleidos::AppState : uint8_t

Top-level application finite-state-machine states.

State Meaning Entered from
BootCheck Initial routing after a reset or a wake a cold boot, a wake, a restart
ONBOARDING First-time setup BootCheck, PinEntry
PinEntry The unlock screen: a PIN or a passphrase, by the board BootCheck, Home
Home Credentials, 2FA codes and settings PinEntry, ONBOARDING, BleHidTyping, AdminMode
BleHidTyping Sending a credential or a code Home
AdminMode The Wi-Fi admin portal, which also installs an update Home, PinEntry
HwTest Hardware test screens (debug builds) any state
DeepSleep Terminal: the production sleep any state
ComponentGallery Interface component gallery (debug builds) any state

What moves the machine from one state to the next is the table of Application States.

Note
HwTest and ComponentGallery are reached only from the serial console of a debug build; no screen leads to them. Both enumerators always exist, and the gallery's handler is linked in debug builds only.
AdminMode is the state that owns the update upload; the FSM has no separate update state. An installed update restarts the device, and the next boot starts at BootCheck.
Enumerator
BootCheck 

Initial routing after reset.

ONBOARDING 

First-time setup (no vault, setup never finished).

PinEntry 

The unlock screen (a PIN or a passphrase).

Home 

Credential / TOTP / actions menu.

BleHidTyping 

Sending a credential over BLE HID.

AdminMode 

Wi-Fi admin portal and update.

HwTest 

Hardware test screens (debug builds, from the console).

DeepSleep 

Shutdown into the production sleep.

ComponentGallery 

Interface component gallery (debug builds, from the console).

AutoLockMode #

enum class kleidos::AutoLockMode : uint8_t

Auto-lock policy applied after a credential is sent over BLE HID.

Enumerator
AfterSend 

Lock immediately after the credential is typed.

MANUAL 

Stay unlocked until the user locks manually.

TIMEOUT 

Lock only when the idle timeout elapses.

Burst #

enum class kleidos::states::blesend::Burst : uint8_t

The burst of a session that ended.

Enumerator
Login 

What the owner chose to send: the pair, one field, or a code alone.

Code 

The 2FA code the offer types after the pair.

Ending #

enum class kleidos::states::blesend::Ending : uint8_t

How a burst ended.

Enumerator
Landed 

Every key report went out.

Refused 

It never started: no link to type to, or no code to type.

Failed 

It started, and the link failed under it.

CapsLock 

The host's Caps Lock stayed on, or came on: no ENTER went out.

PairPromptResult #

enum class kleidos::states::pairwin::PairPromptResult : uint8_t

What the owner answered the numeric-comparison prompt.

Enumerator
NotAsked 

No request was pending; nothing was shown and nothing answered.

Accepted 

The digits were confirmed: on the glass, or on another surface.

Rejected 

Refused (on the glass or elsewhere), or the prompt lapsed.

Withdrawn 

The request ended unanswered: its link went, or a newer one replaced it.

PairStep #

enum class kleidos::states::pairwin::PairStep : uint8_t

What the pairing page does with one tick.

Enumerator
Stay 

Keep the page, and the radio with it.

Leave 

Stop the radio and go on.

Prompt #

enum class kleidos::states::boot_recovery::Prompt : uint8_t

The recovery prompt a boot shows.

Enumerator
None 

The vault opens, or a mount only ran out of memory.

StorageRefused 

The partition will not mount and was left as it was.

StorageNotSetUp 

The partition was blank, and formatting it failed.

OlderLayout 

The records are intact, in a layout this build cannot read.

RecordUnreadable 

It mounted, and the vault in it cannot be opened.

RelockAction #

enum class kleidos::states::settings::RelockAction : uint8_t

What the idle auto-lock timer should do this tick.

The vault relock is visually distinct from deep sleep (the ceiling, which tears everything down): auto-lock only drops the radios and zeroizes the key, keeping the device awake at the unlock screen's lock face. Whether that lock face is visible depends on where the screen-off timer already left the backlight.

Enumerator
None 

No relock: still within the auto-lock window (or disabled).

LockFace 

Auto-lock < screen-off: relock with the lock face visible (screen still on).

Silent 

Auto-lock >= screen-off: relock with no visual (screen already off).

Report #

enum class kleidos::states::blesend::Report : uint8_t

What the session says when it ends.

Enumerator
Typed 

Everything the owner sent landed.

CodeNotTyped 

The pair landed; the code the owner accepted did not.

NotTyped 

The burst the owner sent did not land.

CapsLockOn 

The host's Caps Lock is on: the owner turns it off and sends again.

CodeCapsLockOn 

The pair landed; the code did not, for the host's Caps Lock.

ScreenOffStep #

enum class kleidos::states::settings::ScreenOffStep : uint8_t

What the screen-off timer does with the panel on one call.

Enumerator
Stay 

Not due: the panel stays as it is.

Notice 

Due on a lit panel: note it, and put the panel to sleep on the next call.

Sleep 

Noticed on an earlier call, or asleep already: put the panel to sleep.

SecretWord #

enum class kleidos::states::secret_words::SecretWord : uint8_t

A line that names the unlock secret.

Enumerator
Wrong 

A refused secret ("Wrong PIN").

WipeBody 

The vault wipe's card: the secret stays.

FactoryBody 

The factory reset's card: the secret goes.

VaultKept 

The wipe's toast: the secret is unchanged.

VaultNew 

The wipe's toast: set a new secret.

ChangeTitle 

The change wizard's title.

ChangeCurrent 

The change wizard's current-secret step.

ChangeNew 

The change wizard's new-secret step.

ChangeConfirm 

The change wizard's repeat step.

Updated 

The change's toast: the new secret is in force.

ReEnter 

The change's toast: the repeat did not match.

SendRoute #

enum class kleidos::states::sendroute::SendRoute : uint8_t

Where a staged credential goes when the owner sends it.

Enumerator
Direct 

Start the radio for any bonded host (0 or 1 host bonded).

PickerFirst 

Ask which host first (2 or more hosts bonded).

TimerField #

enum class kleidos::states::settings::TimerField : uint8_t

Which of the three idle timers the user just edited (the authoritative one).

Enumerator
ScreenOff 

The screen-off timer.

AutoLock 

The auto-lock timer.

DeepSleep 

The deep-sleep timer (the ceiling).

VaultAction #

enum class kleidos::VaultAction : uint8_t

Action items available in the vault menu.

Value Meaning
SETTINGS Open the on-device settings tree
AddCred Add a new credential
WifiAdmin Launch the WiFi admin portal (BLE must be deinit'd)
SdExport Export the vault to SD (requires HAS_SDCARD)
SdImport Import a vault from SD (requires HAS_SDCARD)
SdCsv Import/export CSV via SD (requires HAS_SDCARD)
LOCK Lock the vault and sleep
PassGen Open the password generator (keyboard boards)
Enumerator
SETTINGS 

Open the on-device settings tree.

AddCred 

Add a new credential.

WifiAdmin 

Launch the WiFi admin portal.

SdExport 

Export the vault to SD.

SdImport 

Import a vault from SD.

SdCsv 

Import/export CSV via SD.

LOCK 

Lock the vault and sleep.

PassGen 

Open the password generator (keyboard boards).

Back to the top

Function Documentation

adminEntryFor() #

AdminEntry kleidos::states::adminEntryFor(bool portalOff, bool bleOff)
constexpr

What the admin state's first tick does, from the radios' state.

Parameters
NameDirectionMeaning
portalOffinThe admin portal is off.
bleOffinThe BLE stack is off.
Returns
The step to take.

boardRowLabel() #

const kleidos::settings::LabelTiers & kleidos::states::secret_words::boardRowLabel(const kleidos::settings::SettingsOption & opt, security::pin_policy::SecretKind kind)
constexpr

The label opt shows on this board over a secret of kind.

Parameters
NameDirectionMeaning
optinThe settings row.
kindinThe kind of secret the vault records.
Returns
rowLabel on security::pin_policy::kBoardSetSurface.

boardSecretWord() #

i18n::StringId kleidos::states::secret_words::boardSecretWord(SecretWord word, security::pin_policy::SecretKind kind)
constexpr

The words of word on this board for a secret of kind.

Parameters
NameDirectionMeaning
wordinThe line.
kindinThe kind of secret the vault records.
Returns
secretWord on security::pin_policy::kBoardSetSurface.

buildActions() #

ActionList kleidos::states::bletype::buildActions(bool hasTotp)
nodiscardconstexpr

Build the chooser action list in its fixed order.

Order: User+TAB+Password always first (the default), TOTP second only when the credential embeds one, then Username, then Password. Only the TOTP entry is conditional.

Parameters
NameDirectionMeaning
hasTotpinTrue when the credential embeds a TOTP secret.
Returns
The ordered action list.

clampIdleTimers() #

IdleTimers kleidos::states::settings::clampIdleTimers(IdleTimers t, TimerField edited)
constexpr

Repair the deep-sleep-ceiling invariant after one timer was edited.

Deep sleep is the ceiling: after the edit, neither screen-off nor auto-lock may exceed it. The edited field is authoritative and is never moved; the others yield the minimum needed:

  • editing ScreenOff / AutoLock: the edited value is capped at the current deep-sleep ceiling (a timer cannot outlast deep sleep);
  • editing DeepSleep: the new (possibly lower) ceiling pulls screen-off and auto-lock down to it if either was above.
Parameters
NameDirectionMeaning
tinThe three timers after applying the raw edit.
editedinThe field the user just committed (kept authoritative).
Returns
The repaired timers with the ceiling invariant restored.

compositorPassRuns() #

bool kleidos::states::compositorPassRuns(bool modalOwnsGlass, bool stateChanged, bool enteredDrew)
constexpr

Whether the main loop's last compositor pass runs on this tick.

Parameters
NameDirectionMeaning
modalOwnsGlassinA handler-owned modal phase or the critical-battery dwell holds the glass.
stateChangedinThe FSM changed state on this tick.
enteredDrewinThe entering state drew its first screen in its enter() (only read when stateChanged).
Return values
ValueMeaning
trueThe pass composites over the current state's screen.
falseThe glass is a modal's, or still the old state's.

copyFor() #

ReportCopy kleidos::states::blesend::copyFor(Report report)
constexpr

The notice for a report.

Parameters
NameDirectionMeaning
reportinWhat the session says.
Returns
Its two lines and its tone.

decidePairStep() #

PairStep kleidos::states::pairwin::decidePairStep(const PairTick & t)
constexpr

What the pairing page does with t.

A pairing in flight outranks every clock the page keeps. The owner's own skip or continue outranks the pairing, because abandoning it is their choice.

Parameters
NameDirectionMeaning
tinThis tick, as the page reads it.
Returns
Whether to stay on the page or leave it.

decideRelock() #

RelockAction kleidos::states::settings::decideRelock(uint32_t idleMs, uint32_t autoLockMs, uint32_t screenOffMs, bool vaultUnlocked, bool panelAsleep = false)
constexpr

Decide whether idle time has reached the vault auto-lock, and how.

Pure policy for the FSM's auto-lock: once the unlocked vault has been idle for at least autoLockMs it relocks. If the backlight is still on (auto-lock fires before the screen-off timeout) the relock shows the lock face; if the screen has already powered off (auto-lock at or past screen-off) it relocks silently, and the next input only wakes the panel, which dismisses the lock face too (wake_press.h): the input after it reaches the entry. Deep sleep is the ceiling and is handled separately (each idle view sleeps at its own idleSleepMs), so this never needs to consider it: the invariant autoLockMs <= deepSleepMs guarantees auto-lock fires first. Both timers are read through idleTimerElapsed, so a parked one never fires.

A zero autoLockMs disables auto-lock too. No writer stores one (every path clamps to the editor's 15 s floor), and a timer that fired on every tick would lock the owner out of the vault the moment it opened.

A panel that is dark already relocks silently whatever the idle time says: the screen-off timer is not the only thing that puts it to sleep (the debug console's forced screen-off does), and an activity stamp that wakes nothing (the re-encryption's slices) restarts the idle time on a dark panel. A relock onto that panel must not light it.

Parameters
NameDirectionMeaning
idleMsinMilliseconds the session has been idle (idleSinceInputOrHold).
autoLockMsinThe vault-relock timeout (0 or kTimerNeverMs never fires).
screenOffMsinThe backlight-off timeout (splits LockFace vs Silent).
vaultUnlockedinWhether a vault session is live (nothing to relock otherwise).
panelAsleepinThe panel sleeps already (display::isAsleep).
Returns
The relock action for this tick.

decideScreenOff() #

ScreenOffStep kleidos::states::settings::decideScreenOff(bool due, bool panelAsleep, bool noticed)
constexpr

Decide what the screen-off timer does with the panel this tick.

The timer does not put a lit panel to sleep on the call it comes due. That call only notices, so on the tick between, while the panel still takes a paint, a screen that shows a value which is wrong once stale (a one-time code) takes it off the glass (sleeping_panel.h). The next call puts the panel to sleep, and a panel that sleeps already is sent the sleep again, which costs nothing.

Parameters
NameDirectionMeaning
dueinThe display is dimmed, the screen-off timeout ran out and the caller lets the panel go off.
panelAsleepinThe panel sleeps already.
noticedinAn earlier call noticed the timeout, and the panel has not woken since.
Returns
The step for this call.

decideSendRoute() #

SendRoute kleidos::states::sendroute::decideSendRoute(uint8_t bonded)
constexpr

The route a send takes with bonded hosts in the table.

Parameters
NameDirectionMeaning
bondedinHosts the bond table lists.
Returns
PickerFirst from kPickerMinHosts hosts on, else Direct.

derivedDimMs() #

uint32_t kleidos::states::settings::derivedDimMs(uint32_t screenOffMs)
constexpr

Derived dim time for a screen-off window (85 %, the final-15 % rule).

Parameters
NameDirectionMeaning
screenOffMsinThe screen-off timeout in ms, or kTimerNeverMs.
Returns
The dim-start time in ms; kTimerNeverMs for a parked screen-off, which never dims either.

hasPendingTotp() #

bool kleidos::states::bletype::hasPendingTotp(uint16_t id)
nodiscardconstexpr

Whether a staged follow-up id names a credential whose code is still to be offered.

Parameters
NameDirectionMeaning
idinThe staged follow-up id.
Return values
ValueMeaning
trueid names a slot this device has.
falseNothing is pending, or the id names no slot at all.

idleSinceInputOrHold() #

uint32_t kleidos::states::settings::idleSinceInputOrHold(uint32_t sinceInputMs, bool held, uint32_t sinceHoldMs)
constexpr

The idle time the auto-lock and the idle sleep count: since the last input, or since the last hold when that came later.

A hold (AppContext::holdIdleSleep) keeps the idle sleep from coming due through a wait the user is not idle in although no input reaches the board, without counting as input: the dim and screen-off timers count from the last input alone, so the panel still goes dark. Only the Bluetooth typing screen holds, and HOME's entry is an input that ends the hold, so the auto-lock reads the same time as the last input there.

Parameters
NameDirectionMeaning
sinceInputMsinMilliseconds since the last input.
heldinA hold was made since the last input.
sinceHoldMsinMilliseconds since the last hold.
Returns
sinceHoldMs when held and the hold is the later of the two, otherwise sinceInputMs.

idleTimerElapsed() #

bool kleidos::states::settings::idleTimerElapsed(uint32_t idleMs, uint32_t timeoutMs)
constexpr

Whether an idle timer has run out: the one idle predicate.

Every idle timeout (screen dim, screen off, auto-lock, deep sleep, the PIN screen's own sleep) is polled through this. idleMs is the wrapping unsigned difference now - lastActivity, so it can reach every 32-bit value: a plain idleMs >= timeoutMs would come true for one millisecond per clock wrap even on a parked timer. A parked timer therefore never fires here.

Parameters
NameDirectionMeaning
idleMsinMilliseconds since the last user activity.
timeoutMsinThe timeout, or kTimerNeverMs for a parked timer.
Returns
true once idleMs has reached a finite timeoutMs.

idleTimerRemaining() #

uint32_t kleidos::states::settings::idleTimerRemaining(uint32_t idleMs, uint32_t timeoutMs)
constexpr

Time left before an idle timer runs out, read through the same rule.

Parameters
NameDirectionMeaning
idleMsinMilliseconds since the last user activity.
timeoutMsinThe timeout, or kTimerNeverMs for a parked timer.
Returns
kTimerNeverMs for a parked timer, 0 once idleTimerElapsed holds, otherwise the milliseconds still to go.

labelFor() #

i18n::StringId kleidos::states::bletype::labelFor(Action action)
nodiscardconstexpr

i18n label id for one chooser action.

Parameters
NameDirectionMeaning
actioninChooser action.
Returns
The i18n::StringId naming the action row.

locksAfterSend() #

bool kleidos::states::blesend::locksAfterSend(Report report)
constexpr

Whether the after-send lock applies once the session ends so.

Only when everything the owner sent landed: a session that leaves a code or a login untyped stays unlocked, so its notice is read on a lit panel and the owner can send what is missing. The idle lock still runs.

Parameters
NameDirectionMeaning
reportinWhat the session said.
Return values
ValueMeaning
trueThe owner's "After typing: Lock now" locks the device.
falseThe device stays unlocked.

namesPassword() #

bool kleidos::states::secret_words::namesPassword(security::pin_policy::SetSurface surface, security::pin_policy::SecretKind kind)
constexpr

Whether surface names a secret of kind a password.

Parameters
NameDirectionMeaning
surfaceinThe board's entry surface.
kindinThe kind of secret the vault records.
Returns
True on a keyboard, and for a passphrase on any surface.

newHostLinked() #

bool kleidos::states::pairwin::newHostLinked(bool connected, uint8_t bondsNow, uint8_t bondsAtOpen)
constexpr

Whether the add-host page's host is linked: a new bond, on the link.

A link alone is not success there: the page is for a host the table did not hold when it opened. A bonded host the filter let through anyway (a keystore it could not read) is a link with no new bond, and the page keeps waiting.

Parameters
NameDirectionMeaning
connectedinA host holds an authenticated link.
bondsNowinHosts the bond table lists now.
bondsAtOpeninHosts it listed when the page opened.
Returns
true once a host joined the table and holds the link.

pairingHolds() #

bool kleidos::states::pairwin::pairingHolds(bool promptPending, bool linkPairing, bool accepted, uint32_t sinceAnswerMs)
constexpr

Whether the add-host page's pairing outranks its own clock.

A comparison on the glass always does. A link that is not yet authenticated does only after the owner said yes to it, and only for kAcceptedPairingHoldMs from that answer: a central that connects and never asks (or whose pairing stalls) does not keep the window, and the radio with it, open past the page's timeout.

Parameters
NameDirectionMeaning
promptPendinginA numeric comparison waits for the owner.
linkPairinginA link is up and not yet authenticated (or a prompt is pending).
acceptedinThe last comparison answered on the page was a yes.
sinceAnswerMsinSince that answer.
Returns
true while the pairing holds the page.

pairPromptOutcome() #

PairPromptOutcome kleidos::states::pairwin::pairPromptOutcome(::kleidos::ui::popup::ConfirmResult closed, AnswerElsewhere elsewhere)
constexpr

What a closed pairing prompt means, from how its dialog closed.

A yes on the glass pairs and anything else the owner did there refuses, a dialog left to lapse included; the prompt passes either to the stack, for the request it showed and no other. A dialog that closed because that request was no longer pending (ConfirmResult::WITHDRAWN) was answered elsewhere, or ended unanswered: the stack is told nothing more, an answer given elsewhere stands, and a request that ended unanswered (its link went, or a newer request replaced it) reads as withdrawn, which refuses nothing the session still holds: the next request raises its own prompt.

Parameters
NameDirectionMeaning
closedinHow the confirm dialog closed.
elsewhereinThe verdict of the request the dialog showed (ble::Facade::ncVerdictFor), read once it closed.
Returns
The answer that stands, and whether the prompt tells the stack.

promptFor() #

Prompt kleidos::states::boot_recovery::promptFor(bool mountRefused, bool formatFailed, bool legacyLayout, bool needsManualRecovery)
constexpr

Choose the prompt for what the vault's mount reported.

Parameters
NameDirectionMeaning
mountRefusedinVaultStore::mountRefused
formatFailedinVaultStore::formatFailed
legacyLayoutinVaultStore::legacyLayoutDetected
needsManualRecoveryinVaultStore::needsManualRecovery
Returns
The prompt to show.

reportFor() #

Report kleidos::states::blesend::reportFor(Burst burst, Ending ending)
constexpr

The report a session ends with, from its last burst.

Parameters
NameDirectionMeaning
burstinThe burst that ended.
endinginHow it ended.
Returns
What the session says.

restsIn() #

bool kleidos::states::entry_idle::restsIn(AuthUIState state)
constexpr

Whether an entry in state is at rest: nothing on it is in motion.

Parameters
NameDirectionMeaning
stateinThe entry's state (AuthEntryUI::getState).
Return values
ValueMeaning
trueIt waits for input, typed into or not (IDLE, ENTERING), or holds a lockout (LockedOut): an idle timer may run.
falseA hold is filling the dial, a digit just locked, a verify is running or its result is on the glass.

rowLabel() #

constexpr

The label opt shows on surface over a secret of kind.

Parameters
NameDirectionMeaning
optinThe settings row.
surfaceinThe board's entry surface.
kindinThe kind of secret the vault records.
Returns
The row's password label from kSecretRowLabels where namesPassword, else the row's own label.

secretWord() #

i18n::StringId kleidos::states::secret_words::secretWord(SecretWord word, security::pin_policy::SetSurface surface, security::pin_policy::SecretKind kind)
constexpr

The words of word on surface for a secret of kind.

Parameters
NameDirectionMeaning
wordinThe line.
surfaceinThe board's entry surface.
kindinThe kind of secret the vault records.
Returns
The line's password words where namesPassword, else its PIN words.

secretWordsInOrder() #

bool kleidos::states::secret_words::secretWordsInOrder()
consteval

Whether every entry of kSecretWords stands at its line's index.

Returns
True when the table lists the lines in the order of SecretWord.

textOf() #

PromptText kleidos::states::boot_recovery::textOf(Prompt prompt)
constexpr

The title and body of prompt.

Parameters
NameDirectionMeaning
promptinA prompt other than Prompt::None, which shows nothing.
Returns
The strings to show.

waitMs() #

uint32_t kleidos::states::idle_wait::waitMs(const Inputs & in)
constexpr

Whether the loop may wait out an idle stretch now, and how long.

Parameters
NameDirectionMeaning
ininWhat the loop read this tick.
Returns
0 to keep the active cadence; otherwise the longest idle wait, ms.

Back to the top

Variable Documentation

kAcceptedPairingHoldMs #

uint32_t kleidos::states::pairwin::kAcceptedPairingHoldMs
inlineconstexpr

How long a comparison the owner accepted on the add-host page holds the page while its keys land: the stack's own pairing timer.

kAddHostPairTimeoutMs #

uint32_t kleidos::states::pairwin::kAddHostPairTimeoutMs
inlineconstexpr

How long Settings' add-host page waits with nothing paired: longer than setup's, since the owner may walk to a second computer to pair it.

kDarkWaitMs #

uint32_t kleidos::states::idle_wait::kDarkWaitMs
inlineconstexpr

Longest idle wait while the panel is asleep, ms. Also the longest a polled input (a power key the PMIC latches) waits to be read.

kIdleCpuMhz #

uint32_t kleidos::states::unlock::kIdleCpuMhz
inlineconstexpr

Core clock the auth screen idles at under the boost policy: the base clock of the boards. A lock face, a digit dial and a keyboard panel are all input-bound, so the base is enough and it is the frequency the device wakes into.

kLockedRereadMs #

uint32_t kleidos::states::lockout_read::kLockedRereadMs
inlineconstexpr

How often a surface reads the guard while a lock holds, in milliseconds.

Twice per second of the countdown a color panel shows, so the seconds on the glass never skip one and a lock is released within half a second of running out; and longer than the cue a wrong secret plays (two 100 ms tones behind a lead-in), so the read that follows the one made as the lock was armed does not land on it.

kNoPendingTotp #

uint16_t kleidos::states::bletype::kNoPendingTotp
inlineconstexpr

The staged follow-up id that means "no one-time code is pending".

What is staged is a credential SLOT id, and slot 0 is the first slot a fresh vault allocates (CredentialRepository::findFreeSlot hands out the lowest absent id), so 0 cannot also mean "nothing pending": under that reading the first credential a device ever stores is the one credential whose code is never offered after its pair is typed. The not-a-slot value of every board is what every surface that stages, clears or consumes the follow-up writes.

kPairDwellMs #

uint32_t kleidos::states::pairwin::kPairDwellMs
inlineconstexpr

How long a pairing page stays once its host is linked, before it moves on by itself. What it shows during that dwell is the page's own business: the button and touch pages raise a "Paired" toast, the keyboard setup flips its link chip to "Connected" and beeps.

kScreenDimPermille #

uint32_t kleidos::states::settings::kScreenDimPermille
constexpr

Fraction of the screen-off window at which the display starts dimming.

The screen dims in the final 15 % of its time, so the dim threshold is 85 % of the screen-off timeout: derived, never a separate setting.

kSecretRowLabels #

std::array<SecretRowLabel, 1> kleidos::states::secret_words::kSecretRowLabels
inlineconstexpr

Every settings row whose label names the unlock secret; each one's own label (SettingsOption::label) carries its PIN words.

kSetupPairTimeoutMs #

uint32_t kleidos::states::pairwin::kSetupPairTimeoutMs
inlineconstexpr

How long setup's pairing page waits with nothing paired, where it gives up on its own.

kTimerNeverMs #

uint32_t kleidos::states::settings::kTimerNeverMs
inlineconstexpr

Idle-timer sentinel meaning "this timer never fires".

The debug stay-awake paths of the console (and the build option that disables auto-lock) park the screen-off timer, the dim time derived from it and the deep-sleep timer here; nothing parks auto-lock. Anything that PRESENTS a timer must recognize the sentinel (dividing it into seconds prints a meaningless 4294967s), and anything that POLLS one goes through idleTimerElapsed, which never fires it.

Back to the top