Update bt fork to be based on v5.3

This commit is contained in:
jacqueline
2024-08-13 06:02:54 +00:00
committed by cooljqln
parent be9725c1c7
commit 5a02f34ed9
508 changed files with 42429 additions and 5168 deletions
@@ -12,6 +12,7 @@
#if (BT_CONTROLLER_INCLUDED == TRUE)
#include "esp_bt.h"
#endif
#include "hci_log/bt_hci_log.h"
#define LOG_TAG "HCI_API"
@@ -59,6 +60,9 @@ bool hci_host_check_send_available(void)
void hci_host_send_packet(uint8_t *data, uint16_t len)
{
#if (BT_HCI_LOG_INCLUDED == TRUE)
bt_hci_log_record_hci_data(data[0], &data[1], len - 1);
#endif
#if (BT_CONTROLLER_INCLUDED == TRUE)
esp_vhci_host_send_packet(data, len);
#else /* BT_CONTROLLER_INCLUDED == TRUE */
+31 -6
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -12,6 +12,21 @@
#include "btc/btc_task.h"
#include "btc/btc_dev.h"
#include "btc/btc_config.h"
#include "btc/btc_manage.h"
esp_err_t esp_bt_dev_register_callback(esp_bt_dev_cb_t callback)
{
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (callback == NULL) {
return ESP_ERR_INVALID_ARG;
}
btc_profile_cb_set(BTC_PID_DEV, callback);
return ESP_OK;
}
const uint8_t *esp_bt_dev_get_address(void)
{
@@ -39,14 +54,24 @@ esp_err_t esp_bt_dev_set_device_name(const char *name)
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_DEV;
msg.act = BTC_DEV_ACT_SET_DEVICE_NAME;
arg.set_dev_name.device_name = (char *)osi_malloc((BTC_MAX_LOC_BD_NAME_LEN + 1) * sizeof(char));
if (!arg.set_dev_name.device_name) {
return ESP_ERR_NO_MEM;
arg.set_dev_name.device_name = (char *)name;
return (btc_transfer_context(&msg, &arg, sizeof(btc_dev_args_t), btc_dev_call_arg_deep_copy, btc_dev_call_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_bt_dev_get_device_name(void)
{
btc_msg_t msg = {0};
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
strcpy(arg.set_dev_name.device_name, name);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_DEV;
msg.act = BTC_DEV_ACT_GET_DEVICE_NAME;
return (btc_transfer_context(&msg, &arg, sizeof(btc_dev_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#if (ESP_COEX_VSC_INCLUDED == TRUE)
+11 -1
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -15,6 +15,8 @@
#include "osi/future.h"
#include "osi/allocator.h"
#include "config/stack_config.h"
#include "hci_log/bt_hci_log.h"
#include "bt_common.h"
static bool bd_already_enable = false;
static bool bd_already_init = false;
@@ -180,6 +182,10 @@ esp_err_t esp_bluedroid_init_with_cfg(esp_bluedroid_config_t *cfg)
bd_already_init = true;
#if (BT_HCI_LOG_INCLUDED == TRUE)
bt_hci_log_init();
#endif // (BT_HCI_LOG_INCLUDED == TRUE)
return ESP_OK;
}
@@ -224,6 +230,10 @@ esp_err_t esp_bluedroid_deinit(void)
bluedriod_config_deinit();
#if (BT_HCI_LOG_INCLUDED == TRUE)
bt_hci_log_deinit();
#endif // (BT_HCI_LOG_INCLUDED == TRUE)
bd_already_init = false;
return ESP_OK;
+129 -4
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -13,7 +13,7 @@
#include "btc/btc_manage.h"
#include "btc_gap_ble.h"
#include "btc/btc_ble_storage.h"
#include "esp_random.h"
esp_err_t esp_ble_gap_register_callback(esp_gap_ble_cb_t callback)
{
@@ -188,6 +188,25 @@ esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_addr_create_static(esp_bd_addr_t rand_addr)
{
// Static device address: First two bits are '11', rest is random
rand_addr[0] = 0xC0 | (esp_random() & 0x3F);
for (int i = 1; i < 6; i++) {
rand_addr[i] = esp_random() & 0xFF; // Randomize remaining bits
}
return ESP_OK;
}
esp_err_t esp_ble_gap_addr_create_nrpa(esp_bd_addr_t rand_addr)
{
// Non-resolvable private address: First two bits are '00', rest is random
rand_addr[0] = (esp_random() & 0x3F);
for (int i = 1; i < 6; i++) {
rand_addr[i] = esp_random() & 0xFF; // Randomize remaining bits
}
return ESP_OK;
}
esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr)
{
@@ -204,6 +223,48 @@ esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr)
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_set_resolvable_private_address_timeout(uint16_t rpa_timeout)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (rpa_timeout < 0x0001 || rpa_timeout > 0x0E10) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg = {0};
btc_ble_gap_args_t arg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_ACT_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT;
arg.set_rpa_timeout.rpa_timeout = rpa_timeout;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_add_device_to_resolving_list(esp_bd_addr_t peer_addr, uint8_t addr_type, uint8_t *peer_irk)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (addr_type > BLE_ADDR_TYPE_RANDOM ||!peer_addr || (addr_type && ((peer_addr[0] & 0xC0) != 0xC0))) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg = {0};
btc_ble_gap_args_t arg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_ACT_ADD_DEVICE_TO_RESOLVING_LIST;
memcpy(arg.add_dev_to_resolving_list.addr, peer_addr, ESP_BD_ADDR_LEN);
arg.add_dev_to_resolving_list.addr_type = addr_type;
memcpy(arg.add_dev_to_resolving_list.irk, peer_irk, ESP_PEER_IRK_LEN);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_clear_rand_addr(void)
{
btc_msg_t msg;
@@ -299,6 +360,7 @@ esp_err_t esp_ble_gap_config_local_icon (uint16_t icon)
case ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV:
case ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD:
case ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV:
case ESP_BLE_APPEARANCE_STANDALONE_SPEAKER:
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_ACT_CONFIG_LOCAL_ICON;
@@ -396,9 +458,25 @@ esp_err_t esp_ble_gap_set_prefer_conn_params(esp_bd_addr_t bd_addr,
esp_err_t esp_ble_gap_set_device_name(const char *name)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
btc_msg_t msg = {0};
btc_ble_gap_args_t arg;
return esp_bt_dev_set_device_name(name);
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (!name){
return ESP_ERR_INVALID_ARG;
}
if (strlen(name) > BTC_MAX_LOC_BD_NAME_LEN) {
return ESP_ERR_INVALID_ARG;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_ACT_SET_DEV_NAME;
arg.set_dev_name.device_name = (char *)name;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy, btc_gap_ble_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_get_device_name(void)
@@ -936,6 +1014,25 @@ esp_err_t esp_ble_dtm_stop(void)
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_set_privacy_mode(esp_ble_addr_type_t addr_type, esp_bd_addr_t addr, esp_ble_privacy_mode_t mode)
{
btc_msg_t msg;
btc_ble_gap_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_SET_PRIVACY_MODE;
arg.set_privacy_mode.addr_type = addr_type;
memcpy(arg.set_privacy_mode.addr, addr, sizeof(esp_bd_addr_t));
arg.set_privacy_mode.privacy_mode = mode;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#if (BLE_50_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gap_read_phy(esp_bd_addr_t bd_addr)
@@ -1599,3 +1696,31 @@ esp_err_t esp_ble_gap_set_periodic_adv_sync_trans_params(esp_bd_addr_t addr, con
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif //#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
esp_err_t esp_ble_gap_vendor_command_send(esp_ble_vendor_cmd_params_t *vendor_cmd_param)
{
btc_msg_t msg = {0};
btc_ble_gap_args_t arg;
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (!vendor_cmd_param || !vendor_cmd_param->p_param_buf || !vendor_cmd_param->param_len) {
return ESP_ERR_NOT_ALLOWED;
}
// If command is not a VSC, return error
if ((vendor_cmd_param->opcode & VENDOR_HCI_CMD_MASK) != VENDOR_HCI_CMD_MASK) {
return ESP_ERR_NOT_ALLOWED;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT;
arg.vendor_cmd_send.opcode = vendor_cmd_param->opcode;
arg.vendor_cmd_send.param_len = vendor_cmd_param->param_len;
arg.vendor_cmd_send.p_param_buf = vendor_cmd_param->p_param_buf;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy, btc_gap_ble_arg_deep_free)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
+60 -1
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -494,4 +494,63 @@ esp_err_t esp_bt_gap_set_acl_pkt_types(esp_bd_addr_t remote_bda, uint16_t pkt_ty
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
esp_err_t esp_bt_gap_set_min_enc_key_size(uint8_t key_size)
{
btc_msg_t msg;
btc_gap_bt_args_t arg;
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (key_size < ESP_BT_ENC_KEY_SIZE_CTRL_MIN || key_size > ESP_BT_ENC_KEY_SIZE_CTRL_MAX) {
return ESP_ERR_INVALID_ARG;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BT;
msg.act = BTC_GAP_BT_ACT_SET_MIN_ENC_KEY_SIZE;
arg.set_min_enc_key_size.key_size = key_size;
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* #if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE) */
esp_err_t esp_bt_gap_set_device_name(const char *name)
{
btc_msg_t msg;
btc_gap_bt_args_t arg;
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if ((!name) || (strlen(name) > BTC_MAX_LOC_BD_NAME_LEN)) {
return ESP_ERR_INVALID_ARG;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BT;
msg.act = BTC_GAP_BT_ACT_SET_DEV_NAME;
arg.bt_set_dev_name.device_name = (char *)name;
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), btc_gap_bt_arg_deep_copy,
btc_gap_bt_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_bt_gap_get_device_name(void)
{
btc_msg_t msg;
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BT;
msg.act = BTC_GAP_BT_ACT_GET_DEV_NAME;
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* #if BTC_GAP_BT_INCLUDED == TRUE */
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -19,7 +19,7 @@ extern "C" {
return ESP_ERR_INVALID_STATE; \
}
#define ESP_BT_STATUS_BASE_FOR_HCI_ERR 0X0100 /* base for coverting HCI error code to ESP status */
#define ESP_BT_STATUS_BASE_FOR_HCI_ERR 0X0100 /* base for converting HCI error code to ESP status */
/* relate to BT_STATUS_xxx in bt_def.h */
/// Status Return Value
@@ -163,6 +163,9 @@ typedef enum {
/// Bluetooth address length
#define ESP_BD_ADDR_LEN 6
/// Bluetooth peer irk
#define ESP_PEER_IRK_LEN 16
/// Bluetooth device address
typedef uint8_t esp_bd_addr_t[ESP_BD_ADDR_LEN];
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -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".
@@ -61,7 +96,21 @@ const uint8_t *esp_bt_dev_get_address(void);
* - ESP_ERR_INVALID_STATE : if bluetooth stack is not yet enabled
* - ESP_FAIL : others
*/
esp_err_t esp_bt_dev_set_device_name(const char *name);
esp_err_t esp_bt_dev_set_device_name(const char *name) __attribute__((deprecated("Please use esp_bt_gap_set_device_name or esp_ble_gap_set_device_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) __attribute__((deprecated("Please use esp_bt_gap_get_device_name or esp_ble_gap_get_device_name")));
/**
* @brief Config bluetooth device coexis status. This function should be called after esp_bluedroid_enable()
@@ -70,7 +70,7 @@ esp_err_t esp_bluedroid_disable(void);
* - ESP_OK : Succeed
* - Other : Failed
*/
esp_err_t esp_bluedroid_init(void) __attribute__((deprecated("Please use esp_bluedroid_init_with_cfg")));
esp_err_t esp_bluedroid_init(void);
/**
* @brief Init and alloc the resource for bluetooth, must be prior to every bluetooth stuff.
@@ -54,7 +54,7 @@ typedef uint8_t esp_ble_auth_req_t; /*!< combination of the above bit
#define ESP_BLE_ONLY_ACCEPT_SPECIFIED_AUTH_DISABLE 0 /*!< authentication disable*/
#define ESP_BLE_ONLY_ACCEPT_SPECIFIED_AUTH_ENABLE 1 /*!< authentication enable*/
#define ESP_BLE_OOB_DISABLE 0 /*!< disbale the out of bond*/
#define ESP_BLE_OOB_DISABLE 0 /*!< disable the out of bond*/
#define ESP_BLE_OOB_ENABLE 1 /*!< enable the out of bond*/
/// relate to BTM_IO_CAP_xxx in stack/btm_api.h
@@ -104,6 +104,7 @@ typedef uint8_t esp_ble_auth_req_t; /*!< combination of the above bit
#define ESP_BLE_APPEARANCE_CYCLING_CADENCE 0x0483 /*!< relate to BTM_BLE_APPEARANCE_CYCLING_CADENCE in stack/btm_ble_api.h */
#define ESP_BLE_APPEARANCE_CYCLING_POWER 0x0484 /*!< relate to BTM_BLE_APPEARANCE_CYCLING_POWER in stack/btm_ble_api.h */
#define ESP_BLE_APPEARANCE_CYCLING_SPEED_CADENCE 0x0485 /*!< relate to BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE in stack/btm_ble_api.h */
#define ESP_BLE_APPEARANCE_STANDALONE_SPEAKER 0x0841 /*!< relate to BTM_BLE_APPEARANCE_STANDALONE_SPEAKER in stack/btm_ble_api.h */
#define ESP_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 0x0C40 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER in stack/btm_ble_api.h */
#define ESP_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 0x0C41 /*!< relate to BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP in stack/btm_ble_api.h */
#define ESP_BLE_APPEARANCE_PULSE_OXIMETER_WRIST 0x0C42 /*!< relate to BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST in stack/btm_ble_api.h */
@@ -156,7 +157,7 @@ typedef enum {
ESP_GAP_BLE_PASSKEY_REQ_EVT, /*!< passkey request event */
ESP_GAP_BLE_OOB_REQ_EVT, /*!< OOB request event */
ESP_GAP_BLE_LOCAL_IR_EVT, /*!< BLE local IR (identity Root 128-bit random static value used to generate Long Term Key) event */
ESP_GAP_BLE_LOCAL_ER_EVT, /*!< BLE local ER (Encryption Root vakue used to genrate identity resolving key) event */
ESP_GAP_BLE_LOCAL_ER_EVT, /*!< BLE local ER (Encryption Root value used to generate identity resolving key) event */
ESP_GAP_BLE_NC_REQ_EVT, /*!< Numeric Comparison request event */
//BLE_42_FEATURE_SUPPORT
ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT, /*!< When stop adv complete, the event comes */
@@ -224,6 +225,10 @@ typedef enum {
ESP_GAP_BLE_DTM_TEST_UPDATE_EVT, /*!< when direct test mode state changes, the event comes */
// BLE_INCLUDED
ESP_GAP_BLE_ADV_CLEAR_COMPLETE_EVT, /*!< When clear advertising complete, the event comes */
ESP_GAP_BLE_SET_RPA_TIMEOUT_COMPLETE_EVT, /*!< When set the Resolvable Private Address (RPA) timeout completes, the event comes */
ESP_GAP_BLE_ADD_DEV_TO_RESOLVING_LIST_COMPLETE_EVT, /*!< when add a device to the resolving list completes, the event comes*/
ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT, /*!< When vendor hci command complete, the event comes */
ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT, /*!< When set privacy mode complete, the event comes */
ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */
} esp_gap_ble_cb_event_t;
@@ -238,6 +243,8 @@ typedef uint8_t esp_gap_ble_channels[ESP_GAP_BLE_CHANNELS_LEN];
/// Scan response data maximum length
#define ESP_BLE_SCAN_RSP_DATA_LEN_MAX 31
#define VENDOR_HCI_CMD_MASK (0x3F << 10) /**!< 0xFC00 */
/* relate to BTM_BLE_AD_TYPE_xxx in stack/btm_ble_api.h */
/// The type of advertising data(not adv_type)
typedef enum {
@@ -364,6 +371,15 @@ typedef enum {
DTM_TEST_STOP_EVT,
} esp_ble_dtm_update_evt_t;
/**
* @brief Vendor HCI command parameters
*/
typedef struct {
uint16_t opcode; /*!< vendor hci command opcode */
uint8_t param_len; /*!< the length of parameter */
uint8_t *p_param_buf; /*!< the point of parameter buffer */
} esp_ble_vendor_cmd_params_t;
#if (BLE_42_FEATURE_SUPPORT == TRUE)
/**
* @brief DTM TX parameters
@@ -786,9 +802,9 @@ typedef uint8_t esp_ble_gap_all_phys_t;
#define ESP_BLE_GAP_PRI_PHY_CODED ESP_BLE_GAP_PHY_CODED /*!< Primary Phy is LE CODED */
typedef uint8_t esp_ble_gap_pri_phy_t; // primary phy
#define ESP_BLE_GAP_PHY_1M_PREF_MASK (1 << 0) /*!< The Host prefers use the LE1M transmitter or reciever PHY */
#define ESP_BLE_GAP_PHY_2M_PREF_MASK (1 << 1) /*!< The Host prefers use the LE2M transmitter or reciever PHY */
#define ESP_BLE_GAP_PHY_CODED_PREF_MASK (1 << 2) /*!< The Host prefers use the LE CODED transmitter or reciever PHY */
#define ESP_BLE_GAP_PHY_1M_PREF_MASK (1 << 0) /*!< The Host prefers use the LE1M transmitter or receiver PHY */
#define ESP_BLE_GAP_PHY_2M_PREF_MASK (1 << 1) /*!< The Host prefers use the LE2M transmitter or receiver PHY */
#define ESP_BLE_GAP_PHY_CODED_PREF_MASK (1 << 2) /*!< The Host prefers use the LE CODED transmitter or receiver PHY */
typedef uint8_t esp_ble_gap_phy_mask_t;
#define ESP_BLE_GAP_PHY_OPTIONS_NO_PREF 0 /*!< The Host has no preferred coding when transmitting on the LE Coded PHY */
@@ -945,7 +961,7 @@ typedef struct {
esp_ble_gap_ext_adv_data_status_t data_status; /*!< data type */
uint8_t adv_data_len; /*!< extend advertising data length */
uint8_t adv_data[251]; /*!< extend advertising data */
} esp_ble_gap_ext_adv_reprot_t;
} esp_ble_gap_ext_adv_report_t;
/**
* @brief periodic adv report parameters
@@ -1015,6 +1031,11 @@ typedef struct {
} esp_ble_gap_past_params_t;
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
typedef enum{
ESP_BLE_NETWORK_PRIVACY_MODE = 0X00, /*!< Network Privacy Mode for peer device (default) */
ESP_BLE_DEVICE_PRIVACY_MODE = 0X01, /*!< Device Privacy Mode for peer device */
} esp_ble_privacy_mode_t;
/**
* @brief Gap callback parameters union
*/
@@ -1140,6 +1161,19 @@ typedef union {
struct ble_local_privacy_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate the set local privacy operation success status */
} local_privacy_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_SET_RPA_TIMEOUT_COMPLETE_EVT
*/
struct ble_rpa_timeout_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate the set RPA timeout operation success status */
} set_rpa_timeout_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_RPA_TIMEOUT_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_ADD_DEV_TO_RESOLVING_LIST_COMPLETE_EVT
*/
struct ble_add_dev_to_resolving_list_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicates the success status of adding a device to the resolving list */
} add_dev_to_resolving_list_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADD_DEV_TO_RESOLVING_LIST_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT
*/
@@ -1410,7 +1444,7 @@ typedef union {
* @brief ESP_GAP_BLE_EXT_ADV_REPORT_EVT
*/
struct ble_ext_adv_report_param {
esp_ble_gap_ext_adv_reprot_t params; /*!< extend advertising report parameters */
esp_ble_gap_ext_adv_report_t params; /*!< extend advertising report parameters */
} ext_adv_report; /*!< Event parameter of ESP_GAP_BLE_EXT_ADV_REPORT_EVT */
/**
* @brief ESP_GAP_BLE_PERIODIC_ADV_REPORT_EVT
@@ -1471,6 +1505,20 @@ typedef union {
esp_ble_dtm_update_evt_t update_evt; /*!< DTM state change event, 0x00: DTM TX start, 0x01: DTM RX start, 0x02:DTM end */
uint16_t num_of_pkt; /*!< number of packets received, only valid if update_evt is DTM_TEST_STOP_EVT and shall be reported as 0 for a transmitter */
} dtm_state_update; /*!< Event parameter of ESP_GAP_BLE_DTM_TEST_UPDATE_EVT */
/**
* @brief ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT
*/
struct vendor_cmd_cmpl_evt_param {
uint16_t opcode; /*!< vendor hci command opcode */
uint16_t param_len; /*!< The length of parameter buffer */
uint8_t *p_param_buf; /*!< The point of parameter buffer */
} vendor_cmd_cmpl; /*!< Event parameter of ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT
*/
struct ble_set_privacy_mode_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate privacy mode set operation success status */
} set_privacy_mode_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT */
} esp_ble_gap_cb_param_t;
/**
@@ -1608,13 +1656,13 @@ esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_
*
* @param[in] rand_addr: The address to be configured. Refer to the table below for possible address subtypes:
*
* | address [47:46] | Address Type |
* |-----------------|--------------------------|
* | 0b00 | Non-Resolvable Private |
* | | Address |
* |-----------------|--------------------------|
* | 0b11 | Static Random Address |
* |-----------------|--------------------------|
* | address [47:46] | Address Type | Corresponding API |
* |-----------------|-----------------------------|----------------------------------------|
* | 0b00 | Non-Resolvable Private | esp_ble_gap_addr_create_nrpa |
* | | Address (NRPA) | |
* |-----------------|-----------------------------|----------------------------------------|
* | 0b11 | Static Random Address | esp_ble_gap_addr_create_static |
* |-----------------|-----------------------------|----------------------------------------|
*
* @return
* - ESP_OK : success
@@ -1623,6 +1671,60 @@ esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_
*/
esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr);
/**
* @brief Create a static device address
* @param[out] rand_addr: Pointer to the buffer where the static device address will be stored.
* @return - ESP_OK : Success
* - Other : Failed
*/
esp_err_t esp_ble_gap_addr_create_static(esp_bd_addr_t rand_addr);
/**
* @brief Create a non-resolvable private address (NRPA)
* @param[out] rand_addr: Pointer to the buffer where the NRPA will be stored.
* @return - ESP_OK : Success
* - Other : Failed
*/
esp_err_t esp_ble_gap_addr_create_nrpa(esp_bd_addr_t rand_addr);
/**
* @brief This function sets the length of time the Controller uses a Resolvable Private Address
* before generating and starting to use a new resolvable private address.
*
* @note Note: This function is currently not supported on the ESP32 but will be enabled in a future update.
*
* @param[in] rpa_timeout: The timeout duration in seconds for how long a Resolvable Private Address
* is used before a new one is generated. The value must be within the range specified by
* the Bluetooth specification (0x0001 to 0x0E10), which corresponds to a time range of
* 1 second to 1 hour. The default value is 0x0384 (900 seconds or 15 minutes).
* @return
* - ESP_OK : success
* - other : failed
*
*/
esp_err_t esp_ble_gap_set_resolvable_private_address_timeout(uint16_t rpa_timeout);
/**
* @brief This function adds a device to the resolving list used to generate and resolve Resolvable Private Addresses
* in the Controller.
*
* @note Note: This function shall not be used when address resolution is enabled in the Controller and:
* - Advertising (other than periodic advertising) is enabled,
* - Scanning is enabled, or
* - an HCI_LE_Create_Connection, HCI_LE_Extended_Create_Connection, or HCI_LE_Periodic_Advertising_Create_Sync command is pending.
* This command may be used at any time when address resolution is disabled in the Controller.
* The added device shall be set to Network Privacy mode.
*
* @param[in] peer_addr: The peer identity address of the device to be added to the resolving list.
* @param[in] addr_type: The address type of the peer identity address (BLE_ADDR_TYPE_PUBLIC or BLE_ADDR_TYPE_RANDOM).
* @param[in] peer_irk: The Identity Resolving Key (IRK) of the device.
* @return
* - ESP_OK : success
* - other : failed
*
*/
esp_err_t esp_ble_gap_add_device_to_resolving_list(esp_bd_addr_t peer_addr, uint8_t addr_type, uint8_t *peer_irk);
/**
* @brief This function clears the random address for the application
*
@@ -1633,8 +1735,6 @@ esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr);
*/
esp_err_t esp_ble_gap_clear_rand_addr(void);
/**
* @brief Enable/disable privacy (including address resolution) on the local device
*
@@ -1949,7 +2049,6 @@ esp_err_t esp_ble_remove_bond_device(esp_bd_addr_t bd_addr);
*/
int esp_ble_get_bond_device_num(void);
/**
* @brief Get the device from the security database list of peer device.
* It will return the device bonded information immediately.
@@ -2540,6 +2639,34 @@ esp_err_t esp_ble_dtm_stop(void);
*/
esp_err_t esp_ble_gap_clear_advertising(void);
/**
* @brief This function is called to send vendor hci command.
*
*
*
* @param[in] vendor_cmd_param: vendor hci command parameters
*
* @return
* - ESP_OK : success
* - other : failed
*/
esp_err_t esp_ble_gap_vendor_command_send(esp_ble_vendor_cmd_params_t *vendor_cmd_param);
/**
* @brief This function set the privacy mode of the device in resolving list.
*
* @note This feature is not supported on ESP32.
*
* @param[in] addr_type: The address type of the peer identity address (BLE_ADDR_TYPE_PUBLIC or BLE_ADDR_TYPE_RANDOM).
* @param[in] addr: The peer identity address of the device.
* @param[in] mode: The privacy mode of the device.
*
* @return
* - ESP_OK : success
* - other : failed
*/
esp_err_t esp_ble_gap_set_privacy_mode(esp_ble_addr_type_t addr_type, esp_bd_addr_t addr, esp_ble_privacy_mode_t mode);
#ifdef __cplusplus
}
#endif
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -105,7 +105,7 @@ typedef uint8_t esp_bt_eir_type_t;
#define ESP_BT_ACL_PKT_TYPES_MASK_NO_2_DH5 0x1000
#define ESP_BT_ACL_PKT_TYPES_MASK_NO_3_DH5 0x2000
// DM1 cann not be disabled. All options are mandatory to include DM1.
// DM1 can not be disabled. All options are mandatory to include DM1.
#define ESP_BT_ACL_DM1_ONLY (ESP_BT_ACL_PKT_TYPES_MASK_DM1 | 0x330e) /* 0x330e */
#define ESP_BT_ACL_DH1_ONLY (ESP_BT_ACL_PKT_TYPES_MASK_DH1 | 0x330e) /* 0x331e */
#define ESP_BT_ACL_DM3_ONLY (ESP_BT_ACL_PKT_TYPES_MASK_DM3 | 0x330e) /* 0x370e */
@@ -121,6 +121,10 @@ typedef uint8_t esp_bt_eir_type_t;
typedef uint16_t esp_bt_acl_pkt_type_t;
/* Range of encryption key size */
#define ESP_BT_ENC_KEY_SIZE_CTRL_MAX (16)
#define ESP_BT_ENC_KEY_SIZE_CTRL_MIN (7)
/* ESP_BT_EIR_FLAG bit definition */
#define ESP_BT_EIR_FLAG_LIMIT_DISC (0x01 << 0)
#define ESP_BT_EIR_FLAG_GEN_DISC (0x01 << 1)
@@ -142,7 +146,7 @@ typedef struct {
uint8_t *p_url; /*!< URL point */
} esp_bt_eir_data_t;
/// Major service class field of Class of Device, mutiple bits can be set
/// Major service class field of Class of Device, multiple bits can be set
typedef enum {
ESP_BT_COD_SRVC_NONE = 0, /*!< None indicates an invalid value */
ESP_BT_COD_SRVC_LMTD_DISCOVER = 0x1, /*!< Limited Discoverable Mode */
@@ -266,6 +270,8 @@ typedef enum {
ESP_BT_GAP_GET_PAGE_TO_EVT, /*!< Get page timeout event */
ESP_BT_GAP_ACL_PKT_TYPE_CHANGED_EVT, /*!< Set ACL packet types event */
ESP_BT_GAP_ENC_CHG_EVT, /*!< Encryption change event */
ESP_BT_GAP_SET_MIN_ENC_KEY_SIZE_EVT, /*!< Set minimum encryption key size */
ESP_BT_GAP_GET_DEV_NAME_CMPL_EVT, /*!< Get device name complete event */
ESP_BT_GAP_EVT_MAX,
} esp_bt_gap_cb_event_t;
@@ -458,6 +464,13 @@ typedef union {
uint16_t pkt_types; /*!< packet types successfully set */
} set_acl_pkt_types; /*!< set ACL packet types parameter struct */
/**
* @brief ESP_BT_GAP_SET_MIN_ENC_KEY_SIZE_EVT
*/
struct set_min_enc_key_size_param {
esp_bt_status_t status; /*!< set minimum encryption key size status */
} set_min_enc_key_size; /*!< set minimum encryption key size parameter struct */
/**
* @brief ESP_BT_GAP_ACL_CONN_CMPL_STAT_EVT
*/
@@ -475,6 +488,14 @@ typedef union {
uint16_t handle; /*!< ACL connection handle */
esp_bd_addr_t bda; /*!< remote bluetooth device address */
} acl_disconn_cmpl_stat; /*!< ACL disconnection complete status parameter struct */
/**
* @brief ESP_GAP_BT_GET_DEV_NAME_CMPL_EVT
*/
struct get_dev_name_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate the get device name success status */
char *name; /*!< Name of bluetooth device */
} get_dev_name_cmpl; /*!< Get device name complete status parameter struct */
} esp_bt_gap_cb_param_t;
/**
@@ -541,7 +562,7 @@ static inline uint32_t esp_bt_gap_get_cod_format_type(uint32_t cod)
*
* @return
* - true if cod is valid
* - false otherise
* - false otherwise
*/
static inline bool esp_bt_gap_is_valid_cod(uint32_t cod)
{
@@ -909,6 +930,35 @@ esp_err_t esp_bt_gap_get_page_timeout(void);
*/
esp_err_t esp_bt_gap_set_acl_pkt_types(esp_bd_addr_t remote_bda, esp_bt_acl_pkt_type_t pkt_types);
/**
* @brief Set the minimal size of encryption key
*
* @return - ESP_OK: success
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
* - other: failed
*/
esp_err_t esp_bt_gap_set_min_enc_key_size(uint8_t key_size);
/**
* @brief Set device name to the local device
*
* @param[in] name - device name.
*
* @return
* - ESP_OK : success
* - other : failed
*/
esp_err_t esp_bt_gap_set_device_name(const char *name);
/**
* @brief Get device name of the local device
*
* @return
* - ESP_OK : success
* - other : failed
*/
esp_err_t esp_bt_gap_get_device_name(void);
#ifdef __cplusplus
}
#endif
@@ -1,337 +1,552 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __ESP_GATT_DEFS_H__
#define __ESP_GATT_DEFS_H__
#pragma once
#include "esp_bt_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/// GATT INVALID UUID
/** @brief GATT INVALID UUID. */
#define ESP_GATT_ILLEGAL_UUID 0
/// GATT INVALID HANDLE
/** @brief GATT INVALID HANDLE. */
#define ESP_GATT_ILLEGAL_HANDLE 0
/// GATT attribute max handle
/** @brief GATT attribute max handle. */
#define ESP_GATT_ATTR_HANDLE_MAX UC_CONFIG_BT_GATT_MAX_SR_ATTRIBUTES
#define ESP_GATT_MAX_READ_MULTI_HANDLES 10 /* Max attributes to read in one request */
/** @brief Maximum number of attributes to read in one request. */
#define ESP_GATT_MAX_READ_MULTI_HANDLES 10
/**@{
* All "ESP_GATT_UUID_xxx" is attribute types
/**
* @defgroup GATT_UUIDs GATT Service UUIDs
* @brief Definitions of GATT Service UUIDs.
*
* This module contains the definitions of standard GATT service UUIDs. These UUIDs
* identify the type of GATT service.
* @{
*/
#define ESP_GATT_UUID_IMMEDIATE_ALERT_SVC 0x1802 /* Immediate alert Service*/
#define ESP_GATT_UUID_LINK_LOSS_SVC 0x1803 /* Link Loss Service*/
#define ESP_GATT_UUID_TX_POWER_SVC 0x1804 /* TX Power Service*/
#define ESP_GATT_UUID_CURRENT_TIME_SVC 0x1805 /* Current Time Service Service*/
#define ESP_GATT_UUID_REF_TIME_UPDATE_SVC 0x1806 /* Reference Time Update Service*/
#define ESP_GATT_UUID_NEXT_DST_CHANGE_SVC 0x1807 /* Next DST Change Service*/
#define ESP_GATT_UUID_GLUCOSE_SVC 0x1808 /* Glucose Service*/
#define ESP_GATT_UUID_HEALTH_THERMOM_SVC 0x1809 /* Health Thermometer Service*/
#define ESP_GATT_UUID_DEVICE_INFO_SVC 0x180A /* Device Information Service*/
#define ESP_GATT_UUID_HEART_RATE_SVC 0x180D /* Heart Rate Service*/
#define ESP_GATT_UUID_PHONE_ALERT_STATUS_SVC 0x180E /* Phone Alert Status Service*/
#define ESP_GATT_UUID_BATTERY_SERVICE_SVC 0x180F /* Battery Service*/
#define ESP_GATT_UUID_BLOOD_PRESSURE_SVC 0x1810 /* Blood Pressure Service*/
#define ESP_GATT_UUID_ALERT_NTF_SVC 0x1811 /* Alert Notification Service*/
#define ESP_GATT_UUID_HID_SVC 0x1812 /* HID Service*/
#define ESP_GATT_UUID_SCAN_PARAMETERS_SVC 0x1813 /* Scan Parameters Service*/
#define ESP_GATT_UUID_RUNNING_SPEED_CADENCE_SVC 0x1814 /* Running Speed and Cadence Service*/
#define ESP_GATT_UUID_Automation_IO_SVC 0x1815 /* Automation IO Service*/
#define ESP_GATT_UUID_CYCLING_SPEED_CADENCE_SVC 0x1816 /* Cycling Speed and Cadence Service*/
#define ESP_GATT_UUID_CYCLING_POWER_SVC 0x1818 /* Cycling Power Service*/
#define ESP_GATT_UUID_LOCATION_AND_NAVIGATION_SVC 0x1819 /* Location and Navigation Service*/
#define ESP_GATT_UUID_ENVIRONMENTAL_SENSING_SVC 0x181A /* Environmental Sensing Service*/
#define ESP_GATT_UUID_BODY_COMPOSITION 0x181B /* Body Composition Service*/
#define ESP_GATT_UUID_USER_DATA_SVC 0x181C /* User Data Service*/
#define ESP_GATT_UUID_WEIGHT_SCALE_SVC 0x181D /* Weight Scale Service*/
#define ESP_GATT_UUID_BOND_MANAGEMENT_SVC 0x181E /* Bond Management Service*/
#define ESP_GATT_UUID_CONT_GLUCOSE_MONITOR_SVC 0x181F /* Continuous Glucose Monitoring Service*/
/** @brief Immediate Alert Service UUID. */
#define ESP_GATT_UUID_IMMEDIATE_ALERT_SVC 0x1802
/** @brief Link Loss Service UUID. */
#define ESP_GATT_UUID_LINK_LOSS_SVC 0x1803
/** @brief TX Power Service UUID. */
#define ESP_GATT_UUID_TX_POWER_SVC 0x1804
/** @brief Current Time Service UUID. */
#define ESP_GATT_UUID_CURRENT_TIME_SVC 0x1805
/** @brief Reference Time Update Service UUID. */
#define ESP_GATT_UUID_REF_TIME_UPDATE_SVC 0x1806
/** @brief Next DST Change Service UUID. */
#define ESP_GATT_UUID_NEXT_DST_CHANGE_SVC 0x1807
/** @brief Glucose Service UUID. */
#define ESP_GATT_UUID_GLUCOSE_SVC 0x1808
/** @brief Health Thermometer Service UUID. */
#define ESP_GATT_UUID_HEALTH_THERMOM_SVC 0x1809
/** @brief Device Information Service UUID. */
#define ESP_GATT_UUID_DEVICE_INFO_SVC 0x180A
/** @brief Heart Rate Service UUID. */
#define ESP_GATT_UUID_HEART_RATE_SVC 0x180D
/** @brief Phone Alert Status Service UUID. */
#define ESP_GATT_UUID_PHONE_ALERT_STATUS_SVC 0x180E
/** @brief Battery Service UUID. */
#define ESP_GATT_UUID_BATTERY_SERVICE_SVC 0x180F
/** @brief Blood Pressure Service UUID. */
#define ESP_GATT_UUID_BLOOD_PRESSURE_SVC 0x1810
/** @brief Alert Notification Service UUID. */
#define ESP_GATT_UUID_ALERT_NTF_SVC 0x1811
/** @brief HID Service UUID. */
#define ESP_GATT_UUID_HID_SVC 0x1812
/** @brief Scan Parameters Service UUID. */
#define ESP_GATT_UUID_SCAN_PARAMETERS_SVC 0x1813
/** @brief Running Speed and Cadence Service UUID. */
#define ESP_GATT_UUID_RUNNING_SPEED_CADENCE_SVC 0x1814
/** @brief Automation IO Service UUID. */
#define ESP_GATT_UUID_Automation_IO_SVC 0x1815
/** @brief Cycling Speed and Cadence Service UUID. */
#define ESP_GATT_UUID_CYCLING_SPEED_CADENCE_SVC 0x1816
/** @brief Cycling Power Service UUID. */
#define ESP_GATT_UUID_CYCLING_POWER_SVC 0x1818
/** @brief Location and Navigation Service UUID. */
#define ESP_GATT_UUID_LOCATION_AND_NAVIGATION_SVC 0x1819
/** @brief Environmental Sensing Service UUID. */
#define ESP_GATT_UUID_ENVIRONMENTAL_SENSING_SVC 0x181A
/** @brief Body Composition Service UUID. */
#define ESP_GATT_UUID_BODY_COMPOSITION 0x181B
/** @brief User Data Service UUID. */
#define ESP_GATT_UUID_USER_DATA_SVC 0x181C
/** @brief Weight Scale Service UUID. */
#define ESP_GATT_UUID_WEIGHT_SCALE_SVC 0x181D
/** @brief Bond Management Service UUID. */
#define ESP_GATT_UUID_BOND_MANAGEMENT_SVC 0x181E
/** @brief Continuous Glucose Monitoring Service UUID. */
#define ESP_GATT_UUID_CONT_GLUCOSE_MONITOR_SVC 0x181F
/** @brief Primary Service UUID. */
#define ESP_GATT_UUID_PRI_SERVICE 0x2800
/** @brief Secondary Service UUID. */
#define ESP_GATT_UUID_SEC_SERVICE 0x2801
/** @brief Include Service UUID. */
#define ESP_GATT_UUID_INCLUDE_SERVICE 0x2802
#define ESP_GATT_UUID_CHAR_DECLARE 0x2803 /* Characteristic Declaration*/
#define ESP_GATT_UUID_CHAR_EXT_PROP 0x2900 /* Characteristic Extended Properties */
#define ESP_GATT_UUID_CHAR_DESCRIPTION 0x2901 /* Characteristic User Description*/
#define ESP_GATT_UUID_CHAR_CLIENT_CONFIG 0x2902 /* Client Characteristic Configuration */
#define ESP_GATT_UUID_CHAR_SRVR_CONFIG 0x2903 /* Server Characteristic Configuration */
#define ESP_GATT_UUID_CHAR_PRESENT_FORMAT 0x2904 /* Characteristic Presentation Format*/
#define ESP_GATT_UUID_CHAR_AGG_FORMAT 0x2905 /* Characteristic Aggregate Format*/
#define ESP_GATT_UUID_CHAR_VALID_RANGE 0x2906 /* Characteristic Valid Range */
#define ESP_GATT_UUID_EXT_RPT_REF_DESCR 0x2907 /* External Report Reference */
#define ESP_GATT_UUID_RPT_REF_DESCR 0x2908 /* Report Reference */
#define ESP_GATT_UUID_NUM_DIGITALS_DESCR 0x2909 /* Number of Digitals */
#define ESP_GATT_UUID_VALUE_TRIGGER_DESCR 0x290A /* Value Trigger Setting */
#define ESP_GATT_UUID_ENV_SENSING_CONFIG_DESCR 0x290B /* Environmental Sensing Configuration */
#define ESP_GATT_UUID_ENV_SENSING_MEASUREMENT_DESCR 0x290C /* Environmental Sensing Measurement */
#define ESP_GATT_UUID_ENV_SENSING_TRIGGER_DESCR 0x290D /* Environmental Sensing Trigger Setting */
#define ESP_GATT_UUID_TIME_TRIGGER_DESCR 0x290E /* Time Trigger Setting */
/** @brief Characteristic Declaration UUID. */
#define ESP_GATT_UUID_CHAR_DECLARE 0x2803
/** @brief Characteristic Extended Properties UUID. */
#define ESP_GATT_UUID_CHAR_EXT_PROP 0x2900
/** @brief Characteristic User Description UUID. */
#define ESP_GATT_UUID_CHAR_DESCRIPTION 0x2901
/** @brief Client Characteristic Configuration UUID. */
#define ESP_GATT_UUID_CHAR_CLIENT_CONFIG 0x2902
/** @brief Server Characteristic Configuration UUID. */
#define ESP_GATT_UUID_CHAR_SRVR_CONFIG 0x2903
/** @brief Characteristic Presentation Format UUID. */
#define ESP_GATT_UUID_CHAR_PRESENT_FORMAT 0x2904
/** @brief Characteristic Aggregate Format UUID. */
#define ESP_GATT_UUID_CHAR_AGG_FORMAT 0x2905
/** @brief Characteristic Valid Range UUID. */
#define ESP_GATT_UUID_CHAR_VALID_RANGE 0x2906
/** @brief External Report Reference Descriptor UUID. */
#define ESP_GATT_UUID_EXT_RPT_REF_DESCR 0x2907
/** @brief Report Reference Descriptor UUID. */
#define ESP_GATT_UUID_RPT_REF_DESCR 0x2908
/** @brief Number of Digitals Descriptor UUID. */
#define ESP_GATT_UUID_NUM_DIGITALS_DESCR 0x2909
/** @brief Value Trigger Setting Descriptor UUID. */
#define ESP_GATT_UUID_VALUE_TRIGGER_DESCR 0x290A
/** @brief Environmental Sensing Configuration Descriptor UUID. */
#define ESP_GATT_UUID_ENV_SENSING_CONFIG_DESCR 0x290B
/** @brief Environmental Sensing Measurement Descriptor UUID. */
#define ESP_GATT_UUID_ENV_SENSING_MEASUREMENT_DESCR 0x290C
/** @brief Environmental Sensing Trigger Setting Descriptor UUID. */
#define ESP_GATT_UUID_ENV_SENSING_TRIGGER_DESCR 0x290D
/** @brief Time Trigger Setting Descriptor UUID. */
#define ESP_GATT_UUID_TIME_TRIGGER_DESCR 0x290E
/* GAP Profile Attributes */
/** @brief GAP Device Name UUID. */
#define ESP_GATT_UUID_GAP_DEVICE_NAME 0x2A00
/** @brief GAP Icon UUID. */
#define ESP_GATT_UUID_GAP_ICON 0x2A01
/** @brief GAP Preferred Connection Parameters UUID. */
#define ESP_GATT_UUID_GAP_PREF_CONN_PARAM 0x2A04
/** @brief GAP Central Address Resolution UUID. */
#define ESP_GATT_UUID_GAP_CENTRAL_ADDR_RESOL 0x2AA6
/* Attribute Profile Attribute UUID */
/** @brief GATT Service Changed UUID. */
#define ESP_GATT_UUID_GATT_SRV_CHGD 0x2A05
/* Link ESP_Loss Service */
#define ESP_GATT_UUID_ALERT_LEVEL 0x2A06 /* Alert Level */
#define ESP_GATT_UUID_TX_POWER_LEVEL 0x2A07 /* TX power level */
/* Link Loss Service */
/** @brief Alert Level UUID. */
#define ESP_GATT_UUID_ALERT_LEVEL 0x2A06
/** @brief TX Power Level UUID. */
#define ESP_GATT_UUID_TX_POWER_LEVEL 0x2A07
/* Current Time Service */
#define ESP_GATT_UUID_CURRENT_TIME 0x2A2B /* Current Time */
#define ESP_GATT_UUID_LOCAL_TIME_INFO 0x2A0F /* Local time info */
#define ESP_GATT_UUID_REF_TIME_INFO 0x2A14 /* reference time information */
/** @brief Current Time UUID. */
#define ESP_GATT_UUID_CURRENT_TIME 0x2A2B
/** @brief Local Time Info UUID. */
#define ESP_GATT_UUID_LOCAL_TIME_INFO 0x2A0F
/** @brief Reference Time Information UUID. */
#define ESP_GATT_UUID_REF_TIME_INFO 0x2A14
/* Network availability Profile */
#define ESP_GATT_UUID_NW_STATUS 0x2A18 /* network availability status */
#define ESP_GATT_UUID_NW_TRIGGER 0x2A1A /* Network availability trigger */
/* Network Availability Service */
/** @brief Network Availability Status UUID. */
#define ESP_GATT_UUID_NW_STATUS 0x2A18
/** @brief Network Availability Trigger UUID. */
#define ESP_GATT_UUID_NW_TRIGGER 0x2A1A
/* Phone alert */
#define ESP_GATT_UUID_ALERT_STATUS 0x2A3F /* alert status */
#define ESP_GATT_UUID_RINGER_CP 0x2A40 /* ringer control point */
#define ESP_GATT_UUID_RINGER_SETTING 0x2A41 /* ringer setting */
/* Phone Alert Status Service */
/** @brief Alert Status UUID. */
#define ESP_GATT_UUID_ALERT_STATUS 0x2A3F
/** @brief Ringer Control Point UUID. */
#define ESP_GATT_UUID_RINGER_CP 0x2A40
/** @brief Ringer Setting UUID. */
#define ESP_GATT_UUID_RINGER_SETTING 0x2A41
/* Glucose Service */
/** @brief Glucose Measurement Characteristic UUID. */
#define ESP_GATT_UUID_GM_MEASUREMENT 0x2A18
/** @brief Glucose Measurement Context Characteristic UUID. */
#define ESP_GATT_UUID_GM_CONTEXT 0x2A34
/** @brief Glucose Control Point Characteristic UUID. */
#define ESP_GATT_UUID_GM_CONTROL_POINT 0x2A52
/** @brief Glucose Feature Characteristic UUID. */
#define ESP_GATT_UUID_GM_FEATURE 0x2A51
/* device information characteristic */
/* Device Information Service Characteristics */
/** @brief System ID Characteristic UUID. */
#define ESP_GATT_UUID_SYSTEM_ID 0x2A23
/** @brief Model Number String Characteristic UUID. */
#define ESP_GATT_UUID_MODEL_NUMBER_STR 0x2A24
/** @brief Serial Number String Characteristic UUID. */
#define ESP_GATT_UUID_SERIAL_NUMBER_STR 0x2A25
/** @brief Firmware Revision String Characteristic UUID. */
#define ESP_GATT_UUID_FW_VERSION_STR 0x2A26
/** @brief Hardware Revision String Characteristic UUID. */
#define ESP_GATT_UUID_HW_VERSION_STR 0x2A27
/** @brief Software Revision String Characteristic UUID. */
#define ESP_GATT_UUID_SW_VERSION_STR 0x2A28
/** @brief Manufacturer Name String Characteristic UUID. */
#define ESP_GATT_UUID_MANU_NAME 0x2A29
/** @brief IEEE 11073-20601 Regulatory Certification Data List Characteristic UUID. */
#define ESP_GATT_UUID_IEEE_DATA 0x2A2A
/** @brief PnP ID Characteristic UUID. */
#define ESP_GATT_UUID_PNP_ID 0x2A50
/* HID characteristics */
/* HID Service Characteristics */
/** @brief HID Information Characteristic UUID. */
#define ESP_GATT_UUID_HID_INFORMATION 0x2A4A
/** @brief HID Report Map Characteristic UUID. */
#define ESP_GATT_UUID_HID_REPORT_MAP 0x2A4B
/** @brief HID Control Point Characteristic UUID. */
#define ESP_GATT_UUID_HID_CONTROL_POINT 0x2A4C
/** @brief HID Report Characteristic UUID. */
#define ESP_GATT_UUID_HID_REPORT 0x2A4D
/** @brief HID Protocol Mode Characteristic UUID. */
#define ESP_GATT_UUID_HID_PROTO_MODE 0x2A4E
/** @brief HID Bluetooth Keyboard Input Characteristic UUID. */
#define ESP_GATT_UUID_HID_BT_KB_INPUT 0x2A22
/** @brief HID Bluetooth Keyboard Output Characteristic UUID. */
#define ESP_GATT_UUID_HID_BT_KB_OUTPUT 0x2A32
/** @brief HID Bluetooth Mouse Input Characteristic UUID. */
#define ESP_GATT_UUID_HID_BT_MOUSE_INPUT 0x2A33
/// Heart Rate Measurement
#define ESP_GATT_HEART_RATE_MEAS 0x2A37
/// Body Sensor Location
#define ESP_GATT_BODY_SENSOR_LOCATION 0x2A38
/// Heart Rate Control Point
#define ESP_GATT_HEART_RATE_CNTL_POINT 0x2A39
/* Heart Rate Service Characteristics */
/** @brief Heart Rate Measurement Characteristic UUID. */
#define ESP_GATT_HEART_RATE_MEAS 0x2A37
/** @brief Body Sensor Location Characteristic UUID. */
#define ESP_GATT_BODY_SENSOR_LOCATION 0x2A38
/** @brief Heart Rate Control Point Characteristic UUID. */
#define ESP_GATT_HEART_RATE_CNTL_POINT 0x2A39
/* Battery Service characteristics */
/* Battery Service Characteristics */
/** @brief Battery Level Characteristic UUID. */
#define ESP_GATT_UUID_BATTERY_LEVEL 0x2A19
/* Sensor Service */
/* Sensor Service Characteristics */
/** @brief Sensor Control Point Characteristic UUID. */
#define ESP_GATT_UUID_SC_CONTROL_POINT 0x2A55
/** @brief Sensor Location Characteristic UUID. */
#define ESP_GATT_UUID_SENSOR_LOCATION 0x2A5D
/* Runners speed and cadence service */
/* Running Speed and Cadence Service Characteristics */
/** @brief RSC Measurement Characteristic UUID. */
#define ESP_GATT_UUID_RSC_MEASUREMENT 0x2A53
/** @brief RSC Feature Characteristic UUID. */
#define ESP_GATT_UUID_RSC_FEATURE 0x2A54
/* Cycling speed and cadence service */
/* Cycling Speed and Cadence Service Characteristics */
/** @brief CSC Measurement Characteristic UUID. */
#define ESP_GATT_UUID_CSC_MEASUREMENT 0x2A5B
/** @brief CSC Feature Characteristic UUID. */
#define ESP_GATT_UUID_CSC_FEATURE 0x2A5C
/* Scan ESP_Parameter characteristics */
/* Scan Parameters Service Characteristics */
/** @brief Scan Interval Window Characteristic UUID. */
#define ESP_GATT_UUID_SCAN_INT_WINDOW 0x2A4F
/** @brief Scan Refresh UUID. */
#define ESP_GATT_UUID_SCAN_REFRESH 0x2A31
/**
* @}
*/
/* Additional GATT Services not covered yet */
/** @} */ // End of group GATT_UUIDs
/* relate to BTA_GATT_PREP_WRITE_xxx in bta/bta_gatt_api.h */
/// Attribute write data type from the client
/**
* @brief Defines the attribute write operation types from the client.
*
* These values are used to specify the type of write operation in a prepare write sequence.
* relate to BTA_GATT_PREP_WRITE_xxx in bta/bta_gatt_api.h.
*/
typedef enum {
ESP_GATT_PREP_WRITE_CANCEL = 0x00, /*!< Prepare write cancel */ /* relate to BTA_GATT_PREP_WRITE_CANCEL in bta/bta_gatt_api.h */
ESP_GATT_PREP_WRITE_EXEC = 0x01, /*!< Prepare write execute */ /* relate to BTA_GATT_PREP_WRITE_EXEC in bta/bta_gatt_api.h */
ESP_GATT_PREP_WRITE_CANCEL = 0x00, /*!< Prepare write cancel. Corresponds to BTA_GATT_PREP_WRITE_CANCEL. */
ESP_GATT_PREP_WRITE_EXEC = 0x01, /*!< Prepare write execute. Corresponds to BTA_GATT_PREP_WRITE_EXEC. */
} esp_gatt_prep_write_type;
/* relate to BTA_GATT_xxx in bta/bta_gatt_api.h */
/**
* @brief GATT success code and error codes
* @brief GATT operation status codes.
*
* These status codes are used to indicate the result of various GATT operations.
* relate to BTA_GATT_xxx in bta/bta_gatt_api.h .
*/
typedef enum {
ESP_GATT_OK = 0x0, /* relate to BTA_GATT_OK in bta/bta_gatt_api.h */
ESP_GATT_INVALID_HANDLE = 0x01, /* 0x0001 */ /* relate to BTA_GATT_INVALID_HANDLE in bta/bta_gatt_api.h */
ESP_GATT_READ_NOT_PERMIT = 0x02, /* 0x0002 */ /* relate to BTA_GATT_READ_NOT_PERMIT in bta/bta_gatt_api.h */
ESP_GATT_WRITE_NOT_PERMIT = 0x03, /* 0x0003 */ /* relate to BTA_GATT_WRITE_NOT_PERMIT in bta/bta_gatt_api.h */
ESP_GATT_INVALID_PDU = 0x04, /* 0x0004 */ /* relate to BTA_GATT_INVALID_PDU in bta/bta_gatt_api.h */
ESP_GATT_INSUF_AUTHENTICATION = 0x05, /* 0x0005 */ /* relate to BTA_GATT_INSUF_AUTHENTICATION in bta/bta_gatt_api.h */
ESP_GATT_REQ_NOT_SUPPORTED = 0x06, /* 0x0006 */ /* relate to BTA_GATT_REQ_NOT_SUPPORTED in bta/bta_gatt_api.h */
ESP_GATT_INVALID_OFFSET = 0x07, /* 0x0007 */ /* relate to BTA_GATT_INVALID_OFFSET in bta/bta_gatt_api.h */
ESP_GATT_INSUF_AUTHORIZATION = 0x08, /* 0x0008 */ /* relate to BTA_GATT_INSUF_AUTHORIZATION in bta/bta_gatt_api.h */
ESP_GATT_PREPARE_Q_FULL = 0x09, /* 0x0009 */ /* relate to BTA_GATT_PREPARE_Q_FULL in bta/bta_gatt_api.h */
ESP_GATT_NOT_FOUND = 0x0a, /* 0x000a */ /* relate to BTA_GATT_NOT_FOUND in bta/bta_gatt_api.h */
ESP_GATT_NOT_LONG = 0x0b, /* 0x000b */ /* relate to BTA_GATT_NOT_LONG in bta/bta_gatt_api.h */
ESP_GATT_INSUF_KEY_SIZE = 0x0c, /* 0x000c */ /* relate to BTA_GATT_INSUF_KEY_SIZE in bta/bta_gatt_api.h */
ESP_GATT_INVALID_ATTR_LEN = 0x0d, /* 0x000d */ /* relate to BTA_GATT_INVALID_ATTR_LEN in bta/bta_gatt_api.h */
ESP_GATT_ERR_UNLIKELY = 0x0e, /* 0x000e */ /* relate to BTA_GATT_ERR_UNLIKELY in bta/bta_gatt_api.h */
ESP_GATT_INSUF_ENCRYPTION = 0x0f, /* 0x000f */ /* relate to BTA_GATT_INSUF_ENCRYPTION in bta/bta_gatt_api.h */
ESP_GATT_UNSUPPORT_GRP_TYPE = 0x10, /* 0x0010 */ /* relate to BTA_GATT_UNSUPPORT_GRP_TYPE in bta/bta_gatt_api.h */
ESP_GATT_INSUF_RESOURCE = 0x11, /* 0x0011 */ /* relate to BTA_GATT_INSUF_RESOURCE in bta/bta_gatt_api.h */
ESP_GATT_OK = 0x0, /*!< 0x0, Operation successful. Corresponds to BTA_GATT_OK. */
ESP_GATT_INVALID_HANDLE = 0x01, /*!< 0x01, Invalid handle. Corresponds to BTA_GATT_INVALID_HANDLE. */
ESP_GATT_READ_NOT_PERMIT = 0x02, /*!< 0x02, Read operation not permitted. Corresponds to BTA_GATT_READ_NOT_PERMIT. */
ESP_GATT_WRITE_NOT_PERMIT = 0x03, /*!< 0x03, Write operation not permitted. Corresponds to BTA_GATT_WRITE_NOT_PERMIT. */
ESP_GATT_INVALID_PDU = 0x04, /*!< 0x04, Invalid PDU. Corresponds to BTA_GATT_INVALID_PDU. */
ESP_GATT_INSUF_AUTHENTICATION = 0x05, /*!< 0x05, Insufficient authentication. Corresponds to BTA_GATT_INSUF_AUTHENTICATION. */
ESP_GATT_REQ_NOT_SUPPORTED = 0x06, /*!< 0x06, Request not supported. Corresponds to BTA_GATT_REQ_NOT_SUPPORTED. */
ESP_GATT_INVALID_OFFSET = 0x07, /*!< 0x07, Invalid offset. Corresponds to BTA_GATT_INVALID_OFFSET. */
ESP_GATT_INSUF_AUTHORIZATION = 0x08, /*!< 0x08, Insufficient authorization. Corresponds to BTA_GATT_INSUF_AUTHORIZATION. */
ESP_GATT_PREPARE_Q_FULL = 0x09, /*!< 0x09, Prepare queue full. Corresponds to BTA_GATT_PREPARE_Q_FULL. */
ESP_GATT_NOT_FOUND = 0x0a, /*!< 0x0a, Not found. Corresponds to BTA_GATT_NOT_FOUND. */
ESP_GATT_NOT_LONG = 0x0b, /*!< 0x0b, Not long. Corresponds to BTA_GATT_NOT_LONG. */
ESP_GATT_INSUF_KEY_SIZE = 0x0c, /*!< 0x0c, Insufficient key size. Corresponds to BTA_GATT_INSUF_KEY_SIZE. */
ESP_GATT_INVALID_ATTR_LEN = 0x0d, /*!< 0x0d, Invalid attribute length. Corresponds to BTA_GATT_INVALID_ATTR_LEN. */
ESP_GATT_ERR_UNLIKELY = 0x0e, /*!< 0x0e, Unlikely error. Corresponds to BTA_GATT_ERR_UNLIKELY. */
ESP_GATT_INSUF_ENCRYPTION = 0x0f, /*!< 0x0f, Insufficient encryption. Corresponds to BTA_GATT_INSUF_ENCRYPTION. */
ESP_GATT_UNSUPPORT_GRP_TYPE = 0x10, /*!< 0x10, Unsupported group type. Corresponds to BTA_GATT_UNSUPPORT_GRP_TYPE. */
ESP_GATT_INSUF_RESOURCE = 0x11, /*!< 0x11, Insufficient resource. Corresponds to BTA_GATT_INSUF_RESOURCE. */
ESP_GATT_NO_RESOURCES = 0x80, /* 0x80 */ /* relate to BTA_GATT_NO_RESOURCES in bta/bta_gatt_api.h */
ESP_GATT_INTERNAL_ERROR = 0x81, /* 0x81 */ /* relate to BTA_GATT_INTERNAL_ERROR in bta/bta_gatt_api.h */
ESP_GATT_WRONG_STATE = 0x82, /* 0x82 */ /* relate to BTA_GATT_WRONG_STATE in bta/bta_gatt_api.h */
ESP_GATT_DB_FULL = 0x83, /* 0x83 */ /* relate to BTA_GATT_DB_FULL in bta/bta_gatt_api.h */
ESP_GATT_BUSY = 0x84, /* 0x84 */ /* relate to BTA_GATT_BUSY in bta/bta_gatt_api.h */
ESP_GATT_ERROR = 0x85, /* 0x85 */ /* relate to BTA_GATT_ERROR in bta/bta_gatt_api.h */
ESP_GATT_CMD_STARTED = 0x86, /* 0x86 */ /* relate to BTA_GATT_CMD_STARTED in bta/bta_gatt_api.h */
ESP_GATT_ILLEGAL_PARAMETER = 0x87, /* 0x87 */ /* relate to BTA_GATT_ILLEGAL_PARAMETER in bta/bta_gatt_api.h */
ESP_GATT_PENDING = 0x88, /* 0x88 */ /* relate to BTA_GATT_PENDING in bta/bta_gatt_api.h */
ESP_GATT_AUTH_FAIL = 0x89, /* 0x89 */ /* relate to BTA_GATT_AUTH_FAIL in bta/bta_gatt_api.h */
ESP_GATT_MORE = 0x8a, /* 0x8a */ /* relate to BTA_GATT_MORE in bta/bta_gatt_api.h */
ESP_GATT_INVALID_CFG = 0x8b, /* 0x8b */ /* relate to BTA_GATT_INVALID_CFG in bta/bta_gatt_api.h */
ESP_GATT_SERVICE_STARTED = 0x8c, /* 0x8c */ /* relate to BTA_GATT_SERVICE_STARTED in bta/bta_gatt_api.h */
ESP_GATT_ENCRYPTED_MITM = ESP_GATT_OK, /* relate to BTA_GATT_ENCRYPED_MITM in bta/bta_gatt_api.h */
ESP_GATT_ENCRYPTED_NO_MITM = 0x8d, /* 0x8d */ /* relate to BTA_GATT_ENCRYPED_NO_MITM in bta/bta_gatt_api.h */
ESP_GATT_NOT_ENCRYPTED = 0x8e, /* 0x8e */ /* relate to BTA_GATT_NOT_ENCRYPTED in bta/bta_gatt_api.h */
ESP_GATT_CONGESTED = 0x8f, /* 0x8f */ /* relate to BTA_GATT_CONGESTED in bta/bta_gatt_api.h */
ESP_GATT_DUP_REG = 0x90, /* 0x90 */ /* relate to BTA_GATT_DUP_REG in bta/bta_gatt_api.h */
ESP_GATT_ALREADY_OPEN = 0x91, /* 0x91 */ /* relate to BTA_GATT_ALREADY_OPEN in bta/bta_gatt_api.h */
ESP_GATT_CANCEL = 0x92, /* 0x92 */ /* relate to BTA_GATT_CANCEL in bta/bta_gatt_api.h */
/* Additional error codes specific to implementation or future use */
ESP_GATT_NO_RESOURCES = 0x80, /*!< 0x80, No resources. Corresponds to BTA_GATT_NO_RESOURCES. */
ESP_GATT_INTERNAL_ERROR = 0x81, /*!< 0x81, Internal error. Corresponds to BTA_GATT_INTERNAL_ERROR. */
ESP_GATT_WRONG_STATE = 0x82, /*!< 0x82, Wrong state. Corresponds to BTA_GATT_WRONG_STATE. */
ESP_GATT_DB_FULL = 0x83, /*!< 0x83, Database full. Corresponds to BTA_GATT_DB_FULL. */
ESP_GATT_BUSY = 0x84, /*!< 0x84, Busy. Corresponds to BTA_GATT_BUSY. */
ESP_GATT_ERROR = 0x85, /*!< 0x85, Generic error. Corresponds to BTA_GATT_ERROR. */
ESP_GATT_CMD_STARTED = 0x86, /*!< 0x86, Command started. Corresponds to BTA_GATT_CMD_STARTED. */
ESP_GATT_ILLEGAL_PARAMETER = 0x87, /*!< 0x87, Illegal parameter. Corresponds to BTA_GATT_ILLEGAL_PARAMETER. */
ESP_GATT_PENDING = 0x88, /*!< 0x88, Operation pending. Corresponds to BTA_GATT_PENDING. */
ESP_GATT_AUTH_FAIL = 0x89, /*!< 0x89, Authentication failed. Corresponds to BTA_GATT_AUTH_FAIL. */
ESP_GATT_MORE = 0x8a, /*!< 0x8a, More data available. Corresponds to BTA_GATT_MORE. */
ESP_GATT_INVALID_CFG = 0x8b, /*!< 0x8b, Invalid configuration. Corresponds to BTA_GATT_INVALID_CFG. */
ESP_GATT_SERVICE_STARTED = 0x8c, /*!< 0x8c, Service started. Corresponds to BTA_GATT_SERVICE_STARTED. */
ESP_GATT_ENCRYPTED_MITM = ESP_GATT_OK, /*!< 0x0, Encrypted, with MITM protection. Corresponds to BTA_GATT_ENCRYPTED_MITM. */
ESP_GATT_ENCRYPTED_NO_MITM = 0x8d, /*!< 0x8d, Encrypted, without MITM protection. Corresponds to BTA_GATT_ENCRYPTED_NO_MITM. */
ESP_GATT_NOT_ENCRYPTED = 0x8e, /*!< 0x8e, Not encrypted. Corresponds to BTA_GATT_NOT_ENCRYPTED. */
ESP_GATT_CONGESTED = 0x8f, /*!< 0x8f, Congested. Corresponds to BTA_GATT_CONGESTED. */
ESP_GATT_DUP_REG = 0x90, /*!< 0x90, Duplicate registration. Corresponds to BTA_GATT_DUP_REG. */
ESP_GATT_ALREADY_OPEN = 0x91, /*!< 0x91, Already open. Corresponds to BTA_GATT_ALREADY_OPEN. */
ESP_GATT_CANCEL = 0x92, /*!< 0x92, Operation cancelled. Corresponds to BTA_GATT_CANCEL. */
/* 0xE0 ~ 0xFC reserved for future use */
ESP_GATT_STACK_RSP = 0xe0, /* 0xe0 */ /* relate to BTA_GATT_STACK_RSP in bta/bta_gatt_api.h */
ESP_GATT_APP_RSP = 0xe1, /* 0xe1 */ /* relate to BTA_GATT_APP_RSP in bta/bta_gatt_api.h */
//Error caused by customer application or stack bug
ESP_GATT_UNKNOWN_ERROR = 0xef, /* 0xef */ /* relate to BTA_GATT_UNKNOWN_ERROR in bta/bta_gatt_api.h */
ESP_GATT_CCC_CFG_ERR = 0xfd, /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */ /* relate to BTA_GATT_CCC_CFG_ERR in bta/bta_gatt_api.h */
ESP_GATT_PRC_IN_PROGRESS = 0xfe, /* 0xFE Procedure Already in progress */ /* relate to BTA_GATT_PRC_IN_PROGRESS in bta/bta_gatt_api.h */
ESP_GATT_OUT_OF_RANGE = 0xff, /* 0xFF Attribute value out of range */ /* relate to BTA_GATT_OUT_OF_RANGE in bta/bta_gatt_api.h */
ESP_GATT_STACK_RSP = 0xe0, /*!< 0xe0, Stack response. Corresponds to BTA_GATT_STACK_RSP. */
ESP_GATT_APP_RSP = 0xe1, /*!< 0xe1, Application response. Corresponds to BTA_GATT_APP_RSP. */
/* Error caused by customer application or stack bug */
ESP_GATT_UNKNOWN_ERROR = 0xef, /*!< 0xef, Unknown error. Corresponds to BTA_GATT_UNKNOWN_ERROR. */
ESP_GATT_CCC_CFG_ERR = 0xfd, /*!< 0xfd, Client Characteristic Configuration Descriptor improperly configured. Corresponds to BTA_GATT_CCC_CFG_ERR. */
ESP_GATT_PRC_IN_PROGRESS = 0xfe, /*!< 0xfe, Procedure already in progress. Corresponds to BTA_GATT_PRC_IN_PROGRESS. */
ESP_GATT_OUT_OF_RANGE = 0xff /*!< 0xff, Attribute value out of range. Corresponds to BTA_GATT_OUT_OF_RANGE. */
} esp_gatt_status_t;
/* relate to BTA_GATT_CONN_xxx in bta/bta_gatt_api.h */
/**
* @brief Gatt Connection reason enum
* @brief Enumerates reasons for GATT connection.
*/
typedef enum {
ESP_GATT_CONN_UNKNOWN = 0, /*!< Gatt connection unknown */ /* relate to BTA_GATT_CONN_UNKNOWN in bta/bta_gatt_api.h */
ESP_GATT_CONN_L2C_FAILURE = 1, /*!< General L2cap failure */ /* relate to BTA_GATT_CONN_L2C_FAILURE in bta/bta_gatt_api.h */
ESP_GATT_CONN_TIMEOUT = 0x08, /*!< Connection timeout */ /* relate to BTA_GATT_CONN_TIMEOUT in bta/bta_gatt_api.h */
ESP_GATT_CONN_TERMINATE_PEER_USER = 0x13, /*!< Connection terminate by peer user */ /* relate to BTA_GATT_CONN_TERMINATE_PEER_USER in bta/bta_gatt_api.h */
ESP_GATT_CONN_TERMINATE_LOCAL_HOST = 0x16, /*!< Connection terminated by local host */ /* relate to BTA_GATT_CONN_TERMINATE_LOCAL_HOST in bta/bta_gatt_api.h */
ESP_GATT_CONN_FAIL_ESTABLISH = 0x3e, /*!< Connection fail to establish */ /* relate to BTA_GATT_CONN_FAIL_ESTABLISH in bta/bta_gatt_api.h */
ESP_GATT_CONN_LMP_TIMEOUT = 0x22, /*!< Connection fail for LMP response tout */ /* relate to BTA_GATT_CONN_LMP_TIMEOUT in bta/bta_gatt_api.h */
ESP_GATT_CONN_CONN_CANCEL = 0x0100, /*!< L2CAP connection cancelled */ /* relate to BTA_GATT_CONN_CONN_CANCEL in bta/bta_gatt_api.h */
ESP_GATT_CONN_NONE = 0x0101 /*!< No connection to cancel */ /* relate to BTA_GATT_CONN_NONE in bta/bta_gatt_api.h */
ESP_GATT_CONN_UNKNOWN = 0, /*!< Unknown connection reason. Corresponds to BTA_GATT_CONN_UNKNOWN in bta/bta_gatt_api.h */
ESP_GATT_CONN_L2C_FAILURE = 1, /*!< General L2CAP failure. Corresponds to BTA_GATT_CONN_L2C_FAILURE in bta/bta_gatt_api.h */
ESP_GATT_CONN_TIMEOUT = 0x08, /*!< Connection timeout. Corresponds to BTA_GATT_CONN_TIMEOUT in bta/bta_gatt_api.h */
ESP_GATT_CONN_TERMINATE_PEER_USER = 0x13, /*!< Connection terminated by peer user. Corresponds to BTA_GATT_CONN_TERMINATE_PEER_USER in bta/bta_gatt_api.h */
ESP_GATT_CONN_TERMINATE_LOCAL_HOST = 0x16, /*!< Connection terminated by local host. Corresponds to BTA_GATT_CONN_TERMINATE_LOCAL_HOST in bta/bta_gatt_api.h */
ESP_GATT_CONN_FAIL_ESTABLISH = 0x3e, /*!< Failure to establish connection. Corresponds to BTA_GATT_CONN_FAIL_ESTABLISH in bta/bta_gatt_api.h */
ESP_GATT_CONN_LMP_TIMEOUT = 0x22, /*!< Connection failed due to LMP response timeout. Corresponds to BTA_GATT_CONN_LMP_TIMEOUT in bta/bta_gatt_api.h */
ESP_GATT_CONN_CONN_CANCEL = 0x0100, /*!< L2CAP connection cancelled. Corresponds to BTA_GATT_CONN_CONN_CANCEL in bta/bta_gatt_api.h */
ESP_GATT_CONN_NONE = 0x0101 /*!< No connection to cancel. Corresponds to BTA_GATT_CONN_NONE in bta/bta_gatt_api.h */
} esp_gatt_conn_reason_t;
/**
* @brief Gatt id, include uuid and instance id
* @brief Represents a GATT identifier.
*/
typedef struct {
esp_bt_uuid_t uuid; /*!< UUID */
uint8_t inst_id; /*!< Instance id */
esp_bt_uuid_t uuid; /*!< @brief The UUID component of the GATT ID. */
uint8_t inst_id; /*!< @brief The instance ID component of the GATT ID, providing further differentiation of the GATT ID. */
} __attribute__((packed)) esp_gatt_id_t;
/**
* @brief Gatt service id, include id
* (uuid and instance id) and primary flag
* @brief Represents a GATT service identifier.
*/
typedef struct {
esp_gatt_id_t id; /*!< Gatt id, include uuid and instance */
bool is_primary; /*!< This service is primary or not */
esp_gatt_id_t id; /*!< @brief Encapsulates the UUID and instance ID of the GATT service. */
bool is_primary; /*!< @brief Indicates if the service is primary. A value of true means it is a primary service, false indicates a secondary service. */
} __attribute__((packed)) esp_gatt_srvc_id_t;
/* relate to BTA_GATT_AUTH_REQ_xxx in bta/bta_gatt_api.h */
/**
* @brief Gatt authentication request type
* @brief Defines the GATT authentication request types.
*
* This enumeration lists the types of authentication requests that can be made.
* It corresponds to the `BTA_GATT_AUTH_REQ_xxx` values defined in `bta/bta_gatt_api.h`.
* The types include options for no authentication, unauthenticated encryption, authenticated encryption,
* and both signed versions with and without MITM (Man-In-The-Middle) protection.
*/
typedef enum {
ESP_GATT_AUTH_REQ_NONE = 0, /* relate to BTA_GATT_AUTH_REQ_NONE in bta/bta_gatt_api.h */
ESP_GATT_AUTH_REQ_NO_MITM = 1, /* unauthenticated encryption */ /* relate to BTA_GATT_AUTH_REQ_NO_MITM in bta/bta_gatt_api.h */
ESP_GATT_AUTH_REQ_MITM = 2, /* authenticated encryption */ /* relate to BTA_GATT_AUTH_REQ_MITM in bta/bta_gatt_api.h */
ESP_GATT_AUTH_REQ_SIGNED_NO_MITM = 3, /* relate to BTA_GATT_AUTH_REQ_SIGNED_NO_MITM in bta/bta_gatt_api.h */
ESP_GATT_AUTH_REQ_SIGNED_MITM = 4, /* relate to BTA_GATT_AUTH_REQ_SIGNED_MITM in bta/bta_gatt_api.h */
ESP_GATT_AUTH_REQ_NONE = 0, /*!< No authentication required. Corresponds to BTA_GATT_AUTH_REQ_NONE. */
ESP_GATT_AUTH_REQ_NO_MITM = 1, /*!< Unauthenticated encryption. Corresponds to BTA_GATT_AUTH_REQ_NO_MITM. */
ESP_GATT_AUTH_REQ_MITM = 2, /*!< Authenticated encryption (MITM protection). Corresponds to BTA_GATT_AUTH_REQ_MITM. */
ESP_GATT_AUTH_REQ_SIGNED_NO_MITM = 3, /*!< Signed data, no MITM protection. Corresponds to BTA_GATT_AUTH_REQ_SIGNED_NO_MITM. */
ESP_GATT_AUTH_REQ_SIGNED_MITM = 4, /*!< Signed data with MITM protection. Corresponds to BTA_GATT_AUTH_REQ_SIGNED_MITM. */
} esp_gatt_auth_req_t;
/* relate to BTA_GATT_PERM_xxx in bta/bta_gatt_api.h */
/**
* @brief Attribute permissions
*/
#define ESP_GATT_PERM_READ (1 << 0) /* bit 0 - 0x0001 */ /* relate to BTA_GATT_PERM_READ in bta/bta_gatt_api.h */
#define ESP_GATT_PERM_READ_ENCRYPTED (1 << 1) /* bit 1 - 0x0002 */ /* relate to BTA_GATT_PERM_READ_ENCRYPTED in bta/bta_gatt_api.h */
#define ESP_GATT_PERM_READ_ENC_MITM (1 << 2) /* bit 2 - 0x0004 */ /* relate to BTA_GATT_PERM_READ_ENC_MITM in bta/bta_gatt_api.h */
#define ESP_GATT_PERM_WRITE (1 << 4) /* bit 4 - 0x0010 */ /* relate to BTA_GATT_PERM_WRITE in bta/bta_gatt_api.h */
#define ESP_GATT_PERM_WRITE_ENCRYPTED (1 << 5) /* bit 5 - 0x0020 */ /* relate to BTA_GATT_PERM_WRITE_ENCRYPTED in bta/bta_gatt_api.h */
#define ESP_GATT_PERM_WRITE_ENC_MITM (1 << 6) /* bit 6 - 0x0040 */ /* relate to BTA_GATT_PERM_WRITE_ENC_MITM in bta/bta_gatt_api.h */
#define ESP_GATT_PERM_WRITE_SIGNED (1 << 7) /* bit 7 - 0x0080 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED in bta/bta_gatt_api.h */
#define ESP_GATT_PERM_WRITE_SIGNED_MITM (1 << 8) /* bit 8 - 0x0100 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED_MITM in bta/bta_gatt_api.h */
#define ESP_GATT_PERM_READ_AUTHORIZATION (1 << 9) /* bit 9 - 0x0200 */
#define ESP_GATT_PERM_WRITE_AUTHORIZATION (1 << 10) /* bit 10 - 0x0400 */
#define ESP_GATT_PERM_ENCRYPT_KEY_SIZE(keysize) (((keysize - 6) & 0xF) << 12) /* bit 12:15 - 0xF000 */
typedef uint16_t esp_gatt_perm_t;
/* relate to BTA_GATT_CHAR_PROP_BIT_xxx in bta/bta_gatt_api.h */
/* definition of characteristic properties */
#define ESP_GATT_CHAR_PROP_BIT_BROADCAST (1 << 0) /* 0x01 */ /* relate to BTA_GATT_CHAR_PROP_BIT_BROADCAST in bta/bta_gatt_api.h */
#define ESP_GATT_CHAR_PROP_BIT_READ (1 << 1) /* 0x02 */ /* relate to BTA_GATT_CHAR_PROP_BIT_READ in bta/bta_gatt_api.h */
#define ESP_GATT_CHAR_PROP_BIT_WRITE_NR (1 << 2) /* 0x04 */ /* relate to BTA_GATT_CHAR_PROP_BIT_WRITE_NR in bta/bta_gatt_api.h */
#define ESP_GATT_CHAR_PROP_BIT_WRITE (1 << 3) /* 0x08 */ /* relate to BTA_GATT_CHAR_PROP_BIT_WRITE in bta/bta_gatt_api.h */
#define ESP_GATT_CHAR_PROP_BIT_NOTIFY (1 << 4) /* 0x10 */ /* relate to BTA_GATT_CHAR_PROP_BIT_NOTIFY in bta/bta_gatt_api.h */
#define ESP_GATT_CHAR_PROP_BIT_INDICATE (1 << 5) /* 0x20 */ /* relate to BTA_GATT_CHAR_PROP_BIT_INDICATE in bta/bta_gatt_api.h */
#define ESP_GATT_CHAR_PROP_BIT_AUTH (1 << 6) /* 0x40 */ /* relate to BTA_GATT_CHAR_PROP_BIT_AUTH in bta/bta_gatt_api.h */
#define ESP_GATT_CHAR_PROP_BIT_EXT_PROP (1 << 7) /* 0x80 */ /* relate to BTA_GATT_CHAR_PROP_BIT_EXT_PROP in bta/bta_gatt_api.h */
/**
* @brief Defines GATT attribute permission flags.
*
* These permission flags are used to specify the security requirements for GATT attributes.
* They correlate directly with the BTA_GATT_PERM_xxx definitions found in bta/bta_gatt_api.h.
*/
/** @defgroup GATT_PERMS GATT Attribute Permissions
* @brief Definitions of permission flags for GATT attributes.
* @{
*/
/** @brief Permission to read the attribute. Corresponds to BTA_GATT_PERM_READ. */
#define ESP_GATT_PERM_READ (1 << 0)
/** @brief Permission to read the attribute with encryption. Corresponds to BTA_GATT_PERM_READ_ENCRYPTED. */
#define ESP_GATT_PERM_READ_ENCRYPTED (1 << 1)
/** @brief Permission to read the attribute with encrypted MITM (Man In The Middle) protection. Corresponds to BTA_GATT_PERM_READ_ENC_MITM.*/
#define ESP_GATT_PERM_READ_ENC_MITM (1 << 2)
/** @brief Permission to write to the attribute. Corresponds to BTA_GATT_PERM_WRITE. */
#define ESP_GATT_PERM_WRITE (1 << 4)
/** @brief Permission to write to the attribute with encryption. Corresponds to BTA_GATT_PERM_WRITE_ENCRYPTED. */
#define ESP_GATT_PERM_WRITE_ENCRYPTED (1 << 5)
/** @brief Permission to write to the attribute with encrypted MITM protection. Corresponds to BTA_GATT_PERM_WRITE_ENC_MITM. */
#define ESP_GATT_PERM_WRITE_ENC_MITM (1 << 6)
/** @brief Permission for signed writes to the attribute. Corresponds to BTA_GATT_PERM_WRITE_SIGNED. */
#define ESP_GATT_PERM_WRITE_SIGNED (1 << 7)
/** @brief Permission for signed writes to the attribute with MITM protection. Corresponds to BTA_GATT_PERM_WRITE_SIGNED_MITM. */
#define ESP_GATT_PERM_WRITE_SIGNED_MITM (1 << 8)
/** @brief Permission to read the attribute with authorization. */
#define ESP_GATT_PERM_READ_AUTHORIZATION (1 << 9)
/** @brief Permission to write to the attribute with authorization. */
#define ESP_GATT_PERM_WRITE_AUTHORIZATION (1 << 10)
/**
* @brief Macro to specify minimum encryption key size.
*
* @param keysize The minimum size of the encryption key, in bytes.
*/
#define ESP_GATT_PERM_ENCRYPT_KEY_SIZE(keysize) (((keysize - 6) & 0xF) << 12)
/** @} */ // End of GATT_PERMS group
typedef uint16_t esp_gatt_perm_t; ///< Type to represent GATT attribute permissions.
/**
* @brief Defines GATT characteristic properties.
*
* These properties are related to `BTA_GATT_CHAR_PROP_BIT_xxx` in `bta/bta_gatt_api.h`.
*/
/** @defgroup GATT_CHAR_PROPERTIES GATT Characteristic Properties
* These properties define various capabilities of a GATT characteristic.
* @{
*/
/** @brief Ability to broadcast.Corresponds to BTA_GATT_CHAR_PROP_BIT_BROADCAST. */
#define ESP_GATT_CHAR_PROP_BIT_BROADCAST (1 << 0)
/** @brief Ability to read.Corresponds to BTA_GATT_CHAR_PROP_BIT_READ. */
#define ESP_GATT_CHAR_PROP_BIT_READ (1 << 1)
/** @brief Ability to write without response.Corresponds to BTA_GATT_CHAR_PROP_BIT_WRITE_NR. */
#define ESP_GATT_CHAR_PROP_BIT_WRITE_NR (1 << 2)
/** @brief Ability to write.Corresponds to BTA_GATT_CHAR_PROP_BIT_WRITE. */
#define ESP_GATT_CHAR_PROP_BIT_WRITE (1 << 3)
/** @brief Ability to notify.Corresponds to BTA_GATT_CHAR_PROP_BIT_NOTIFY. */
#define ESP_GATT_CHAR_PROP_BIT_NOTIFY (1 << 4)
/** @brief Ability to indicate.Corresponds to BTA_GATT_CHAR_PROP_BIT_INDICATE. */
#define ESP_GATT_CHAR_PROP_BIT_INDICATE (1 << 5)
/** @brief Ability to authenticate.Corresponds to BTA_GATT_CHAR_PROP_BIT_AUTH. */
#define ESP_GATT_CHAR_PROP_BIT_AUTH (1 << 6)
/** @brief Has extended properties.Corresponds to BTA_GATT_CHAR_PROP_BIT_EXT_PROP. */
#define ESP_GATT_CHAR_PROP_BIT_EXT_PROP (1 << 7)
/** @} */ // end of GATT_CHAR_PROPERTIES
/**
* @typedef esp_gatt_char_prop_t
* @brief Type for characteristic properties bitmask.
*/
typedef uint8_t esp_gatt_char_prop_t;
/// GATT maximum attribute length
#define ESP_GATT_MAX_ATTR_LEN 600 //as same as GATT_MAX_ATTR_LEN
/**
* @brief Defines the maximum length of a GATT attribute.
*
* This definition specifies the maximum number of bytes that a GATT attribute can hold.
*/
#define ESP_GATT_MAX_ATTR_LEN 512 /*!< As same as GATT_MAX_ATTR_LEN. */
/**
* @brief Enumerates the possible sources of a GATT service discovery.
*
* This enumeration identifies the source of a GATT service discovery process,
* indicating whether the service information was obtained from a remote device,
* from NVS (Non-Volatile Storage) flash, or the source is unknown.
*/
typedef enum {
ESP_GATT_SERVICE_FROM_REMOTE_DEVICE = 0, /* relate to BTA_GATTC_SERVICE_INFO_FROM_REMOTE_DEVICE in bta_gattc_int.h */
ESP_GATT_SERVICE_FROM_NVS_FLASH = 1, /* relate to BTA_GATTC_SERVICE_INFO_FROM_NVS_FLASH in bta_gattc_int.h */
ESP_GATT_SERVICE_FROM_UNKNOWN = 2, /* relate to BTA_GATTC_SERVICE_INFO_FROM_UNKNOWN in bta_gattc_int.h */
ESP_GATT_SERVICE_FROM_REMOTE_DEVICE = 0, /*!< Service information from a remote device. Relates to BTA_GATTC_SERVICE_INFO_FROM_REMOTE_DEVICE. */
ESP_GATT_SERVICE_FROM_NVS_FLASH = 1, /*!< Service information from NVS flash. Relates to BTA_GATTC_SERVICE_INFO_FROM_NVS_FLASH. */
ESP_GATT_SERVICE_FROM_UNKNOWN = 2, /*!< Service source is unknown. Relates to BTA_GATTC_SERVICE_INFO_FROM_UNKNOWN. */
} esp_service_source_t;
/**
* @brief Attribute description (used to create database)
*/
typedef struct
{
uint16_t uuid_length; /*!< UUID length */
uint8_t *uuid_p; /*!< UUID value */
uint16_t perm; /*!< Attribute permission */
uint16_t max_length; /*!< Maximum length of the element*/
uint16_t length; /*!< Current length of the element*/
uint8_t *value; /*!< Element value array*/
} esp_attr_desc_t;
/**
* @brief attribute auto response flag
* @brief Defines an attribute's description.
*
* This structure is used to describe an attribute in the GATT database. It includes
* details such as the UUID of the attribute, its permissions, and its value.
*/
typedef struct
{
uint16_t uuid_length; /*!< Length of the UUID in bytes. */
uint8_t *uuid_p; /*!< Pointer to the UUID value. */
uint16_t perm; /*!< Attribute permissions, defined by esp_gatt_perm_t. */
uint16_t max_length; /*!< Maximum length of the attribute's value. */
uint16_t length; /*!< Current length of the attribute's value. */
uint8_t *value; /*!< Pointer to the attribute's value array. */
} esp_attr_desc_t;
/**
* @brief Defines attribute control for GATT operations.
*
* This module provides definitions for controlling attribute auto responses
* in GATT operations.
*/
/** @brief Response to Write/Read operations should be handled by the application. */
#define ESP_GATT_RSP_BY_APP 0
/** @brief Response to Write/Read operations should be automatically handled by the GATT stack. */
#define ESP_GATT_AUTO_RSP 1
/**
* @brief Defines the auto response setting for attribute operations.
*
* This structure is used to control whether the GATT stack or the application
* will handle responses to Read/Write operations.
*/
typedef struct
{
#define ESP_GATT_RSP_BY_APP 0
#define ESP_GATT_AUTO_RSP 1
/**
* @brief if auto_rsp set to ESP_GATT_RSP_BY_APP, means the response of Write/Read operation will by replied by application.
if auto_rsp set to ESP_GATT_AUTO_RSP, means the response of Write/Read operation will be replied by GATT stack automatically.
* @brief Controls who handles the response to Read/Write operations.
*
* - If set to @c ESP_GATT_RSP_BY_APP, the application is responsible for
* generating the response.
* - If set to @c ESP_GATT_AUTO_RSP, the GATT stack will automatically generate
* the response.
*/
uint8_t auto_rsp;
} esp_attr_control_t;
/**
* @brief attribute type added to the gatt server database
* @brief attribute type added to the GATT server database
*/
typedef struct
{
@@ -370,116 +585,103 @@ typedef struct
uint16_t end_hdl; /*!< Gatt end handle value of included 128 bit service */
} esp_gatts_incl128_svc_desc_t; /*!< Gatt include 128 bit service entry element */
/// Gatt attribute value
/**
* @brief Represents a GATT attribute's value.
*/
typedef struct {
uint8_t value[ESP_GATT_MAX_ATTR_LEN]; /*!< Gatt attribute value */
uint16_t handle; /*!< Gatt attribute handle */
uint16_t offset; /*!< Gatt attribute value offset */
uint16_t len; /*!< Gatt attribute value length */
uint8_t auth_req; /*!< Gatt authentication request */
uint8_t value[ESP_GATT_MAX_ATTR_LEN]; /*!< Array holding the value of the GATT attribute. */
uint16_t handle; /*!< Unique identifier (handle) of the GATT attribute. */
uint16_t offset; /*!< Offset within the attribute's value, for partial updates. */
uint16_t len; /*!< Current length of the data in the value array. */
uint8_t auth_req; /*!< Authentication requirements for accessing this attribute. */
} esp_gatt_value_t;
/// GATT remote read request response type
/**
* @brief Represents the response type for a GATT remote read request.
*/
typedef union {
esp_gatt_value_t attr_value; /*!< Gatt attribute structure */
uint16_t handle; /*!< Gatt attribute handle */
esp_gatt_value_t attr_value; /*!< The GATT attribute value, including its data, handle, and metadata. */
uint16_t handle; /*!< Only the handle of the GATT attribute, when that's the only required information. */
} esp_gatt_rsp_t;
/**
* @brief Gatt write type
*/
* @brief Defines the types of GATT write operations.
*/
typedef enum {
ESP_GATT_WRITE_TYPE_NO_RSP = 1, /*!< Gatt write attribute need no response */
ESP_GATT_WRITE_TYPE_RSP, /*!< Gatt write attribute need remote response */
ESP_GATT_WRITE_TYPE_NO_RSP = 1, /*!< Write operation where no response is needed. */
ESP_GATT_WRITE_TYPE_RSP = 2, /*!< Write operation that requires a remote response. */
} esp_gatt_write_type_t;
/**
* @brief Connection parameters information
*/
/** @brief Connection parameters for GATT. */
typedef struct {
uint16_t interval; /*!< connection interval */
uint16_t latency; /*!< Slave latency for the connection in number of connection events. Range: 0x0000 to 0x01F3 */
uint16_t timeout; /*!< Supervision timeout for the LE Link. Range: 0x000A to 0x0C80.
Mandatory Range: 0x000A to 0x0C80 Time = N * 10 msec
Time Range: 100 msec to 32 seconds */
uint16_t interval; /*!< Connection interval. */
uint16_t latency; /*!< Slave latency for the connection in number of connection events. */
uint16_t timeout; /*!< Supervision timeout for the LE Link. */
} esp_gatt_conn_params_t;
#define ESP_GATT_IF_NONE 0xff /*!< If callback report gattc_if/gatts_if as this macro, means this event is not correspond to any app */
/** @brief Macro indicating no specific GATT interface. */
#define ESP_GATT_IF_NONE 0xff /*!< No specific application GATT interface. */
typedef uint8_t esp_gatt_if_t; /*!< Gatt interface type, different application on GATT client use different gatt_if */
/** @brief GATT interface type for client applications. */
typedef uint8_t esp_gatt_if_t;
/**
* @brief the type of attribute element
*/
/** @brief Enumerates types of GATT database attributes. */
typedef enum {
ESP_GATT_DB_PRIMARY_SERVICE, /*!< Gattc primary service attribute type in the cache */
ESP_GATT_DB_SECONDARY_SERVICE, /*!< Gattc secondary service attribute type in the cache */
ESP_GATT_DB_CHARACTERISTIC, /*!< Gattc characteristic attribute type in the cache */
ESP_GATT_DB_DESCRIPTOR, /*!< Gattc characteristic descriptor attribute type in the cache */
ESP_GATT_DB_INCLUDED_SERVICE, /*!< Gattc include service attribute type in the cache */
ESP_GATT_DB_ALL, /*!< Gattc all the attribute (primary service & secondary service & include service & char & descriptor) type in the cache */
} esp_gatt_db_attr_type_t; /*!< Gattc attribute type element */
ESP_GATT_DB_PRIMARY_SERVICE, /*!< Primary service attribute. */
ESP_GATT_DB_SECONDARY_SERVICE, /*!< Secondary service attribute. */
ESP_GATT_DB_CHARACTERISTIC, /*!< Characteristic attribute. */
ESP_GATT_DB_DESCRIPTOR, /*!< Descriptor attribute. */
ESP_GATT_DB_INCLUDED_SERVICE, /*!< Included service attribute. */
ESP_GATT_DB_ALL, /*!< All attribute types. */
} esp_gatt_db_attr_type_t;
/**
* @brief read multiple attribute
*/
/** @brief Represents multiple attributes for reading. */
typedef struct {
uint8_t num_attr; /*!< The number of the attribute */
uint16_t handles[ESP_GATT_MAX_READ_MULTI_HANDLES]; /*!< The handles list */
} esp_gattc_multi_t; /*!< The gattc multiple read element */
uint8_t num_attr; /*!< Number of attributes. */
uint16_t handles[ESP_GATT_MAX_READ_MULTI_HANDLES]; /*!< List of attribute handles. */
} esp_gattc_multi_t;
/**
* @brief data base attribute element
*/
/** @brief GATT database attribute element. */
typedef struct {
esp_gatt_db_attr_type_t type; /*!< The attribute type */
uint16_t attribute_handle; /*!< The attribute handle, it's valid for all of the type */
uint16_t start_handle; /*!< The service start handle, it's valid only when the type = ESP_GATT_DB_PRIMARY_SERVICE or ESP_GATT_DB_SECONDARY_SERVICE */
uint16_t end_handle; /*!< The service end handle, it's valid only when the type = ESP_GATT_DB_PRIMARY_SERVICE or ESP_GATT_DB_SECONDARY_SERVICE */
esp_gatt_char_prop_t properties; /*!< The characteristic properties, it's valid only when the type = ESP_GATT_DB_CHARACTERISTIC */
esp_bt_uuid_t uuid; /*!< The attribute uuid, it's valid for all of the type */
} esp_gattc_db_elem_t; /*!< The gattc service data base element in the cache */
esp_gatt_db_attr_type_t type; /*!< Attribute type. */
uint16_t attribute_handle; /*!< Attribute handle. */
uint16_t start_handle; /*!< Service start handle. */
uint16_t end_handle; /*!< Service end handle. */
esp_gatt_char_prop_t properties; /*!< Characteristic properties. */
esp_bt_uuid_t uuid; /*!< Attribute UUID. */
} esp_gattc_db_elem_t;
/**
* @brief service element
*/
/** @brief Represents a GATT service element. */
typedef struct {
bool is_primary; /*!< The service flag, true if the service is primary service, else is secondary service */
uint16_t start_handle; /*!< The start handle of the service */
uint16_t end_handle; /*!< The end handle of the service */
esp_bt_uuid_t uuid; /*!< The uuid of the service */
} esp_gattc_service_elem_t; /*!< The gattc service element */
bool is_primary; /*!< Indicates if the service is primary. */
uint16_t start_handle; /*!< Service start handle. */
uint16_t end_handle; /*!< Service end handle. */
esp_bt_uuid_t uuid; /*!< Service UUID. */
} esp_gattc_service_elem_t;
/**
* @brief characteristic element
*/
/** @brief Represents a GATT characteristic element. */
typedef struct {
uint16_t char_handle; /*!< The characteristic handle */
esp_gatt_char_prop_t properties; /*!< The characteristic properties */
esp_bt_uuid_t uuid; /*!< The characteristic uuid */
} esp_gattc_char_elem_t; /*!< The gattc characteristic element */
uint16_t char_handle; /*!< Characteristic handle. */
esp_gatt_char_prop_t properties; /*!< Characteristic properties. */
esp_bt_uuid_t uuid; /*!< Characteristic UUID. */
} esp_gattc_char_elem_t;
/**
* @brief descriptor element
*/
/** @brief Represents a GATT descriptor element. */
typedef struct {
uint16_t handle; /*!< The characteristic descriptor handle */
esp_bt_uuid_t uuid; /*!< The characteristic descriptor uuid */
} esp_gattc_descr_elem_t; /*!< The gattc descriptor type element */
uint16_t handle; /*!< Descriptor handle. */
esp_bt_uuid_t uuid; /*!< Descriptor UUID. */
} esp_gattc_descr_elem_t;
/**
* @brief include service element
*/
/** @brief Represents an included GATT service element. */
typedef struct {
uint16_t handle; /*!< The include service current attribute handle */
uint16_t incl_srvc_s_handle; /*!< The start handle of the service which has been included */
uint16_t incl_srvc_e_handle; /*!< The end handle of the service which has been included */
esp_bt_uuid_t uuid; /*!< The include service uuid */
} esp_gattc_incl_svc_elem_t; /*!< The gattc include service element */
uint16_t handle; /*!< Current attribute handle of the included service. */
uint16_t incl_srvc_s_handle; /*!< Start handle of the included service. */
uint16_t incl_srvc_e_handle; /*!< End handle of the included service. */
esp_bt_uuid_t uuid; /*!< Included service UUID. */
} esp_gattc_incl_svc_elem_t;
#ifdef __cplusplus
}
#endif
#endif /* __ESP_GATT_DEFS_H__ */