@@ -47,6 +47,7 @@ typedef struct {
47
47
bool avrcp_conn_state ;
48
48
audio_stream_type_t stream_type ;
49
49
uint8_t trans_label ;
50
+ esp_bd_addr_t connected_bd_addr ;
50
51
51
52
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL (4 , 0 , 0 ))
52
53
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)
121
122
bda [0 ], bda [1 ], bda [2 ], bda [3 ], bda [4 ], bda [5 ]);
122
123
if (param -> conn_stat .state == ESP_A2D_CONNECTION_STATE_DISCONNECTED ) {
123
124
ESP_LOGI (TAG , "A2DP connection state = DISCONNECTED" );
125
+ memset (s_aadp_handler .connected_bd_addr , 0x00 , ESP_BD_ADDR_LEN );
124
126
if (s_aadp_handler .sink_stream ) {
125
127
audio_element_report_status (s_aadp_handler .sink_stream , AEL_STATUS_INPUT_DONE );
126
128
}
@@ -129,6 +131,7 @@ static void bt_a2d_sink_cb(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param)
129
131
}
130
132
} else if (param -> conn_stat .state == ESP_A2D_CONNECTION_STATE_CONNECTED ) {
131
133
ESP_LOGI (TAG , "A2DP connection state = CONNECTED" );
134
+ memcpy (s_aadp_handler .connected_bd_addr , bda , ESP_BD_ADDR_LEN );
132
135
if (s_aadp_handler .bt_avrc_periph ) {
133
136
esp_periph_send_event (s_aadp_handler .bt_avrc_periph , PERIPH_BLUETOOTH_CONNECTED , NULL , 0 );
134
137
}
@@ -614,4 +617,12 @@ esp_err_t periph_bt_volume_down(esp_periph_handle_t periph)
614
617
}
615
618
#endif
616
619
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
+
617
628
#endif
0 commit comments