feat(bt): Add API to get profile status

This commit is contained in:
xiongweichao
2025-04-14 15:43:22 +08:00
committed by BOT
parent 756cd17c61
commit ecf646cefc
39 changed files with 595 additions and 47 deletions
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -229,6 +229,21 @@ esp_err_t esp_a2d_media_ctrl(esp_a2d_media_ctrl_t ctrl)
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}
esp_err_t esp_a2d_get_profile_status(esp_a2d_profile_status_t *profile_status)
{
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (profile_status == NULL) {
return ESP_ERR_INVALID_ARG;
}
memset(profile_status, 0, sizeof(esp_a2d_profile_status_t));
btc_a2dp_get_profile_status(profile_status);
return ESP_OK;
}
#if BTC_AV_SRC_INCLUDED
esp_err_t esp_a2d_source_init(void)
{
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -554,4 +554,20 @@ esp_err_t esp_bt_gap_get_device_name(void)
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_bt_gap_get_profile_status(esp_bt_gap_profile_status_t *profile_status)
{
if (profile_status == NULL) {
return ESP_ERR_INVALID_ARG;
}
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
memset(profile_status, 0, sizeof(esp_bt_gap_profile_status_t));
btc_gap_bt_status_get(profile_status);
return ESP_OK;
}
#endif /* #if BTC_GAP_BT_INCLUDED == TRUE */
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -548,6 +548,21 @@ esp_err_t esp_hf_ag_register_data_callback(esp_hf_incoming_data_cb_t recv, esp_h
return (status == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}
esp_err_t esp_hf_ag_get_profile_status(esp_hf_profile_status_t *profile_status)
{
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (profile_status == NULL) {
return ESP_ERR_INVALID_ARG;
}
memset(profile_status, 0, sizeof(esp_hf_profile_status_t));
btc_hf_get_profile_status(profile_status);
return ESP_OK;
}
#if (BTM_SCO_HCI_INCLUDED == TRUE)
esp_err_t esp_hf_ag_pkt_stat_nums_get(uint16_t sync_conn_handle)
{
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -515,6 +515,21 @@ esp_err_t esp_hf_client_register_data_callback(esp_hf_client_incoming_data_cb_t
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}
esp_err_t esp_hf_client_get_profile_status(esp_hf_client_profile_status_t *profile_status)
{
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (profile_status == NULL) {
return ESP_ERR_INVALID_ARG;
}
memset(profile_status, 0, sizeof(esp_hf_client_profile_status_t));
btc_hf_client_get_profile_status(profile_status);
return ESP_OK;
}
#if (BTM_SCO_HCI_INCLUDED == TRUE)
esp_err_t esp_hf_client_pkt_stat_nums_get(uint16_t sync_conn_handle)
{
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -167,4 +167,17 @@ esp_err_t esp_bt_hid_device_virtual_cable_unplug(void)
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}
esp_err_t esp_bt_hid_device_get_profile_status(esp_hidd_profile_status_t *profile_status)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (profile_status == NULL) {
return ESP_ERR_INVALID_ARG;
}
memset(profile_status, 0, sizeof(esp_hidd_profile_status_t));
btc_hd_get_profile_status(profile_status);
return ESP_OK;
}
#endif /* defined BTC_HD_INCLUDED && BTC_HD_INCLUDED == TRUE */
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -247,4 +247,17 @@ esp_err_t esp_bt_hid_host_send_data(esp_bd_addr_t bd_addr, uint8_t *data, size_t
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}
esp_err_t esp_bt_hid_host_get_profile_status(esp_hidh_profile_status_t *profile_status)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (profile_status == NULL) {
return ESP_ERR_INVALID_ARG;
}
memset(profile_status, 0, sizeof(esp_hidh_profile_status_t));
btc_hh_get_profile_status(profile_status);
return ESP_OK;
}
#endif /* defined BTC_HH_INCLUDED && BTC_HH_INCLUDED == TRUE */
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -128,4 +128,17 @@ esp_err_t esp_bt_l2cap_vfs_unregister(void)
return btc_l2cap_vfs_unregister();
}
esp_err_t esp_bt_l2cap_get_protocol_status(esp_bt_l2cap_protocol_status_t *status)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (status == NULL) {
return ESP_ERR_INVALID_ARG;
}
memset(status, 0, sizeof(esp_bt_l2cap_protocol_status_t));
btc_l2cap_get_protocol_status(status);
return ESP_OK;
}
#endif ///defined BTC_L2CAP_INCLUDED && BTC_L2CAP_INCLUDED == TRUE
@@ -174,4 +174,17 @@ esp_err_t esp_sdp_remove_record(int record_handle)
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}
esp_err_t esp_sdp_get_protocol_status(esp_sdp_protocol_status_t *status)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (status == NULL) {
return ESP_ERR_INVALID_ARG;
}
memset(status, 0, sizeof(esp_sdp_protocol_status_t));
btc_sdp_get_protocol_status(status);
return ESP_OK;
}
#endif ///defined BTC_SDP_COMMON_INCLUDED && BTC_SDP_COMMON_INCLUDED == TRUE
+14 -1
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -252,4 +252,17 @@ esp_err_t esp_spp_vfs_unregister(void)
return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_spp_get_profile_status(esp_spp_profile_status_t *profile_status)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (profile_status == NULL) {
return ESP_ERR_INVALID_ARG;
}
memset(profile_status, 0, sizeof(esp_spp_profile_status_t));
btc_spp_get_profile_status(profile_status);
return ESP_OK;
}
#endif ///defined BTC_SPP_INCLUDED && BTC_SPP_INCLUDED == TRUE
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -111,6 +111,15 @@ typedef enum {
ESP_A2D_SET_INVALID_PARAMS /*!< A2DP profile set delay report value is invalid parameter */
} esp_a2d_set_delay_value_state_t;
/**
* @brief A2DP profile status parameters
*/
typedef struct {
bool a2d_snk_inited; /*!< A2DP sink initialization */
bool a2d_src_inited; /*!< A2DP source initialization */
uint8_t conn_num; /*!< Number of connections */
} esp_a2d_profile_status_t;
/**
* @brief A2DP callback events
*/
@@ -376,6 +385,18 @@ esp_err_t esp_a2d_sink_get_delay_value(void);
esp_err_t esp_a2d_media_ctrl(esp_a2d_media_ctrl_t ctrl);
/**
* @brief This function is used to get the status of A2DP
*
* @param[out] profile_status - A2DP status
*
* @return
* - ESP_OK: success
* - other: failed
*/
esp_err_t esp_a2d_get_profile_status(esp_a2d_profile_status_t *profile_status);
/**
*
* @brief Initialize the bluetooth A2DP source module. A2DP can work independently.
@@ -409,7 +430,7 @@ esp_err_t esp_a2d_source_deinit(void);
/**
* @brief Register A2DP source data input function. For now, the input shoule be PCM data stream.
* @brief Register A2DP source data input function. For now, the input should be PCM data stream.
* This function should be called only after esp_bluedroid_enable() completes
* successfully. The callback is invoked in the context of A2DP source task whose
* stack size is configurable through menuconfig.
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -313,6 +313,14 @@ typedef enum {
#define ESP_BT_GAP_TPOLL_DFT (0x0028) /*!< Default poll interval, unit is 625 microseconds */
#define ESP_BT_GAP_TPOLL_MAX (0x1000) /*!< Maximum poll interval, unit is 625 microseconds */
/** GAP status */
typedef struct {
esp_bt_gap_discovery_state_t disc_stat; /*!< Device Discovery state */
esp_bt_connection_mode_t conn_mode; /*!< Connection mode */
esp_bt_discovery_mode_t disc_mode; /*!< Discovery mode */
uint8_t bredr_acl_link_num; /*!< Number of bredr link connections */
} esp_bt_gap_profile_status_t;
/// GAP state callback parameters
typedef union {
/**
@@ -983,6 +991,17 @@ esp_err_t esp_bt_gap_set_device_name(const char *name);
*/
esp_err_t esp_bt_gap_get_device_name(void);
/**
* @brief Get the status of GAP
*
* @param[out] profile_status - GAP status
*
* @return
* - ESP_OK : success
* - other : failed
*/
esp_err_t esp_bt_gap_get_profile_status(esp_bt_gap_profile_status_t *profile_status);
#ifdef __cplusplus
}
#endif
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -74,6 +74,13 @@ typedef enum
ESP_HF_DIAL_MEM, /*!< Dial with a memory position */
} esp_hf_dial_type_t;
/// HFP AG profile status parameters
typedef struct {
bool hfp_ag_inited; /*!< hfp ag initialization */
uint8_t conn_num; /*!< Number of connections */
} esp_hf_profile_status_t;
/// HFP AG callback parameters
typedef union
{
@@ -719,6 +726,17 @@ esp_err_t esp_hf_ag_pkt_stat_nums_get(uint16_t sync_conn_handle);
*/
void esp_hf_ag_outgoing_data_ready(void);
/**
* @brief This function is used to get the status of hfp ag
*
* @param[out] profile_status - hfp ag status
*
* @return
* - ESP_OK: success
* - other: failed
*/
esp_err_t esp_hf_ag_get_profile_status(esp_hf_profile_status_t *profile_status);
#ifdef __cplusplus
}
#endif
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -42,6 +42,14 @@ typedef enum {
ESP_HF_CLIENT_IN_BAND_RINGTONE_PROVIDED,
} esp_hf_client_in_band_ring_state_t;
/**
* @brief HF client profile status parameters
*/
typedef struct {
bool hf_client_inited; /*!< hf client initialization */
uint8_t conn_num; /*!< Number of connections */
} esp_hf_client_profile_status_t;
/* features masks of AG */
#define ESP_HF_CLIENT_PEER_FEAT_3WAY 0x01 /* Three-way calling */
#define ESP_HF_CLIENT_PEER_FEAT_ECNR 0x02 /* Echo cancellation and/or noise reduction */
@@ -738,6 +746,17 @@ void esp_hf_client_pcm_resample_deinit(void);
*/
int32_t esp_hf_client_pcm_resample(void *src, uint32_t in_bytes, void *dst);
/**
* @brief This function is used to get the status of hf client
*
* @param[out] profile_status - hf client status
*
* @return
* - ESP_OK: success
* - other: failed
*/
esp_err_t esp_hf_client_get_profile_status(esp_hf_client_profile_status_t *profile_status);
#ifdef __cplusplus
}
#endif
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -145,6 +145,14 @@ typedef enum {
ESP_HIDD_NO_CONNECTION, /*!< connection may have been closed */
} esp_hidd_status_t;
/**
* @brief HID device profile status parameters
*/
typedef struct {
bool hidd_inited; /*!< HID device initialization */
uint8_t conn_num; /*!< Number of connections */
} esp_hidd_profile_status_t;
/**
* @brief HID device callback parameters union
*/
@@ -406,6 +414,17 @@ esp_err_t esp_bt_hid_device_report_error(esp_hidd_handshake_error_t error);
*/
esp_err_t esp_bt_hid_device_virtual_cable_unplug(void);
/**
* @brief This function is used to get the status of hid device
*
* @param[out] profile_status - HID device status
*
* @return
* - ESP_OK: success
* - other: failed
*/
esp_err_t esp_bt_hid_device_get_profile_status(esp_hidd_profile_status_t *profile_status);
#ifdef __cplusplus
}
#endif
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -104,7 +104,7 @@ typedef enum {
typedef enum {
ESP_HIDH_DEV_ATTR_VIRTUAL_CABLE = 0x0001, /*!< whether Virtual Cables is supported */
ESP_HIDH_DEV_ATTR_NORMALLY_CONNECTABLE = 0x0002, /*!< whether device is in Page Scan mode when there is no active connection */
ESP_HIDH_DEV_ATTR_RECONNECT_INITIATE = 0x0004, /*!< whether the HID device inititates the reconnection process */
ESP_HIDH_DEV_ATTR_RECONNECT_INITIATE = 0x0004, /*!< whether the HID device initiates the reconnection process */
} esp_hidh_dev_attr_t;
/**
@@ -128,11 +128,19 @@ typedef struct {
int vendor_id; /*!< Device ID information: vendor ID */
int product_id; /*!< Device ID information: product ID */
int version; /*!< Device ID information: version */
uint8_t ctry_code; /*!< SDP attrbutes of HID devices: HID country code (https://www.usb.org/sites/default/files/hid1_11.pdf) */
int dl_len; /*!< SDP attrbutes of HID devices: HID device descriptor length */
uint8_t dsc_list[BTHH_MAX_DSC_LEN]; /*!< SDP attrbutes of HID devices: HID device descriptor definition */
uint8_t ctry_code; /*!< SDP attributes of HID devices: HID country code (https://www.usb.org/sites/default/files/hid1_11.pdf) */
int dl_len; /*!< SDP attributes of HID devices: HID device descriptor length */
uint8_t dsc_list[BTHH_MAX_DSC_LEN]; /*!< SDP attributes of HID devices: HID device descriptor definition */
} esp_hidh_hid_info_t;
/**
* @brief HID host profile status parameters
*/
typedef struct {
bool hidh_inited; /*!< HID host initialization */
uint8_t conn_num; /*!< Number of connections */
} esp_hidh_profile_status_t;
/**
* @brief HID host callback parameters union
*/
@@ -157,7 +165,7 @@ typedef union {
struct hidh_open_evt_param {
esp_hidh_status_t status; /*!< operation status */
esp_hidh_connection_state_t conn_status; /*!< connection status */
bool is_orig; /*!< indicate if host intiate the connection */
bool is_orig; /*!< indicate if host initiate the connection */
uint8_t handle; /*!< device handle */
esp_bd_addr_t bd_addr; /*!< device address */
} open; /*!< HIDH callback param of ESP_HIDH_OPEN_EVT */
@@ -475,6 +483,17 @@ esp_err_t esp_bt_hid_host_set_report(esp_bd_addr_t bd_addr, esp_hidh_report_type
*/
esp_err_t esp_bt_hid_host_send_data(esp_bd_addr_t bd_addr, uint8_t *data, size_t len);
/**
* @brief This function is used to get the status of hid host
*
* @param[out] profile_status - HID host status
*
* @return
* - ESP_OK: success
* - other: failed
*/
esp_err_t esp_bt_hid_host_get_profile_status(esp_hidh_profile_status_t *profile_status);
#ifdef __cplusplus
}
#endif
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -40,6 +40,14 @@ typedef enum {
#define ESP_BT_L2CAP_SEC_ENCRYPT 0x0024 /*!< Encryption required */
typedef uint32_t esp_bt_l2cap_cntl_flags_t;
/**
* @brief L2CAP status parameters
*/
typedef struct {
bool l2cap_inited; /*!< l2cap initialization */
uint8_t conn_num; /*!< Number of connections */
} esp_bt_l2cap_protocol_status_t;
/**
* @brief L2CAP callback function events
*/
@@ -244,6 +252,17 @@ esp_err_t esp_bt_l2cap_vfs_register(void);
*/
esp_err_t esp_bt_l2cap_vfs_unregister(void);
/**
* @brief This function is used to get the status of L2CAP
*
* @param[out] status - l2cap status
*
* @return
* - ESP_OK: success
* - other: failed
*/
esp_err_t esp_bt_l2cap_get_protocol_status(esp_bt_l2cap_protocol_status_t *status);
#ifdef __cplusplus
}
#endif
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -37,6 +37,14 @@ typedef enum {
ESP_SDP_NO_CREATE_RECORD, /*!< No record created */
} esp_sdp_status_t;
/**
* @brief SDP protocol status parameters
*/
typedef struct {
bool sdp_inited; /*!< SDP initialization */
uint8_t records_num; /*!< Number of created records */
} esp_sdp_protocol_status_t;
/**
* @brief SDP callback function events
*/
@@ -305,6 +313,17 @@ esp_err_t esp_sdp_create_record(esp_bluetooth_sdp_record_t *record);
*/
esp_err_t esp_sdp_remove_record(int record_handle);
/**
* @brief This function is used to get the status of SDP
*
* @param[out] status - sdp status
*
* @return
* - ESP_OK: success
* - other: failed
*/
esp_err_t esp_sdp_get_protocol_status(esp_sdp_protocol_status_t *status);
#ifdef __cplusplus
}
#endif
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -102,6 +102,13 @@ typedef enum {
ESP_SPP_VFS_UNREGISTER_EVT = 37, /*!< When SPP VFS unregister, the event comes */
} esp_spp_cb_event_t;
/**
* @brief SPP profile status parameters
*/
typedef struct {
bool spp_inited; /*!< spp initialization */
uint8_t conn_num; /*!< Number of connections */
} esp_spp_profile_status_t;
/**
* @brief SPP callback parameters union
@@ -432,6 +439,17 @@ esp_err_t esp_spp_vfs_register(void);
*/
esp_err_t esp_spp_vfs_unregister(void);
/**
* @brief This function is used to get the status of SPP
*
* @param[out] profile_status - SPP status
*
* @return
* - ESP_OK: success
* - other: failed
*/
esp_err_t esp_spp_get_profile_status(esp_spp_profile_status_t *profile_status);
#ifdef __cplusplus
}
#endif