feat(bt/bluedroid): Added API to get local device name

This commit is contained in:
Jin Cheng
2023-12-05 14:07:53 +08:00
parent 25fcb2de2d
commit a3f68aef8a
28 changed files with 254 additions and 26 deletions

View File

@@ -37,6 +37,41 @@ typedef enum {
ESP_BT_DEV_COEX_TYPE_BT,
} esp_bt_dev_coex_type_t;
/// BT device callback events
typedef enum {
ESP_BT_DEV_NAME_RES_EVT = 0, /*!< Device name result event */
ESP_BT_DEV_EVT_MAX,
} esp_bt_dev_cb_event_t;
/// BT device callback parameters
typedef union {
/**
* @brief ESP_BT_DEV_NAME_RES_EVT
*/
struct name_res_param {
esp_bt_status_t status; /*!< Status of getting device name */
char *name; /*!< Name of Bluetooth device */
} name_res; /*!< discovery result parameter struct */
} esp_bt_dev_cb_param_t;
/**
* @brief bluetooth device callback function type
*
* @param event : Event type
*
* @param param : Pointer to callback parameter
*/
typedef void (* esp_bt_dev_cb_t)(esp_bt_dev_cb_event_t event, esp_bt_dev_cb_param_t *param);
/**
* @brief register callback function. This function should be called after esp_bluedroid_enable() completes successfully
*
* @return
* - ESP_OK : Succeed
* - ESP_FAIL: others
*/
esp_err_t esp_bt_dev_register_callback(esp_bt_dev_cb_t callback);
/**
*
* @brief Get bluetooth device address. Must use after "esp_bluedroid_enable".
@@ -63,6 +98,20 @@ const uint8_t *esp_bt_dev_get_address(void);
*/
esp_err_t esp_bt_dev_set_device_name(const char *name);
/**
* @brief Get bluetooth device name. This function should be called after esp_bluedroid_enable()
* completes successfully.
*
* A BR/EDR/LE device type shall have a single Bluetooth device name which shall be
* identical irrespective of the physical channel used to perform the name discovery procedure.
*
* @return
* - ESP_OK : Succeed
* - ESP_ERR_INVALID_STATE : if bluetooth stack is not yet enabled
* - ESP_FAIL : others
*/
esp_err_t esp_bt_dev_get_device_name(void);
/**
* @brief Config bluetooth device coexis status. This function should be called after esp_bluedroid_enable()
* completes successfully.

View File

@@ -1714,7 +1714,7 @@ esp_err_t esp_ble_gap_set_prefer_conn_params(esp_bd_addr_t bd_addr,
* - other : failed
*
*/
esp_err_t esp_ble_gap_set_device_name(const char *name);
esp_err_t esp_ble_gap_set_device_name(const char *name) __attribute__((deprecated("Please use esp_bt_dev_set_device_name")));
/**
* @brief Get device name of the local device
@@ -1724,7 +1724,7 @@ esp_err_t esp_ble_gap_set_device_name(const char *name);
* - other : failed
*
*/
esp_err_t esp_ble_gap_get_device_name(void);
esp_err_t esp_ble_gap_get_device_name(void) __attribute__((deprecated("Please use esp_bt_dev_get_device_name")));
/**
* @brief This function is called to get local used address and address type.