diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index 27c8944..e29e48e 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -9,7 +9,8 @@ module.exports = {
uni: 'writable',
getApp: 'writable',
wx: 'writable',
- getCurrentPages: 'writable'
+ getCurrentPages: 'writable',
+ requirePlugin: 'writable'
},
// 指定如何解析语法
parser: 'vue-eslint-parser',
diff --git a/App.vue b/App.vue
index 6b24e74..18c5e7f 100644
--- a/App.vue
+++ b/App.vue
@@ -16,6 +16,7 @@
appid: '',
// 小程序版本
envVersion: '',
+ sn: '',
// 获取环境配置
getEnvConfig() {
const envVersionStorage = getStorage('envVersion')
@@ -84,6 +85,13 @@
key: 'Call',
routeType: 'switchTab'
})
+
+ wmpfVoip.onVoipEvent(event => {
+ if (event.eventName === 'callPageOnShow') {
+ const query = wmpfVoip.getPluginOnloadOptions()
+ getApp().globalData.sn = query.callerId
+ }
+ })
},
// 强制升级
updateMiniProgram() {
@@ -104,5 +112,5 @@
diff --git a/constant/transportType.js b/constant/transportType.js
new file mode 100644
index 0000000..7effc3f
--- /dev/null
+++ b/constant/transportType.js
@@ -0,0 +1,7 @@
+export const transportType = {
+ TRANSPORT_BLUETOOTH: 0,
+ TRANSPORT_OFFLINE: 10,
+ TRANSPORT_GATEWAY: 20,
+ TRANSPORT_WIFI: 30,
+ TRANSPORT_TENCENT_YUN: 40
+}
diff --git a/pages/addDevice/searchDevice.vue b/pages/addDevice/searchDevice.vue
index abdb58f..b1f0689 100644
--- a/pages/addDevice/searchDevice.vue
+++ b/pages/addDevice/searchDevice.vue
@@ -67,7 +67,7 @@
'getCommKey',
'connectBluetoothDevice',
'updateServerTimestamp',
- 'getLockStatus'
+ 'getLockStatusInfo'
]),
...mapActions(useBasicStore, ['getDeviceInfo', 'routeJump', 'getNetworkType']),
async connect(device) {
@@ -123,7 +123,7 @@
}
const date = new Date()
const timestamp = this.serverTimestamp - date.getTimezoneOffset() * 60
- const { code } = await this.getLockStatus({
+ const { code } = await this.getLockStatusInfo({
name: this.currentLockInfo.name,
uid: this.userInfo.uid.toString(),
nowTime: this.serverTimestamp,
@@ -148,7 +148,8 @@
icon: 'none'
})
}
- } catch (res) {
+ } catch (error) {
+ console.log('连接失败', error)
uni.hideLoading()
uni.showToast({
title: '连接失败,请靠近设备并保持设备处于唤醒状态',
diff --git a/pages/main/customBox.vue b/pages/main/customBox.vue
index 2249512..c616fe2 100644
--- a/pages/main/customBox.vue
+++ b/pages/main/customBox.vue
@@ -1,5 +1,5 @@
-
+
{
- const { code, data, message } = await getLockDetailRequest({
- lockId: lockId.value
+ const accountInfo = uni.getAccountInfoSync()
+ 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
- $bluetooth.updateCurrentLockInfo({
- ...lockInfo.value,
- name: lockInfo.value.lockName,
- deviceId: lockInfo.value.lockName,
- commKey: lockInfo.value.privateKey
+
+ if (result.code === 0) {
+ lockId.value = result.data.lockId
+ const { code, data, message } = await getLockDetailRequest({
+ lockId: lockId.value
})
+ 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 {
uni.showToast({
- title: message,
+ title: result.message,
icon: 'none'
})
}
- await getServeTime()
})
const getServeTime = async () => {
diff --git a/pages/p2p/authorizeWechat.vue b/pages/p2p/authorizeWechat.vue
index 5c957bb..75d6808 100644
--- a/pages/p2p/authorizeWechat.vue
+++ b/pages/p2p/authorizeWechat.vue
@@ -32,6 +32,7 @@
import { passthrough } from '@/api/sdk'
import { useBluetoothStore } from '@/stores/bluetooth'
import env from '@/config/env'
+ import { getStorage } from '@/utils/storage'
const $bluetooth = useBluetoothStore()
@@ -57,6 +58,17 @@
const data = list.value.find(item => item.sn === result.data.WXIoTDeviceInfo.SN)
if (data) {
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
} else if (data.status === 0) {
reject.value = true
@@ -116,10 +128,19 @@
snTicket: result.data.WXIoTDeviceInfo.SNTicket,
modelId: result.data.WXIoTDeviceInfo.ModelId,
deviceName: await env[await getApp().globalData.getEnvConfig()].appName,
- success() {
+ async success() {
isAuthorized.value = true
uni.hideLoading()
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({
title: '授权成功',
icon: 'none'
diff --git a/stores/bluetooth.js b/stores/bluetooth.js
index 71a91a2..b5c5610 100644
--- a/stores/bluetooth.js
+++ b/stores/bluetooth.js
@@ -13,6 +13,8 @@ import { updateTimezoneOffsetRequest } from '@/api/user'
import log from '@/utils/log'
import { useUserStore } from '@/stores/user'
import { getLastRecordTimeRequest, uploadRecordRequest } from '@/api/record'
+import { transportType } from '@/constant/transportType'
+import { passthrough } from '@/api/sdk'
// 定时器
let timer
@@ -1312,32 +1314,52 @@ export const useBluetoothStore = defineStore('ble', {
return true
},
// 写入特征值
- async writeBLECharacteristicValue(binaryData) {
+ async transportMessage(binaryData) {
const that = this
- 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)
+ if (that.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) {
+ const { code, data, message } = await passthrough({
+ request_method: 'GET',
+ request_uri: '/api/v1/tencentYun/getTencentTriple',
+ post_args: {
+ lockId: that.currentLockInfo.lockId,
+ data: binaryData
}
})
+
+ 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)
- await this.writeBLECharacteristicValue(packageArray)
- return this.getWriteResult()
+ await this.transportMessage(packageArray)
+ return this.getResult()
},
// 获取私钥
async getCommKey(name, keyId, authUid, nowTime) {
@@ -1518,8 +1540,8 @@ export const useBluetoothStore = defineStore('ble', {
const packageArray = this.createPackageEnd(headArray, cebArray)
- await this.writeBLECharacteristicValue(packageArray)
- return this.getWriteResult()
+ await this.transportMessage(packageArray)
+ return this.getResult()
},
// md5加密
md5Encrypte(text, token, key) {
@@ -1538,6 +1560,70 @@ export const useBluetoothStore = defineStore('ble', {
},
// 获取锁状态
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) {
console.log('写入未执行', this.bluetoothStatus)
@@ -1590,9 +1676,9 @@ export const useBluetoothStore = defineStore('ble', {
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列表
async getWifiList(data) {
@@ -1643,9 +1729,9 @@ export const useBluetoothStore = defineStore('ble', {
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) {
@@ -1707,9 +1793,9 @@ export const useBluetoothStore = defineStore('ble', {
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) {
@@ -1728,7 +1814,10 @@ export const useBluetoothStore = defineStore('ble', {
// 添加用户
async addLockUser(data) {
// 确认蓝牙状态正常
- if (this.bluetoothStatus !== 0) {
+ if (
+ this.bluetoothStatus !== 0 &&
+ this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
+ ) {
console.log('写入未执行', this.bluetoothStatus)
this.getBluetoothStatus()
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()
if (searchResult.code !== 0) {
return searchResult
@@ -1838,8 +1930,8 @@ export const useBluetoothStore = defineStore('ble', {
})
const packageArray = this.createPackageEnd(headArray, cebArray)
- await this.writeBLECharacteristicValue(packageArray, false)
- return this.getWriteResult(this.addLockUser, data)
+ await this.transportMessage(packageArray, false)
+ return this.getResult(this.addLockUser, data)
},
// 添加用户
async bindLock(data) {
@@ -1954,14 +2046,14 @@ export const useBluetoothStore = defineStore('ble', {
})
const packageArray = this.createPackageEnd(headArray, cebArray)
- await this.writeBLECharacteristicValue(packageArray, false)
- return this.getWriteResult(this.bindLock, data)
+ await this.transportMessage(packageArray, false)
+ return this.getResult(this.bindLock, data)
},
// 获取写入结果
- getWriteResult(request, params) {
+ getResult(request, params) {
const $user = useUserStore()
return new Promise(resolve => {
- const getWriteResultTimer = setTimeout(() => {
+ const getResultTimer = setTimeout(() => {
log.info({
code: -1,
message: `操作失败,蓝牙操作超时`,
@@ -1991,10 +2083,10 @@ export const useBluetoothStore = defineStore('ble', {
email: $user.userInfo.email
}
})
- clearTimeout(getWriteResultTimer)
+ clearTimeout(getResultTimer)
resolve(await request(params))
} else {
- clearTimeout(getWriteResultTimer)
+ clearTimeout(getResultTimer)
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)
this.getBluetoothStatus()
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()
if (searchResult.code === 0) {
log.info({
@@ -2332,9 +2430,9 @@ export const useBluetoothStore = defineStore('ble', {
email: $user.userInfo.email
}
})
- this.writeBLECharacteristicValue(packageArray)
+ this.transportMessage(packageArray)
- return this.getWriteResult(this.openDoor, data)
+ return this.getResult(this.openDoor, data)
} catch (e) {
log.error({
code: -1,
@@ -2349,7 +2447,10 @@ export const useBluetoothStore = defineStore('ble', {
// 清理用户
async cleanLockUser(data) {
// 确认蓝牙状态正常
- if (this.bluetoothStatus !== 0) {
+ if (
+ this.bluetoothStatus !== 0 &&
+ this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
+ ) {
console.log('写入未执行', this.bluetoothStatus)
this.getBluetoothStatus()
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()
if (searchResult.code !== 0) {
return searchResult
@@ -2431,14 +2535,17 @@ export const useBluetoothStore = defineStore('ble', {
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) {
// 确认蓝牙状态正常
- if (this.bluetoothStatus !== 0) {
+ if (
+ this.bluetoothStatus !== 0 &&
+ this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
+ ) {
console.log('写入未执行', this.bluetoothStatus)
this.getBluetoothStatus()
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()
if (searchResult.code !== 0) {
return searchResult
@@ -2506,14 +2616,17 @@ export const useBluetoothStore = defineStore('ble', {
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) {
// 确认蓝牙状态正常
- if (this.bluetoothStatus !== 0) {
+ if (
+ this.bluetoothStatus !== 0 &&
+ this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
+ ) {
console.log('写入未执行', this.bluetoothStatus)
this.getBluetoothStatus()
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()
if (searchResult.code !== 0) {
return searchResult
@@ -2589,14 +2705,17 @@ export const useBluetoothStore = defineStore('ble', {
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) {
// 确认蓝牙状态正常
- if (this.bluetoothStatus !== 0) {
+ if (
+ this.bluetoothStatus !== 0 &&
+ this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
+ ) {
console.log('写入未执行', this.bluetoothStatus)
this.getBluetoothStatus()
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()
if (searchResult.code !== 0) {
return searchResult
@@ -2688,9 +2810,9 @@ export const useBluetoothStore = defineStore('ble', {
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) {
let timeList = [0, 0, 0, 0]
@@ -2706,7 +2828,10 @@ export const useBluetoothStore = defineStore('ble', {
// 注册身份认证
async registerAuthentication(data) {
// 确认蓝牙状态正常
- if (this.bluetoothStatus !== 0) {
+ if (
+ this.bluetoothStatus !== 0 &&
+ this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
+ ) {
console.log('写入未执行', this.bluetoothStatus)
this.getBluetoothStatus()
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()
if (searchResult.code !== 0) {
return searchResult
@@ -2835,9 +2963,9 @@ export const useBluetoothStore = defineStore('ble', {
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) {
@@ -2892,14 +3020,17 @@ export const useBluetoothStore = defineStore('ble', {
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) {
// 确认蓝牙状态正常
- if (this.bluetoothStatus !== 0) {
+ if (
+ this.bluetoothStatus !== 0 &&
+ this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
+ ) {
console.log('写入未执行', this.bluetoothStatus)
this.getBluetoothStatus()
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()
if (searchResult.code !== 0) {
return searchResult
@@ -3013,14 +3147,17 @@ export const useBluetoothStore = defineStore('ble', {
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) {
// 确认蓝牙状态正常
- if (this.bluetoothStatus !== 0) {
+ if (
+ this.bluetoothStatus !== 0 &&
+ this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
+ ) {
console.log('写入未执行', this.bluetoothStatus)
this.getBluetoothStatus()
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()
if (searchResult.code !== 0) {
return searchResult
@@ -3109,14 +3249,17 @@ export const useBluetoothStore = defineStore('ble', {
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) {
// 确认蓝牙状态正常
- if (this.bluetoothStatus !== 0) {
+ if (
+ this.bluetoothStatus !== 0 &&
+ this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
+ ) {
console.log('写入未执行', this.bluetoothStatus)
this.getBluetoothStatus()
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()
if (searchResult.code !== 0) {
return searchResult
@@ -3210,14 +3356,17 @@ export const useBluetoothStore = defineStore('ble', {
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) {
// 确认蓝牙状态正常
- if (this.bluetoothStatus !== 0) {
+ if (
+ this.bluetoothStatus !== 0 &&
+ this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
+ ) {
console.log('写入未执行', this.bluetoothStatus)
this.getBluetoothStatus()
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()
if (searchResult.code !== 0) {
return searchResult
@@ -3288,14 +3440,17 @@ export const useBluetoothStore = defineStore('ble', {
})
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) {
// 确认蓝牙状态正常
- if (this.bluetoothStatus !== 0) {
+ if (
+ this.bluetoothStatus !== 0 &&
+ this.currentLockInfo.transport_type !== transportType.TRANSPORT_TENCENT_YUN
+ ) {
console.log('写入未执行', this.bluetoothStatus)
this.getBluetoothStatus()
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()
if (searchResult.code !== 0) {
return searchResult
@@ -3401,9 +3559,9 @@ export const useBluetoothStore = defineStore('ble', {
})
const packageArray = this.createPackageEnd(headArray, cebArray)
- this.writeBLECharacteristicValue(packageArray)
+ this.transportMessage(packageArray)
- return this.getWriteResult(this.getLockDataList, data)
+ return this.getResult(this.getLockDataList, data)
}
}
})