NymeaWifiService

class NymeaWifiService(scanner: BleScanner, connectionFactory: BleConnectionFactory, dispatcher: CoroutineDispatcher)(source)

GATT client for the nymea-networkmanager WiFi provisioning profile.

Responsibilities:

  • Scan for a device advertising WIRELESS_SERVICE_UUID.

  • Connect and subscribe to the Commander Response characteristic.

  • Send JSON commands (chunked into ≤20-byte BLE packets) via the Wireless Commander characteristic.

  • Reassemble newline-terminated JSON responses from notification packets.

  • Parse the nymea JSON protocol into typed Kotlin results.

Lifecycle: create once per provisioning session, call connect, use scanNetworks / provision, then close.

Constructors

Link copied to clipboard
constructor(scanner: BleScanner, connectionFactory: BleConnectionFactory, dispatcher: CoroutineDispatcher)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun cancel()

Synchronous teardown — cancels the service scope (and its child BLE connection) without suspending.

Link copied to clipboard
suspend fun close()

Disconnect and cancel the service scope.

Link copied to clipboard
suspend fun connect(address: String? = null): Result<String>

Scan for a device advertising the nymea wireless service and connect to it.

Link copied to clipboard
suspend fun provision(ssid: String, password: String, hidden: Boolean = false): ProvisionResult

Provision the device with the given WiFi credentials.

Link copied to clipboard

Trigger a fresh WiFi scan on the device, then return the list of visible networks.