MeshNetwork
A BLE Mesh network.
MeshNetwork is the central entry point for BLE Mesh operations. It manages the network state (keys, nodes, IV Index), provides connectivity via GATT Proxy, and enables sending and receiving mesh messages.
Lifecycle
Created via MeshNetwork factory function with a builder DSL.
connectProxy establishes mesh connectivity through a proxy node.
send transmits mesh messages to any address on the network.
close disconnects the proxy and releases all resources.
Usage
val network = MeshNetwork {
networkKey(myNetKey)
applicationKey(myAppKey)
element(MeshElement(0, UnicastAddress(0x0001u), ElementLocation.MAIN,
listOf(MeshModelId.GenericOnOffClient)))
}
network.connectProxy(proxyPeripheral)
network.send(destination, MeshModelId.GenericOnOffServer,
MeshOpcode(0x8202u), byteArrayOf(0x01), myAppKey)
network.close()Inheritors
Properties
Application keys registered in this network.
Client for configuring nodes post-provisioning.
Flow of incoming mesh messages addressed to our models.
Whether we are currently connected to a proxy node.
Network keys registered in this network.
Our unicast address on this mesh network.
Functions
Add an application key to this network.
Add a network key to this network.
Connect to the mesh network via a GATT Proxy node.
Disconnect from the current proxy node.
Find a node by its primary unicast address.
Remove a node from this network.
Send a mesh message to a destination address.
Send a configuration message encrypted with the node's DeviceKey.