WifiProvisionViewModel

class WifiProvisionViewModel(bleScanner: BleScanner, bleConnectionFactory: BleConnectionFactory, dispatchers: CoroutineDispatchers) : ViewModel(source)

ViewModel for the WiFi provisioning flow.

Uses KoinViewModel so the instance is scoped to the navigation entry's ViewModelStoreOwner. A fresh NymeaWifiService (and its own BleConnectionFactory-backed org.meshtastic.core.ble.BleConnection) is created lazily for each provisioning session and cleaned up via onCleared.

Constructors

Link copied to clipboard
constructor(bleScanner: BleScanner, bleConnectionFactory: BleConnectionFactory, dispatchers: CoroutineDispatchers)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Functions

Link copied to clipboard
expect open fun addCloseable(closeable: AutoCloseable)
expect fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
fun connectToDevice(address: String? = null)

Scan for the nearest nymea-networkmanager device and connect to it. Pauses at the WifiProvisionUiState.Phase.DeviceFound phase so the user can confirm before proceeding — this is the Android analog of the web flasher's native BLE pairing dialog.

Link copied to clipboard

Disconnect and close any active BLE connection.

Link copied to clipboard
expect fun <T : AutoCloseable> getCloseable(key: String): T?
Link copied to clipboard
fun provisionWifi(ssid: String, password: String)

Send WiFi credentials to the device.

Link copied to clipboard

Called when the user confirms they want to scan networks after device discovery.