NodeRepositoryImpl

class NodeRepositoryImpl(processLifecycle: Lifecycle, nodeInfoReadDataSource: NodeInfoReadDataSource, nodeInfoWriteDataSource: NodeInfoWriteDataSource, dispatchers: CoroutineDispatchers, localStatsDataSource: LocalStatsDataSource) : NodeRepository(source)

Repository for managing node-related data, including hardware info, node database, and identity.

Constructors

Link copied to clipboard
constructor(processLifecycle: Lifecycle, nodeInfoReadDataSource: NodeInfoReadDataSource, nodeInfoWriteDataSource: NodeInfoWriteDataSource, dispatchers: CoroutineDispatchers, localStatsDataSource: LocalStatsDataSource)

Properties

Link copied to clipboard
open override val localStats: StateFlow<LocalStats>

The latest local stats telemetry received from the locally connected node.

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

The unique userId (hex string) of our local node.

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

Hardware info about our local device (can be null if not connected).

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

A reactive map from nodeNum to Node objects, representing the entire mesh.

Link copied to clipboard
open override val onlineNodeCount: Flow<Int>

Flow emitting the count of nodes currently considered "online".

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

Information about the locally connected node, as seen from the mesh.

Link copied to clipboard
open override val totalNodeCount: Flow<Int>

Flow emitting the total number of nodes in the database.

Functions

Link copied to clipboard
open suspend override fun clearMyNodeInfo()

Clears the local node's connection info.

Link copied to clipboard
open suspend override fun clearNodeDB(preserveFavorites: Boolean)

Deletes all nodes from the database, optionally preserving favorites.

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

Deletes a node and its metadata by num.

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

Deletes multiple nodes and their metadata.

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

Returns the node number used for log queries. Maps nodeNum to MeshLog.NODE_NUM_LOCAL (0) if it is the locally connected node.

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

Returns the Node associated with a given userId. Falls back to a generic node if not found.

Link copied to clipboard
Link copied to clipboard
open override fun getNodes(sort: NodeSortOption, filter: String, includeUnknown: Boolean, onlyOnline: Boolean, onlyDirect: Boolean): Flow<List<Node>>

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

Link copied to clipboard
open suspend override fun getNodesOlderThan(lastHeard: Int): List<Node>
Link copied to clipboard
open suspend override fun getUnknownNodes(): List<Node>
Link copied to clipboard
open override fun getUser(nodeNum: Int): User

Returns the User info for a given nodeNum.

open override fun getUser(userId: String): User

Returns the User info for a given userId. Falls back to a generic user if not found.

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

Persists hardware metadata for a node.

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

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

Link copied to clipboard
open suspend override fun setNodeNotes(num: Int, notes: String)
Link copied to clipboard
open override fun updateLocalStats(stats: LocalStats)

Update the cached local stats telemetry.

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

Upserts a Node to the database.