Auto Reconnect from Pipeline_A2DP_Sink Stream

RBAGDAZIAN
Posts: 5
Joined: Sun Feb 04, 2024 10:03 pm

Auto Reconnect from Pipeline_A2DP_Sink Stream

Postby RBAGDAZIAN » Fri Jul 11, 2025 11:14 pm

Hello,
I have built and successfully run the Pipeline_A2DP_Sink_Stream ESP-ADF project onto my ESP32 WROOM compatible board. I can connect via Bluetooth and play music and respond to button presses so everything seems to be working fine. My problem is that I would like the ESP32 board to auto reconnect to the last known A2DP source that completed pairing when it is available. I have been able to make this work using esp-idf example code, I can't figure out what I'm doing wrong in the ESP-ADF code.

When my application code receives a connection indication from the Source device I save its BDA address. Then when it disconnects, it attempts to reconnect periodically using a call to:
esp_a2d_sink_connect(&priorBDA[0]);

This function returns with an ESP_OK status, but in the BT_GAP event handling I get a notice that the connection has failed due to a timeout. I can't figure out what I'm doing wrong. I have set up the Bluetooth stack to use SSP Just Works authentication, but for somereason, it isn't able to complete the authentication.

I was wondering if anyone has insight into what I might be missing,

Thanks in advance.

RBAGDAZIAN
Posts: 5
Joined: Sun Feb 04, 2024 10:03 pm

Re: Auto Reconnect from Pipeline_A2DP_Sink Stream

Postby RBAGDAZIAN » Sun Jul 13, 2025 4:32 pm

I was able to figure out what I was doing wrong. here's the right way to obtain the remote BDA during a connection event in the a2sp sink call back handler:
.
.
.
switch (event) {
case ESP_A2D_CONNECTION_STATE_EVT:
a2d = (esp_a2d_cb_param_t *)(p_param);
uint8_t *bda = a2d->conn_stat.remote_bda;
ESP_LOGD(TAG, "A2DP connection state: %s, [%02x:%02x:%02x:%02x:%02x:%02x]",
conn_state_str[a2d->conn_stat.state], bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);

cofiemark™
Posts: 2
Joined: Wed Jul 23, 2025 7:08 am

Re: Auto Reconnect from Pipeline_A2DP_Sink Stream

Postby cofiemark™ » Wed Jul 23, 2025 7:21 am

Great to hear you've been able to resolve the reconnection problem. Which esp-idf example did you use for this project... I'm just being curious ;)

Who is online

Users browsing this forum: No registered users and 2 guests