From cc02eb5998c23f1d9ddaeb7834f96f7524ed9b9f Mon Sep 17 00:00:00 2001 From: ozh Date: Thu, 30 Apr 2026 16:52:48 +0800 Subject: [PATCH] =?UTF-8?q?fix(ble):=20=E4=BF=AE=E5=A4=8D=E9=A6=96?= =?UTF-8?q?=E6=AC=A1=E6=90=9C=E7=B4=A2=E6=97=B6=20stopDiscovery=20?= =?UTF-8?q?=E8=AF=AF=E6=8A=A5=E9=80=82=E9=85=8D=E5=99=A8=E6=9C=AA=E6=89=93?= =?UTF-8?q?=E5=BC=80=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit stopDiscoverySilently 移入 initialized 判断块内,仅在适配器已初始化时才尝试停止扫描 --- hooks/useBluetoothDiscovery.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hooks/useBluetoothDiscovery.js b/hooks/useBluetoothDiscovery.js index 60c54b0..8c678aa 100644 --- a/hooks/useBluetoothDiscovery.js +++ b/hooks/useBluetoothDiscovery.js @@ -384,7 +384,7 @@ export function createBluetoothDiscovery(options = {}) { } offStateChange = controller.ble.on('state:change', (state) => { - console.debug('state:change', state) + // console.debug('state:change', state) onStageChange(state.stage) if (state.profileId && state.profileId !== currentProfileId) { @@ -615,11 +615,9 @@ export function createBluetoothDiscovery(options = {}) { clearDiscoveryPollTimer() clearAutoStopTimer() - // 先停止上一次残留扫描 - await stopDiscoverySilently() - // 重置 BLE 适配器:关闭并重开,确保每次搜索都是干净的初始状态 if (initialized) { + await stopDiscoverySilently() unbindControllerEvents() await controller.ble.closeAdapter() await delay(RESTART_SCAN_DELAY_MS)