From b3c4cfb0fbffbc8bf7ac1147eea4ad0b85e7ac50 Mon Sep 17 00:00:00 2001 From: Zhang Hai Peng Date: Tue, 21 Jul 2026 10:53:28 +0800 Subject: [PATCH] fix(ble/bluedroid): track ext scan state for rand addr check Update inq_var.state only after btsnd_hcic_ble_ext_scan_enable succeeds. Clear BTM_BLE_SCANNING on explicit stop and controller scan timeout. (cherry picked from commit 23519567e4fb6aacbc6105024002dddf71501a17) Co-authored-by: zhanghaipeng --- components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c index 6caefb5b1a8..77f8e27a5bf 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c @@ -1093,6 +1093,12 @@ tBTM_STATUS BTM_BleExtendedScan(BOOLEAN enable, UINT16 duration, UINT16 period) if ((err = btsnd_hcic_ble_ext_scan_enable(enable, extend_adv_cb.scan_duplicate, duration, period)) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE ES En=%d: cmd err=0x%x", enable, err); status = BTM_HCI_ERROR | err; + } else { + if (enable) { + btm_cb.ble_ctr_cb.inq_var.state |= BTM_BLE_SCANNING; + } else { + btm_cb.ble_ctr_cb.inq_var.state &= ~BTM_BLE_SCANNING; + } } end: @@ -1245,6 +1251,7 @@ void btm_ble_update_phy_evt(tBTM_BLE_UPDATE_PHY *params) #if (BLE_50_EXTEND_SCAN_EN == TRUE) void btm_ble_scan_timeout_evt(void) { + btm_cb.ble_ctr_cb.inq_var.state &= ~BTM_BLE_SCANNING; BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_SCAN_TIMEOUT_EVT, NULL); } #endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE)