In development. It changes without notice.
Topic
BLE Types
The values every part of Bluetooth speaks: the keyboard layouts, the commands and events, the state of a session and of the stack, and the record of a host.
There are seven keyboard layouts: US, Spanish, UK, French, German, Portuguese and Italian (kleidos::
Files | |
| file | src/ |
| POD command envelope posted from FSM/UI/web to the BLE stack task. | |
| file | src/ |
| POD event payloads published by the BLE stack task to subscribers. | |
| file | src/ |
| Per-layout ASCII-to-HID-scancode tables for BLE HID typing. | |
| file | src/ |
| Stable on-flash record for the BLE host-name store. | |
| file | src/ |
| The HID session's runtime state and the rules every layer reads it by. | |
| file | src/ |
| The BLE stack's public lifecycle state, as the screens read it. | |
Namespaces | |
| namespace | kleidos:: |
| The rules the session state is read by: its public state, whether it takes a burst, and the state a burst leaves it in. | |
Classes | |
| struct | kleidos:: |
Typed command envelope posted to BleCommandQueue (≤ 64 B by contract). More about kleidos:: | |
| struct | kleidos:: |
Typed event envelope published on ble::. More about kleidos:: | |
| struct | kleidos:: |
| One ASCII glyph expressed as a HID scancode plus modifier flags. More about kleidos:: | |
| struct | kleidos:: |
| Packed 44-byte persisted host-name record. More about kleidos:: | |
| struct | kleidos:: |
| How long an advertising session waits for a host. More about kleidos:: | |
Typedefs | |
| using | kleidos:: |
| Subscriber callback for BleEvent values (heap-free, fixed size), the argument of kleidos:: | |
| using | kleidos:: |
| Event-subscription handle; 0 = invalid. | |
Functions | |
| constexpr StackState | kleidos:: |
| The state the screens are told the session is in. | |
| constexpr bool | kleidos:: |
Whether a new burst of key reports may start in s. | |
| constexpr BleState | kleidos:: |
The state a burst that ended with r leaves the session in. | |
| constexpr bool | kleidos:: |
Whether the radio advertises in s once a link has ended. | |
| constexpr HostAsk | kleidos:: |
| What an advertising session waits on, from what the link reads now. | |
| constexpr bool | kleidos:: |
| Whether the window of what the session waits on starts on this poll. | |
| constexpr AskWindow | kleidos:: |
| The window an ask is judged on. | |
| constexpr bool | kleidos:: |
| Whether an authenticated link ends an allowed re-pair. | |
| constexpr bool | kleidos:: |
| Whether an advertising session has waited for a host as long as it may. | |
Variables | |
| constexpr uint8_t | kleidos:: |
| const std::array< LayoutEntry, 128 > | kleidos:: |
| Spanish (Spain) table. | |
| const std::array< LayoutEntry, 128 > | kleidos:: |
| United Kingdom table. | |
| const std::array< LayoutEntry, 128 > | kleidos:: |
| French (France) table. | |
| const std::array< LayoutEntry, 128 > | kleidos:: |
| German (Germany) table. | |
| const std::array< LayoutEntry, 128 > | kleidos:: |
| Portuguese table. | |
| const std::array< LayoutEntry, 128 > | kleidos:: |
| Italian table. | |
| constexpr uint8_t | kleidos:: |
| Bond-table capacity. | |
| constexpr uint8_t | kleidos:: |
| Current on-flash record version. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr uint16_t | kleidos:: |
| Host-name buffer size (incl. NUL). | |
Typedef Documentation
EventHandler #
Subscriber callback for BleEvent values (heap-free, fixed size), the argument of kleidos::
Shared by kleidos::
SubscriptionId #
Event-subscription handle; 0 = invalid.
Shared by kleidos::
Enumeration Type Documentation
AskWindow #
BleState #
Observable lifecycle state of the NimBLE HID session.
| State | Entered from | Trigger | Exits to |
|---|---|---|---|
OFF | (initial) | Boot, full deinit | ADVERTISING |
ADVERTISING | OFF | begin() / disconnect | CONNECTED, ERROR |
CONNECTED | ADVERTISING / TYPING | Host paired + authenticated, or a burst landed | TYPING, ADVERTISING |
TYPING | CONNECTED | typeCredential() | CONNECTED, ERROR |
ERROR | ADVERTISING / TYPING | Init / connection / link error | OFF (via end()) |
A host that is pairing keeps the session in ADVERTISING (the screens read it as AUTHENTICATING, kleidos::
A burst that lands leaves the link as it found it, ready for the next one: the 2FA code the device offers after the login is a second burst of the same session.
BleTypingResult #
CommandKind #
Discriminator for the BleCommand union payload.
| Enumerator | |
|---|---|
| Start | Begin advertising in the requested |
| Stop | Tear the radio down gracefully. |
| AcceptNc | Accept the Numeric Comparison request |
| RejectNc | Reject the Numeric Comparison request |
| BeginTyping | Type a staged credential/ |
| CancelTyping | Abort the in-flight typing operation. |
| SetTargetHost | Select the active bonded host slot. |
| RemoveBond | Remove a bonded host by slot. |
| RenameBond | Rename a bonded host by slot. |
| ResolveEviction | Resolve the full-table bond-eviction prompt. |
| ApproveRepair | Delete the re-pairing host's bond and drop its link (an Allow). |
| Settle | Run nothing; acknowledged once the state is published. |
EventKind #
Discriminator for the BleEvent union payload.
HostAsk #
What an advertising session waits on once a host has asked something of it.
KbLayout #
StackState #
Observable lifecycle state of the BLE stack.
The table below documents the public transitions published by ble:: via ble::. Terminal ERROR transitions clear the radio through stop() before the next start() may be issued.
| From | Allowed next states | Trigger |
|---|---|---|
OFF | STARTING | Facade:: accepted |
STARTING | ADVERTISING, ERROR | NimBLE init success / failure |
ADVERTISING | AUTHENTICATING, CONNECTED, ERROR | NC raised / bonded host reconnects / timeout |
AUTHENTICATING | CONNECTED, ADVERTISING, ERROR | Keys land / NC refused, pairing failed, host left / timeout |
CONNECTED | TYPING, ADVERTISING, OFF | Credential selected / link drop |
TYPING | CONNECTED, OFF, ERROR | Reports flushed / link drop |
STOPPING | OFF | nimble_ done |
ERROR | STARTING | Facade:: retry |
TypingEventStatus #
Status code packed inside TypingFinished / TypingFailed events.
| Enumerator | |
|---|---|
| Success | Credential typed without error. |
| Disconnected | Host disconnected mid-typing. |
| NotConnected | Link was not connected at start. |
| Cancelled | Caller cancelled the operation. |
| Timeout | Host stopped acknowledging reports. |
| Unsupported | Codepoint not typeable on the active layout. |
| Error | Generic failure. |
UnstoredPairing #
What a pairing the owner confirmed left when the keystore did not keep its keys (Facade::).
Function Documentation
acceptsBurst() #
Whether a new burst of key reports may start in s.
The link must also be up and authenticated; this is the state's half of that rule.
- Parameters
-
Name Direction Meaning s in Runtime session state.
- Return values
-
Value Meaning true A burst may start. false The session is not ready for one.
advertisesAfterLink() #
Whether the radio advertises in s once a link has ended.
A failed session (ERROR) is quiet: no host can reach it until its owner, who reads the failure, stops the stack or advertises again on purpose (BleHidManager::). A stack that is down (OFF) has no advertising to resume. Every other state takes the next host.
- Parameters
-
Name Direction Meaning s in Runtime session state.
- Return values
-
Value Meaning true Advertising resumes after the link ends. false The radio stays quiet.
afterBurst() #
The state a burst that ended with r leaves the session in.
- Parameters
-
Name Direction Meaning r in How the burst ended.
- Returns
- The runtime state to store.
askWindow() #
The window an ask is judged on.
A re-pair prompt and a comparison are asked by the live link, and each new one gets the link's window afresh. The return of the host whose re-pair the owner allowed is that host's: its window is armed from the first poll after the Allow and kept until the approval ends (that host's fresh pairing, the session's end, the hard stop), so another host's link or comparison in between neither closes nor restarts it.
- Parameters
-
Name Direction Meaning ask in What the session waits on.
- Returns
- Its window.
askWindowStarts() #
Whether the window of what the session waits on starts on this poll.
- Parameters
-
Name Direction Meaning was in What the session waited on at the previous poll. now in What it waits on now.
- Return values
-
Value Meaning true A new ask began: the first poll of a prompt, of the reconnect an Allow awaits, or of a pairing. false Nothing is asked, or the same ask goes on.
hostAsk() #
What an advertising session waits on, from what the link reads now.
A bonded host that asks to pair again is refused until the owner answers the re-pair prompt, and keeps its link up meanwhile: the prompt is a pairing under way as much as the comparison is, and waits on a window of its own, not on what the host window has left. An Allow deletes the host's old bond and drops its link, and the session waits for the host to come back, on a window of its own again; the fresh pairing it starts then (its comparison) runs on a third. Each starts when the session reads it, and the hard stop bounds them all.
- Parameters
-
Name Direction Meaning repairPrompted in A re-pair prompt is armed for the live link. reconnecting in The owner allowed a re-pair whose fresh pairing has not completed yet. pairing in The link reads as pairing.
- Returns
- What the session waits on.
hostWaitLapsed() #
Whether an advertising session has waited for a host as long as it may.
- Parameters
-
Name Direction Meaning budget in The session's windows. advertisingMs in Time since advertising started. pairingMs in Time since the session first read the link as pairing; empty while no pairing is under way.
- Return values
-
Value Meaning true The wait is over: past the hard stop, past the pairing's own window, or, with no pairing under way, past the host window. false The session keeps waiting.
publicState() #
The state the screens are told the session is in.
The session waits in ADVERTISING until a host's link authenticates. A host that is pairing is already on the link by then, and from the numeric comparison it raised until its keys land the screens are told AUTHENTICATING: the owner has been asked about that host, and once the owner says yes the device waits on the host's own confirmation. A host that reconnects with a bond it already holds raises no comparison, so its link goes from ADVERTISING straight to CONNECTED.
- Parameters
-
Name Direction Meaning s in Runtime session state. pairing in A pairing the owner was asked about is under way on the live link: a comparison raised on it, or a re-pair the owner allowed, and the link has not authenticated, failed or been refused since.
- Returns
- Its public
StackState.
repairEndsWithLink() #
Whether an authenticated link ends an allowed re-pair.
The approval, the pairing window it opened and its reconnect window belong to the host that asked: only that host's fresh pairing ends them on a link. A different host connecting, bonded or pairing new, leaves them as they are; the session's end and the hard stop end them whatever links came.
- Parameters
-
Name Direction Meaning approved in The owner allowed a re-pair still awaited. askingHostPaired in The link paired fresh (a comparison on it), and its identity is the one that asked.
- Returns
truewhen the approval is spent.
Variable Documentation
kKbLayoutCount #
Number of KbLayout values. Every layout is below it, so a stored byte at or past it names no layout.
kNameRecordActiveFlag #
flags bit marking an active slot.
kNameRecordPendingUnpairFlag #
flags bit marking a forgotten-but-not-yet-unpaired tombstone. The record keeps the identity address so the deferred NimBLE keystore deletion can run at the next host start-up; the slot is inactive (no kNameRecordActiveFlag) so it never appears as a bonded host.