ConnectableDeviceStateImplRepo

A BaseConnectableDeviceStateRepo managed by a DeviceConnectionManager

Parameters

defaultReconnectionSettings

the default ConnectionSettings.ReconnectionSettings to use when reconnecting after the device disconnects unexpectedly

connectionManager
coroutineContext

the CoroutineContext of this repo

Constructors

Link copied to clipboard
constructor(defaultReconnectionSettings: ConnectionSettings.ReconnectionSettings, connectionManager: DeviceConnectionManager, coroutineContext: CoroutineContext)

Properties

Link copied to clipboard
Link copied to clipboard
open override val lazyMutableSharedFlow: Lazy<MutableStateFlow<ConnectableDeviceState>>
Link copied to clipboard
open override val stateFlow: StateFlow<ConnectableDeviceState>
Link copied to clipboard
val subscriptionCount: StateFlow<Int>

Functions

Link copied to clipboard
Link copied to clipboard
suspend fun Flow<ConnectableDevice?>.characteristic(serviceUUID: String, characteristicUUID: String): RemoteCharacteristic

Provides access to RemoteCharacteristic by service and characteristic string uuids. The method will suspend if characteristic is not available.

Link copied to clipboard
fun Flow<ConnectableDevice?>.characteristicFlow(serviceUUID: String, characteristicUUID: String): Flow<RemoteCharacteristic>

Provides access to RemoteCharacteristic's flow by service and characteristic string uuids. Only emits after services have been discovered.

Link copied to clipboard
suspend fun Flow<ConnectableDevice?>.characteristicOrNull(serviceUUID: String, characteristicUUID: String): RemoteCharacteristic?

Provides access to RemoteCharacteristic by service and characteristic string uuids or null if not available.

Link copied to clipboard
fun Flow<ConnectableDevice?>.characteristicOrNullFlow(serviceUUID: String, characteristicUUID: String): Flow<RemoteCharacteristic?>

Provides access to RemoteCharacteristic's flow by service and characteristic string uuids. Emits null if the characteristic cannot be found.

Link copied to clipboard

Gets a (Flow of) the list RemoteCharacteristic associated with the RemoteService in a Flow

Link copied to clipboard
open suspend override fun collect(collector: FlowCollector<ConnectableDeviceState>): Nothing
Link copied to clipboard
suspend fun Flow<ConnectableDevice?>.connect(reconnectionSettings: ConnectionSettings.ReconnectionSettings? = null): Boolean

Attempts to connect to the ConnectableDevice from a Flow of ConnectableDevice When this method completes, the devices should be in a ConnectableDeviceState.Connected state

Link copied to clipboard
fun Flow<ConnectableDevice?>.dataFlow(serviceUUID: String, characteristicUUID: String): Flow<ByteArray>

Provides access to device data flow by service and characteristic string uuids. Only emits after services have been discovered.

inline fun <T> Flow<ConnectableDevice?>.dataFlow(serviceUUID: String, characteristicUUID: String, deserializationStrategy: DeserializationStrategy<T>, bluetoothFormat: BluetoothFormat = BluetoothFormat): Flow<T>

Provides access to device data flow T by service and characteristic string uuids. Only emits after services have been discovered.

Link copied to clipboard
fun Flow<ConnectableDevice?>.dataOrEmptyFlow(serviceUUID: String, characteristicUUID: String): Flow<ByteArray>

Provides access to device data flow by service and characteristic string uuids. Emits and empty ByteArray if the service cannot be found.

Link copied to clipboard
inline fun <T> Flow<ConnectableDevice?>.dataOrNullFlow(serviceUUID: String, characteristicUUID: String, deserializationStrategy: DeserializationStrategy<T>, bluetoothFormat: BluetoothFormat = BluetoothFormat): Flow<T?>

Provides access to device data flow T by service and characteristic string uuids. Emits null if the descriptor cannot be found.

Link copied to clipboard
suspend fun Flow<ConnectableDevice?>.descriptor(serviceUUID: String, characteristicUUID: String, descriptorUUID: String): RemoteDescriptor

Provides access to RemoteDescriptor by service, characteristic and descriptor string uuids. The method will suspend if descriptor is not available.

Link copied to clipboard
fun Flow<ConnectableDevice?>.descriptorFlow(serviceUUID: String, characteristicUUID: String, descriptorUUID: String): Flow<RemoteDescriptor>

Provides access to RemoteDescriptor's flow by service, characteristic, and descriptor string uuids. Only emits after services have been discovered.

Link copied to clipboard
fun Flow<ConnectableDevice?>.descriptorOrNullFlow(serviceUUID: String, characteristicUUID: String, descriptorUUID: String): Flow<RemoteDescriptor?>

Provides access to RemoteDescriptor's flow by service, characteristic, and descriptor string uuids. Emits null if the descriptor cannot be found.

Link copied to clipboard

Gets a (Flow of) the list RemoteDescriptor associated with the RemoteCharacteristic in a Flow

Link copied to clipboard
suspend fun Flow<ConnectableDevice?>.disconnect()

Attempts to disconnect to the ConnectableDevice from a Flow of ConnectableDevice When this method completes, the devices should be in a ConnectableDeviceState.Disconnected state

Link copied to clipboard

Gets a (Flow of) the list of Service associated with the ConnectableDevice in a Flow This will automatically discover services if the device is in a ConnectableDeviceState.Connected.NoServices state. This differs from services in that the resulting flow will only emit once services are discovered.

Link copied to clipboard
fun Flow<ConnectableDevice?>.distance(environmentalFactor: Double = 2.0, averageOver: Int = 5): Flow<Double>

Gets the (Flow of) the distance in meters between the scanner and a Flow of ConnectableDevice. To get a more stable result, this method will average the distance over the last averageOver results.

Link copied to clipboard
operator fun Flow<List<ConnectableDevice>>.get(identifier: Identifier): Flow<ConnectableDevice?>

Gets a (Flow of) ConnectableDevice with a given Identifier from a Flow of a list of ConnectableDevice.

Link copied to clipboard

Gets a (Flow of) the list RemoteService that are included with the RemoteService in a Flow

Link copied to clipboard
fun Flow<ConnectableDevice?>.info(): Flow<DeviceInfo>

Gets the (Flow of) DeviceInfo from a Flow of ConnectableDevice

Link copied to clipboard
suspend override fun initialValue(): ConnectableDeviceState
Link copied to clipboard
fun launchTakeAndChangeState(context: CoroutineContext, action: suspend (ConnectableDeviceState) -> suspend () -> ConnectableDeviceState): Job
fun <K : ConnectableDeviceState> launchTakeAndChangeState(context: CoroutineContext, remainIfStateNot: KClass<K>, action: suspend (K) -> suspend () -> ConnectableDeviceState): Job
Link copied to clipboard
fun <Result> launchUseState(context: CoroutineContext, action: suspend (ConnectableDeviceState) -> Result): Job
Link copied to clipboard
fun Flow<ConnectableDevice?>.mtu(): Flow<Int?>

Gets the (Flow of) the MTU from a Flow of ConnectableDevice

Link copied to clipboard
suspend fun Flow<ConnectableDevice?>.pair()

Pairs a (Flow of) ConnectableDevice by waiting for it to become connected and calling [ConnectableDeviceState.Connected.pair]

Link copied to clipboard
Link copied to clipboard

Attempts to request a MTU size for the ConnectableDevice from a Flow of ConnectableDevice

Link copied to clipboard
fun Flow<ConnectableDevice?>.rssi(): Flow<RSSI>

Gets the (Flow of) the RSSI value from a Flow of ConnectableDevice

Link copied to clipboard
suspend fun Flow<ConnectableDevice?>.service(serviceUUID: String): RemoteService

Provides access to RemoteService by service string uuids. The method will suspend until services have been discovered.

Link copied to clipboard
fun Flow<ConnectableDevice?>.serviceFlow(serviceUUID: String): Flow<RemoteService>

Provides access to a RemoteService by service string uuids. Only emits after services have been discovered.

Link copied to clipboard
suspend fun Flow<ConnectableDevice?>.serviceOrNull(serviceUUID: String): RemoteService?

Provides access to RemoteService by service and characteristic string uuids or null if not available.

Link copied to clipboard
fun Flow<ConnectableDevice?>.serviceOrNullFlow(serviceUUID: String): Flow<RemoteService?>

Provides access to a RemoteService by service string uuids. Emits null if the service cannot be found.

Link copied to clipboard

Gets a (Flow of) the list of Service associated with the ConnectableDevice in a Flow This will automatically discover services if the device is in a ConnectableDeviceState.Connected.NoServices state.

Link copied to clipboard
fun Flow<ConnectableDevice?>.state(): Flow<DeviceState>

Gets a (Flow of) DeviceState from a Flow or ConnectableDevice

Link copied to clipboard
suspend fun <K : ConnectableDeviceState> takeAndChangeState(remainIfStateNot: KClass<K>, action: suspend (K) -> suspend () -> ConnectableDeviceState): ConnectableDeviceState
Link copied to clipboard
suspend fun Flow<ConnectableDevice?>.unpair()

Pairs a (Flow of) ConnectableDevice by calling [ConnectableDeviceState.unpair] on the first ConnectableDeviceState

Link copied to clipboard
suspend fun Flow<ConnectableDevice?>.updateRssi()

Attempts to request an update to the RSSI of the ConnectableDevice from a Flow of ConnectableDevice When this method completes, the devices should have had ConnectableDeviceState.Connected.readRssi called

Link copied to clipboard
suspend fun <Result> useState(action: suspend (ConnectableDeviceState) -> Result): Result
Link copied to clipboard

Gets a (Flow of) the ByteArray value from a Flow of an RemoteCharacteristic This method will automatically subscribe/unsubscribe to the RemoteCharacteristic when the Flow is collected

inline fun <T> Flow<RemoteCharacteristic?>.value(bluetoothFormat: BluetoothFormat = BluetoothFormat): Flow<T>
fun <T> Flow<RemoteCharacteristic?>.value(deserializationStrategy: DeserializationStrategy<T>, bluetoothFormat: BluetoothFormat = BluetoothFormat): Flow<T>

Gets a (Flow of) T value from a Flow of an RemoteCharacteristic This method will automatically subscribe/unsubscribe to the RemoteCharacteristic when the Flow is collected

Link copied to clipboard

Gets a (Flow of) the ByteArray value from a Flow of an RemoteCharacteristic or an empty ByteArray if data is unavailable This method will automatically subscribe/unsubscribe to the RemoteCharacteristic when the Flow is collected

Link copied to clipboard
inline fun <T> Flow<RemoteCharacteristic?>.valueOrNull(bluetoothFormat: BluetoothFormat = BluetoothFormat): Flow<T?>

Gets a (Flow of) T value from a Flow of an RemoteCharacteristic This method will automatically subscribe/unsubscribe to the RemoteCharacteristic when the Flow is collected

fun <T> Flow<RemoteCharacteristic?>.valueOrNull(deserializationStrategy: DeserializationStrategy<T>, bluetoothFormat: BluetoothFormat = BluetoothFormat): Flow<T?>

Gets a (Flow of) T value from a Flow of an RemoteCharacteristic or null if data is unavailable This method will automatically subscribe/unsubscribe to the RemoteCharacteristic when the Flow is collected