ScanningStateRepo

class ScanningStateRepo(settingsBuilder: suspend (CoroutineContext) -> BaseScanner.Settings, builder: BaseScanner.Builder, contextForIdentifier: (Identifier) -> CoroutineContext, coroutineContext: CoroutineContext) : ScanningStateImplRepo

A ScanningStateImplRepo using a BaseScanner

Parameters

settingsBuilder

method for creating BaseScanner.Settings

builder

the BaseScanner.Builder for building a BaseScanner

contextForIdentifier

method for creating CoroutineContext given an Identifier

coroutineContext

the CoroutineContext the CoroutineContext used to create a coroutine scope for this state machine

Constructors

Link copied to clipboard
constructor(settingsBuilder: suspend (CoroutineContext) -> BaseScanner.Settings, builder: BaseScanner.Builder, contextForIdentifier: (Identifier) -> CoroutineContext, coroutineContext: CoroutineContext)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val lazyMutableFlow: Lazy<MutableStateFlow<ScanningState>>
Link copied to clipboard
open override val stateFlow: StateFlow<ScanningState>
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<ScanningState>): 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
open suspend override fun firstCollection()
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(): ScanningState
Link copied to clipboard
open suspend override fun laterCollections(): ScanningState
Link copied to clipboard
fun launchTakeAndChangeState(context: CoroutineContext, action: suspend (ScanningState) -> suspend () -> ScanningState): Job
fun <K : ScanningState> launchTakeAndChangeState(context: CoroutineContext, remainIfStateNot: KClass<K>, action: suspend (K) -> suspend () -> ScanningState): Job
Link copied to clipboard
fun <Result> launchUseState(context: CoroutineContext, action: suspend (ScanningState) -> 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 override fun noMoreCollections(): ScanningState
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 takeAndChangeState(action: suspend (ScanningState) -> suspend () -> ScanningState): ScanningState
suspend fun <K : ScanningState> takeAndChangeState(remainIfStateNot: KClass<K>, action: suspend (K) -> suspend () -> ScanningState): ScanningState
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 (ScanningState) -> Result): Result
Link copied to clipboard