btdm:fix emit ESP_BT_GAP_DISC_STATE_CHANGED_EVT event when call API esp_bt_gap_start_discovery

closes BT-594

See merge request espressif/esp-idf!8808
This commit is contained in:
liqigan 2020-05-20 22:43:44 +08:00
parent 56c307b356
commit 55f6a927b5
3 changed files with 5 additions and 20 deletions

View file

@ -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, &param);
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, &param);
btc_gap_bt_inquiry_in_progress = false;
} else if (bl_flags == BTM_BL_INQUIRY_COMPLETE) {
btc_gap_bt_inquiry_in_progress = false;
}
}

View file

@ -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;

View file

@ -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;