Kleidos API Search

In development. It changes without notice.

Topic

Notifications

Notices about the battery, the link, the portal, the lock and an update, shown once and not again until the state really changes.

Files

file src/ui/notifications/status_notifier.h
Hysteresis-aware status toasts layered on PopupSystem.

Classes

struct kleidos::ui::notifier::BatteryState
Edge-triggered battery state kept across calls. More about kleidos::ui::notifier::BatteryState
struct kleidos::ui::notifier::HostState
BLE host connection state for edge-detect logic. More about kleidos::ui::notifier::HostState
struct kleidos::ui::notifier::AdminClientState
Admin WiFi client count state for edge-detect logic. More about kleidos::ui::notifier::AdminClientState
struct kleidos::ui::notifier::AdminIdleState
Idle/timeout state for the admin portal warning. More about kleidos::ui::notifier::AdminIdleState
struct kleidos::ui::notifier::AutoLockState
Auto-lock countdown edge state. More about kleidos::ui::notifier::AutoLockState
struct kleidos::ui::notifier::OtaAppliedState
OTA-applied one-shot state. More about kleidos::ui::notifier::OtaAppliedState

Enumerations

enum class kleidos::ui::notifier::Event : uint8_t { kleidos::ui::notifier::Event::NONE, kleidos::ui::notifier::Event::BatteryLow, kleidos::ui::notifier::Event::BatteryCritical, kleidos::ui::notifier::Event::BatteryCharging, kleidos::ui::notifier::Event::BatteryFull, kleidos::ui::notifier::Event::BleHostConnected, kleidos::ui::notifier::Event::BleHostDisconnected, kleidos::ui::notifier::Event::AdminClientConnected, kleidos::ui::notifier::Event::AdminIdleWarning, kleidos::ui::notifier::Event::AdminTimeout, kleidos::ui::notifier::Event::AutoLockCountdown, kleidos::ui::notifier::Event::OtaApplied }
One of the events the notifier can decide to emit. Tests compare against this enum; the runtime wrapper maps each event to a popup::toast() call. More about kleidos::ui::notifier::Event

Functions

Eventkleidos::ui::notifier::decideBattery (BatteryState &st, uint8_t pct, bool isCharging)
Decide which (if any) battery event should be emitted given a new sample.
Eventkleidos::ui::notifier::decideBleHost (HostState &st, bool isConnected)
Decide which (if any) BLE host event to emit on a connection change.
Eventkleidos::ui::notifier::decideAdminClient (AdminClientState &st, uint8_t stationCount)
Decide which (if any) admin-client event to emit.
Eventkleidos::ui::notifier::decideAdminIdle (AdminIdleState &st, uint32_t elapsedMs, uint32_t totalTimeoutMs, uint32_t warnLeadMs)
Fire ADMIN_IDLE_WARNING once when elapsedMs crosses the warn threshold, and ADMIN_TIMEOUT once when it reaches totalTimeoutMs.
Eventkleidos::ui::notifier::decideAutoLock (AutoLockState &st, uint32_t msToSleep, uint32_t windowMs)
Fire AUTO_LOCK_COUNTDOWN once per idle session when remaining sleep time drops below windowMs.
Eventkleidos::ui::notifier::decideOtaApplied (OtaAppliedState &st, bool otaJustApplied)
Emit OTA_APPLIED once if otaJustApplied is true on this boot.
voidkleidos::ui::status_notifier::reset ()
Reset every internal state (call on fresh boot / factory reset).
voidkleidos::ui::status_notifier::notifyBatteryPoll (uint8_t pct, bool isCharging, uint32_t nowMs)
Poll battery at BATT_POLL_MS cadence. Must be called from the main loop.
voidkleidos::ui::status_notifier::notifyBleConnected (bool isConnected)
Called from BleHidManager polling / VaultState BLE watcher.
voidkleidos::ui::status_notifier::notifyAdminClientCount (uint8_t stationCount)
Called from AdminState::update() after AdminPortal::update().
voidkleidos::ui::status_notifier::notifyAdminIdle (uint32_t elapsedMs, uint32_t totalTimeoutMs, uint32_t warnLeadMs)
Called every frame from AdminState::update() with the elapsed time since last activity.
voidkleidos::ui::status_notifier::notifyAutoLockCountdown (uint32_t msToSleep, bool activityJustReset)
Called from the global activity watchdog with milliseconds remaining until deep sleep.
voidkleidos::ui::status_notifier::notifyOtaApplied (bool otaJustApplied, const char *version)
Called once, by the first loop tick that marked a freshly applied OTA image valid (kleidos::app::confirmFirmwareOnFirstTick).

Variables

constexpr uint8_tkleidos::ui::notifier::kBattLowPct
Battery % at which the LOW toast fires (the header gauge turns red later, at 15 %).
constexpr uint8_tkleidos::ui::notifier::kBattLowExitPct
Hysteresis: re-arm low above this.
constexpr uint8_tkleidos::ui::notifier::kNotifyBattCritPct
Battery % at which the notifier's CRITICAL toast fires.
constexpr uint8_tkleidos::ui::notifier::kBattFullPct
Battery % at which the FULL toast fires.
constexpr uint32_tkleidos::ui::notifier::kBattPollMs
constexpr uint32_tkleidos::ui::notifier::kAutoLockWarnLeadMs
How long before deep sleep the auto-lock countdown toast fires, in milliseconds.

Back to the top

Enumeration Type Documentation

Event #

enum class kleidos::ui::notifier::Event : uint8_t

One of the events the notifier can decide to emit. Tests compare against this enum; the runtime wrapper maps each event to a popup::toast() call.

Enumerator
NONE 

No event to emit.

BatteryLow 

Battery dropped to or below kBattLowPct (rising edge).

BatteryCritical 

Battery dropped to or below kNotifyBattCritPct (one-shot per boot).

BatteryCharging 

Charger just connected (rising edge).

BatteryFull 

Battery reached kBattFullPct while charging (one-shot per session).

BleHostConnected 

BLE host connection just established.

BleHostDisconnected 

BLE host connection just lost.

AdminClientConnected 

Admin WiFi station count increased.

AdminIdleWarning 

Admin portal idle has crossed the warn threshold.

AdminTimeout 

Admin portal has reached its full timeout.

AutoLockCountdown 

Auto-lock will fire in under the warn window.

OtaApplied 

New firmware image was just applied at boot.

Back to the top

Function Documentation

decideAdminClient() #

Event kleidos::ui::notifier::decideAdminClient(AdminClientState & st, uint8_t stationCount)

Decide which (if any) admin-client event to emit.

Pure logic; host-testable.

Parameters
NameDirectionMeaning
stin, outPersistent client count state.
stationCountinNumber of currently connected WiFi stations.
Return values
ValueMeaning
Event::AdminClientConnectedStation count just increased.
Event::NONENo event this call.

decideAdminIdle() #

Event kleidos::ui::notifier::decideAdminIdle(AdminIdleState & st, uint32_t elapsedMs, uint32_t totalTimeoutMs, uint32_t warnLeadMs)

Fire ADMIN_IDLE_WARNING once when elapsedMs crosses the warn threshold, and ADMIN_TIMEOUT once when it reaches totalTimeoutMs.

Pure logic; host-testable. Activity reset (elapsedMs == 0) re-arms both events and returns NONE.

Parameters
NameDirectionMeaning
stin, outPersistent idle state.
elapsedMsinElapsed milliseconds since last client activity.
totalTimeoutMsinTotal portal timeout in milliseconds (e.g. 300000).
warnLeadMsinWarning lead time in milliseconds (e.g. 30000).
Return values
ValueMeaning
Event::AdminIdleWarningElapsed reached totalTimeoutMs - warnLeadMs.
Event::AdminTimeoutElapsed reached totalTimeoutMs.
Event::NONENo event this call.

decideAutoLock() #

Event kleidos::ui::notifier::decideAutoLock(AutoLockState & st, uint32_t msToSleep, uint32_t windowMs)

Fire AUTO_LOCK_COUNTDOWN once per idle session when remaining sleep time drops below windowMs.

Pure logic; host-testable. Re-arms when msToSleep rises above windowMs.

Parameters
NameDirectionMeaning
stin, outPersistent auto-lock state.
msToSleepinMilliseconds remaining until deep sleep.
windowMsinWarning window in milliseconds (e.g. 5000).
Return values
ValueMeaning
Event::AutoLockCountdownmsToSleep just dropped below windowMs.
Event::NONENo event this call.

decideBattery() #

Event kleidos::ui::notifier::decideBattery(BatteryState & st, uint8_t pct, bool isCharging)

Decide which (if any) battery event should be emitted given a new sample.

Never returns more than one event per call. Pure logic; host-testable.

Parameters
NameDirectionMeaning
stin, outPersistent battery state (updated in place).
pctinCurrent battery percentage (0..100).
isCharginginTrue if the charger is connected.
Return values
ValueMeaning
Event::BatteryLowBattery dipped to kBattLowPct (rising edge).
Event::BatteryCriticalBattery hit kNotifyBattCritPct (one-shot per boot).
Event::BatteryChargingCharger just connected (rising edge).
Event::BatteryFullBattery reached kBattFullPct while charging.
Event::NONENo event this call.

decideBleHost() #

Event kleidos::ui::notifier::decideBleHost(HostState & st, bool isConnected)

Decide which (if any) BLE host event to emit on a connection change.

Pure logic; host-testable.

Parameters
NameDirectionMeaning
stin, outPersistent host connection state.
isConnectedinTrue if a BLE host is currently connected.
Return values
ValueMeaning
Event::BleHostConnectedConnection just established (rising edge).
Event::BleHostDisconnectedConnection just lost (falling edge).
Event::NONENo event this call.

decideOtaApplied() #

Event kleidos::ui::notifier::decideOtaApplied(OtaAppliedState & st, bool otaJustApplied)

Emit OTA_APPLIED once if otaJustApplied is true on this boot.

Pure logic; host-testable.

Parameters
NameDirectionMeaning
stin, outPersistent OTA-applied state.
otaJustAppliedinTrue if a new firmware was just applied.
Return values
ValueMeaning
Event::OtaAppliedFirst call with otaJustApplied == true.
Event::NONEAlready fired or otaJustApplied is false.

notifyAdminClientCount() #

void kleidos::ui::status_notifier::notifyAdminClientCount(uint8_t stationCount)

Called from AdminState::update() after AdminPortal::update().

Parameters
NameDirectionMeaning
stationCountinNumber of currently connected WiFi stations.

notifyAdminIdle() #

void kleidos::ui::status_notifier::notifyAdminIdle(uint32_t elapsedMs, uint32_t totalTimeoutMs, uint32_t warnLeadMs)

Called every frame from AdminState::update() with the elapsed time since last activity.

Parameters
NameDirectionMeaning
elapsedMsinElapsed milliseconds since last client activity (0 to re-arm).
totalTimeoutMsinTotal admin portal timeout in milliseconds.
warnLeadMsinWarning lead time in milliseconds.

notifyAutoLockCountdown() #

void kleidos::ui::status_notifier::notifyAutoLockCountdown(uint32_t msToSleep, bool activityJustReset)

Called from the global activity watchdog with milliseconds remaining until deep sleep.

Parameters
NameDirectionMeaning
msToSleepinMilliseconds remaining until deep sleep.
activityJustResetinTrue to re-arm the countdown toast.

notifyBatteryPoll() #

void kleidos::ui::status_notifier::notifyBatteryPoll(uint8_t pct, bool isCharging, uint32_t nowMs)

Poll battery at BATT_POLL_MS cadence. Must be called from the main loop.

Parameters
NameDirectionMeaning
pctinCurrent battery percentage.
isCharginginTrue if charger is connected.
nowMsinCurrent monotonic time in milliseconds.

notifyBleConnected() #

void kleidos::ui::status_notifier::notifyBleConnected(bool isConnected)

Called from BleHidManager polling / VaultState BLE watcher.

Parameters
NameDirectionMeaning
isConnectedinTrue when a BLE host is connected.

notifyOtaApplied() #

void kleidos::ui::status_notifier::notifyOtaApplied(bool otaJustApplied, const char * version)

Called once, by the first loop tick that marked a freshly applied OTA image valid (kleidos::app::confirmFirmwareOnFirstTick).

Parameters
NameDirectionMeaning
otaJustAppliedinTrue if a new firmware was just applied.
versioninVersion string to include in the toast.

Back to the top

Variable Documentation

kBattPollMs #

uint32_t kleidos::ui::notifier::kBattPollMs
constexpr

Battery polling interval in milliseconds.

Back to the top