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>(emptyList()) val deviceList = _deviceList.asStateFlow() protected val _bleState = MutableStateFlow(-1) val bleState = _bleState.asStateFlow() val bleReadyStateFlow = MutableStateFlow(false) val blePowerState = MutableStateFlow(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() }