feat: 腾讯锁联调
This commit is contained in:
parent
5af784a18d
commit
f34f3aa14a
@ -1,7 +1,13 @@
|
|||||||
export const transportType = {
|
export const transportType = {
|
||||||
TRANSPORT_BLUETOOTH: 0,
|
TRANSPORT_BLUETOOTH: 10,
|
||||||
TRANSPORT_OFFLINE: 10,
|
TRANSPORT_OFFLINE: 20,
|
||||||
TRANSPORT_GATEWAY: 20,
|
TRANSPORT_GATEWAY: 30,
|
||||||
TRANSPORT_WIFI: 30,
|
TRANSPORT_WIFI: 40,
|
||||||
TRANSPORT_TENCENT_YUN: 40
|
TRANSPORT_TENCENT_YUN: 50,
|
||||||
|
TRANSPORT_WIFI_PRIORITY: 60,
|
||||||
|
TRANSPORT_BLUETOOTH_PRIORITY: 70
|
||||||
|
}
|
||||||
|
|
||||||
|
export const model = {
|
||||||
|
TENCENT_YUN_LOCK: 'XB007'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,22 +12,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||||
import { useBasicStore } from '@/stores/basic'
|
import { useBasicStore } from '@/stores/basic'
|
||||||
|
|
||||||
const bluetoothStore = useBluetoothStore()
|
const bluetoothStore = useBluetoothStore()
|
||||||
const basicStore = useBasicStore()
|
const basicStore = useBasicStore()
|
||||||
|
|
||||||
const type = ref('bluetooth')
|
|
||||||
|
|
||||||
onLoad(options => {
|
|
||||||
if (options.type) {
|
|
||||||
type.value = options.type
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const toSearchDevice = async () => {
|
const toSearchDevice = async () => {
|
||||||
if (bluetoothStore.bluetoothStatus !== 0) {
|
if (bluetoothStore.bluetoothStatus !== 0) {
|
||||||
bluetoothStore.getBluetoothStatus()
|
bluetoothStore.getBluetoothStatus()
|
||||||
@ -38,17 +28,10 @@
|
|||||||
result = await bluetoothStore.initAndListenBluetooth()
|
result = await bluetoothStore.initAndListenBluetooth()
|
||||||
}
|
}
|
||||||
if (result) {
|
if (result) {
|
||||||
if (type.value === 'bluetooth') {
|
basicStore.routeJump({
|
||||||
basicStore.routeJump({
|
type: 'redirectTo',
|
||||||
type: 'redirectTo',
|
name: 'searchDevice'
|
||||||
name: 'searchDevice'
|
})
|
||||||
})
|
|
||||||
} else if (type.value === 'wifi') {
|
|
||||||
basicStore.routeJump({
|
|
||||||
type: 'redirectTo',
|
|
||||||
name: 'distributionNetwork'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
bluetoothStore.checkSetting()
|
bluetoothStore.checkSetting()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
>
|
>
|
||||||
<view class="flex items-center">
|
<view class="flex items-center">
|
||||||
<view class="mr-4">WiFi</view>
|
<view class="mr-4">WiFi</view>
|
||||||
<view>{{ wifiList[wifiIndex]?.SSID ?? '搜索中...' }}</view>
|
<view>{{ wifiList[wifiIndex]?.SSID ?? '请选择WiFi' }}</view>
|
||||||
<view class="ml-a">
|
<view class="ml-a">
|
||||||
<up-icon name="arrow-right" size="24rpx"></up-icon>
|
<up-icon name="arrow-right" size="24rpx"></up-icon>
|
||||||
</view>
|
</view>
|
||||||
@ -61,12 +61,12 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, onUnmounted, ref } from 'vue'
|
import { onMounted, onUnmounted, ref } from 'vue'
|
||||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||||
// import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
import { useBasicStore } from '@/stores/basic'
|
import { useBasicStore } from '@/stores/basic'
|
||||||
import { passthrough } from '@/api/sdk'
|
import { passthrough } from '@/api/sdk'
|
||||||
|
|
||||||
const $bluetooth = useBluetoothStore()
|
const $bluetooth = useBluetoothStore()
|
||||||
// const $user = useUserStore()
|
const $user = useUserStore()
|
||||||
const $basic = useBasicStore()
|
const $basic = useBasicStore()
|
||||||
|
|
||||||
const wifiList = ref([])
|
const wifiList = ref([])
|
||||||
@ -77,42 +77,26 @@
|
|||||||
|
|
||||||
const pending = ref(false)
|
const pending = ref(false)
|
||||||
|
|
||||||
|
const result = ref(false)
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '搜索中'
|
title: '搜索中'
|
||||||
})
|
})
|
||||||
// const result = await $bluetooth.getWifiList({
|
const result = await $bluetooth.getWifiList({
|
||||||
// uid: $user.userInfo.uid.toString()
|
uid: $user.userInfo.uid.toString()
|
||||||
// })
|
})
|
||||||
// if (result.code !== 0) {
|
if (result.code !== 0) {
|
||||||
// uni.showModal({
|
uni.showModal({
|
||||||
// title: '提示',
|
title: '提示',
|
||||||
// content: '搜索失败,请返回重试',
|
content: '搜索失败,请返回重试',
|
||||||
// showCancel: false,
|
showCancel: false,
|
||||||
// success: () => {
|
success: () => {
|
||||||
// uni.navigateBack()
|
uni.navigateBack()
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
listenEvent()
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.hideLoading()
|
|
||||||
wifiList.value = [
|
|
||||||
{
|
|
||||||
SSID: '测试1',
|
|
||||||
rssi: 10
|
|
||||||
},
|
|
||||||
{
|
|
||||||
SSID: '测试2',
|
|
||||||
rssi: 20
|
|
||||||
},
|
|
||||||
{
|
|
||||||
SSID: '测试3',
|
|
||||||
rssi: 30
|
|
||||||
}
|
}
|
||||||
]
|
})
|
||||||
wifiIndex.value = 0
|
}
|
||||||
}, 2000)
|
listenEvent()
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
@ -124,6 +108,9 @@
|
|||||||
uni.$on('wifiList', async data => {
|
uni.$on('wifiList', async data => {
|
||||||
if (data.status === 0) {
|
if (data.status === 0) {
|
||||||
wifiList.value = data.wifiList
|
wifiList.value = data.wifiList
|
||||||
|
if (wifiList.value.length > 0) {
|
||||||
|
wifiIndex.value = 0
|
||||||
|
}
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
} else {
|
} else {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
@ -137,6 +124,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
uni.$on('distributionNetworkResult', async data => {
|
uni.$on('distributionNetworkResult', async data => {
|
||||||
|
result.value = false
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
pending.value = false
|
pending.value = false
|
||||||
if (data.status === 0) {
|
if (data.status === 0) {
|
||||||
@ -192,35 +180,36 @@
|
|||||||
if (result.code === 0) {
|
if (result.code === 0) {
|
||||||
$bluetooth.updateCurrentLockInfo({
|
$bluetooth.updateCurrentLockInfo({
|
||||||
...$bluetooth.currentLockInfo,
|
...$bluetooth.currentLockInfo,
|
||||||
tencentYunLock: {
|
tencentYunLock: result.data
|
||||||
productId: result.data.productId,
|
|
||||||
deviceName: result.data.deviceName,
|
|
||||||
devicePsk: result.data.devicePsk
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
// const result = await $bluetooth.distributionNetwork({
|
|
||||||
// SSID: wifiList.value[wifiIndex.value].SSID,
|
|
||||||
// password: password.value,
|
|
||||||
// json: JSON.stringify({
|
|
||||||
// productId: result.data.productId,
|
|
||||||
// deviceName: result.data.deviceName,
|
|
||||||
// devicePsk: result.data.devicePsk
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// if (result.code !== 0) {
|
|
||||||
// uni.showToast({
|
|
||||||
// title: '连接失败,请重试',
|
|
||||||
// icon: 'none'
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
setTimeout(() => {
|
const res = await $bluetooth.distributionNetwork({
|
||||||
$basic.routeJump({
|
SSID: wifiList.value[wifiIndex.value].SSID,
|
||||||
type: 'redirectTo',
|
password: password.value,
|
||||||
name: 'selectAddress'
|
json: JSON.stringify(result.data)
|
||||||
|
})
|
||||||
|
|
||||||
|
if (res.code === 0) {
|
||||||
|
result.value = true
|
||||||
|
setTimeout(() => {
|
||||||
|
pending.value = false
|
||||||
|
if (result.value) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '配网失败,请检查密码是否正确',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, 10000)
|
||||||
|
} else {
|
||||||
|
pending.value = false
|
||||||
|
uni.showToast({
|
||||||
|
title: res.message,
|
||||||
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}, 3000)
|
}
|
||||||
} else {
|
} else {
|
||||||
|
uni.hideLoading()
|
||||||
|
pending.value = false
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: result.message,
|
title: result.message,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
|
|||||||
@ -40,6 +40,7 @@
|
|||||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||||
import { useBasicStore } from '@/stores/basic'
|
import { useBasicStore } from '@/stores/basic'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
|
import { model } from '@/constant/transportType'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@ -139,7 +140,10 @@
|
|||||||
}
|
}
|
||||||
this.routeJump({
|
this.routeJump({
|
||||||
type: 'redirectTo',
|
type: 'redirectTo',
|
||||||
name: false ? 'selectAddress' : 'distributionNetwork'
|
name:
|
||||||
|
this.currentLockInfo.lockConfig.model === model.TENCENT_YUN_LOCK
|
||||||
|
? 'distributionNetwork'
|
||||||
|
: 'selectAddress'
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
|
|||||||
@ -251,7 +251,7 @@
|
|||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
eventChannel.emit('refresherList', {})
|
eventChannel.emit('refresherList', {})
|
||||||
$basic.backAndToast('添加成功')
|
$basic.backAndToast('添加成功')
|
||||||
if ($bluetooth.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) {
|
if ($bluetooth.currentLockInfo.transportType === transportType.TRANSPORT_TENCENT_YUN) {
|
||||||
$bluetooth.addLockUser({
|
$bluetooth.addLockUser({
|
||||||
name: $bluetooth.currentLockInfo.name,
|
name: $bluetooth.currentLockInfo.name,
|
||||||
keyId: $bluetooth.keyId,
|
keyId: $bluetooth.keyId,
|
||||||
|
|||||||
@ -307,7 +307,7 @@
|
|||||||
cardName: params.cardName
|
cardName: params.cardName
|
||||||
})
|
})
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
if ($bluetooth.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) {
|
if ($bluetooth.currentLockInfo.transportType === transportType.TRANSPORT_TENCENT_YUN) {
|
||||||
const { code } = await $bluetooth.registerAuthentication(params)
|
const { code } = await $bluetooth.registerAuthentication(params)
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
$basic.backAndToast('请在锁端添加卡片')
|
$basic.backAndToast('请在锁端添加卡片')
|
||||||
|
|||||||
@ -276,7 +276,7 @@
|
|||||||
faceName: params.faceName
|
faceName: params.faceName
|
||||||
})
|
})
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
if ($bluetooth.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) {
|
if ($bluetooth.currentLockInfo.transportType === transportType.TRANSPORT_TENCENT_YUN) {
|
||||||
const { code } = await $bluetooth.registerAuthentication(params)
|
const { code } = await $bluetooth.registerAuthentication(params)
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
$basic.backAndToast('请在锁端添加人脸')
|
$basic.backAndToast('请在锁端添加人脸')
|
||||||
|
|||||||
@ -307,7 +307,7 @@
|
|||||||
fingerprintName: params.fingerprintName
|
fingerprintName: params.fingerprintName
|
||||||
})
|
})
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
if ($bluetooth.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) {
|
if ($bluetooth.currentLockInfo.transportType === transportType.TRANSPORT_TENCENT_YUN) {
|
||||||
const { code } = await $bluetooth.registerAuthentication(params)
|
const { code } = await $bluetooth.registerAuthentication(params)
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
$basic.backAndToast('请在锁端添加指纹')
|
$basic.backAndToast('请在锁端添加指纹')
|
||||||
|
|||||||
@ -282,7 +282,7 @@
|
|||||||
})
|
})
|
||||||
this.getKeyList(this.keySearch)
|
this.getKeyList(this.keySearch)
|
||||||
this.backAndToast('钥匙已发送')
|
this.backAndToast('钥匙已发送')
|
||||||
if (this.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) {
|
if (this.currentLockInfo.transportType === transportType.TRANSPORT_TENCENT_YUN) {
|
||||||
this.addLockUser({
|
this.addLockUser({
|
||||||
name: this.currentLockInfo.name,
|
name: this.currentLockInfo.name,
|
||||||
keyId: this.keyId,
|
keyId: this.keyId,
|
||||||
|
|||||||
@ -308,7 +308,7 @@
|
|||||||
palmVeinName: params.palmVeinName
|
palmVeinName: params.palmVeinName
|
||||||
})
|
})
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
if ($bluetooth.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) {
|
if ($bluetooth.currentLockInfo.transportType === transportType.TRANSPORT_TENCENT_YUN) {
|
||||||
const { code } = await $bluetooth.registerAuthentication(params)
|
const { code } = await $bluetooth.registerAuthentication(params)
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
$basic.backAndToast('请在锁端添加掌静脉')
|
$basic.backAndToast('请在锁端添加掌静脉')
|
||||||
|
|||||||
@ -249,7 +249,7 @@
|
|||||||
remoteName: params.remoteName
|
remoteName: params.remoteName
|
||||||
})
|
})
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
if ($bluetooth.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) {
|
if ($bluetooth.currentLockInfo.transportType === transportType.TRANSPORT_TENCENT_YUN) {
|
||||||
const { code } = await $bluetooth.registerAuthentication(params)
|
const { code } = await $bluetooth.registerAuthentication(params)
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
$basic.backAndToast('请在锁端添加远程')
|
$basic.backAndToast('请在锁端添加远程')
|
||||||
|
|||||||
@ -353,7 +353,8 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
const cebBinaryData = binaryData.slice(12, binaryData.length - 2)
|
const cebBinaryData = binaryData.slice(12, binaryData.length - 2)
|
||||||
const decrypted = sm4.decrypt(cebBinaryData, that.currentLockInfo.commKey, {
|
const decrypted = sm4.decrypt(cebBinaryData, that.currentLockInfo.commKey, {
|
||||||
mode: 'ecb',
|
mode: 'ecb',
|
||||||
output: 'array'
|
output: 'array',
|
||||||
|
padding: 'none'
|
||||||
})
|
})
|
||||||
const length = binaryData[10] * 256 + binaryData[11]
|
const length = binaryData[10] * 256 + binaryData[11]
|
||||||
console.log('ecb解密后的数据', decrypted)
|
console.log('ecb解密后的数据', decrypted)
|
||||||
@ -1313,22 +1314,37 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
|
uint8ArrayToHex(uint8Array) {
|
||||||
|
return Array.from(uint8Array)
|
||||||
|
.map(b => b.toString(16).padStart(2, '0'))
|
||||||
|
.join('')
|
||||||
|
},
|
||||||
|
hexToArray(hexString) {
|
||||||
|
const result = []
|
||||||
|
for (let i = 0; i < hexString.length; i += 2) {
|
||||||
|
result.push(parseInt(hexString.slice(i, i + 2), 16))
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
},
|
||||||
// 写入特征值
|
// 写入特征值
|
||||||
async transportMessage(binaryData) {
|
async transportMessage(binaryData) {
|
||||||
const that = this
|
const that = this
|
||||||
|
|
||||||
if (that.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) {
|
if (that.currentLockInfo.transportType === transportType.TRANSPORT_TENCENT_YUN) {
|
||||||
|
const content = that.uint8ArrayToHex(binaryData)
|
||||||
const { code, data, message } = await passthrough({
|
const { code, data, message } = await passthrough({
|
||||||
request_method: 'GET',
|
request_method: 'POST',
|
||||||
request_uri: '/api/v1/tencentYun/getTencentTriple',
|
request_uri: '/api/v1/tencentYun/CallDeviceActionSync',
|
||||||
post_args: {
|
post_args: {
|
||||||
lockId: that.currentLockInfo.lockId,
|
lockId: that.currentLockInfo.lockId,
|
||||||
data: binaryData
|
actionId: 'starcloud_action',
|
||||||
|
len: content.length,
|
||||||
|
content
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (code === 0) {
|
if (code === 0 && data.outputParams) {
|
||||||
that.parsingCharacteristicValue(data)
|
that.parsingCharacteristicValue(that.hexToArray(data.outputParams))
|
||||||
} else {
|
} else {
|
||||||
characteristicValueCallback({
|
characteristicValueCallback({
|
||||||
code,
|
code,
|
||||||
@ -1336,10 +1352,14 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('设备ID:', that.currentLockInfo.deviceId)
|
console.log(
|
||||||
console.log('设备名称:', that.currentLockInfo.name)
|
'设备ID:',
|
||||||
console.log('设备主服务:', that.currentLockInfo.serviceId)
|
that.currentLockInfo.deviceId,
|
||||||
console.log('设备写入特征值:', that.currentLockInfo.writeCharacteristicId)
|
'设备名称:',
|
||||||
|
that.currentLockInfo.name,
|
||||||
|
'私钥:',
|
||||||
|
that.currentLockInfo.commKey
|
||||||
|
)
|
||||||
console.log('设备写入数据:', Array.from(binaryData))
|
console.log('设备写入数据:', Array.from(binaryData))
|
||||||
|
|
||||||
// 次数
|
// 次数
|
||||||
@ -1393,6 +1413,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
} else {
|
} else {
|
||||||
headArray[7] = 0x23
|
headArray[7] = 0x23
|
||||||
}
|
}
|
||||||
|
console.log('包标识', headArray[7])
|
||||||
|
|
||||||
// 数据长度
|
// 数据长度
|
||||||
if (encryptionType === 0) {
|
if (encryptionType === 0) {
|
||||||
@ -1563,7 +1584,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (
|
if (
|
||||||
this.bluetoothStatus !== 0 &&
|
this.bluetoothStatus !== 0 &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
@ -1575,7 +1596,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (
|
if (
|
||||||
!this.currentLockInfo.connected &&
|
!this.currentLockInfo.connected &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
@ -1765,7 +1786,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { SSID, password, json } = data
|
const { SSID, password, json } = data
|
||||||
const length = 2 + 30 + 20 + json.length
|
const length = 2 + 30 + 20 + 2 + json.length
|
||||||
const headArray = this.createPackageHeader(3, length)
|
const headArray = this.createPackageHeader(3, length)
|
||||||
|
|
||||||
const contentArray = new Uint8Array(length)
|
const contentArray = new Uint8Array(length)
|
||||||
@ -1788,7 +1809,8 @@ 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'
|
||||||
})
|
})
|
||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
@ -1816,7 +1838,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (
|
if (
|
||||||
this.bluetoothStatus !== 0 &&
|
this.bluetoothStatus !== 0 &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
@ -1828,7 +1850,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (
|
if (
|
||||||
!this.currentLockInfo.connected &&
|
!this.currentLockInfo.connected &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
@ -2111,7 +2133,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (
|
if (
|
||||||
this.bluetoothStatus !== 0 &&
|
this.bluetoothStatus !== 0 &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
@ -2189,7 +2211,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (
|
if (
|
||||||
!this.currentLockInfo.connected &&
|
!this.currentLockInfo.connected &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code === 0) {
|
if (searchResult.code === 0) {
|
||||||
@ -2449,7 +2471,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (
|
if (
|
||||||
this.bluetoothStatus !== 0 &&
|
this.bluetoothStatus !== 0 &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
@ -2461,7 +2483,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (
|
if (
|
||||||
!this.currentLockInfo.connected &&
|
!this.currentLockInfo.connected &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
@ -2544,7 +2566,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (
|
if (
|
||||||
this.bluetoothStatus !== 0 &&
|
this.bluetoothStatus !== 0 &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
@ -2556,7 +2578,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (
|
if (
|
||||||
!this.currentLockInfo.connected &&
|
!this.currentLockInfo.connected &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
@ -2625,7 +2647,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (
|
if (
|
||||||
this.bluetoothStatus !== 0 &&
|
this.bluetoothStatus !== 0 &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
@ -2637,7 +2659,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (
|
if (
|
||||||
!this.currentLockInfo.connected &&
|
!this.currentLockInfo.connected &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
@ -2714,7 +2736,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (
|
if (
|
||||||
this.bluetoothStatus !== 0 &&
|
this.bluetoothStatus !== 0 &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
@ -2726,7 +2748,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (
|
if (
|
||||||
!this.currentLockInfo.connected &&
|
!this.currentLockInfo.connected &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
@ -2830,7 +2852,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (
|
if (
|
||||||
this.bluetoothStatus !== 0 &&
|
this.bluetoothStatus !== 0 &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
@ -2842,7 +2864,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (
|
if (
|
||||||
!this.currentLockInfo.connected &&
|
!this.currentLockInfo.connected &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
@ -3029,7 +3051,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (
|
if (
|
||||||
this.bluetoothStatus !== 0 &&
|
this.bluetoothStatus !== 0 &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
@ -3041,7 +3063,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (
|
if (
|
||||||
!this.currentLockInfo.connected &&
|
!this.currentLockInfo.connected &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
@ -3156,7 +3178,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (
|
if (
|
||||||
this.bluetoothStatus !== 0 &&
|
this.bluetoothStatus !== 0 &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
@ -3168,7 +3190,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (
|
if (
|
||||||
!this.currentLockInfo.connected &&
|
!this.currentLockInfo.connected &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
@ -3258,7 +3280,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (
|
if (
|
||||||
this.bluetoothStatus !== 0 &&
|
this.bluetoothStatus !== 0 &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
@ -3270,7 +3292,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (
|
if (
|
||||||
!this.currentLockInfo.connected &&
|
!this.currentLockInfo.connected &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
@ -3365,7 +3387,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (
|
if (
|
||||||
this.bluetoothStatus !== 0 &&
|
this.bluetoothStatus !== 0 &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
@ -3377,7 +3399,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (
|
if (
|
||||||
!this.currentLockInfo.connected &&
|
!this.currentLockInfo.connected &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
@ -3449,7 +3471,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (
|
if (
|
||||||
this.bluetoothStatus !== 0 &&
|
this.bluetoothStatus !== 0 &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
@ -3461,7 +3483,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (
|
if (
|
||||||
!this.currentLockInfo.connected &&
|
!this.currentLockInfo.connected &&
|
||||||
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
this.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
) {
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user