ConnectedMockClient

A mock Bluetooth device that has been connected and had its services discovered, ready to route reads and writes.

Obtain one with connectedMockClient. The device is exposed through client so the generated SharedDeviceClient.bluetooth(client, identifier) factory can look it up by identifier.

The device stays connected for the lifetime of this object: its connection state repo and a background collection of its discoveredServices() run on a dedicated child scope that keeps the device connected so reads and writes route. Call close (e.g. in a finally) when done; otherwise structured concurrency will wait forever on those background coroutines.

Properties

Link copied to clipboard

The MockBluetoothClient exposing the connected device.

Link copied to clipboard

The MockDeviceConnectionManager driving the connected device. Use it (or pump) to complete queued actions.

Link copied to clipboard

The Identifier of the connected device.

Link copied to clipboard

The discovered RemoteServices of the connected device.

Functions

Link copied to clipboard

Returns the MockCharacteristicWrapper for the characteristic with the given characteristic uuid on the service with the given service uuid. Use it to set the value a read will return or to inspect what a write recorded.

Link copied to clipboard
fun close()

Cancels the background coroutines that keep the device connected. Always call this when done with the client.

Link copied to clipboard
suspend fun pump()

Pumps the currently queued com.splendo.kaluga.bluetooth.device.DeviceAction so the enqueued read/write completes. Equivalent to connectionManager.handleCurrentAction().