NodeRepository

Repository interface for managing node-related data.

This component provides access to the mesh's node database, local device information, and mesh-wide statistics. It supports reactive queries for node lists, counts, and filtered/sorted views.

This interface is shared across platforms via Kotlin Multiplatform (KMP).

Properties

Link copied to clipboard
abstract val localStats: StateFlow<LocalStats>

Reactive flow of the latest local stats telemetry received from the radio.

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

The unique userId (hex string, e.g., "!1234abcd") of our local node.

Link copied to clipboard
abstract val myNodeInfo: StateFlow<MyNodeInfo?>

Reactive flow of hardware info about our local radio device.

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

A reactive map of all known nodes in the mesh, keyed by their 32-bit node number.

Link copied to clipboard
abstract val onlineNodeCount: Flow<Int>

Flow emitting the count of nodes currently considered "online" (heard from recently).

Link copied to clipboard
abstract val ourNodeInfo: StateFlow<Node?>

Reactive flow of information about the locally connected node as seen by the mesh.

Link copied to clipboard
abstract val totalNodeCount: Flow<Int>

Flow emitting the total number of nodes in the database.

Functions

Link copied to clipboard
abstract suspend fun clearMyNodeInfo()

Clears the local node's connection info from the cache.

Link copied to clipboard
abstract suspend fun clearNodeDB(preserveFavorites: Boolean = false)

Deletes all nodes from the database.

Link copied to clipboard
abstract suspend fun deleteNode(num: Int)

Deletes a specific node by its node number.

Link copied to clipboard
abstract suspend fun deleteNodes(nodeNums: List<Int>)

Deletes multiple nodes by their node numbers.

Link copied to clipboard
abstract fun effectiveLogNodeId(nodeNum: Int): Flow<Int>

Returns the node number used for log queries.

Link copied to clipboard
abstract fun getNode(userId: String): Node

Returns the Node associated with a given userId.

Link copied to clipboard
abstract fun getNodes(sort: NodeSortOption = NodeSortOption.LAST_HEARD, filter: String = "", includeUnknown: Boolean = true, onlyOnline: Boolean = false, onlyDirect: Boolean = false): Flow<List<Node>>

Returns a reactive flow of nodes filtered and sorted according to the parameters.

Link copied to clipboard
abstract suspend fun getNodesOlderThan(lastHeard: Int): List<Node>

Returns all nodes that haven't been heard from since the given timestamp.

Link copied to clipboard
abstract suspend fun getUnknownNodes(): List<Node>

Returns all nodes with unknown hardware models.

Link copied to clipboard
abstract fun getUser(nodeNum: Int): User

Returns the User info for a given nodeNum.

abstract fun getUser(userId: String): User

Returns the User info for a given userId.

Link copied to clipboard
abstract suspend fun insertMetadata(nodeNum: Int, metadata: DeviceMetadata)

Persists hardware metadata for a node.

Link copied to clipboard
abstract suspend fun installConfig(mi: MyNodeInfo, nodes: List<Node>)

Installs initial configuration data (local info and remote nodes) into the database.

Link copied to clipboard
abstract suspend fun setNodeNotes(num: Int, notes: String)

Updates the personal notes for a node.

Link copied to clipboard
abstract fun updateLocalStats(stats: LocalStats)

Updates the cached local stats telemetry.

Link copied to clipboard
abstract suspend fun upsert(node: Node)

Upserts a Node into the persistent database.