FakeMeshNetwork

class FakeMeshNetwork(initialNodes: List<MeshNode> = emptyList(), initialNetKeys: List<NetworkKey> = emptyList(), initialAppKeys: List<ApplicationKey> = emptyList()) : MeshNetwork

Fake MeshNetwork for unit testing without hardware.

Provides an in-memory mesh network with controllable state, injected nodes, and recorded sent messages for assertion.

Constructors

Link copied to clipboard
constructor(initialNodes: List<MeshNode> = emptyList(), initialNetKeys: List<NetworkKey> = emptyList(), initialAppKeys: List<ApplicationKey> = emptyList())

Properties

Link copied to clipboard
open override val applicationKeys: List<ApplicationKey>

Application keys registered in this network.

Link copied to clipboard

Client for configuring nodes post-provisioning.

Link copied to clipboard
open override val incomingMessages: Flow<MeshMessage>

Flow of incoming mesh messages addressed to our models.

Link copied to clipboard
open override val isProxyConnected: StateFlow<Boolean>

Whether we are currently connected to a proxy node.

Link copied to clipboard
open override val ivIndex: StateFlow<IvIndex>

Current IV Index of the network.

Link copied to clipboard
open override val networkKeys: List<NetworkKey>

Network keys registered in this network.

Link copied to clipboard
open override val nodes: StateFlow<List<MeshNode>>

All provisioned nodes in this network.

Link copied to clipboard

Our unicast address on this mesh network.

Functions

Link copied to clipboard
open suspend override fun addApplicationKey(key: ApplicationKey)

Add an application key to this network.

Link copied to clipboard
open suspend override fun addNetworkKey(key: NetworkKey)

Add a network key to this network.

Link copied to clipboard
open suspend override fun addNode(node: MeshNode)

Add a provisioned node to this network.

Link copied to clipboard
open override fun close()

Close the network and release all resources.

Link copied to clipboard
open suspend override fun connectProxy(peripheral: Peripheral): ProxyConnection

Connect to the mesh network via a GATT Proxy node.

Link copied to clipboard
open suspend override fun disconnectProxy()

Disconnect from the current proxy node.

Link copied to clipboard
open override fun findNode(address: MeshAddress.UnicastAddress): MeshNode?

Find a node by its primary unicast address.

Link copied to clipboard
Link copied to clipboard
open suspend override fun removeNode(address: MeshAddress.UnicastAddress)

Remove a node from this network.

Link copied to clipboard
open suspend override fun send(destination: MeshAddress, modelId: MeshModelId, opcode: MeshOpcode, payload: ByteArray, appKey: ApplicationKey, acknowledged: Boolean = true, ttl: UByte): MeshMessageResponse?

Send a mesh message to a destination address.

Link copied to clipboard
open suspend override fun sendConfig(destination: MeshAddress, opcode: MeshOpcode, payload: ByteArray, deviceKey: DeviceKey, acknowledged: Boolean = true, ttl: UByte): MeshMessageResponse?

Send a configuration message encrypted with the node's DeviceKey.

Link copied to clipboard
suspend fun simulateIncomingMessage(message: MeshMessage)
Link copied to clipboard
Link copied to clipboard