BaseConnectableDeviceStateRepo

A HotStateFlowRepo to manage the ConnectableDeviceState of a Device

Parameters

initialState

gets the initial ConnectableDeviceState when observation starts

coroutineContext

the CoroutineContext of this repo

Inheritors

Constructors

Link copied to clipboard
constructor(initialState: () -> ConnectableDeviceState, 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

Gets the (Flow of) BaseAdvertisementData from a Flow of Device

Link copied to clipboard

Gets a (Flow of) the list Characteristic associated with the Service in a Flow

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

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

Link copied to clipboard

Gets a (Flow of) the list Descriptor associated with the Characteristic in a Flow

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

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

Link copied to clipboard
fun Flow<Device?>.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 Device. To get a more stable result, this method will average the distance over the last averageOver results.

Link copied to clipboard

Gets a (Flow of) AttributeType of a given UUID from a Flow of a list of AttributeType

@JvmName(name = "getService")
operator fun Flow<List<Service>>.get(uuid: UUID): Flow<Service?>

Gets a (Flow of) Service of a given UUID from a Flow of a list of Service

operator fun Flow<List<Device>>.get(identifier: Identifier): Flow<Device?>

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

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

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

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<Device?>.mtu(): Flow<MTU?>

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

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

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

Link copied to clipboard
Link copied to clipboard
suspend fun Flow<Device?>.requestMtu(mtu: MTU): Boolean

Attempts to request a MTU size for the Device from a Flow of Device When this method completes, the devices should have had ConnectableDeviceState.Connected.requestMtu called

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

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

Link copied to clipboard
fun Flow<Device?>.services(): Flow<List<Service>>

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

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

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

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<Device?>.unpair()

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

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

Attempts to request an update to the RSSI of the Device from a Flow of Device 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