RadioInterfaceService

The selected radio and its SDK client: device selection, session admission and the per-session SDK clients.

The SDK client owns connecting and reconnecting. This service builds one client per selected device, starts and stops it, nudges it when the environment recovers, and derives ServiceRepository.connectionState from the client's org.meshtastic.sdk.ConnectionState and the installed snapshot, which is what UI and features observe.

Properties

Link copied to clipboard
abstract val activeSession: StateFlow<RadioSessionContext?>

The radio session that still owns lifecycle completion, or null once teardown has joined its scope's work. The session collector's inline handlers can still be finishing then; they are joined when the link closes.

Link copied to clipboard
abstract val connectionError: Flow<String>

Flow of user-facing connection error messages (e.g. a radio that gave its slot to another client).

Link copied to clipboard
abstract val currentDeviceAddressFlow: StateFlow<String?>

Flow of the current device address.

Link copied to clipboard

Whether this build carries the packet capture the replay transport needs. False means selecting a replay address would fall back to the plain mock, so callers offering a replay device must hide it.

Link copied to clipboard
abstract val meshActivity: Flow<MeshActivity>

Flow of radio activity events.

Link copied to clipboard
abstract val mockTransportEnabled: StateFlow<Boolean>

Whether the virtual demo transports may be offered and bound right now.

Link copied to clipboard
abstract val sessionGeneration: StateFlow<Long>

Monotonically increasing generation bumped on every app session, one per SDK session, a reconnect included. Consumers use this to discard state retained from a previous session. Stub implementations expose a constant zero flow.

Link copied to clipboard

The device types supported by this platform's radio interface.

Functions

Link copied to clipboard
open fun adminForSession(session: RadioSessionContext): AdminApi?

Captures the SDK admin API for a single active radio session.

Link copied to clipboard
open fun adminSessionStatus(node: NodeId): Flow<AdminSessionStatus>

Observes per-node admin status across radio session changes.

Link copied to clipboard
open fun clientForSession(session: RadioSessionContext): RadioClient?

Captures the SDK client for a single active radio session, or null once session no longer owns admission.

Link copied to clipboard
abstract fun connect()

Connects the selected radio: starts its client, or asks a client waiting out a reconnect backoff to try now. A client that failed or was disconnected is replaced by a fresh one.

Link copied to clipboard
open suspend fun deliverMqttProxy(message: MqttClientProxyMessage): Boolean

Hands a broker message to the active session's MQTT client proxy; false when no session can take it.

Link copied to clipboard
abstract suspend fun disconnect()

Revokes app session admission and disconnects the selected radio's client after its session work drains. Safe to call with nothing connected. Suspends until teardown completes.

Link copied to clipboard
abstract fun getDeviceAddress(): String?

Returns the current device address.

Link copied to clipboard

Whether session still owns admission; false once teardown starts, while activeSession still holds it.

Link copied to clipboard

Reports one frame received from the radio on meshActivity.

Link copied to clipboard

Reports one packet the app queued for the radio on meshActivity.

Requests that the next Bluetooth connection refreshes Android's GATT service cache before service discovery, after a firmware update that may have changed the radio's service table on the same address. Cleared by disconnect and by selecting a different radio.

Link copied to clipboard

Queues a nodes-only refresh for the admitted SDK session.

Link copied to clipboard
suspend fun RadioSessionAuthority.runInSession(session: RadioSessionContext, block: suspend () -> Unit): Boolean

Runs block as a child of session's scope and returns true, or false when the session is closed or closes first. Teardown cancels block; the caller's cancellation cancels it too. A failure in block reaches the caller.

Link copied to clipboard
open fun sendPaced(session: RadioSessionContext, packet: MeshPacket): PacedMessageHandle?

Submits a mesh packet only while session owns transport admission.

Link copied to clipboard
abstract fun sessionScope(session: RadioSessionContext): CoroutineScope?

The scope session's work runs in while it owns admission, else null. Teardown cancels this scope and joins its children before activeSession clears or a replacement session is admitted; a child that needs to finish (a persistence unit) runs its body under NonCancellable.

Link copied to clipboard
abstract fun setDeviceAddress(deviceAddr: String?): Boolean

Sets the device address to connect to.

Link copied to clipboard
abstract fun toInterfaceAddress(interfaceId: InterfaceId, rest: String): String

Constructs a full radio address for the specific interface type.

Link copied to clipboard
open fun tryLockdown(session: RadioSessionContext, auth: LockdownAuth): Boolean

Queues authentication only while session owns the link.