Skip to main content

Module state_machine

Module state_machine 

Source
Expand description

Token operating state machine.

The token transitions between a small set of named states based on external events: USB boot complete, PIN verified, sign request received, touch detected, timer elapsed, error reported. Each state has an associated LED pattern that drives the visual indicator at the right cadence.

The state machine is pure logic. It consumes events and returns the new state plus the new LED pattern. It does not perform I/O. The firmware’s main task drives the I/O around it (sampling the button, toggling the LEDs, waking on timeouts). This separation makes the machine fully testable in a host context.

Enums§

Event
Events that drive transitions.
LedPattern
Visual LED pattern associated with each state.
TokenState
All the operating states the token can be in.

Constants§

ERROR_DISPLAY_MS
How long the token displays the error pattern before returning to idle.
TOUCH_TIMEOUT_MS
How long the user has to touch the button before the signing request is cancelled.