SessionManager

Owns per-node remote-administration session state — the session passkey the firmware embeds in every admin response and the timestamp it was last refreshed at.

Replaces the single global passkey atomic that previously lived in CommandSenderImpl, which silently invalidated the session of node A as soon as node B responded with a different key (the multi-remote-admin bug).

Lifecycle:

  • recordSession is called by the admin packet handler whenever an inbound admin response carries a non-empty session_passkey.

  • getPasskey is read on the send path to attach the appropriate per-destination key.

  • clearAll is called on radio teardown to prevent stale keys from surviving a reconnect.

Properties

Link copied to clipboard
abstract val sessionRefreshFlow: SharedFlow<Int>

Hot stream of srcNodeNum values, emitted exactly once per call to recordSession with a non-empty passkey. Used by EnsureRemoteAdminSessionUseCase to await a session refresh from a specific node without polling.

Functions

Link copied to clipboard
abstract fun clearAll()

Clears all per-node session state. Call on radio disconnect / teardown.

Link copied to clipboard
abstract fun getPasskey(destNum: Int): ByteString

Returns the most recently observed passkey for destNum, or ByteString.EMPTY if none.

Link copied to clipboard
abstract fun observeSessionStatus(destNum: Int): Flow<SessionStatus>

Cold per-node SessionStatus flow. Emits the current status synchronously on subscription and re-emits whenever the underlying state crosses the staleness threshold.

Link copied to clipboard
abstract fun recordSession(srcNodeNum: Int, passkey: ByteString)

Record an inbound session refresh from srcNodeNum. No-op for empty passkey.