|
|
@@ -468,17 +468,28 @@ object BusinessManager {
|
|
|
fun registerConnectListener(mac: String, callBack: ((Boolean, BleBean?) -> Unit)? = null) {
|
|
|
LogUtil.i("registerConnectListener : $mac")
|
|
|
if (connectListeners.any { it.mac == mac }) {
|
|
|
+ LogUtil.w("Ignore mac : $mac 已存在")
|
|
|
return
|
|
|
}
|
|
|
if (deviceList.none { it.bleDevice.mac == mac }) {
|
|
|
connectListeners.add(ConnectListener(mac, callBack))
|
|
|
- if (connectListeners.size == 1) {
|
|
|
+ if (connectListeners.size > 0) {
|
|
|
Executor.runOnMain {
|
|
|
connectKey()
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- callBack?.invoke(true, deviceList.find { it.bleDevice.mac == mac })
|
|
|
+ val bean = deviceList.find { it.bleDevice.mac == mac }
|
|
|
+ if (bean?.token == null) {
|
|
|
+ connectListeners.add(ConnectListener(mac, callBack))
|
|
|
+ if (connectListeners.size > 0) {
|
|
|
+ Executor.runOnMain {
|
|
|
+ connectKey()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ callBack?.invoke(true, bean)
|
|
|
}
|
|
|
}
|
|
|
|