diff --git a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_bt.c b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_bt.c index fe941aabb..de48e7e71 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_bt.c +++ b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_bt.c @@ -950,11 +950,12 @@ void btc_gap_bt_busy_level_updated(uint8_t bl_flags) param.disc_st_chg.state = ESP_BT_GAP_DISCOVERY_STARTED; btc_gap_bt_cb_to_app(ESP_BT_GAP_DISC_STATE_CHANGED_EVT, ¶m); btc_gap_bt_inquiry_in_progress = true; - } else if (bl_flags == BTM_BL_INQUIRY_CANCELLED || - bl_flags == BTM_BL_INQUIRY_COMPLETE) { + } else if (bl_flags == BTM_BL_INQUIRY_CANCELLED) { param.disc_st_chg.state = ESP_BT_GAP_DISCOVERY_STOPPED; btc_gap_bt_cb_to_app(ESP_BT_GAP_DISC_STATE_CHANGED_EVT, ¶m); btc_gap_bt_inquiry_in_progress = false; + } else if (bl_flags == BTM_BL_INQUIRY_COMPLETE) { + btc_gap_bt_inquiry_in_progress = false; } } diff --git a/examples/bluetooth/esp_hid_device/main/esp_hid_gap.c b/examples/bluetooth/esp_hid_device/main/esp_hid_gap.c index 428a1356a..2c3ff904d 100644 --- a/examples/bluetooth/esp_hid_device/main/esp_hid_gap.c +++ b/examples/bluetooth/esp_hid_device/main/esp_hid_gap.c @@ -379,18 +379,10 @@ static void handle_ble_device_result(struct ble_scan_result_evt_param *scan_rst) static void bt_gap_event_handler(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param) { - static bool scan_running = false; - static bool scan_wait_stop = false; switch (event) { case ESP_BT_GAP_DISC_STATE_CHANGED_EVT: { ESP_LOGV(TAG, "BT GAP DISC_STATE %s", (param->disc_st_chg.state == ESP_BT_GAP_DISCOVERY_STARTED) ? "START" : "STOP"); - if (param->disc_st_chg.state == ESP_BT_GAP_DISCOVERY_STARTED) { - scan_running = true; - scan_wait_stop = true; - } else if (scan_wait_stop) { - scan_wait_stop = false; - } else if (scan_running) { - scan_running = false; + if (param->disc_st_chg.state == ESP_BT_GAP_DISCOVERY_STOPPED) { SEND_BT_CB(); } break; diff --git a/examples/bluetooth/esp_hid_host/main/esp_hid_gap.c b/examples/bluetooth/esp_hid_host/main/esp_hid_gap.c index 428a1356a..2c3ff904d 100644 --- a/examples/bluetooth/esp_hid_host/main/esp_hid_gap.c +++ b/examples/bluetooth/esp_hid_host/main/esp_hid_gap.c @@ -379,18 +379,10 @@ static void handle_ble_device_result(struct ble_scan_result_evt_param *scan_rst) static void bt_gap_event_handler(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param) { - static bool scan_running = false; - static bool scan_wait_stop = false; switch (event) { case ESP_BT_GAP_DISC_STATE_CHANGED_EVT: { ESP_LOGV(TAG, "BT GAP DISC_STATE %s", (param->disc_st_chg.state == ESP_BT_GAP_DISCOVERY_STARTED) ? "START" : "STOP"); - if (param->disc_st_chg.state == ESP_BT_GAP_DISCOVERY_STARTED) { - scan_running = true; - scan_wait_stop = true; - } else if (scan_wait_stop) { - scan_wait_stop = false; - } else if (scan_running) { - scan_running = false; + if (param->disc_st_chg.state == ESP_BT_GAP_DISCOVERY_STOPPED) { SEND_BT_CB(); } break;