You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1012 B
30 lines
1012 B
package com.whitefish.ring.device
|
|
|
|
import com.whitefish.ring.bean.ui.Device
|
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
import kotlinx.coroutines.flow.MutableStateFlow
|
|
import kotlinx.coroutines.flow.asSharedFlow
|
|
import kotlinx.coroutines.flow.asStateFlow
|
|
|
|
abstract class IDeviceManager {
|
|
protected val _deviceList = MutableStateFlow<List<Device>>(emptyList())
|
|
val deviceList = _deviceList.asStateFlow()
|
|
protected val _bleState = MutableStateFlow<Int>(-1)
|
|
val bleState = _bleState.asStateFlow()
|
|
val bleReadyStateFlow = MutableStateFlow(false)
|
|
val blePowerState = MutableStateFlow<Boolean>(false) // ios的蓝牙是懒加载的,安卓则无此特性
|
|
|
|
private val bleStateListeners = arrayListOf<(Int) -> Unit>()
|
|
fun bleStateListeners() = bleStateListeners
|
|
|
|
|
|
fun setOnBleStateChange(event: (Int) -> Unit) {
|
|
bleStateListeners.add(event)
|
|
}
|
|
|
|
|
|
abstract fun startScan()
|
|
abstract fun stopScan()
|
|
abstract fun connect(mac: String)
|
|
abstract fun bind()
|
|
}
|