mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
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:
parent
56c307b356
commit
55f6a927b5
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user