|
@@ -161,7 +161,7 @@ object BleConnectionManager {
|
|
|
currentConnectingMac = null
|
|
currentConnectingMac = null
|
|
|
if (!isDone) {
|
|
if (!isDone) {
|
|
|
// 判断是否仍然待连,防止拿走;移到末尾,防止循环影响
|
|
// 判断是否仍然待连,防止拿走;移到末尾,防止循环影响
|
|
|
- if (checkProcess(listener.mac)) {
|
|
|
|
|
|
|
+ if (checkProcess(listener.mac, false)) {
|
|
|
listener.callBack?.invoke(false, null)
|
|
listener.callBack?.invoke(false, null)
|
|
|
unregisterConnectListener(listener.mac)
|
|
unregisterConnectListener(listener.mac)
|
|
|
}
|
|
}
|
|
@@ -188,7 +188,7 @@ object BleConnectionManager {
|
|
|
isNeedLoading: Boolean = false,
|
|
isNeedLoading: Boolean = false,
|
|
|
prepareDoneCallBack: ((Boolean, BleBean?) -> Unit)?
|
|
prepareDoneCallBack: ((Boolean, BleBean?) -> Unit)?
|
|
|
) {
|
|
) {
|
|
|
- if (!checkProcess(mac)) {
|
|
|
|
|
|
|
+ if (!checkProcess(mac, false)) {
|
|
|
LogUtil.e("蓝牙连接-Prepare is canceled : $mac")
|
|
LogUtil.e("蓝牙连接-Prepare is canceled : $mac")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -206,7 +206,7 @@ object BleConnectionManager {
|
|
|
prepareDoneCallBack: ((Boolean, BleBean?) -> Unit)?
|
|
prepareDoneCallBack: ((Boolean, BleBean?) -> Unit)?
|
|
|
) {
|
|
) {
|
|
|
LogUtil.i("蓝牙连接-doScanBle:$mac")
|
|
LogUtil.i("蓝牙连接-doScanBle:$mac")
|
|
|
- if (!checkProcess(mac)) {
|
|
|
|
|
|
|
+ if (!checkProcess(mac, false)) {
|
|
|
LogUtil.e("蓝牙连接-Prepare is canceled : $mac")
|
|
LogUtil.e("蓝牙连接-Prepare is canceled : $mac")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -272,7 +272,7 @@ object BleConnectionManager {
|
|
|
prepareDoneCallBack: ((Boolean, BleBean?) -> Unit)?
|
|
prepareDoneCallBack: ((Boolean, BleBean?) -> Unit)?
|
|
|
) {
|
|
) {
|
|
|
LogUtil.i("蓝牙连接-doConnect : ${bleDevice.mac}")
|
|
LogUtil.i("蓝牙连接-doConnect : ${bleDevice.mac}")
|
|
|
- if (!checkProcess(bleDevice.mac)) {
|
|
|
|
|
|
|
+ if (!checkProcess(bleDevice.mac, false)) {
|
|
|
LogUtil.e("蓝牙连接-Prepare is canceled : ${bleDevice.mac}")
|
|
LogUtil.e("蓝牙连接-Prepare is canceled : ${bleDevice.mac}")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -328,7 +328,7 @@ object BleConnectionManager {
|
|
|
removeExceptionKey(it.mac)
|
|
removeExceptionKey(it.mac)
|
|
|
// 设置MTU
|
|
// 设置MTU
|
|
|
Executor.delayOnMain(200) {
|
|
Executor.delayOnMain(200) {
|
|
|
- if (!checkProcess(bleDevice.mac)) {
|
|
|
|
|
|
|
+ if (!checkProcess(bleDevice.mac, false)) {
|
|
|
LogUtil.e("Prepare is canceled : ${bleDevice.mac}")
|
|
LogUtil.e("Prepare is canceled : ${bleDevice.mac}")
|
|
|
return@delayOnMain
|
|
return@delayOnMain
|
|
|
}
|
|
}
|
|
@@ -391,7 +391,7 @@ object BleConnectionManager {
|
|
|
isNeedLoading: Boolean = false,
|
|
isNeedLoading: Boolean = false,
|
|
|
prepareDoneCallBack: ((Boolean, BleBean?) -> Unit)?
|
|
prepareDoneCallBack: ((Boolean, BleBean?) -> Unit)?
|
|
|
) {
|
|
) {
|
|
|
- if (!checkProcess(bleBean?.bleDevice?.mac)) {
|
|
|
|
|
|
|
+ if (!checkProcess(bleBean?.bleDevice?.mac, false)) {
|
|
|
LogUtil.e("蓝牙连接-Prepare is canceled : ${bleBean?.bleDevice?.mac}")
|
|
LogUtil.e("蓝牙连接-Prepare is canceled : ${bleBean?.bleDevice?.mac}")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -693,7 +693,7 @@ object BleConnectionManager {
|
|
|
/**
|
|
/**
|
|
|
* 扫描在线的蓝牙
|
|
* 扫描在线的蓝牙
|
|
|
*/
|
|
*/
|
|
|
- fun scanOnlineKeyLockMac(callback: (MutableList<BleDevice>?) -> Unit) {
|
|
|
|
|
|
|
+ fun scanOnlineKeyLockMac(callback: (List<BleDevice>?) -> Unit) {
|
|
|
BleUtil.instance?.scan(object : CustomBleScanCallback() {
|
|
BleUtil.instance?.scan(object : CustomBleScanCallback() {
|
|
|
override fun onPrompt(promptStr: String?) {
|
|
override fun onPrompt(promptStr: String?) {
|
|
|
// 蓝牙未启动重试
|
|
// 蓝牙未启动重试
|
|
@@ -720,7 +720,7 @@ object BleConnectionManager {
|
|
|
|
|
|
|
|
override fun onScanFinished(scanResultList: MutableList<BleDevice>?) {
|
|
override fun onScanFinished(scanResultList: MutableList<BleDevice>?) {
|
|
|
LogUtil.d("设备录入-扫描完成:$scanResultList")
|
|
LogUtil.d("设备录入-扫描完成:$scanResultList")
|
|
|
- callback(scanResultList)
|
|
|
|
|
|
|
+ callback(scanResultList?.toList())
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|