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