mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-18 23:54:39 +00:00
Modify esp_bt_gap_set_scan_mode() to be able to set connection modes as well as discoverable modes
The current API is insufficient to allow the users to set different combinations of connection and discoverable mode Users should be able to choose the device modes independently: 1. Connectable- i. Non-connectable mode ii. Connectable mode 2. Discoverable- i. Non-discoverable mode ii. Limited discoverable mode iii. General discoverable mode
This commit is contained in:
@@ -328,7 +328,7 @@ static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
|
||||
esp_a2d_source_init();
|
||||
|
||||
/* set discoverable and connectable mode */
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
|
||||
|
||||
/* start device discovery */
|
||||
ESP_LOGI(BT_AV_TAG, "Starting device discovery...");
|
||||
@@ -434,7 +434,7 @@ static void bt_app_av_state_connecting(uint16_t event, void *param)
|
||||
ESP_LOGI(BT_AV_TAG, "a2dp connected");
|
||||
s_a2d_state = APP_AV_STATE_CONNECTED;
|
||||
s_media_state = APP_AV_MEDIA_STATE_IDLE;
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_SCAN_MODE_NONE);
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_NON_CONNECTABLE, ESP_BT_NON_DISCOVERABLE);
|
||||
} else if (a2d->conn_stat.state == ESP_A2D_CONNECTION_STATE_DISCONNECTED) {
|
||||
s_a2d_state = APP_AV_STATE_UNCONNECTED;
|
||||
}
|
||||
@@ -530,7 +530,7 @@ static void bt_app_av_state_connected(uint16_t event, void *param)
|
||||
if (a2d->conn_stat.state == ESP_A2D_CONNECTION_STATE_DISCONNECTED) {
|
||||
ESP_LOGI(BT_AV_TAG, "a2dp disconnected");
|
||||
s_a2d_state = APP_AV_STATE_UNCONNECTED;
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -564,7 +564,7 @@ static void bt_app_av_state_disconnecting(uint16_t event, void *param)
|
||||
if (a2d->conn_stat.state == ESP_A2D_CONNECTION_STATE_DISCONNECTED) {
|
||||
ESP_LOGI(BT_AV_TAG, "a2dp disconnected");
|
||||
s_a2d_state = APP_AV_STATE_UNCONNECTED;
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
|
||||
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user