diff --git a/basic.js b/basic.js index bc745bf..37ced86 100644 --- a/basic.js +++ b/basic.js @@ -257,21 +257,12 @@ function openBluetoothAdapter() { } // 关闭蓝牙模块 -function closeBluetoothAdapter() { - return new Promise(resolve => { - uni.closeBluetoothAdapter({ - success() { - resolve(Result.Success) - }, - async fail(err) { - resolve(await handleError(err)) - } - }) - }) +export function closeBluetoothAdapter() { + uni.closeBluetoothAdapter() } // 移除蓝牙适配器的全部监听 -function offBluetoothAdapterStateChange() { +export function offBluetoothAdapterStateChange() { uni.offBluetoothAdapterStateChange() } diff --git a/starCloud.js b/starCloud.js index 0fc6bb2..fbfd96b 100644 --- a/starCloud.js +++ b/starCloud.js @@ -18,8 +18,10 @@ import { import { getStorage, removeStorage, setStorage } from '@/starCloud/storage' import { closeBLEConnection, + closeBluetoothAdapter, createBLEConnection, getBluetoothDevices, + offBluetoothAdapterStateChange, onBLECharacteristicValueChange, Result, searchAndConnectDevice, @@ -659,6 +661,10 @@ export const useStarCloudStore = defineStore('starCloud', { if (addUserResult.code !== Result.Success.code) { return addUserResult } + + offBluetoothAdapterStateChange() + closeBluetoothAdapter() + const params = { lockAlias: this.lockInfo.bluetooth.bluetoothDeviceName, lockInfo: {