Skip to content

Commit 1a6c9d7

Browse files
committed
feat(bt): Add API to get profile status
1 parent cc4fc21 commit 1a6c9d7

39 files changed

+582
-35
lines changed

components/bt/common/btc/core/btc_task.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,9 @@ bt_status_t btc_init(void)
536536
return BT_STATUS_NOMEM;
537537
}
538538
#endif
539+
#if BTC_GAP_BT_INCLUDED
540+
btc_gap_bt_init();
541+
#endif
539542

540543
#if (BLE_INCLUDED == TRUE)
541544
btc_gap_callback_init();
@@ -554,6 +557,9 @@ bt_status_t btc_init(void)
554557

555558
void btc_deinit(void)
556559
{
560+
#if BTC_GAP_BT_INCLUDED
561+
btc_gap_bt_deinit();
562+
#endif
557563
#if BTC_DYNAMIC_MEMORY
558564
btc_deinit_mem();
559565
#endif

components/bt/host/bluedroid/api/esp_a2dp_api.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,21 @@ esp_err_t esp_a2d_media_ctrl(esp_a2d_media_ctrl_t ctrl)
313313
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
314314
}
315315

316+
esp_err_t esp_a2d_get_profile_status(esp_a2d_profile_status_t *profile_status)
317+
{
318+
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
319+
return ESP_ERR_INVALID_STATE;
320+
}
321+
if (profile_status == NULL) {
322+
return ESP_ERR_INVALID_ARG;
323+
}
324+
325+
memset(profile_status, 0, sizeof(esp_a2d_profile_status_t));
326+
btc_a2dp_get_profile_status(profile_status);
327+
328+
return ESP_OK;
329+
}
330+
316331
#if BTC_AV_SRC_INCLUDED
317332
esp_err_t esp_a2d_source_init(void)
318333
{

components/bt/host/bluedroid/api/esp_gap_bt_api.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -554,4 +554,20 @@ esp_err_t esp_bt_gap_get_device_name(void)
554554
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
555555
}
556556

557+
esp_err_t esp_bt_gap_get_profile_status(esp_bt_gap_profile_status_t *profile_status)
558+
{
559+
if (profile_status == NULL) {
560+
return ESP_ERR_INVALID_ARG;
561+
}
562+
563+
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
564+
return ESP_ERR_INVALID_STATE;
565+
}
566+
567+
memset(profile_status, 0, sizeof(esp_bt_gap_profile_status_t));
568+
btc_gap_bt_status_get(profile_status);
569+
570+
return ESP_OK;
571+
}
572+
557573
#endif /* #if BTC_GAP_BT_INCLUDED == TRUE */

components/bt/host/bluedroid/api/esp_hf_ag_api.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,21 @@ esp_err_t esp_hf_ag_out_call(esp_bd_addr_t remote_addr, int num_active, int num_
528528
return (status == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
529529
}
530530

531+
esp_err_t esp_hf_ag_get_profile_status(esp_hf_profile_status_t *profile_status)
532+
{
533+
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
534+
return ESP_ERR_INVALID_STATE;
535+
}
536+
if (profile_status == NULL) {
537+
return ESP_ERR_INVALID_ARG;
538+
}
539+
540+
memset(profile_status, 0, sizeof(esp_hf_profile_status_t));
541+
btc_hf_get_profile_status(profile_status);
542+
543+
return ESP_OK;
544+
}
545+
531546
#if (BTM_SCO_HCI_INCLUDED == TRUE)
532547

533548
esp_err_t esp_hf_ag_register_data_callback(esp_hf_incoming_data_cb_t recv, esp_hf_outgoing_data_cb_t send)

components/bt/host/bluedroid/api/esp_hf_client_api.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,21 @@ esp_err_t esp_hf_client_register_data_callback(esp_hf_client_incoming_data_cb_t
515515
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
516516
}
517517

518+
esp_err_t esp_hf_client_get_profile_status(esp_hf_client_profile_status_t *profile_status)
519+
{
520+
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
521+
return ESP_ERR_INVALID_STATE;
522+
}
523+
if (profile_status == NULL) {
524+
return ESP_ERR_INVALID_ARG;
525+
}
526+
527+
memset(profile_status, 0, sizeof(esp_hf_client_profile_status_t));
528+
btc_hf_client_get_profile_status(profile_status);
529+
530+
return ESP_OK;
531+
}
532+
518533
#if (BTM_SCO_HCI_INCLUDED == TRUE)
519534
esp_err_t esp_hf_client_pkt_stat_nums_get(uint16_t sync_conn_handle)
520535
{

components/bt/host/bluedroid/api/esp_hidd_api.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -167,4 +167,17 @@ esp_err_t esp_bt_hid_device_virtual_cable_unplug(void)
167167
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
168168
}
169169

170+
esp_err_t esp_bt_hid_device_get_profile_status(esp_hidd_profile_status_t *profile_status)
171+
{
172+
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
173+
if (profile_status == NULL) {
174+
return ESP_ERR_INVALID_ARG;
175+
}
176+
177+
memset(profile_status, 0, sizeof(esp_hidd_profile_status_t));
178+
btc_hd_get_profile_status(profile_status);
179+
180+
return ESP_OK;
181+
}
182+
170183
#endif /* defined BTC_HD_INCLUDED && BTC_HD_INCLUDED == TRUE */

components/bt/host/bluedroid/api/esp_hidh_api.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -247,4 +247,17 @@ esp_err_t esp_bt_hid_host_send_data(esp_bd_addr_t bd_addr, uint8_t *data, size_t
247247
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
248248
}
249249

250+
esp_err_t esp_bt_hid_host_get_profile_status(esp_hidh_profile_status_t *profile_status)
251+
{
252+
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
253+
if (profile_status == NULL) {
254+
return ESP_ERR_INVALID_ARG;
255+
}
256+
257+
memset(profile_status, 0, sizeof(esp_hidh_profile_status_t));
258+
btc_hh_get_profile_status(profile_status);
259+
260+
return ESP_OK;
261+
}
262+
250263
#endif /* defined BTC_HH_INCLUDED && BTC_HH_INCLUDED == TRUE */

components/bt/host/bluedroid/api/esp_l2cap_bt_api.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -128,4 +128,17 @@ esp_err_t esp_bt_l2cap_vfs_unregister(void)
128128
return btc_l2cap_vfs_unregister();
129129
}
130130

131+
esp_err_t esp_bt_l2cap_get_protocol_status(esp_bt_l2cap_protocol_status_t *status)
132+
{
133+
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
134+
if (status == NULL) {
135+
return ESP_ERR_INVALID_ARG;
136+
}
137+
138+
memset(status, 0, sizeof(esp_bt_l2cap_protocol_status_t));
139+
btc_l2cap_get_protocol_status(status);
140+
141+
return ESP_OK;
142+
}
143+
131144
#endif ///defined BTC_L2CAP_INCLUDED && BTC_L2CAP_INCLUDED == TRUE

components/bt/host/bluedroid/api/esp_sdp_api.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,17 @@ esp_err_t esp_sdp_remove_record(int record_handle)
174174
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
175175
}
176176

177+
esp_err_t esp_sdp_get_protocol_status(esp_sdp_protocol_status_t *status)
178+
{
179+
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
180+
if (status == NULL) {
181+
return ESP_ERR_INVALID_ARG;
182+
}
183+
184+
memset(status, 0, sizeof(esp_sdp_protocol_status_t));
185+
btc_sdp_get_protocol_status(status);
186+
187+
return ESP_OK;
188+
}
189+
177190
#endif ///defined BTC_SDP_COMMON_INCLUDED && BTC_SDP_COMMON_INCLUDED == TRUE

components/bt/host/bluedroid/api/esp_spp_api.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -252,4 +252,17 @@ esp_err_t esp_spp_vfs_unregister(void)
252252
return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
253253
}
254254

255+
esp_err_t esp_spp_get_profile_status(esp_spp_profile_status_t *profile_status)
256+
{
257+
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
258+
if (profile_status == NULL) {
259+
return ESP_ERR_INVALID_ARG;
260+
}
261+
262+
memset(profile_status, 0, sizeof(esp_spp_profile_status_t));
263+
btc_spp_get_profile_status(profile_status);
264+
265+
return ESP_OK;
266+
}
267+
255268
#endif ///defined BTC_SPP_INCLUDED && BTC_SPP_INCLUDED == TRUE

0 commit comments

Comments
 (0)