Skip to content

Commit

Permalink
Merge branch 'bugfix/a2dp_source_app_state_error_v4.4' into 'release/…
Browse files Browse the repository at this point in the history
…v4.4'

bt: Fixed the issue that the a2dp source would not send the media start command due to the connection initiated by the peer device(v4.4)

See merge request espressif/esp-idf!23555
  • Loading branch information
jack0c committed Jun 9, 2023
2 parents 4462c00 + 0a40826 commit 01cc59c
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
esp_a2d_register_callback(&bt_app_a2d_cb);
esp_a2d_source_register_data_callback(bt_app_a2d_data_cb);

esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
/* Avoid the state error of s_a2d_state caused by the connection initiated by the peer device. */
esp_bt_gap_set_scan_mode(ESP_BT_NON_CONNECTABLE, ESP_BT_NON_DISCOVERABLE);

ESP_LOGI(BT_AV_TAG, "Starting device discovery...");
s_a2d_state = APP_AV_STATE_DISCOVERING;
Expand Down Expand Up @@ -432,7 +433,6 @@ static void bt_app_av_state_connecting_hdlr(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_NON_CONNECTABLE, ESP_BT_NON_DISCOVERABLE);
} else if (a2d->conn_stat.state == ESP_A2D_CONNECTION_STATE_DISCONNECTED) {
s_a2d_state = APP_AV_STATE_UNCONNECTED;
}
Expand Down Expand Up @@ -539,7 +539,6 @@ static void bt_app_av_state_connected_hdlr(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_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
}
break;
}
Expand Down Expand Up @@ -576,7 +575,6 @@ static void bt_app_av_state_disconnecting_hdlr(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_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
}
break;
}
Expand Down

0 comments on commit 01cc59c

Please sign in to comment.