EnsureRemoteAdminSessionUseCase

open class EnsureRemoteAdminSessionUseCase(sessionManager: SessionManager, meshActionHandler: MeshActionHandler, serviceRepository: ServiceRepository, serviceScope: CoroutineScope)(source)

Ensures a remote-admin session exists for the target node, dispatching a metadata request and awaiting a refreshed passkey if necessary.

Why this exists: the firmware embeds an 8-byte rotating passkey in every admin response and rejects admin traffic lacking a fresh key (firmware/src/modules/AdminModule.cpp:1460-1481). Before this use case the UI silently tunneled the user into a remote-admin screen that immediately failed if no metadata had been requested first.

Concurrency model:

  • One in-flight ensure per destNum. Concurrent callers dedupe onto the same Deferred so a double-tap doesn't blast two metadata requests at the radio.

  • The refresh-flow subscription is established before the metadata request is dispatched to avoid losing the response on the inherently raceful MutableSharedFlow.

  • The withTimeoutOrNull is a UX deadline only — late responses still update the durable SessionStatus flow that the UI observes, so a "Timeout" outcome here can self-heal in the chip without re-tapping.

Constructors

Link copied to clipboard
constructor(sessionManager: SessionManager, meshActionHandler: MeshActionHandler, serviceRepository: ServiceRepository, serviceScope: CoroutineScope)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open suspend operator fun invoke(destNum: Int): EnsureSessionResult