|
|
@@ -726,7 +726,13 @@ object BusinessManager {
|
|
|
}
|
|
|
// 断开和重连之间最好间隔一段时间,否则可能会出现长时间连接不上的情况
|
|
|
Executor.delayOnMain(300) {
|
|
|
- registerConnectListener(bleDevice.mac)
|
|
|
+ registerConnectListener(bleDevice.mac) { isDone, bleBean ->
|
|
|
+ if (isDone && bleBean != null) {
|
|
|
+ Executor.delayOnMain(300) {
|
|
|
+ getCurrentStatus(6, bleBean.bleDevice)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
ModBusController.updateKeyReadyStatus(bleDevice.mac, false, 3)
|
|
|
@@ -1102,8 +1108,10 @@ object BusinessManager {
|
|
|
fun getCurrentStatus(from: Int, bleDevice: BleDevice, retryCount: Int = 3) {
|
|
|
LogUtil.i("getCurrentStatus - ${bleDevice.mac} - from : $from")
|
|
|
var isTimeout = true
|
|
|
+ // 加1秒防止早于onWriteFailure开始处理导致多次处理
|
|
|
Executor.delayOnMain((BleUtil.OPERATE_TIMEOUT + 1).toLong()) {
|
|
|
if (isTimeout) {
|
|
|
+ LogUtil.e("getCurrentStatus timeout : mac = ${bleDevice.mac}, retryCount = $retryCount")
|
|
|
if (retryCount > 0) {
|
|
|
Executor.delayOnMain(1000) {
|
|
|
getCurrentStatus(from, bleDevice, retryCount - 1)
|