|
|
@@ -11,6 +11,7 @@ import com.grkj.iscs.ble.BleConnectionManager
|
|
|
import com.grkj.iscs.ble.CustomBleWriteCallback
|
|
|
import com.grkj.iscs.extentions.removeLeadingZeros
|
|
|
import com.grkj.iscs.extentions.toHexStrings
|
|
|
+import com.grkj.iscs.model.DeviceConst
|
|
|
import com.grkj.iscs.model.DeviceConst.DEVICE_TYPE_CARD
|
|
|
import com.grkj.iscs.model.DeviceConst.DEVICE_TYPE_FINGERPRINT
|
|
|
import com.grkj.iscs.model.DeviceConst.DEVICE_TYPE_KEY
|
|
|
@@ -20,6 +21,7 @@ import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_ELEC_LOCK_BOARD
|
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_KEY
|
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_LOCK
|
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_PORTABLE
|
|
|
+import com.grkj.iscs.model.ISCSDomainData
|
|
|
import com.grkj.iscs.model.vo.hardware.CabinetSlotsRecord
|
|
|
import com.grkj.iscs.util.CommonUtils
|
|
|
import com.grkj.iscs.util.Executor
|
|
|
@@ -196,9 +198,10 @@ object ModBusController {
|
|
|
val rfid = res.copyOfRange(3, 11).toHexStrings(false).removeLeadingZeros()
|
|
|
LogUtil.i("初始化锁具 RFID : $rfid")
|
|
|
updateLockRfid(dockBean.addr, idx, rfid)
|
|
|
- NetApi.getLockInfo(rfid) {
|
|
|
- updateLockNewHardware(dockBean.addr, idx, it == null)
|
|
|
- }
|
|
|
+ //todo 为设备录入增加
|
|
|
+// NetApi.getLockInfo(rfid) {
|
|
|
+// updateLockNewHardware(dockBean.addr, idx, it == null)
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
controlLockBuckle(false, dockBean.addr, hasLockIdxList)
|
|
|
@@ -224,10 +227,6 @@ object ModBusController {
|
|
|
val rfid =
|
|
|
res.copyOfRange(3, 11).toHexStrings(false).removeLeadingZeros()
|
|
|
LogUtil.i("初始化钥匙 RFID : $rfid")
|
|
|
- controlKeyCharge(false, key.isLeft, dockBean.addr) {
|
|
|
- LogUtil.i("关闭充电:${it.toHexStrings()}")
|
|
|
- LogUtil.i("关闭充电: $rfid")
|
|
|
- }
|
|
|
// 更新rfid
|
|
|
updateKeyRfid(dockBean.addr, isLeft, rfid)
|
|
|
// 蓝牙准备操作
|
|
|
@@ -237,18 +236,19 @@ object ModBusController {
|
|
|
if (keyInfo != null && !keyInfo.macAddress.isNullOrEmpty()) {
|
|
|
// 更新mac
|
|
|
updateKeyMac(dockBean.addr, key.isLeft, keyInfo.macAddress)
|
|
|
- controlKeyCharge(true, keyInfo.macAddress) {
|
|
|
- ThreadUtils.runOnIODelayed(500) {
|
|
|
- BusinessManager.registerConnectListener(
|
|
|
+ ThreadUtils.runOnIO {
|
|
|
+ val isConnect =
|
|
|
+ BleConnectionManager.tryConnectWithOptionalCharge(
|
|
|
keyInfo.macAddress
|
|
|
- ) { isDone, bleBean ->
|
|
|
- if (isDone && bleBean?.bleDevice != null) {
|
|
|
- Executor.delayOnMain(500) {
|
|
|
- BusinessManager.getCurrentStatus(
|
|
|
- 3, bleBean.bleDevice
|
|
|
- )
|
|
|
- BusinessManager.getBatteryPower(bleBean.bleDevice)
|
|
|
- }
|
|
|
+ )
|
|
|
+ if (isConnect){
|
|
|
+ val bleBean = BusinessManager.getBleDeviceByMac(keyInfo.macAddress)
|
|
|
+ bleBean?.let {
|
|
|
+ Executor.delayOnMain(500) {
|
|
|
+ BusinessManager.getCurrentStatus(
|
|
|
+ 3, it.bleDevice
|
|
|
+ )
|
|
|
+ BusinessManager.getBatteryPower(it.bleDevice)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -261,11 +261,6 @@ object ModBusController {
|
|
|
controlKeyBuckle(false, key.isLeft, dockBean.addr)
|
|
|
} else {
|
|
|
controlKeyBuckle(true, key.isLeft, dockBean.addr)
|
|
|
- controlKeyCharge(
|
|
|
- false, key.isLeft, dockBean.addr
|
|
|
- ) {
|
|
|
- LogUtil.i("关闭充电:${it.toHexStrings()}")
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -707,6 +702,9 @@ object ModBusController {
|
|
|
slaveAddress?.let {
|
|
|
ModBusCMDHelper.generateKeyBuckleCmd(isOpen, if (isLeft) 0 else 1)?.let { cmd ->
|
|
|
modBusManager?.sendTo(it, cmd) { res ->
|
|
|
+ if (isOpen) {
|
|
|
+ controlKeyCharge(false, isLeft, slaveAddress)
|
|
|
+ }
|
|
|
done?.invoke(res)
|
|
|
}
|
|
|
}
|
|
|
@@ -1014,7 +1012,6 @@ object ModBusController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 根据数量获取锁具(基于锁柜和便携柜不存在接一起的情况)
|
|
|
*
|