@@ -47,6 +47,7 @@ typedef struct {
4747 bool avrcp_conn_state ;
4848 audio_stream_type_t stream_type ;
4949 uint8_t trans_label ;
50+ esp_bd_addr_t connected_bd_addr ;
5051
5152#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL (4 , 0 , 0 ))
5253 audio_hal_handle_t audio_hal ;
@@ -121,6 +122,7 @@ static void bt_a2d_sink_cb(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param)
121122 bda [0 ], bda [1 ], bda [2 ], bda [3 ], bda [4 ], bda [5 ]);
122123 if (param -> conn_stat .state == ESP_A2D_CONNECTION_STATE_DISCONNECTED ) {
123124 ESP_LOGI (TAG , "A2DP connection state = DISCONNECTED" );
125+ memset (s_aadp_handler .connected_bd_addr , 0x00 , ESP_BD_ADDR_LEN );
124126 if (s_aadp_handler .sink_stream ) {
125127 audio_element_report_status (s_aadp_handler .sink_stream , AEL_STATUS_INPUT_DONE );
126128 }
@@ -129,6 +131,7 @@ static void bt_a2d_sink_cb(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param)
129131 }
130132 } else if (param -> conn_stat .state == ESP_A2D_CONNECTION_STATE_CONNECTED ) {
131133 ESP_LOGI (TAG , "A2DP connection state = CONNECTED" );
134+ memcpy (s_aadp_handler .connected_bd_addr , bda , ESP_BD_ADDR_LEN );
132135 if (s_aadp_handler .bt_avrc_periph ) {
133136 esp_periph_send_event (s_aadp_handler .bt_avrc_periph , PERIPH_BLUETOOTH_CONNECTED , NULL , 0 );
134137 }
@@ -614,4 +617,12 @@ esp_err_t periph_bt_volume_down(esp_periph_handle_t periph)
614617}
615618#endif
616619
620+ esp_err_t periph_bt_get_connected_bd_addr (esp_periph_handle_t periph , uint8_t * dest )
621+ {
622+ if (!dest )
623+ return ESP_ERR_INVALID_ARG ;
624+ memcpy (dest , s_aadp_handler .connected_bd_addr , ESP_BD_ADDR_LEN );
625+ return ESP_OK ;
626+ }
627+
617628#endif
0 commit comments