fix: 修复命令下发时的bug
This commit is contained in:
parent
7397461512
commit
8c19ae5a2e
@ -362,14 +362,6 @@
|
||||
openTime: parseInt(new Date().getTime() / 1000, 10) + time.value,
|
||||
onlineToken: onlineToken.value
|
||||
})
|
||||
$bluetooth
|
||||
.syncRecord({
|
||||
keyId: $bluetooth.currentLockInfo.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString()
|
||||
})
|
||||
.then(() => {
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
})
|
||||
if (type === 'open') {
|
||||
uni.reportEvent('open_door', {
|
||||
result: code,
|
||||
@ -382,6 +374,14 @@
|
||||
})
|
||||
}
|
||||
if (code === 0) {
|
||||
$bluetooth
|
||||
.syncRecord({
|
||||
keyId: $bluetooth.currentLockInfo.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString()
|
||||
})
|
||||
.then(() => {
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
})
|
||||
show.value = true
|
||||
typeValue.value = type
|
||||
setTimeout(() => {
|
||||
|
||||
@ -1052,15 +1052,17 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
// 断开蓝牙连接
|
||||
closeBluetoothConnection() {
|
||||
const that = this
|
||||
uni.closeBLEConnection({
|
||||
deviceId: that.currentLockInfo.deviceId,
|
||||
success(res) {
|
||||
console.log('断开连接成功', res)
|
||||
},
|
||||
fail(res) {
|
||||
console.log('断开连接失败', res)
|
||||
}
|
||||
})
|
||||
if (that.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN) {
|
||||
uni.closeBLEConnection({
|
||||
deviceId: that.currentLockInfo.deviceId,
|
||||
success(res) {
|
||||
console.log('断开连接成功', res)
|
||||
},
|
||||
fail(res) {
|
||||
console.log('断开连接失败', res)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
// 周数组转换
|
||||
convertWeekdaysToNumber(weekDay) {
|
||||
@ -1347,21 +1349,25 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
})
|
||||
|
||||
if (code === 0) {
|
||||
if (data.status === '') {
|
||||
that.parsingCharacteristicValue(that.hexToArray(data.outputParams.result))
|
||||
} else {
|
||||
let code = -10
|
||||
if (data.status === 'FailedOperation.ActionUnreachable') {
|
||||
code = -11
|
||||
if (data.Status === 'action execute success!') {
|
||||
if (data.OutputParams.result === '') {
|
||||
characteristicValueCallback({
|
||||
code: 0,
|
||||
message: `成功,${data.Status}`
|
||||
})
|
||||
} else {
|
||||
const params = that.hexToArray(data.OutputParams.result)
|
||||
console.log('转换后的数据', params)
|
||||
that.parsingCharacteristicValue(params)
|
||||
}
|
||||
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: `设备状态异常,${code}`,
|
||||
title: `命令下发失败,${data.Status}`,
|
||||
icon: 'none'
|
||||
})
|
||||
characteristicValueCallback({
|
||||
code: -10,
|
||||
message: '设备状态异常'
|
||||
message: `命令下发失败,${data.Status}`
|
||||
})
|
||||
}
|
||||
} else {
|
||||
@ -1508,7 +1514,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, contentArray)
|
||||
|
||||
await this.transportMessage(packageArray)
|
||||
this.transportMessage(packageArray)
|
||||
return this.getResult()
|
||||
},
|
||||
// 获取私钥
|
||||
@ -1580,7 +1586,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
|
||||
await this.transportMessage(packageArray)
|
||||
this.transportMessage(packageArray)
|
||||
return this.getResult()
|
||||
},
|
||||
// md5加密
|
||||
@ -1658,7 +1664,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
|
||||
await this.transportMessage(packageArray)
|
||||
this.transportMessage(packageArray)
|
||||
|
||||
return this.getResult(this.getLockStatus, data)
|
||||
},
|
||||
@ -1716,7 +1722,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
|
||||
await this.transportMessage(packageArray)
|
||||
this.transportMessage(packageArray)
|
||||
|
||||
return this.getResult(this.getLockStatusInfo, data)
|
||||
},
|
||||
@ -1769,7 +1775,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
|
||||
await this.transportMessage(packageArray)
|
||||
this.transportMessage(packageArray)
|
||||
|
||||
return this.getResult(this.getWifiList, data)
|
||||
},
|
||||
@ -1829,12 +1835,12 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.commKey, {
|
||||
mode: 'ecb',
|
||||
output: 'array',
|
||||
padding: 'none'
|
||||
padding: length % 16 === 0 ? 'none' : 'pkcs#5'
|
||||
})
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
|
||||
await this.transportMessage(packageArray)
|
||||
this.transportMessage(packageArray)
|
||||
|
||||
return this.getResult(this.distributionNetwork, data)
|
||||
},
|
||||
@ -1971,7 +1977,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
})
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
await this.transportMessage(packageArray, false)
|
||||
this.transportMessage(packageArray, false)
|
||||
return this.getResult(this.addLockUser, data)
|
||||
},
|
||||
// 添加用户
|
||||
@ -2087,7 +2093,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
})
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
await this.transportMessage(packageArray, false)
|
||||
this.transportMessage(packageArray, false)
|
||||
return this.getResult(this.bindLock, data)
|
||||
},
|
||||
// 获取写入结果
|
||||
@ -2576,7 +2582,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
|
||||
await this.transportMessage(packageArray)
|
||||
this.transportMessage(packageArray)
|
||||
|
||||
return this.getResult(this.cleanLockUser, data)
|
||||
},
|
||||
@ -2657,7 +2663,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
|
||||
await this.transportMessage(packageArray)
|
||||
this.transportMessage(packageArray)
|
||||
|
||||
return this.getResult(this.resetDevice, data)
|
||||
},
|
||||
@ -2746,7 +2752,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
|
||||
await this.transportMessage(packageArray)
|
||||
this.transportMessage(packageArray)
|
||||
|
||||
return this.getResult(this.resetLockPassword, data)
|
||||
},
|
||||
@ -2851,7 +2857,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
|
||||
await this.transportMessage(packageArray)
|
||||
this.transportMessage(packageArray)
|
||||
|
||||
return this.getResult(this.setLockPassword, data)
|
||||
},
|
||||
@ -3004,7 +3010,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
|
||||
await this.transportMessage(packageArray)
|
||||
this.transportMessage(packageArray)
|
||||
|
||||
return this.getResult(this.registerAuthentication, data)
|
||||
},
|
||||
@ -3061,7 +3067,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
|
||||
await this.transportMessage(packageArray)
|
||||
this.transportMessage(packageArray)
|
||||
|
||||
return this.getResult(this.registerAuthenticationCancel, data)
|
||||
},
|
||||
@ -3188,7 +3194,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
|
||||
await this.transportMessage(packageArray)
|
||||
this.transportMessage(packageArray)
|
||||
|
||||
return this.getResult(this.syncSingleRecord, data)
|
||||
},
|
||||
@ -3290,7 +3296,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
|
||||
await this.transportMessage(packageArray)
|
||||
this.transportMessage(packageArray)
|
||||
|
||||
return this.getResult(this.updateAdminPassword, data)
|
||||
},
|
||||
@ -3397,7 +3403,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
|
||||
await this.transportMessage(packageArray)
|
||||
this.transportMessage(packageArray)
|
||||
|
||||
return this.getResult(this.updateSetting, data)
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user