|
|
@@ -37,6 +37,14 @@ class InitDeviceRegistrationKeyAndLockViewModel @Inject constructor(val hardware
|
|
|
*/
|
|
|
fun openAndDetectSlave() {
|
|
|
ModBusController.start()
|
|
|
+ ModBusController.controlKeyCharge(true,0,0x01)
|
|
|
+ ModBusController.controlKeyCharge(true,1,0x01)
|
|
|
+ ModBusController.controlKeyCharge(true,0,0x02)
|
|
|
+ ModBusController.controlKeyCharge(true,1,0x02)
|
|
|
+ ModBusController.controlKeyBuckle(true,0,0x01)
|
|
|
+ ModBusController.controlKeyBuckle(true,1,0x01)
|
|
|
+ ModBusController.controlKeyBuckle(true,0,0x02)
|
|
|
+ ModBusController.controlKeyBuckle(true,1,0x02)
|
|
|
ModBusController.initDevicesStatus()
|
|
|
ModbusBusinessManager.registerMainListener()
|
|
|
}
|
|
|
@@ -59,7 +67,6 @@ class InitDeviceRegistrationKeyAndLockViewModel @Inject constructor(val hardware
|
|
|
|
|
|
fun registerInitListener(): LiveData<Boolean> {
|
|
|
return liveData(Dispatchers.IO) {
|
|
|
- openAndDetectSlave()
|
|
|
isStartCheckKey = false
|
|
|
newHardwareKeyBean.clear()
|
|
|
alreadyUsedMac.clear()
|
|
|
@@ -264,4 +271,11 @@ class InitDeviceRegistrationKeyAndLockViewModel @Inject constructor(val hardware
|
|
|
ModBusController.stop()
|
|
|
ModbusBusinessManager.unregisterMainListener()
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除钥匙表
|
|
|
+ */
|
|
|
+ fun deleteKey() {
|
|
|
+ hardwareRepository.deleteKeyTable()
|
|
|
+ }
|
|
|
}
|