component/bt : add comment for doxygen

1. use doxygen check api comment
This commit is contained in:
Tian Hao 2016-11-28 21:59:04 +08:00
parent fd0d28afc3
commit 9d9e758756
9 changed files with 311 additions and 263 deletions

View file

@ -21,7 +21,7 @@
#include "bta_gatt_api.h"
#include "esp_err.h"
#define ESP_BLUFI_RECV_DATA_LEN_MAX 128
#define ESP_BLUFI_RECV_DATA_LEN_MAX (64+1)
#define ESP_BLUFI_EVENT_INIT_FINISH 0
#define ESP_BLUFI_EVENT_DEINIT_FINISH 1
@ -45,17 +45,19 @@ typedef enum {
typedef union {
//ESP_BLUFI_EVENT_INIT_FINISH
struct blufi_init_finish_evt_param {
esp_blufi_init_state_t state;
} init_finish;
esp_blufi_init_state_t state; /*!< Initial status */
} init_finish; /*!< Blufi callback param of ESP_BLUFI_EVENT_INIT_FINISH */
//ESP_BLUFI_EVENT_DEINIT_FINISH
struct blufi_deinit_finish_evt_param {
esp_blufi_deinit_state_t state;
} deinit_finish;
esp_blufi_deinit_state_t state; /*!< De-initial status */
} deinit_finish; /*!< Blufi callback param of ESP_BLUFI_EVENT_DEINIT_FINISH */
//ESP_BLUFI_EVENT_RECV_DATA
struct blufi_recv_evt_param {
uint8_t data[ESP_BLUFI_RECV_DATA_LEN_MAX];
uint8_t data_len;
} recv_data;
uint8_t data[ESP_BLUFI_RECV_DATA_LEN_MAX]; /*!< Blufi receive data */
uint8_t data_len; /*!< Blufi receive data length */
} recv_data; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_DATA */
} esp_blufi_cb_param_t;
/*******************************************************************************

View file

@ -38,13 +38,13 @@ typedef struct {
#define ESP_UUID_LEN_16 2
#define ESP_UUID_LEN_32 4
#define ESP_UUID_LEN_128 16
uint16_t len;
uint16_t len; /*!< UUID length, 16bit, 32bit or 128bit */
union {
uint16_t uuid16;
uint32_t uuid32;
uint8_t uuid128[ESP_UUID_LEN_128];
} uuid;
} __attribute__((packed)) esp_bt_uuid_t; /* tBT_UUID in "bt_types.h" */
} uuid; /*!< UUID */
} __attribute__((packed)) esp_bt_uuid_t;
typedef enum {
ESP_BT_DEVICE_TYPE_BREDR = 0x01,
@ -53,7 +53,7 @@ typedef enum {
} esp_bt_dev_type_t;
#define ESP_BD_ADDR_LEN 6
typedef uint8_t esp_bd_addr_t[ESP_BD_ADDR_LEN]; /* BD_ADDR in bt_types.h */
typedef uint8_t esp_bd_addr_t[ESP_BD_ADDR_LEN]; /*!< Bluetooth device address */
/// Own BD address source of the device
typedef enum {

View file

@ -67,6 +67,7 @@ typedef enum {
ADV_TYPE_DIRECT_IND_LOW = 0x04,
} esp_ble_adv_type_t;
/// Advertising channel mask
typedef enum {
ADV_CHNL_37 = 0x01,
ADV_CHNL_38 = 0x02,
@ -86,32 +87,39 @@ typedef enum {
///Enumeration end value for advertising filter policy value check
} esp_ble_adv_filter_t;
/// Advertising parameters
typedef struct {
uint16_t adv_int_min;
uint16_t adv_int_max;
esp_ble_adv_type_t adv_type;
esp_ble_addr_type_t own_addr_type;
esp_bd_addr_t peer_addr;
esp_ble_addr_type_t peer_addr_type;
esp_ble_adv_channel_t channel_map;
esp_ble_adv_filter_t adv_filter_policy;
uint16_t adv_int_min; /*!< Minimum advertising interval for
undirected and low duty cycle directed advertising.
Range: 0x0020 to 0x4000 Default: N = 0x0800 (1.28 second)
Time = N * 0.625 msec Time Range: 20 ms to 10.24 sec */
uint16_t adv_int_max; /*!< Maximum advertising interval for
undirected and low duty cycle directed advertising.
Range: 0x0020 to 0x4000 Default: N = 0x0800 (1.28 second)
Time = N * 0.625 msec Time Range: 20 ms to 10.24 sec Advertising max interval */
esp_ble_adv_type_t adv_type; /*!< Advertising type */
esp_ble_addr_type_t own_addr_type; /*!< Owner bluetooth device address type */
esp_bd_addr_t peer_addr; /*!< Peer device bluetooth device address */
esp_ble_addr_type_t peer_addr_type; /*!< Peer device bluetooth device address type */
esp_ble_adv_channel_t channel_map; /*!< Advertising channel map */
esp_ble_adv_filter_t adv_filter_policy; /*!< Advertising filter policy */
} esp_ble_adv_params_t;
/// Advertising data content, according to "Supplement to the Bluetooth Core Specification"
typedef struct {
bool set_scan_rsp;
bool include_name;
bool include_txpower;
int min_interval;
int max_interval;
int appearance;
uint16_t manufacturer_len;
uint8_t *p_manufacturer_data;
uint16_t service_data_len;
uint8_t *p_service_data;
uint16_t service_uuid_len;
uint8_t *p_service_uuid;
uint8_t flag;
bool set_scan_rsp; /*!< Set this advertising data as scan response or not*/
bool include_name; /*!< Advertising data include device name or not */
bool include_txpower; /*!< Advertising data include tx power */
int min_interval; /*!< Advertising data show advertising min internval */
int max_interval; /*!< Advertising data show advertising max internval */
int appearance; /*!< Extenal appearance of device */
uint16_t manufacturer_len; /*!< Manufacturer data length */
uint8_t *p_manufacturer_data; /*!< Manufacturer data point */
uint16_t service_data_len; /*!< Service data length */
uint8_t *p_service_data; /*!< Service data point */
uint16_t service_uuid_len; /*!< Service uuid length */
uint8_t *p_service_uuid; /*!< Service uuid arrary point */
uint8_t flag; /*!< Advertising flag of discovery mode */
} esp_ble_adv_data_t;
/// Own BD address source of the device
@ -130,33 +138,55 @@ typedef enum {
ESP_PROVIDED_RECON_ADDR,
} esp_ble_own_addr_src_t;
/// Ble scan type
typedef enum {
BLE_SCAN_TYPE_PASSIVE = 0x0,
BLE_SCAN_TYPE_ACTIVE = 0x1,
BLE_SCAN_TYPE_PASSIVE = 0x0, /*!< Passive scan */
BLE_SCAN_TYPE_ACTIVE = 0x1, /*!< Active scan */
} esp_ble_scan_type_t;
/// Ble scan filter type
typedef enum {
BLE_SCAN_FILTER_ALLOW_ALL = 0x0,
BLE_SCAN_FILTER_ALLOW_ONLY_WLST = 0x1,
BLE_SCAN_FILTER_ALLOW_UND_RPA_DIR = 0x2,
BLE_SCAN_FILTER_ALLOW_WLIST_PRA_DIR = 0x3,
BLE_SCAN_FILTER_ALLOW_ALL = 0x0, /*!< Accept all :
1. advertisement packets except directed advertising packets not addressed to this device (default). */
BLE_SCAN_FILTER_ALLOW_ONLY_WLST = 0x1, /*!< Accept only :
1. advertisement packets from devices where the advertisers address is in the White list.
2. Directed advertising packets which are not addressed for this device shall be ignored. */
BLE_SCAN_FILTER_ALLOW_UND_RPA_DIR = 0x2, /*!< Accept all :
1. undirected advertisement packets, and
2. directed advertising packets where the initiator address is a resolvable private address, and
3. directed advertising packets addressed to this device. */
BLE_SCAN_FILTER_ALLOW_WLIST_PRA_DIR = 0x3, /*!< Accept all :
1. advertisement packets from devices where the advertisers address is in the White list, and
2. directed advertising packets where the initiator address is a resolvable private address, and
3. directed advertising packets addressed to this device.*/
} esp_ble_scan_filter_t;
/// Ble scan parameters
typedef struct {
esp_ble_scan_type_t scan_type;
esp_ble_addr_type_t own_addr_type;
esp_ble_scan_filter_t scan_filter_policy;
uint16_t scan_interval;
uint16_t scan_window;
esp_ble_scan_type_t scan_type; /*!< Scan type */
esp_ble_addr_type_t own_addr_type; /*!< Owner address type */
esp_ble_scan_filter_t scan_filter_policy; /*!< Scan filter policy */
uint16_t scan_interval; /*!< Scan interval. This is defined as the time interval from
when the Controller started its last LE scan until it begins the subsequent LE scan.
Range: 0x0004 to 0x4000 Default: 0x0010 (10 ms)
Time = N * 0.625 msec
Time Range: 2.5 msec to 10.24 seconds*/
uint16_t scan_window; /*!< Scan window. The duration of the LE scan. LE_Scan_Window
shall be less than or equal to LE_Scan_Interval
Range: 0x0004 to 0x4000 Default: 0x0010 (10 ms)
Time = N * 0.625 msec
Time Range: 2.5 msec to 10240 msec */
} esp_ble_scan_params_t;
/// Connection update parameters
typedef struct {
esp_bd_addr_t bda;
uint16_t min_int;
uint16_t max_int;
uint16_t latency;
uint16_t timeout;
esp_bd_addr_t bda; /*!< Bluetooth device address */
uint16_t min_int; /*!< Min connection interval */
uint16_t max_int; /*!< Max 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 */
} esp_ble_conn_update_params_t;
typedef void (*esp_gap_ble_cb_t)(esp_gap_ble_event_t event, void *param);
@ -173,29 +203,29 @@ typedef enum {
} esp_gap_search_evt_t;
typedef union {
//ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT 0
//ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT
struct ble_adv_data_cmpl_evt_param {
esp_bt_status_t status;
} adv_data_cmpl;
//ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT 1
esp_bt_status_t status; /*!< Indicate the set advertising data operation success status */
} adv_data_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT */
//ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT
struct ble_scan_rsp_data_cmpl_evt_param {
esp_bt_status_t status;
} scan_rsp_data_cmpl;
//ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT 2
esp_bt_status_t status; /*!< Indicate the set scan response data operation success status */
} scan_rsp_data_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT */
//ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT
struct ble_scan_param_cmpl_evt_param {
esp_bt_status_t status;
} scan_param_cmpl;
//ESP_GAP_BLE_SCAN_RESULT_EVT 3
esp_bt_status_t status; /*!< Indicate the set scan param operation success status */
} scan_param_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT */
//ESP_GAP_BLE_SCAN_RESULT_EVT
struct ble_scan_result_evt_param {
esp_gap_search_evt_t search_evt;
esp_bd_addr_t bda;
esp_bt_dev_type_t dev_type;
esp_ble_addr_type_t ble_addr_type;
int rssi;
uint8_t ble_adv[ESP_BLE_ADV_DATA_LEN_MAX]; /* received EIR */
int flag;
int num_resps;
} scan_rst;
esp_gap_search_evt_t search_evt; /*!< Search event type */
esp_bd_addr_t bda; /*!< BD address which has been searched */
esp_bt_dev_type_t dev_type; /*!< Device type */
esp_ble_addr_type_t ble_addr_type; /*!< Ble device address type */
int rssi; /*!< Searched device's rssi */
uint8_t ble_adv[ESP_BLE_ADV_DATA_LEN_MAX]; /*!< Received EIR */
int flag; /*!< Advertising data flag bit */
int num_resps; /*!< Scan result number */
} scan_rst; /*!< Event parameter of ESP_GAP_BLE_SCAN_RESULT_EVT */
} esp_ble_gap_cb_param_t;
/*******************************************************************************

View file

@ -82,13 +82,13 @@ typedef enum {
} esp_gatt_reason_t;
typedef struct {
esp_bt_uuid_t uuid;
uint8_t inst_id;
esp_bt_uuid_t uuid; /*!< UUID */
uint8_t inst_id; /*!< Instance id */
} __attribute__((packed)) esp_gatt_id_t;
typedef struct {
esp_gatt_id_t id;
bool is_primary;
esp_gatt_id_t id; /*!< Gatt id, include uuid and instance */
bool is_primary; /*!< This service is primary or not */
} __attribute__((packed)) esp_gatt_srvc_id_t;
typedef enum {
@ -130,20 +130,21 @@ typedef enum {
#define ESP_GATT_MAX_ATTR_LEN 600 //as same as GATT_MAX_ATTR_LEN
/// Gatt attribute value
typedef struct {
uint8_t value[ESP_GATT_MAX_ATTR_LEN];
uint16_t handle;
uint16_t offset;
uint16_t len;
uint8_t auth_req;
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 */
} esp_gatt_value_t;
/** GATT remote read request response type */
typedef union {
esp_gatt_value_t attr_value;
uint16_t handle;
esp_gatt_value_t attr_value; /*!< Gatt attribute structure */
uint16_t handle; /*!< Gatt attribute handle */
} esp_gatt_rsp_t;
typedef uint32_t esp_gatt_if_t;
typedef uint32_t esp_gatt_if_t; /* Gatt interface type, different application on GATT client use different gatt_if */
#endif /* __ESP_GATT_DEFS_H__ */

View file

@ -69,141 +69,141 @@
/* esp_ble_gattc_cb_param_t */
typedef union {
/*registration data for ESP_GATTC_REG_EVT */
struct gattc_reg_evt_param {
esp_gatt_status_t status;
esp_gatt_if_t gatt_if;
esp_bt_uuid_t uuid; /* btla-specific ++ */
} reg;
struct gattc_reg_evt_param {
esp_gatt_status_t status; /*!< Operation status */
esp_gatt_if_t gatt_if; /*!< Gatt interface id, different application on gatt client different gatt_if */
uint16_t app_id; /*!< Application id which input in register API */
} reg; /*!< Gatt client callback param of ESP_GATTC_REG_EVT */
/* ESP_GATTC_OPEN_EVT */
struct gattc_open_evt_param {
esp_gatt_status_t status;
uint16_t conn_id;
esp_gatt_if_t gatt_if;
esp_bd_addr_t remote_bda;
// tBTA_TRANSPORT transport;
uint16_t mtu;
} open;
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
esp_gatt_if_t gatt_if; /*!< Gatt interface id, different application on gatt client different gatt_if */
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
uint16_t mtu; /*!< MTU size */
} open; /*!< Gatt client callback param of ESP_GATTC_OPEN_EVT */
/* ESP_GATTC_CLOSE_EVT */
struct gattc_close_evt_param {
esp_gatt_status_t status;
uint16_t conn_id;
esp_gatt_if_t gatt_if;
esp_bd_addr_t remote_bda;
esp_gatt_reason_t reason;
} close;
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
esp_gatt_if_t gatt_if; /*!< Gatt interface id, different application on gatt client different gatt_if */
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
esp_gatt_reason_t reason; /*!< The reason of gatt close */
} close; /*!< Gatt client callback param of ESP_GATTC_CLOSE_EVT */
/* ESP_GATTC_CFG_MTU_EVT */
struct gattc_cfg_mtu_evt_param {
uint16_t conn_id;
esp_gatt_status_t status;
uint16_t mtu;
} cfg_mtu;
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
uint16_t mtu; /*!< MTU size */
} cfg_mtu; /*!< Gatt client callback param of ESP_GATTC_CFG_MTU_EVT */
/* ESP_GATTC_SEARCH_CMPL_EVT */
struct gattc_search_cmpl_evt_param {
uint16_t conn_id;
esp_gatt_status_t status;
} search_cmpl;
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
} search_cmpl; /*!< Gatt client callback param of ESP_GATTC_SEARCH_CMPL_EVT */
/* ESP_GATTC_SEARCH_RES_EVT */
struct gattc_search_res_evt_param {
uint16_t conn_id;
esp_gatt_srvc_id_t service_id;
} search_res;
uint16_t conn_id; /*!< Connection id */
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
} search_res; /*!< Gatt client callback param of ESP_GATTC_SEARCH_RES_EVT */
/* ESP_GATTC_READ_CHAR_EVT, ESP_GATTC_READ_DESCR_EVT */
struct gattc_read_char_evt_param {
uint16_t conn_id;
esp_gatt_status_t status;
esp_gatt_srvc_id_t srvc_id;
esp_gatt_id_t char_id;
esp_gatt_id_t descr_id;
uint8_t *value;
uint16_t value_type;
uint16_t value_len;
} read; /* ESP_GATTC_READ_CHAR_EVT */
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
esp_gatt_id_t descr_id; /*!< Descriptor id, include descriptor uuid and other information */
uint8_t *value; /*!< Characteristic value */
uint16_t value_type; /*!< Characteristic value type */
uint16_t value_len; /*!< Characteristic value length */
} read; /*!< Gatt client callback param of ESP_GATTC_READ_CHAR_EVT */
/* ESP_GATTC_WRITE_CHAR_EVT, ESP_GATTC_PREP_WRITE_EVT, ESP_GATTC_WRITE_DESCR_EVT */
struct gattc_write_evt_param {
uint16_t conn_id;
esp_gatt_status_t status;
esp_gatt_srvc_id_t srvc_id;
esp_gatt_id_t char_id;
esp_gatt_id_t descr_id;
} write;
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
esp_gatt_id_t descr_id; /*!< Descriptor id, include descriptor uuid and other information */
} write; /*!< Gatt client callback param of ESP_GATTC_WRITE_DESCR_EVT */
/* ESP_GATTC_EXEC_EVT */
struct gattc_exec_cmpl_evt_param {
uint16_t conn_id;
esp_gatt_status_t status;
} exec_cmpl;
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
} exec_cmpl; /*!< Gatt client callback param of ESP_GATTC_EXEC_EVT */
/* ESP_GATTC_NOTIF_EVT */
/* ESP_GATTC_NOTIFY_EVT */
struct gattc_notify_evt_param {
uint16_t conn_id;
esp_bd_addr_t bda;
esp_gatt_srvc_id_t srvc_id;
esp_gatt_id_t char_id;
esp_gatt_id_t descr_id;
uint16_t value_len;
uint8_t *value;
bool is_notify;
} notify;
uint16_t conn_id; /*!< Connection id */
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
esp_gatt_id_t descr_id; /*!< Descriptor id, include descriptor uuid and other information */
uint16_t value_len; /*!< Notify attribute value */
uint8_t *value; /*!< Notify attribute value */
bool is_notify; /*!< True means notify, false means indicate */
} notify; /*!< Gatt client callback param of ESP_GATTC_NOTIFY_EVT */
/* ESP_GATTC_SRVC_CHG_EVT*/
struct gattc_srvc_chg_evt_param {
esp_bd_addr_t remote_bda;
} srvc_chg;
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
} srvc_chg; /*!< Gatt client callback param of ESP_GATTC_SRVC_CHG_EVT */
/* ESP_GATTC_CONGEST_EVT */
struct gattc_congest_evt_param {
uint16_t conn_id;
bool congested;
} congest;
uint16_t conn_id; /*!< Connection id */
bool congested; /*!< Congested or not */
} congest; /*!< Gatt client callback param of ESP_GATTC_CONGEST_EVT */
/* ESP_GATTC_GET_CHAR_EVT */
struct gattc_get_char_evt_param {
uint16_t conn_id;
esp_gatt_status_t status;
esp_gatt_srvc_id_t srvc_id;
esp_gatt_id_t char_id;
esp_gatt_char_prop_t char_prop;
} get_char;
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
esp_gatt_char_prop_t char_prop; /*!< Characteristic property */
} get_char; /*!< Gatt client callback param of ESP_GATTC_GET_CHAR_EVT */
/* ESP_GATTC_GET_DESCR_EVT */
struct gattc_get_descr_evt_param {
uint16_t conn_id;
esp_gatt_status_t status;
esp_gatt_srvc_id_t srvc_id;
esp_gatt_id_t char_id;
esp_gatt_id_t descr_id;
} get_descr;
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
esp_gatt_id_t descr_id; /*!< Descriptor id, include descriptor uuid and other information */
} get_descr; /*!< Gatt client callback param of ESP_GATTC_GET_DESCR_EVT */
/* ESP_GATTC_GET_INCL_SRVC_EVT */
struct gattc_get_incl_srvc_evt_param {
uint16_t conn_id;
esp_gatt_status_t status;
esp_gatt_srvc_id_t srvc_id;
esp_gatt_srvc_id_t incl_srvc_id;
} get_incl_srvc;
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
esp_gatt_srvc_id_t incl_srvc_id;/*!< Included service id, include service uuid and other information */
} get_incl_srvc; /*!< Gatt client callback param of ESP_GATTC_GET_INCL_SRVC_EVT */
/* ESP_GATTC_REG_FOR_NOTIF_EVT, ESP_GATTC_UNREG_FOR_NOTIF_EVT */
/* ESP_GATTC_REG_FOR_NOTIFY_EVT */
struct gattc_reg_for_notify_evt_param {
esp_gatt_status_t status;
esp_gatt_srvc_id_t srvc_id;
esp_gatt_id_t char_id;
} reg_for_notify;
esp_gatt_status_t status; /*!< Operation status */
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
} reg_for_notify; /*!< Gatt client callback param of ESP_GATTC_REG_FOR_NOTIFY_EVT */
/* ESP_GATTC_UNREG_FOR_NOTIFY_EVT */
struct gattc_unreg_for_notify_evt_param {
esp_gatt_status_t status;
esp_gatt_srvc_id_t srvc_id;
esp_gatt_id_t char_id;
} unreg_for_notify;
esp_gatt_status_t status; /*!< Operation status */
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
} unreg_for_notify; /*!< Gatt client callback param of ESP_GATTC_UNREG_FOR_NOTIFY_EVT */
} esp_ble_gattc_cb_param_t;
} esp_ble_gattc_cb_param_t; /*!< GATT client callback parameter union type */
/*******************************************************************************
@ -229,7 +229,7 @@ esp_err_t esp_ble_gattc_register_callback(esp_profile_cb_t callback);
** @brief This function is called to register application callbacks
** with GATTC module.
**
** @param[in] app_id : Application Identitfy (UUID), for different application
** @param[in] app_id : Application Identify (UUID), for different application
**
** @return ESP_OK - success, other - failed
**
@ -257,10 +257,9 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gatt_if);
** @function esp_ble_gattc_conn
**
** @brief Open a direct connection or add a background auto connection
** bd address
**
** @param[in] gatt_if: application identity.
** @param[in] remote_bda: remote device BD address.
** @param[in] remote_bda: remote device bluetooth device address.
** @param[in] is_direct: direct connection or background auto connection
**
** @return ESP_OK - success, other - failed

View file

@ -34,7 +34,7 @@
#define ESP_GATTS_ADD_INCL_SRVC_EVT 8
#define ESP_GATTS_ADD_CHAR_EVT 9
#define ESP_GATTS_ADD_CHAR_DESCR_EVT 10
#define ESP_GATTS_DELELTE_EVT 11
#define ESP_GATTS_DELETE_EVT 11
#define ESP_GATTS_START_EVT 12
#define ESP_GATTS_STOP_EVT 13
#define ESP_GATTS_CONNECT_EVT 14
@ -51,127 +51,143 @@
typedef union {
//ESP_GATTS_REG_EVT
struct gatts_reg_evt_param {
int status;
uint16_t gatt_if;
uint16_t app_id;
} reg;
int status; /*!< Operation status */
uint16_t gatt_if; /*!< Gatt interface id, different application on gatt client different gatt_if */
uint16_t app_id; /*!< Application id which input in register API */
} reg; /*!< Gatt server callback param of ESP_GATTS_REG_EVT */
// param for ESP_GATTS_READ_EVT
struct gatts_read_evt_param {
uint16_t conn_id;
uint32_t trans_id;
esp_bd_addr_t bda;
uint16_t handle;
uint16_t offset;
bool is_long;
} read;
uint16_t conn_id; /*!< Connection id */
uint32_t trans_id; /*!< Transfer id */
esp_bd_addr_t bda; /*!< The bluetooth device address which been read */
uint16_t handle; /*!< The attribute handle */
uint16_t offset; /*!< Offset of the value, if the value is too long */
bool is_long; /*!< The value is too long or not */
} read; /*!< Gatt server callback param of ESP_GATTS_READ_EVT */
// param for ESP_GATTS_WRITE_EVT
struct gatts_write_evt_param {
uint16_t conn_id;
uint32_t trans_id;
esp_bd_addr_t bda;
uint16_t handle;
uint16_t offset;
bool need_rsp;
bool is_prep;
uint16_t len;
uint8_t *value;
} write;
uint16_t conn_id; /*!< Connection id */
uint32_t trans_id; /*!< Transfer id */
esp_bd_addr_t bda; /*!< The bluetooth device address which been written */
uint16_t handle; /*!< The attribute handle */
uint16_t offset; /*!< Offset of the value, if the value is too long */
bool need_rsp; /*!< The write operation need to do response */
bool is_prep; /*!< This write operation is prepare write */
uint16_t len; /*!< The write attribute value length */
uint8_t *value; /*!< The write attribute value */
} write; /*!< Gatt server callback param of ESP_GATTS_WRITE_EVT */
// param for ESP_GATTS_EXEC_WRITE_EVT
struct gatts_exec_write_evt_param {
uint16_t conn_id;
uint32_t trans_id;
esp_bd_addr_t bda;
uint16_t conn_id; /*!< Connection id */
uint32_t trans_id; /*!< Transfer id */
esp_bd_addr_t bda; /*!< The bluetooth device address which been written */
#define ESP_GATT_PREP_WRITE_CANCEL 0x00
#define ESP_GATT_PREP_WRITE_EXEC 0x01
uint8_t exec_write_flag;
} exec_write;
uint8_t exec_write_flag; /*!< Execute write flag */
} exec_write; /*!< Gatt server callback param of ESP_GATTS_EXEC_WRITE_EVT */
// param for ESP_GATTS_MTU_EVT
struct gatts_mtu_evt_param {
uint16_t conn_id;
uint16_t mtu;
} mtu;
uint16_t conn_id; /*!< Connection id */
uint16_t mtu; /*!< MTU size */
} mtu; /*!< Gatt server callback param of ESP_GATTS_MTU_EVT */
// param for ESP_GATTS_CONF_EVT
struct gatts_conf_evt_param {
uint16_t conn_id;
int status;
} conf;
// param for ESP_GATTS_DEREG_EVT, NONE
int status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
} conf; /*!< Gatt server callback param of ESP_GATTS_CONF_EVT (confirm) */
// param for ESP_GATTS_UNREG_EVT, NONE
// param for ESP_GATTS_CREATE_EVT
struct gatts_create_evt_param {
int status;
uint16_t gatt_if;
uint16_t service_handle; //handle
esp_gatt_srvc_id_t service_id; //id
} create;
int status; /*!< Operation status */
uint16_t gatt_if; /*!< Gatt interface id, different application on gatt client different gatt_if */
uint16_t service_handle; /*!< Service attribute handle */
esp_gatt_srvc_id_t service_id; /*!< Service id, include service uuid and other information */
} create; /*!< Gatt server callback param of ESP_GATTS_CREATE_EVT */
// param for ESP_GATTS_ADD_INCL_SRVC_EVT
struct gatts_add_incl_srvc_evt_param {
int status;
uint16_t gatt_if;
uint16_t attr_handle; //handle
uint16_t service_handle; //handle
} add_incl_srvc;
int status; /*!< Operation status */
uint16_t gatt_if; /*!< Gatt interface id, different application on gatt client different gatt_if */
uint16_t attr_handle; /*!< Included service attribute handle */
uint16_t service_handle; /*!< Service attribute handle */
} add_incl_srvc; /*!< Gatt server callback param of ESP_GATTS_ADD_INCL_SRVC_EVT */
// param for ESP_GATTS_ADD_CHAR_EVT
struct gatts_add_char_evt_param {
int status;
uint16_t gatt_if;
uint16_t attr_handle; //handle
uint16_t service_handle; //handle
esp_bt_uuid_t char_uuid;
} add_char;
int status; /*!< Operation status */
uint16_t gatt_if; /*!< Gatt interface id, different application on gatt client different gatt_if */
uint16_t attr_handle; /*!< Characteristic attribute handle */
uint16_t service_handle; /*!< Service attribute handle */
esp_bt_uuid_t char_uuid; /*!< Characteristic uuid */
} add_char; /*!< Gatt server callback param of ESP_GATTS_ADD_CHAR_EVT */
// param for ESP_GATTS_ADD_CHAR_DESCR_EVT
struct gatts_add_char_descr_evt_param {
int status;
uint16_t gatt_if;
uint16_t attr_handle; //handle
uint16_t service_handle; //handle
esp_bt_uuid_t char_uuid;
} add_char_descr;
// param for ESP_GATTS_DELELTE_EVT
int status; /*!< Operation status */
uint16_t gatt_if; /*!< Gatt interface id, different application on gatt client different gatt_if */
uint16_t attr_handle; /*!< Descriptor attribute handle */
uint16_t service_handle; /*!< Service attribute handle */
esp_bt_uuid_t char_uuid; /*!< Characteristic uuid */
} add_char_descr; /*!< Gatt server callback param of ESP_GATTS_ADD_CHAR_DESCR_EVT */
// param for ESP_GATTS_DELETE_EVT
struct gatts_delete_evt_param {
int status;
uint16_t gatt_if;
uint16_t service_handle; //handle
} del;
int status; /*!< Operation status */
uint16_t gatt_if; /*!< Gatt interface id, different application on gatt client different gatt_if */
uint16_t service_handle; /*!< Service attribute handle */
} del; /*!< Gatt server callback param of ESP_GATTS_DELETE_EVT */
// param for ESP_GATTS_START_EVT
struct gatts_start_evt_param {
int status;
uint16_t gatt_if;
uint16_t service_handle; //handle
} start;
int status; /*!< Operation status */
uint16_t gatt_if; /*!< Gatt interface id, different application on gatt client different gatt_if */
uint16_t service_handle; /*!< Service attribute handle */
} start; /*!< Gatt server callback param of ESP_GATTS_START_EVT */
// param for ESP_GATTS_STOP_EVT
struct gatts_stop_evt_param {
int status;
uint16_t gatt_if;
uint16_t service_handle; //handle
} stop;
int status; /*!< Operation status */
uint16_t gatt_if; /*!< Gatt interface id, different application on gatt client different gatt_if */
uint16_t service_handle; /*!< Service attribute handle */
} stop; /*!< Gatt server callback param of ESP_GATTS_STOP_EVT */
// param for ESP_GATTS_CONNECT_EVT
struct gatts_connect_evt_param {
uint16_t conn_id;
uint16_t gatt_if;
esp_bd_addr_t remote_bda;
bool is_connected;
} connect;
uint16_t conn_id; /*!< Connection id */
uint16_t gatt_if; /*!< Gatt interface id, different application on gatt client different gatt_if */
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
bool is_connected; /*!< Indicate it is connected or not */
} connect; /*!< Gatt server callback param of ESP_GATTS_CONNECT_EVT */
// param for ESP_GATTS_DISCONNECT_EVT
struct gatts_disconnect_evt_param {
uint16_t conn_id;
uint16_t gatt_if;
esp_bd_addr_t remote_bda;
bool is_connected;
} disconnect;
uint16_t conn_id; /*!< Connection id */
uint16_t gatt_if; /*!< Gatt interface id, different application on gatt client different gatt_if */
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
bool is_connected; /*!< Indicate it is connected or not */
} disconnect; /*!< Gatt server callback param of ESP_GATTS_DISCONNECT_EVT */
// param for ESP_GATTS_OPEN_EVT none
// param for ESP_GATTS_CANCEL_OPEN_EVT none
// param for ESP_GATTS_CLOSE_EVT none
// param for ESP_GATTS_LISTEN_EVT none
// param for ESP_GATTS_CONGEST_EVT
struct gatts_congest_evt_param {
uint16_t conn_id;
bool congested;
} congest;
uint16_t conn_id; /*!< Connection id */
bool congested; /*!< Congested or not */
} congest; /*!< Gatt server callback param of ESP_GATTS_CONGEST_EVT */
// param for ESP_GATTS_RESPONSE_EVT
struct gatts_rsp_evt_param {
int status; //response status, 0 is success
uint16_t handle; //attribute handle which send response
} rsp;
int status; /*!< Operation status */
uint16_t handle; /*!< Attribute handle which send response */
} rsp; /*!< Gatt server callback param of ESP_GATTS_RESPONSE_EVT */
} esp_ble_gatts_cb_param_t;
/*******************************************************************************

View file

@ -521,7 +521,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
tBTA_GATTC_REG *reg_oper = &arg->reg_oper;
param.reg.status = reg_oper->status;
param.reg.gatt_if = reg_oper->client_if;
memcpy(&param.reg.uuid, &reg_oper->app_uuid, sizeof(esp_bt_uuid_t));
param.reg.app_id = reg_oper->app_uuid.uu.uuid16;
BTC_GATTC_CB_TO_APP(ESP_GATTC_REG_EVT, &param);
break;
}
@ -566,7 +566,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
case BTA_GATTC_SEARCH_RES_EVT: {
tBTA_GATTC_SRVC_RES *srvc_res = &arg->srvc_res;
param.search_res.conn_id = srvc_res->conn_id;
bta_to_btc_srvc_id(&param.search_res.service_id, &srvc_res->service_uuid);
bta_to_btc_srvc_id(&param.search_res.srvc_id, &srvc_res->service_uuid);
BTC_GATTC_CB_TO_APP(ESP_GATTC_SEARCH_RES_EVT, &param);
break;
}
@ -588,7 +588,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
case BTA_GATTC_NOTIF_EVT: {
tBTA_GATTC_NOTIFY *notify = &arg->notify;
param.notify.conn_id = notify->conn_id;
memcpy(&param.notify.bda, &notify->bda, sizeof(esp_bd_addr_t));
memcpy(&param.notify.remote_bda, &notify->bda, sizeof(esp_bd_addr_t));
bta_to_btc_srvc_id(&param.notify.srvc_id, &notify->char_id.srvc_id);
bta_to_btc_gatt_id(&param.notify.char_id, &notify->char_id.char_id);
bta_to_btc_gatt_id(&param.notify.descr_id, &notify->descr_type);

View file

@ -382,7 +382,7 @@ void btc_gatts_cb_handler(btc_msg_t *msg)
param.del.gatt_if = p_data->srvc_oper.server_if;
param.del.service_handle = p_data->srvc_oper.service_id;
BTC_GATTS_CB_TO_APP(ESP_GATTS_DELELTE_EVT, &param);
BTC_GATTS_CB_TO_APP(ESP_GATTS_DELETE_EVT, &param);
break;
case BTA_GATTS_START_EVT:
param.start.status = p_data->srvc_oper.status;

View file

@ -135,7 +135,7 @@ static void esp_gattc_cb(uint32_t event, void *param)
esp_ble_gattc_search_service(conn_id, NULL);
break;
case ESP_GATTC_SEARCH_RES_EVT: {
esp_gatt_srvc_id_t *srvc_id = &p_data->search_res.service_id;
esp_gatt_srvc_id_t *srvc_id = &p_data->search_res.srvc_id;
conn_id = p_data->open.conn_id;
LOG_INFO("SEARCH RES: conn_id = %x\n", conn_id);
if (srvc_id->id.uuid.len == ESP_UUID_LEN_16) {