feat: 完成蓝牙透传相关功能+被叫时查询锁详情信息
This commit is contained in:
parent
8c4c107127
commit
baecc976ee
@ -9,7 +9,8 @@ module.exports = {
|
|||||||
uni: 'writable',
|
uni: 'writable',
|
||||||
getApp: 'writable',
|
getApp: 'writable',
|
||||||
wx: 'writable',
|
wx: 'writable',
|
||||||
getCurrentPages: 'writable'
|
getCurrentPages: 'writable',
|
||||||
|
requirePlugin: 'writable'
|
||||||
},
|
},
|
||||||
// 指定如何解析语法
|
// 指定如何解析语法
|
||||||
parser: 'vue-eslint-parser',
|
parser: 'vue-eslint-parser',
|
||||||
|
|||||||
10
App.vue
10
App.vue
@ -16,6 +16,7 @@
|
|||||||
appid: '',
|
appid: '',
|
||||||
// 小程序版本
|
// 小程序版本
|
||||||
envVersion: '',
|
envVersion: '',
|
||||||
|
sn: '',
|
||||||
// 获取环境配置
|
// 获取环境配置
|
||||||
getEnvConfig() {
|
getEnvConfig() {
|
||||||
const envVersionStorage = getStorage('envVersion')
|
const envVersionStorage = getStorage('envVersion')
|
||||||
@ -84,6 +85,13 @@
|
|||||||
key: 'Call',
|
key: 'Call',
|
||||||
routeType: 'switchTab'
|
routeType: 'switchTab'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
wmpfVoip.onVoipEvent(event => {
|
||||||
|
if (event.eventName === 'callPageOnShow') {
|
||||||
|
const query = wmpfVoip.getPluginOnloadOptions()
|
||||||
|
getApp().globalData.sn = query.callerId
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
// 强制升级
|
// 强制升级
|
||||||
updateMiniProgram() {
|
updateMiniProgram() {
|
||||||
@ -104,5 +112,5 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@import 'uview-plus/index.scss';
|
@import 'uview-plus/index';
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
7
constant/transportType.js
Normal file
7
constant/transportType.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export const transportType = {
|
||||||
|
TRANSPORT_BLUETOOTH: 0,
|
||||||
|
TRANSPORT_OFFLINE: 10,
|
||||||
|
TRANSPORT_GATEWAY: 20,
|
||||||
|
TRANSPORT_WIFI: 30,
|
||||||
|
TRANSPORT_TENCENT_YUN: 40
|
||||||
|
}
|
||||||
@ -67,7 +67,7 @@
|
|||||||
'getCommKey',
|
'getCommKey',
|
||||||
'connectBluetoothDevice',
|
'connectBluetoothDevice',
|
||||||
'updateServerTimestamp',
|
'updateServerTimestamp',
|
||||||
'getLockStatus'
|
'getLockStatusInfo'
|
||||||
]),
|
]),
|
||||||
...mapActions(useBasicStore, ['getDeviceInfo', 'routeJump', 'getNetworkType']),
|
...mapActions(useBasicStore, ['getDeviceInfo', 'routeJump', 'getNetworkType']),
|
||||||
async connect(device) {
|
async connect(device) {
|
||||||
@ -123,7 +123,7 @@
|
|||||||
}
|
}
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
const timestamp = this.serverTimestamp - date.getTimezoneOffset() * 60
|
const timestamp = this.serverTimestamp - date.getTimezoneOffset() * 60
|
||||||
const { code } = await this.getLockStatus({
|
const { code } = await this.getLockStatusInfo({
|
||||||
name: this.currentLockInfo.name,
|
name: this.currentLockInfo.name,
|
||||||
uid: this.userInfo.uid.toString(),
|
uid: this.userInfo.uid.toString(),
|
||||||
nowTime: this.serverTimestamp,
|
nowTime: this.serverTimestamp,
|
||||||
@ -148,7 +148,8 @@
|
|||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (res) {
|
} catch (error) {
|
||||||
|
console.log('连接失败', error)
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '连接失败,请靠近设备并保持设备处于唤醒状态',
|
title: '连接失败,请靠近设备并保持设备处于唤醒状态',
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="dialog">
|
<view class="dialog" v-if="lockId">
|
||||||
<image
|
<image
|
||||||
class="top-background"
|
class="top-background"
|
||||||
src="https://oss-lock.xhjcn.ltd/mp/background_main.jpg"
|
src="https://oss-lock.xhjcn.ltd/mp/background_main.jpg"
|
||||||
@ -19,6 +19,7 @@
|
|||||||
import { useBasicStore } from '@/stores/basic'
|
import { useBasicStore } from '@/stores/basic'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
import { getLockDetailRequest, getLockNetTokenRequest } from '@/api/lock'
|
import { getLockDetailRequest, getLockNetTokenRequest } from '@/api/lock'
|
||||||
|
import { passthrough } from '@/api/sdk'
|
||||||
|
|
||||||
const $bluetooth = useBluetoothStore()
|
const $bluetooth = useBluetoothStore()
|
||||||
const $basic = useBasicStore()
|
const $basic = useBasicStore()
|
||||||
@ -32,29 +33,49 @@
|
|||||||
|
|
||||||
const onlineToken = ref('0')
|
const onlineToken = ref('0')
|
||||||
|
|
||||||
const lockId = ref(2712)
|
const lockId = ref()
|
||||||
|
|
||||||
const time = ref(0)
|
const time = ref(0)
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const { code, data, message } = await getLockDetailRequest({
|
const accountInfo = uni.getAccountInfoSync()
|
||||||
lockId: lockId.value
|
getApp().globalData.appid = accountInfo.miniProgram.appId
|
||||||
|
getApp().globalData.envVersion = accountInfo.miniProgram.envVersion
|
||||||
|
|
||||||
|
const result = await passthrough({
|
||||||
|
request_method: 'POST',
|
||||||
|
request_uri: '/api/v1/tencentYun/getLockIdBySn',
|
||||||
|
post_args: {
|
||||||
|
wxDeviceSn: getApp().globalData.sn
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (code === 0) {
|
|
||||||
lockInfo.value = data
|
if (result.code === 0) {
|
||||||
$bluetooth.updateCurrentLockInfo({
|
lockId.value = result.data.lockId
|
||||||
...lockInfo.value,
|
const { code, data, message } = await getLockDetailRequest({
|
||||||
name: lockInfo.value.lockName,
|
lockId: lockId.value
|
||||||
deviceId: lockInfo.value.lockName,
|
|
||||||
commKey: lockInfo.value.privateKey
|
|
||||||
})
|
})
|
||||||
|
if (code === 0) {
|
||||||
|
lockInfo.value = data
|
||||||
|
$bluetooth.updateCurrentLockInfo({
|
||||||
|
...lockInfo.value,
|
||||||
|
name: lockInfo.value.lockName,
|
||||||
|
deviceId: lockInfo.value.lockName,
|
||||||
|
commKey: lockInfo.value.privateKey
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
await getServeTime()
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: message,
|
title: result.message,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
await getServeTime()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const getServeTime = async () => {
|
const getServeTime = async () => {
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
import { passthrough } from '@/api/sdk'
|
import { passthrough } from '@/api/sdk'
|
||||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||||
import env from '@/config/env'
|
import env from '@/config/env'
|
||||||
|
import { getStorage } from '@/utils/storage'
|
||||||
|
|
||||||
const $bluetooth = useBluetoothStore()
|
const $bluetooth = useBluetoothStore()
|
||||||
|
|
||||||
@ -57,6 +58,17 @@
|
|||||||
const data = list.value.find(item => item.sn === result.data.WXIoTDeviceInfo.SN)
|
const data = list.value.find(item => item.sn === result.data.WXIoTDeviceInfo.SN)
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data.status === 1) {
|
if (data.status === 1) {
|
||||||
|
if (reject.value) {
|
||||||
|
passthrough({
|
||||||
|
request_method: 'POST',
|
||||||
|
request_uri: '/api/v1/tencentYun/reportWechatAuthSuccess',
|
||||||
|
post_args: {
|
||||||
|
lockId: $bluetooth.currentLockInfo.lockId,
|
||||||
|
wxOpenid: getStorage('openid'),
|
||||||
|
wxDeviceSn: result.data.WXIoTDeviceInfo.SNTicket
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
reject.value = false
|
reject.value = false
|
||||||
} else if (data.status === 0) {
|
} else if (data.status === 0) {
|
||||||
reject.value = true
|
reject.value = true
|
||||||
@ -116,10 +128,19 @@
|
|||||||
snTicket: result.data.WXIoTDeviceInfo.SNTicket,
|
snTicket: result.data.WXIoTDeviceInfo.SNTicket,
|
||||||
modelId: result.data.WXIoTDeviceInfo.ModelId,
|
modelId: result.data.WXIoTDeviceInfo.ModelId,
|
||||||
deviceName: await env[await getApp().globalData.getEnvConfig()].appName,
|
deviceName: await env[await getApp().globalData.getEnvConfig()].appName,
|
||||||
success() {
|
async success() {
|
||||||
isAuthorized.value = true
|
isAuthorized.value = true
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
pending.value = false
|
pending.value = false
|
||||||
|
passthrough({
|
||||||
|
request_method: 'POST',
|
||||||
|
request_uri: '/api/v1/tencentYun/reportWechatAuthSuccess',
|
||||||
|
post_args: {
|
||||||
|
lockId: $bluetooth.currentLockInfo.lockId,
|
||||||
|
wxOpenid: getStorage('openid'),
|
||||||
|
wxDeviceSn: result.data.WXIoTDeviceInfo.SNTicket
|
||||||
|
}
|
||||||
|
})
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '授权成功',
|
title: '授权成功',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
|
|||||||
@ -13,6 +13,8 @@ import { updateTimezoneOffsetRequest } from '@/api/user'
|
|||||||
import log from '@/utils/log'
|
import log from '@/utils/log'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
import { getLastRecordTimeRequest, uploadRecordRequest } from '@/api/record'
|
import { getLastRecordTimeRequest, uploadRecordRequest } from '@/api/record'
|
||||||
|
import { transportType } from '@/constant/transportType'
|
||||||
|
import { passthrough } from '@/api/sdk'
|
||||||
|
|
||||||
// 定时器
|
// 定时器
|
||||||
let timer
|
let timer
|
||||||
@ -1312,32 +1314,52 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
// 写入特征值
|
// 写入特征值
|
||||||
async writeBLECharacteristicValue(binaryData) {
|
async transportMessage(binaryData) {
|
||||||
const that = this
|
const that = this
|
||||||
|
|
||||||
console.log('设备ID:', that.currentLockInfo.deviceId)
|
if (that.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) {
|
||||||
console.log('设备名称:', that.currentLockInfo.name)
|
const { code, data, message } = await passthrough({
|
||||||
console.log('设备主服务:', that.currentLockInfo.serviceId)
|
request_method: 'GET',
|
||||||
console.log('设备写入特征值:', that.currentLockInfo.writeCharacteristicId)
|
request_uri: '/api/v1/tencentYun/getTencentTriple',
|
||||||
console.log('设备写入数据:', Array.from(binaryData))
|
post_args: {
|
||||||
|
lockId: that.currentLockInfo.lockId,
|
||||||
// 次数
|
data: binaryData
|
||||||
const count = Math.ceil(binaryData.length / 20)
|
|
||||||
for (let i = 0; i < count; i++) {
|
|
||||||
const writeData = binaryData.slice(
|
|
||||||
i * 20,
|
|
||||||
i === count - 1 ? binaryData.length : (i + 1) * 20
|
|
||||||
)
|
|
||||||
|
|
||||||
uni.writeBLECharacteristicValue({
|
|
||||||
deviceId: that.currentLockInfo.deviceId,
|
|
||||||
serviceId: that.currentLockInfo.serviceId,
|
|
||||||
characteristicId: that.currentLockInfo.writeCharacteristicId,
|
|
||||||
value: writeData.buffer,
|
|
||||||
fail(res) {
|
|
||||||
console.log('写入失败', res)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (code === 0) {
|
||||||
|
that.parsingCharacteristicValue(data)
|
||||||
|
} else {
|
||||||
|
characteristicValueCallback({
|
||||||
|
code,
|
||||||
|
message
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('设备ID:', that.currentLockInfo.deviceId)
|
||||||
|
console.log('设备名称:', that.currentLockInfo.name)
|
||||||
|
console.log('设备主服务:', that.currentLockInfo.serviceId)
|
||||||
|
console.log('设备写入特征值:', that.currentLockInfo.writeCharacteristicId)
|
||||||
|
console.log('设备写入数据:', Array.from(binaryData))
|
||||||
|
|
||||||
|
// 次数
|
||||||
|
const count = Math.ceil(binaryData.length / 20)
|
||||||
|
for (let i = 0; i < count; i++) {
|
||||||
|
const writeData = binaryData.slice(
|
||||||
|
i * 20,
|
||||||
|
i === count - 1 ? binaryData.length : (i + 1) * 20
|
||||||
|
)
|
||||||
|
|
||||||
|
uni.writeBLECharacteristicValue({
|
||||||
|
deviceId: that.currentLockInfo.deviceId,
|
||||||
|
serviceId: that.currentLockInfo.serviceId,
|
||||||
|
characteristicId: that.currentLockInfo.writeCharacteristicId,
|
||||||
|
value: writeData.buffer,
|
||||||
|
fail(res) {
|
||||||
|
console.log('写入失败', res)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
@ -1446,8 +1468,8 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, contentArray)
|
const packageArray = this.createPackageEnd(headArray, contentArray)
|
||||||
|
|
||||||
await this.writeBLECharacteristicValue(packageArray)
|
await this.transportMessage(packageArray)
|
||||||
return this.getWriteResult()
|
return this.getResult()
|
||||||
},
|
},
|
||||||
// 获取私钥
|
// 获取私钥
|
||||||
async getCommKey(name, keyId, authUid, nowTime) {
|
async getCommKey(name, keyId, authUid, nowTime) {
|
||||||
@ -1518,8 +1540,8 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
await this.writeBLECharacteristicValue(packageArray)
|
await this.transportMessage(packageArray)
|
||||||
return this.getWriteResult()
|
return this.getResult()
|
||||||
},
|
},
|
||||||
// md5加密
|
// md5加密
|
||||||
md5Encrypte(text, token, key) {
|
md5Encrypte(text, token, key) {
|
||||||
@ -1538,6 +1560,70 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
},
|
},
|
||||||
// 获取锁状态
|
// 获取锁状态
|
||||||
async getLockStatus(data) {
|
async getLockStatus(data) {
|
||||||
|
// 确认蓝牙状态正常
|
||||||
|
if (
|
||||||
|
this.bluetoothStatus !== 0 &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
|
this.getBluetoothStatus()
|
||||||
|
return {
|
||||||
|
code: -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认设备连接正常
|
||||||
|
if (
|
||||||
|
!this.currentLockInfo.connected &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
|
if (searchResult.code !== 0) {
|
||||||
|
return searchResult
|
||||||
|
}
|
||||||
|
this.updateCurrentLockInfo({
|
||||||
|
...this.currentLockInfo,
|
||||||
|
deviceId: searchResult.data.deviceId
|
||||||
|
})
|
||||||
|
console.log('设备ID:', this.currentLockInfo.deviceId)
|
||||||
|
const result = await this.connectBluetoothDevice()
|
||||||
|
console.log('连接结果', result)
|
||||||
|
if (!result) {
|
||||||
|
return {
|
||||||
|
code: -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const { name, uid, nowTime, localTime } = data
|
||||||
|
const length = 2 + 40 + 20 + 4 + 4
|
||||||
|
const headArray = this.createPackageHeader(3, length)
|
||||||
|
|
||||||
|
const contentArray = new Uint8Array(length)
|
||||||
|
contentArray[0] = cmdIds.getLockStatus / 256
|
||||||
|
contentArray[1] = cmdIds.getLockStatus % 256
|
||||||
|
for (let i = 0; i < name.length; i++) {
|
||||||
|
contentArray[i + 2] = name.charCodeAt(i)
|
||||||
|
}
|
||||||
|
for (let i = 0; i < uid.length; i++) {
|
||||||
|
contentArray[i + 42] = uid.charCodeAt(i)
|
||||||
|
}
|
||||||
|
contentArray.set(this.timestampToArray(nowTime), 62)
|
||||||
|
contentArray.set(this.timestampToArray(localTime), 66)
|
||||||
|
|
||||||
|
const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.commKey, {
|
||||||
|
mode: 'ecb',
|
||||||
|
output: 'array'
|
||||||
|
})
|
||||||
|
|
||||||
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
|
await this.transportMessage(packageArray)
|
||||||
|
|
||||||
|
return this.getResult(this.getLockStatus, data)
|
||||||
|
},
|
||||||
|
// 获取锁状态
|
||||||
|
async getLockStatusInfo(data) {
|
||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (this.bluetoothStatus !== 0) {
|
if (this.bluetoothStatus !== 0) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
@ -1590,9 +1676,9 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
await this.writeBLECharacteristicValue(packageArray)
|
await this.transportMessage(packageArray)
|
||||||
|
|
||||||
return this.getWriteResult(this.getLockStatus, data)
|
return this.getResult(this.getLockStatusInfo, data)
|
||||||
},
|
},
|
||||||
// 获取Wi-Fi列表
|
// 获取Wi-Fi列表
|
||||||
async getWifiList(data) {
|
async getWifiList(data) {
|
||||||
@ -1643,9 +1729,9 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
await this.writeBLECharacteristicValue(packageArray)
|
await this.transportMessage(packageArray)
|
||||||
|
|
||||||
return this.getWriteResult(this.getWifiList, data)
|
return this.getResult(this.getWifiList, data)
|
||||||
},
|
},
|
||||||
// 配网
|
// 配网
|
||||||
async distributionNetwork(data) {
|
async distributionNetwork(data) {
|
||||||
@ -1707,9 +1793,9 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
await this.writeBLECharacteristicValue(packageArray)
|
await this.transportMessage(packageArray)
|
||||||
|
|
||||||
return this.getWriteResult(this.distributionNetwork, data)
|
return this.getResult(this.distributionNetwork, data)
|
||||||
},
|
},
|
||||||
// 时间戳转二进制
|
// 时间戳转二进制
|
||||||
timestampToArray(timestamp) {
|
timestampToArray(timestamp) {
|
||||||
@ -1728,7 +1814,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 添加用户
|
// 添加用户
|
||||||
async addLockUser(data) {
|
async addLockUser(data) {
|
||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (this.bluetoothStatus !== 0) {
|
if (
|
||||||
|
this.bluetoothStatus !== 0 &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
return {
|
return {
|
||||||
@ -1737,7 +1826,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (!this.currentLockInfo.connected) {
|
if (
|
||||||
|
!this.currentLockInfo.connected &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
return searchResult
|
return searchResult
|
||||||
@ -1838,8 +1930,8 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
await this.writeBLECharacteristicValue(packageArray, false)
|
await this.transportMessage(packageArray, false)
|
||||||
return this.getWriteResult(this.addLockUser, data)
|
return this.getResult(this.addLockUser, data)
|
||||||
},
|
},
|
||||||
// 添加用户
|
// 添加用户
|
||||||
async bindLock(data) {
|
async bindLock(data) {
|
||||||
@ -1954,14 +2046,14 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
await this.writeBLECharacteristicValue(packageArray, false)
|
await this.transportMessage(packageArray, false)
|
||||||
return this.getWriteResult(this.bindLock, data)
|
return this.getResult(this.bindLock, data)
|
||||||
},
|
},
|
||||||
// 获取写入结果
|
// 获取写入结果
|
||||||
getWriteResult(request, params) {
|
getResult(request, params) {
|
||||||
const $user = useUserStore()
|
const $user = useUserStore()
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const getWriteResultTimer = setTimeout(() => {
|
const getResultTimer = setTimeout(() => {
|
||||||
log.info({
|
log.info({
|
||||||
code: -1,
|
code: -1,
|
||||||
message: `操作失败,蓝牙操作超时`,
|
message: `操作失败,蓝牙操作超时`,
|
||||||
@ -1991,10 +2083,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
email: $user.userInfo.email
|
email: $user.userInfo.email
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
clearTimeout(getWriteResultTimer)
|
clearTimeout(getResultTimer)
|
||||||
resolve(await request(params))
|
resolve(await request(params))
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(getWriteResultTimer)
|
clearTimeout(getResultTimer)
|
||||||
resolve(data)
|
resolve(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2017,7 +2109,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (this.bluetoothStatus !== 0) {
|
if (
|
||||||
|
this.bluetoothStatus !== 0 &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
if (this.bluetoothStatus === -1) {
|
if (this.bluetoothStatus === -1) {
|
||||||
@ -2092,7 +2187,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (!this.currentLockInfo.connected) {
|
if (
|
||||||
|
!this.currentLockInfo.connected &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code === 0) {
|
if (searchResult.code === 0) {
|
||||||
log.info({
|
log.info({
|
||||||
@ -2332,9 +2430,9 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
email: $user.userInfo.email
|
email: $user.userInfo.email
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.writeBLECharacteristicValue(packageArray)
|
this.transportMessage(packageArray)
|
||||||
|
|
||||||
return this.getWriteResult(this.openDoor, data)
|
return this.getResult(this.openDoor, data)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error({
|
log.error({
|
||||||
code: -1,
|
code: -1,
|
||||||
@ -2349,7 +2447,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 清理用户
|
// 清理用户
|
||||||
async cleanLockUser(data) {
|
async cleanLockUser(data) {
|
||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (this.bluetoothStatus !== 0) {
|
if (
|
||||||
|
this.bluetoothStatus !== 0 &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
return {
|
return {
|
||||||
@ -2358,7 +2459,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (!this.currentLockInfo.connected) {
|
if (
|
||||||
|
!this.currentLockInfo.connected &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
return searchResult
|
return searchResult
|
||||||
@ -2431,14 +2535,17 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
await this.writeBLECharacteristicValue(packageArray)
|
await this.transportMessage(packageArray)
|
||||||
|
|
||||||
return this.getWriteResult(this.cleanLockUser, data)
|
return this.getResult(this.cleanLockUser, data)
|
||||||
},
|
},
|
||||||
// 恢复出厂设置
|
// 恢复出厂设置
|
||||||
async resetDevice(data) {
|
async resetDevice(data) {
|
||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (this.bluetoothStatus !== 0) {
|
if (
|
||||||
|
this.bluetoothStatus !== 0 &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
return {
|
return {
|
||||||
@ -2447,7 +2554,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (!this.currentLockInfo.connected) {
|
if (
|
||||||
|
!this.currentLockInfo.connected &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
return searchResult
|
return searchResult
|
||||||
@ -2506,14 +2616,17 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
await this.writeBLECharacteristicValue(packageArray)
|
await this.transportMessage(packageArray)
|
||||||
|
|
||||||
return this.getWriteResult(this.resetDevice, data)
|
return this.getResult(this.resetDevice, data)
|
||||||
},
|
},
|
||||||
// 重置开锁密码
|
// 重置开锁密码
|
||||||
async resetLockPassword(data) {
|
async resetLockPassword(data) {
|
||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (this.bluetoothStatus !== 0) {
|
if (
|
||||||
|
this.bluetoothStatus !== 0 &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
return {
|
return {
|
||||||
@ -2522,7 +2635,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (!this.currentLockInfo.connected) {
|
if (
|
||||||
|
!this.currentLockInfo.connected &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
return searchResult
|
return searchResult
|
||||||
@ -2589,14 +2705,17 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
await this.writeBLECharacteristicValue(packageArray)
|
await this.transportMessage(packageArray)
|
||||||
|
|
||||||
return this.getWriteResult(this.resetLockPassword, data)
|
return this.getResult(this.resetLockPassword, data)
|
||||||
},
|
},
|
||||||
// 设置密码
|
// 设置密码
|
||||||
async setLockPassword(data) {
|
async setLockPassword(data) {
|
||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (this.bluetoothStatus !== 0) {
|
if (
|
||||||
|
this.bluetoothStatus !== 0 &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
return {
|
return {
|
||||||
@ -2605,7 +2724,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (!this.currentLockInfo.connected) {
|
if (
|
||||||
|
!this.currentLockInfo.connected &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
return searchResult
|
return searchResult
|
||||||
@ -2688,9 +2810,9 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
await this.writeBLECharacteristicValue(packageArray)
|
await this.transportMessage(packageArray)
|
||||||
|
|
||||||
return this.getWriteResult(this.setLockPassword, data)
|
return this.getResult(this.setLockPassword, data)
|
||||||
},
|
},
|
||||||
parseTimeToList(timeString) {
|
parseTimeToList(timeString) {
|
||||||
let timeList = [0, 0, 0, 0]
|
let timeList = [0, 0, 0, 0]
|
||||||
@ -2706,7 +2828,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 注册身份认证
|
// 注册身份认证
|
||||||
async registerAuthentication(data) {
|
async registerAuthentication(data) {
|
||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (this.bluetoothStatus !== 0) {
|
if (
|
||||||
|
this.bluetoothStatus !== 0 &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
return {
|
return {
|
||||||
@ -2715,7 +2840,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (!this.currentLockInfo.connected) {
|
if (
|
||||||
|
!this.currentLockInfo.connected &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
return searchResult
|
return searchResult
|
||||||
@ -2835,9 +2963,9 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
await this.writeBLECharacteristicValue(packageArray)
|
await this.transportMessage(packageArray)
|
||||||
|
|
||||||
return this.getWriteResult(this.registerAuthentication, data)
|
return this.getResult(this.registerAuthentication, data)
|
||||||
},
|
},
|
||||||
// 注册身份认证取消
|
// 注册身份认证取消
|
||||||
async registerAuthenticationCancel(data) {
|
async registerAuthenticationCancel(data) {
|
||||||
@ -2892,14 +3020,17 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
await this.writeBLECharacteristicValue(packageArray)
|
await this.transportMessage(packageArray)
|
||||||
|
|
||||||
return this.getWriteResult(this.registerAuthenticationCancel, data)
|
return this.getResult(this.registerAuthenticationCancel, data)
|
||||||
},
|
},
|
||||||
// 获取操作记录
|
// 获取操作记录
|
||||||
async syncRecord(params) {
|
async syncRecord(params) {
|
||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (this.bluetoothStatus !== 0) {
|
if (
|
||||||
|
this.bluetoothStatus !== 0 &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
return {
|
return {
|
||||||
@ -2908,7 +3039,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (!this.currentLockInfo.connected) {
|
if (
|
||||||
|
!this.currentLockInfo.connected &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
return searchResult
|
return searchResult
|
||||||
@ -3013,14 +3147,17 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
await this.writeBLECharacteristicValue(packageArray)
|
await this.transportMessage(packageArray)
|
||||||
|
|
||||||
return this.getWriteResult(this.syncSingleRecord, data)
|
return this.getResult(this.syncSingleRecord, data)
|
||||||
},
|
},
|
||||||
// 更新管理员密码
|
// 更新管理员密码
|
||||||
async updateAdminPassword(data) {
|
async updateAdminPassword(data) {
|
||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (this.bluetoothStatus !== 0) {
|
if (
|
||||||
|
this.bluetoothStatus !== 0 &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
return {
|
return {
|
||||||
@ -3029,7 +3166,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (!this.currentLockInfo.connected) {
|
if (
|
||||||
|
!this.currentLockInfo.connected &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
return searchResult
|
return searchResult
|
||||||
@ -3109,14 +3249,17 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
await this.writeBLECharacteristicValue(packageArray)
|
await this.transportMessage(packageArray)
|
||||||
|
|
||||||
return this.getWriteResult(this.updateAdminPassword, data)
|
return this.getResult(this.updateAdminPassword, data)
|
||||||
},
|
},
|
||||||
// 更新设置
|
// 更新设置
|
||||||
async updateSetting(data) {
|
async updateSetting(data) {
|
||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (this.bluetoothStatus !== 0) {
|
if (
|
||||||
|
this.bluetoothStatus !== 0 &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
return {
|
return {
|
||||||
@ -3125,7 +3268,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (!this.currentLockInfo.connected) {
|
if (
|
||||||
|
!this.currentLockInfo.connected &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
return searchResult
|
return searchResult
|
||||||
@ -3210,14 +3356,17 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
await this.writeBLECharacteristicValue(packageArray)
|
await this.transportMessage(packageArray)
|
||||||
|
|
||||||
return this.getWriteResult(this.updateSetting, data)
|
return this.getResult(this.updateSetting, data)
|
||||||
},
|
},
|
||||||
// 校准时间
|
// 校准时间
|
||||||
async calibrationTime(data) {
|
async calibrationTime(data) {
|
||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (this.bluetoothStatus !== 0) {
|
if (
|
||||||
|
this.bluetoothStatus !== 0 &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
return {
|
return {
|
||||||
@ -3226,7 +3375,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (!this.currentLockInfo.connected) {
|
if (
|
||||||
|
!this.currentLockInfo.connected &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
return searchResult
|
return searchResult
|
||||||
@ -3288,14 +3440,17 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
this.writeBLECharacteristicValue(packageArray)
|
this.transportMessage(packageArray)
|
||||||
|
|
||||||
return this.getWriteResult(this.calibrationTime, data)
|
return this.getResult(this.calibrationTime, data)
|
||||||
},
|
},
|
||||||
// 获取锁数据列表
|
// 获取锁数据列表
|
||||||
async getLockDataList(data) {
|
async getLockDataList(data) {
|
||||||
// 确认蓝牙状态正常
|
// 确认蓝牙状态正常
|
||||||
if (this.bluetoothStatus !== 0) {
|
if (
|
||||||
|
this.bluetoothStatus !== 0 &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
return {
|
return {
|
||||||
@ -3304,7 +3459,10 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (!this.currentLockInfo.connected) {
|
if (
|
||||||
|
!this.currentLockInfo.connected &&
|
||||||
|
this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
|
||||||
|
) {
|
||||||
const searchResult = await this.searchAndConnectDevice()
|
const searchResult = await this.searchAndConnectDevice()
|
||||||
if (searchResult.code !== 0) {
|
if (searchResult.code !== 0) {
|
||||||
return searchResult
|
return searchResult
|
||||||
@ -3401,9 +3559,9 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
this.writeBLECharacteristicValue(packageArray)
|
this.transportMessage(packageArray)
|
||||||
|
|
||||||
return this.getWriteResult(this.getLockDataList, data)
|
return this.getResult(this.getLockDataList, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user