MeshStateStore

interface MeshStateStore

Persistence SPI for BLE Mesh network state.

Mesh network state (sequence numbers, IV Index, keys) MUST survive application restarts. Loss of sequence numbers means permanent exclusion from the mesh network due to replay protection.

Implement this interface with your platform's secure storage:

  • Android: DataStore, SharedPreferences, or EncryptedSharedPreferences

  • iOS: Keychain or UserDefaults

  • JVM: File-based storage

For testing, use InMemoryMeshStateStore.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun clearAll(): Result<Unit>

Clear all persisted mesh state.

Link copied to clipboard
abstract suspend fun loadNetworkState(): Result<MeshNetworkState?>

Load the last saved network state.

Link copied to clipboard
abstract suspend fun saveNetworkState(state: MeshNetworkState): Result<Unit>

Atomically save the complete network state.