NodeManager

Interface for managing the in-memory node database and processing received node information.

Properties

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

Whether node database writes are allowed.

Link copied to clipboard
abstract val connectionIdentity: StateFlow<ConnectionIdentity?>

Fresh-handshake identity for the current connection session. Null when no handshake identity has been confirmed for the active transport. Cleared synchronously before a new address is published, and populated atomically when handleMyInfo captures the selected address and decodes nodeNum and deviceId from the same MyNodeInfo packet. Generation-boundary cleanup atomically preserves an identity already published for the new session. Never populated by loadCachedNodeDB or reactive DB cache emissions.

Link copied to clipboard
abstract val firmwareEdition: StateFlow<FirmwareEdition?>

The firmware edition reported by the connected device.

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

Whether the node database is ready.

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

The connected device's factory-burned hardware id from MyNodeInfo, as a thread-safe StateFlow. Null when not connected or when the hardware/firmware doesn't report one. Unlike myNodeNum (which firmware 2.8 re-derives from the public key), this survives upgrades, erases, and key changes.

Link copied to clipboard
abstract val myNodeNum: StateFlow<Int?>

The local node number as a thread-safe StateFlow.

Link copied to clipboard
abstract val nodeDBbyNodeNum: Map<Int, Node>

Reactive map of all nodes by their number.

Functions

Link copied to clipboard
abstract fun applyTrustedIdentityMigrations(removedNums: Collection<Int>)

Applies node-number removals returned by the trusted configuration install. Removed numbers stay retired for the current device/database session so delayed field packets cannot recreate migrated identities.

Link copied to clipboard
abstract fun clear()

Clears the in-memory node database.

Link copied to clipboard

Clears the connection-session identity source synchronously.

Link copied to clipboard
abstract fun clearStaleConnectionIdentity(activeSessionGeneration: Long)

Atomically clears an identity retained from a generation other than activeSessionGeneration. An identity that already belongs to the active generation is preserved, even when its publication races a delayed boundary collector from the same generation.

Link copied to clipboard
abstract fun getMyId(): String

Returns the local node ID.

Link copied to clipboard
abstract fun getMyNodeInfo(): MyNodeInfo?

Returns information about the local node.

Link copied to clipboard
abstract fun getNodeById(id: String): Node?

Look up a node by its user ID string (e.g. "!a1b2c3d4").

Link copied to clipboard
abstract fun handleReceivedNodeStatus(fromNum: Int, s: StatusMessage, session: RadioSessionContext? = null)

Processes a received node status message.

Link copied to clipboard
abstract fun handleReceivedPaxcounter(fromNum: Int, p: Paxcount, session: RadioSessionContext? = null)

Processes a received paxcounter packet.

Link copied to clipboard
abstract fun handleReceivedPosition(fromNum: Int, myNodeNum: Int, p: Position, defaultTime: Long, session: RadioSessionContext? = null)

Processes a received position packet.

Link copied to clipboard
abstract fun handleReceivedTelemetry(fromNum: Int, telemetry: Telemetry)

Processes a received telemetry packet.

Link copied to clipboard
abstract fun handleReceivedUser(fromNum: Int, p: User, channel: Int = 0, manuallyVerified: Boolean = false, session: RadioSessionContext? = null)

Processes a received user packet.

Link copied to clipboard
abstract fun insertMetadata(nodeNum: Int, metadata: DeviceMetadata, session: RadioSessionContext? = null)

Inserts hardware metadata for a node.

Link copied to clipboard
abstract fun installNodeInfo(info: NodeInfo)

Installs node information in memory. Callers that require an immediate standalone write use installNodeInfoAndPersist; configuration handshakes batch the resulting snapshot through the repository.

Link copied to clipboard
abstract suspend fun installNodeInfoAndPersist(info: NodeInfo)

Installs node information and awaits any required persistence.

Link copied to clipboard
abstract fun loadCachedNodeDB()

Loads the cached node database from the repository.

Link copied to clipboard
abstract fun publishConnectionIdentity(sessionGeneration: Long, address: String, nodeNum: Int, deviceId: String?)

Publishes a fresh connection-session identity from a handshake MyNodeInfo. Invoked exactly once per handshake after sessionGeneration, address, nodeNum, and deviceId have been captured for the same session.

Link copied to clipboard
abstract fun removeByNodenum(nodeNum: Int)

Removes a node from the in-memory database by its number.

Link copied to clipboard
abstract fun setAllowNodeDbWrites(allowed: Boolean)

Sets whether node database writes are allowed.

Link copied to clipboard
abstract fun setFirmwareEdition(edition: FirmwareEdition?)

Sets the firmware edition of the connected device.

Link copied to clipboard
abstract fun setMyDeviceId(id: String?)

Sets the connected device's hardware id.

Link copied to clipboard
abstract fun setMyNodeNum(num: Int?)

Sets the local node number.

Link copied to clipboard
abstract fun setNodeDbReady(ready: Boolean)

Sets whether the node database is ready.

Link copied to clipboard
abstract fun toNodeID(nodeNum: Int): String
Link copied to clipboard
abstract fun updateNode(nodeNum: Int, channel: Int = 0, transform: (Node) -> Node)

Updates a node using a side-effect-free transform and schedules persistence. The transform may be evaluated more than once after compare-and-set contention; callers must perform notifications and other effects afterward.

Link copied to clipboard
abstract suspend fun updateNodeAndPersist(nodeNum: Int, channel: Int = 0, transform: (Node) -> Node)

Updates a node using a side-effect-free transform and awaits any required persistence before returning. The transform may be evaluated more than once after compare-and-set contention.

Link copied to clipboard
abstract fun updateNodeForSession(nodeNum: Int, session: RadioSessionContext, channel: Int = 0, transform: (Node) -> Node)

Session-bound counterpart to updateNode; deferred persistence is admitted only for session.

Link copied to clipboard
abstract fun updateNodeStatus(nodeNum: Int, status: String?)

Updates the status string for a node.

Link copied to clipboard
abstract suspend fun updateNodeStatusAndPersist(nodeNum: Int, status: String?)

Updates node status and awaits any required persistence.