mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
component/bt : new architectecture
1st compile ok
This commit is contained in:
@@ -1,106 +0,0 @@
|
||||
#ifndef __ESP_ADV_API_H__
|
||||
#define __ESP_ADV_API_H__
|
||||
|
||||
#include "bt_types.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "bta_gatt_api.h"
|
||||
#include "bt_prf_sys.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_config_adv_data
|
||||
**
|
||||
** @brief This function is called to override the BTA default ADV parameters.
|
||||
**
|
||||
** @param[in] adv_data: Pointer to User defined ADV data structure. This
|
||||
** memory space can not be freed until p_adv_data_cback
|
||||
** is received.
|
||||
** @param[in|out] adv_data_cback: set adv data complete callback.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_config_adv_data (esp_ble_adv_data_cfg_t *adv_data,
|
||||
esp_ble_set_adv_data_cmpl_cb_t *adv_data_cback);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function esp_ble_set_scan_rsp
|
||||
**
|
||||
** Description This function is called to override the app scan response.
|
||||
**
|
||||
** Parameters Pointer to User defined ADV data structure
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_set_scan_rsp(esp_ble_adv_data_cfg_t *scan_rsp_data,
|
||||
esp_ble_set_adv_data_cmpl_cb_t *p_scan_rsp_data_cback);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_set_scan_params
|
||||
**
|
||||
** @brief This function is called to set scan parameters
|
||||
**
|
||||
** @param[in] esp_ble_scan_params: Pointer to User defined scan_params data structure. This
|
||||
** memory space can not be freed until scan_param_setup_cback
|
||||
** @param[in] client_if: Client interface ID
|
||||
** @param[in|out] scan_param_setup_status_cback - Set scan param status callback
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_set_scan_params (esp_ble_scan_params *scan_params, esp_gattc_if_t client_if,
|
||||
esp_scan_param_setup_cb_t scan_param_setup_cback);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_start_scanning
|
||||
**
|
||||
** @brief This procedure keep the device scanning the peer device whith advertising on the air
|
||||
**
|
||||
** @param[in] duration: Keeping the scaning time, the unit is second.
|
||||
** @param[in|out] results_cb: The scanning function callback when the peer device has been scan
|
||||
** which advertising on the air
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_start_scanning (UINT8 duration, esp_dm_search_cb_t *results_cb);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_start_advertising
|
||||
**
|
||||
** @brief This function is called to start advertising.
|
||||
**
|
||||
** @param[in] esp_ble_adv_params_all_t: ointer to User defined adv_params data structure.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_start_advertising (esp_ble_adv_params_all_t *ble_adv_params);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_stop_advertising
|
||||
**
|
||||
** @brief This function is called to stop advertising.
|
||||
**
|
||||
** @param None
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_stop_advertising (void);
|
||||
|
||||
#endif /* __ESP_ADV_API_H__ */
|
@@ -1,84 +0,0 @@
|
||||
#ifndef __ESP_BT_COMMON_H__
|
||||
#define __ESP_BT_COMMON_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bt_types.h"
|
||||
#include "bta_api.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
typedef tBT_UUID esp_bt_uuid_t; /* tBT_UUID in "bt_types.h" */
|
||||
|
||||
typedef BD_ADDR esp_bd_addr_t; /* BD_ADDR in bt_types.h */
|
||||
|
||||
typedef tBTA_DM_SEC_CBACK esp_bt_sec_cb_t;
|
||||
|
||||
typedef void (*bluetooth_init_cb_t)(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_enable_bluetooth
|
||||
**
|
||||
** @brief This function is called to enable bluetooth host. This
|
||||
** function must be called before any other functions in the
|
||||
** API (except esp_bluetooth_init) are called.
|
||||
**
|
||||
** @param[in] p_cback:
|
||||
** security call back function
|
||||
** @param[out] None
|
||||
**
|
||||
** @return ESP_OK - Success; Other - Failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_enable_bluetooth(esp_bt_sec_cb_t p_cback);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_disable_bluetooth
|
||||
**
|
||||
** @brief This function is called to disable bluetooth host
|
||||
**
|
||||
** @param[in] None
|
||||
**
|
||||
** @param[out] None
|
||||
**
|
||||
** @return ESP_OK - Success; Other - Failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_disable_bluetooth(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_init_bluetooth
|
||||
**
|
||||
** @brief This function is called to init bluetooth host and alloc the
|
||||
** resource. This function must be called before all othor API
|
||||
** are called.
|
||||
**
|
||||
** @param[in] cb: When this function called success, the callback will be called
|
||||
**
|
||||
** @param[out] None
|
||||
**
|
||||
** @return ESP_OK - Success; Other - Failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_init_bluetooth(bluetooth_init_cb_t cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_deinit_bluetooth
|
||||
**
|
||||
** @brief This function is called to deinit bluetooth host and free the
|
||||
** resource.
|
||||
**
|
||||
** @param[in] None
|
||||
**
|
||||
** @param[out] None
|
||||
**
|
||||
** @return ESP_OK - Success; Other - Failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_deinit_bluetooth(void);
|
||||
|
||||
#endif /* __ESP_BT_COMMON_H__ */
|
@@ -1,331 +1,72 @@
|
||||
#ifndef __ESP_BT_DEFS_H__
|
||||
#define __ESP_BT_DEFS_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "bta_api.h"
|
||||
#include "btm_ble_api.h"
|
||||
#include "bta_gatt_api.h"
|
||||
/* Status Return Value */
|
||||
typedef enum {
|
||||
ESP_BT_STATUS_SUCCESS = 0, /* Successful operation. */
|
||||
ESP_BT_STATUS_FAILURE = 1, /* Generic failure. */
|
||||
ESP_BT_STATUS_PENDING = 2, /* API cannot be completed right now */
|
||||
ESP_BT_STATUS_BUSY = 3,
|
||||
ESP_BT_STATUS_NO_RESOURCES = 4,
|
||||
ESP_BT_STATUS_WRONG_MODE = 5,
|
||||
} esp_bt_status_t;
|
||||
|
||||
#define ESP_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */
|
||||
|
||||
#define ESP_BLE_ADV_CHNL_MAP (ESP_BLE_ADV_CHNL_37|ESP_BLE_ADV_CHNL_38|ESP_BLE_ADV_CHNL_39)
|
||||
#define ESP_BLE_IS_VALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == ESP_BLE_CONN_PARAM_UNDEF))
|
||||
|
||||
/* advertising channel map */
|
||||
#define ESP_BLE_ADV_CHNL_37 (0x01 << 0)
|
||||
#define ESP_BLE_ADV_CHNL_38 (0x01 << 1)
|
||||
#define ESP_BLE_ADV_CHNL_39 (0x01 << 2)
|
||||
typedef struct {
|
||||
#define ESP_UUID_LEN_16 2
|
||||
#define ESP_UUID_LEN_32 4
|
||||
#define ESP_UUID_LEN_128 16
|
||||
uint16_t len;
|
||||
union {
|
||||
uint16_t uuid16;
|
||||
uint32_t uuid32;
|
||||
uint8_t uuid128[ESP_UUID_LEN_128];
|
||||
} uuid;
|
||||
}esp_bt_uuid_t; /* tBT_UUID in "bt_types.h" */
|
||||
|
||||
typedef tBTA_GATT_STATUS esp_gatt_status_t;
|
||||
typedef enum {
|
||||
ESP_BT_DEVICE_TYPE_BREDR = 0x01,
|
||||
ESP_BT_DEVICE_TYPE_BLE = 0x02,
|
||||
ESP_BT_DEVICE_TYPE_DUMO = 0x03,
|
||||
} 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 */
|
||||
|
||||
/// Own BD address source of the device
|
||||
typedef enum {
|
||||
/// Public Address
|
||||
BD_ADDR_PUBLIC,
|
||||
/// Provided random address
|
||||
BD_ADDR_PROVIDED_RND,
|
||||
/// Provided static random address
|
||||
BD_ADDR_GEN_STATIC_RND,
|
||||
/// Generated resolvable private random address
|
||||
BD_ADDR_GEN_RSLV,
|
||||
/// Generated non-resolvable private random address
|
||||
BD_ADDR_GEN_NON_RSLV,
|
||||
/// Provided Reconnection address
|
||||
BD_ADDR_PROVIDED_RECON,
|
||||
} esp_bd_addr_type_t;
|
||||
|
||||
typedef enum {
|
||||
BLE_ADDR_TYPE_PUBLIC = 0x00,
|
||||
BLE_ADDR_TYPE_RANDOM = 0x01,
|
||||
BLE_ADDR_TYPE_RPA_PUBLIC = 0x02,
|
||||
BLE_ADDR_TYPE_RPA_RANDOM = 0x03,
|
||||
} esp_ble_addr_type_t;
|
||||
|
||||
#define APP_ID_MIN 0x0000
|
||||
#define APP_ID_MAX 0x7fff
|
||||
|
||||
|
||||
typedef UINT16 gatt_size_t;
|
||||
typedef tBT_UUID esp_bt_uuid_t;
|
||||
typedef tBTA_GATT_ID esp_gatt_id_t;
|
||||
|
||||
typedef tBTA_BLE_AD_MASK esp_ble_ad_mask_t;
|
||||
typedef tGATT_IF esp_gatt_if_t;
|
||||
typedef tBTA_GATT_SRVC_ID esp_gatt_srvc_id_t;
|
||||
typedef tBTA_GATTC_CHAR_ID esp_gattc_char_id_t;
|
||||
typedef tBTA_GATTC_CHAR_DESCR_ID esp_gattc_char_descr_id_t;
|
||||
typedef tBTA_GATTC_INCL_SVC_ID esp_gattc_incl_srvc_id_t;
|
||||
typedef tBTA_GATT_AUTH_REQ esp_gatt_auth_req_t;
|
||||
typedef tBTA_GATTC_MULTI esp_gattc_multi_t;
|
||||
typedef tBTA_GATTC_WRITE_TYPE esp_gattc_write_type_t;
|
||||
typedef tBTA_GATT_UNFMT esp_gatt_unfmt_t;
|
||||
typedef tBTA_GATT_PERM esp_gatt_perm_t;
|
||||
typedef tBTA_GATT_CHAR_PROP esp_gatt_char_prop_t;
|
||||
typedef tBTA_GATTC esp_gattc_t;
|
||||
|
||||
typedef tBTA_GATTC_EVT esp_gattc_evt_t;
|
||||
|
||||
typedef tBTA_GATTC_IF esp_gattc_if_t;
|
||||
|
||||
|
||||
|
||||
/* Client callback function events */
|
||||
#define ESP_GATTC_REG_EVT 0 /* GATT client is registered. */
|
||||
#define ESP_GATTC_DEREG_EVT 1 /* GATT client deregistered event */
|
||||
#define ESP_GATTC_OPEN_EVT 2 /* GATTC open request status event */
|
||||
#define ESP_GATTC_READ_CHAR_EVT 3 /* GATT read characteristic event */
|
||||
#define ESP_GATTC_WRITE_CHAR_EVT 4 /* GATT write characteristic or char descriptor event */
|
||||
#define ESP_GATTC_CLOSE_EVT 5 /* GATTC close request status event */
|
||||
#define ESP_GATTC_SEARCH_CMPL_EVT 6 /* GATT discovery complete event */
|
||||
#define ESP_GATTC_SEARCH_RES_EVT 7 /* GATT discovery result event */
|
||||
#define ESP_GATTC_READ_DESCR_EVT 8 /* GATT read characterisitc descriptor event */
|
||||
#define ESP_GATTC_WRITE_DESCR_EVT 9 /* GATT write characteristic descriptor event */
|
||||
#define ESP_GATTC_NOTIF_EVT 10 /* GATT attribute notification event */
|
||||
#define ESP_GATTC_PREP_WRITE_EVT 11 /* GATT prepare write event */
|
||||
#define ESP_GATTC_EXEC_EVT 12 /* execute write complete event */
|
||||
#define ESP_GATTC_ACL_EVT 13 /* ACL up event */
|
||||
#define ESP_GATTC_CANCEL_OPEN_EVT 14 /* cancel open event */
|
||||
#define ESP_GATTC_SRVC_CHG_EVT 15 /* service change event */
|
||||
#define ESP_GATTC_ENC_CMPL_CB_EVT 17 /* encryption complete callback event */
|
||||
#define ESP_GATTC_CFG_MTU_EVT 18 /* configure MTU complete event */
|
||||
#define ESP_GATTC_ADV_DATA_EVT 19 /* ADV data event */
|
||||
#define ESP_GATTC_MULT_ADV_ENB_EVT 20 /* Enable Multi ADV event */
|
||||
#define ESP_GATTC_MULT_ADV_UPD_EVT 21 /* Update parameter event */
|
||||
#define ESP_GATTC_MULT_ADV_DATA_EVT 22 /* Multi ADV data event */
|
||||
#define ESP_GATTC_MULT_ADV_DIS_EVT 23 /* Disable Multi ADV event */
|
||||
#define ESP_GATTC_CONGEST_EVT 24 /* Congestion event */
|
||||
#define ESP_GATTC_BTH_SCAN_ENB_EVT 25 /* Enable batch scan event */
|
||||
#define ESP_GATTC_BTH_SCAN_CFG_EVT 26 /* Config storage event */
|
||||
#define ESP_GATTC_BTH_SCAN_RD_EVT 27 /* Batch scan reports read event */
|
||||
#define ESP_GATTC_BTH_SCAN_THR_EVT 28 /* Batch scan threshold event */
|
||||
#define ESP_GATTC_BTH_SCAN_PARAM_EVT 29 /* Batch scan param event */
|
||||
#define ESP_GATTC_BTH_SCAN_DIS_EVT 30 /* Disable batch scan event */
|
||||
#define ESP_GATTC_SCAN_FLT_CFG_EVT 31 /* Scan filter config event */
|
||||
#define ESP_GATTC_SCAN_FLT_PARAM_EVT 32 /* Param filter event */
|
||||
#define ESP_GATTC_SCAN_FLT_STATUS_EVT 33 /* Filter status event */
|
||||
#define ESP_GATTC_ADV_VSC_EVT 34 /* ADV VSC event */
|
||||
|
||||
|
||||
/* GATT Server Data Structure */
|
||||
/* Server callback function events */
|
||||
#define ESP_GATTS_REG_EVT 0
|
||||
#define ESP_GATTS_READ_EVT GATTS_REQ_TYPE_READ /* 1 */
|
||||
#define ESP_GATTS_WRITE_EVT GATTS_REQ_TYPE_WRITE /* 2 */
|
||||
#define ESP_GATTS_EXEC_WRITE_EVT GATTS_REQ_TYPE_WRITE_EXEC /* 3 */
|
||||
#define ESP_GATTS_MTU_EVT GATTS_REQ_TYPE_MTU /* 4 */
|
||||
#define ESP_GATTS_CFM_EVT GATTS_REQ_TYPE_CONF /* 5 */
|
||||
#define ESP_GATTS_DEREG_EVT 6
|
||||
#define ESP_GATTS_CREATE_EVT 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_START_EVT 12
|
||||
#define ESP_GATTS_STOP_EVT 13
|
||||
#define ESP_GATTS_CONNECT_EVT 14
|
||||
#define ESP_GATTS_DISCONNECT_EVT 15
|
||||
#define ESP_GATTS_OPEN_EVT 16
|
||||
#define ESP_GATTS_CANCEL_OPEN_EVT 17
|
||||
#define ESP_GATTS_CLOSE_EVT 18
|
||||
#define ESP_GATTS_CONGEST_EVT 20
|
||||
|
||||
/* Attribute permissions
|
||||
*/
|
||||
#define ESP_GATT_PERM_READ BTA_GATT_PERM_READ /* bit 0 - 0x0001 */
|
||||
#define ESP_GATT_PERM_READ_ENCRYPTED BTA_GATT_PERM_READ_ENCRYPTED /* bit 1 - 0x0002 */
|
||||
#define ESP_GATT_PERM_READ_ENC_MITM BTA_GATT_PERM_READ_ENC_MITM /* bit 2 - 0x0004 */
|
||||
#define ESP_GATT_PERM_WRITE BTA_GATT_PERM_WRITE /* bit 4 - 0x0010 */
|
||||
#define ESP_GATT_PERM_WRITE_ENCRYPTED BTA_GATT_PERM_WRITE_ENCRYPTED /* bit 5 - 0x0020 */
|
||||
#define ESP_GATT_PERM_WRITE_ENC_MITM BTA_GATT_PERM_WRITE_ENC_MITM /* bit 6 - 0x0040 */
|
||||
#define ESP_GATT_PERM_WRITE_SIGNED BTA_GATT_PERM_WRITE_SIGNED /* bit 7 - 0x0080 */
|
||||
#define ESP_GATT_PERM_WRITE_SIGNED_MITM BTA_GATT_PERM_WRITE_SIGNED_MITM /* bit 8 - 0x0100 */
|
||||
|
||||
#define ESP_GATTS_INVALID_APP 0xff
|
||||
|
||||
#define ESP_GATTS_INVALID_IF 0
|
||||
|
||||
/* definition of characteristic properties */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_BROADCAST BTA_GATT_CHAR_PROP_BIT_BROADCAST /* 0x01 */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_READ BTA_GATT_CHAR_PROP_BIT_READ /* 0x02 */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_WRITE_NR BTA_GATT_CHAR_PROP_BIT_WRITE_NR /* 0x04 */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_WRITE BTA_GATT_CHAR_PROP_BIT_WRITE /* 0x08 */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_NOTIFY BTA_GATT_CHAR_PROP_BIT_NOTIFY /* 0x10 */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_INDICATE BTA_GATT_CHAR_PROP_BIT_INDICATE /* 0x20 */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_AUTH BTA_GATT_CHAR_PROP_BIT_AUTH /* 0x40 */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_EXT_PROP BTA_GATT_CHAR_PROP_BIT_EXT_PROP /* 0x80 */
|
||||
|
||||
typedef tBTA_GATTS_EVT esp_gatts_evt_t;
|
||||
typedef tBTA_GATTS_IF esp_gatts_if_t;
|
||||
|
||||
/* attribute value */
|
||||
typedef tBTA_GATT_VALUE esp_gatt_value_t;
|
||||
|
||||
/* attribute response data */
|
||||
typedef tBTA_GATTS_RSP esp_gatts_rsp_t;
|
||||
|
||||
typedef tBTA_GATTS esp_gatts_t;
|
||||
|
||||
/* attribute request data from the client */
|
||||
#define ESP_GATT_PREP_WRITE_CANCEL 0x00
|
||||
#define ESP_GATT_PREP_WRITE_EXEC 0x01
|
||||
typedef tBTA_GATT_EXEC_FLAG esp_gatt_exec_flag_t;
|
||||
|
||||
/* read request always based on UUID */
|
||||
typedef tBTA_GATT_READ_REQ esp_gatt_read_req_t;
|
||||
|
||||
/* write request data */
|
||||
typedef tBTA_GATT_WRITE_REQ esp_gatt_write_req_t;
|
||||
|
||||
/* callback data for server access request from client */
|
||||
typedef tBTA_GATTS_REQ_DATA esp_gatts_req_data_t;
|
||||
|
||||
|
||||
/* Search callback */
|
||||
typedef tBTA_DM_SEARCH_CBACK esp_dm_search_cb_t;
|
||||
|
||||
typedef tBLE_SCAN_PARAM_SETUP_CBACK esp_scan_param_setup_cb_t;
|
||||
|
||||
|
||||
typedef tBTA_SET_ADV_DATA_CMPL_CBACK esp_ble_set_adv_data_cmpl_cb_t;
|
||||
|
||||
/* GATTC enable callback function */
|
||||
typedef void (esp_gattc_enb_cb_t)(esp_gatt_status_t status);
|
||||
|
||||
/* Client callback function */
|
||||
typedef void (esp_gattc_cb_t)(esp_gattc_evt_t event, esp_gattc_t *cb_data);
|
||||
|
||||
|
||||
/* GATTS enable callback function */
|
||||
typedef void (esp_gatts_enb_cb_t)(esp_gatt_status_t status);
|
||||
|
||||
/* Server callback function */
|
||||
typedef void (esp_gatts_cb_t)(esp_gatts_evt_t event, esp_gatts_t *cb_data);
|
||||
|
||||
|
||||
/* Success code and error codes */
|
||||
#define ESP_GATT_OK BTA_GATT_OK
|
||||
#define ESP_GATT_INVALID_HANDLE BTA_GATT_INVALID_HANDLE /* 0x0001 */
|
||||
#define ESP_GATT_READ_NOT_PERMIT BTA_GATT_READ_NOT_PERMIT /* 0x0002 */
|
||||
#define ESP_GATT_WRITE_NOT_PERMIT BTA_GATT_WRITE_NOT_PERMIT /* 0x0003 */
|
||||
#define ESP_GATT_INVALID_PDU BTA_GATT_INVALID_PDU /* 0x0004 */
|
||||
#define ESP_GATT_INSUF_AUTHENTICATION BTA_GATT_INSUF_AUTHENTICATION /* 0x0005 */
|
||||
#define ESP_GATT_REQ_NOT_SUPPORTED BTA_GATT_REQ_NOT_SUPPORTED /* 0x0006 */
|
||||
#define ESP_GATT_INVALID_OFFSET BTA_GATT_INVALID_OFFSET /* 0x0007 */
|
||||
#define ESP_GATT_INSUF_AUTHORIZATION BTA_GATT_INSUF_AUTHORIZATION /* 0x0008 */
|
||||
#define ESP_GATT_PREPARE_Q_FULL BTA_GATT_PREPARE_Q_FULL /* 0x0009 */
|
||||
#define ESP_GATT_NOT_FOUND BTA_GATT_NOT_FOUND /* 0x000a */
|
||||
#define ESP_GATT_NOT_LONG BTA_GATT_NOT_LONG /* 0x000b */
|
||||
#define ESP_GATT_INSUF_KEY_SIZE BTA_GATT_INSUF_KEY_SIZE /* 0x000c */
|
||||
#define ESP_GATT_INVALID_ATTR_LEN BTA_GATT_INVALID_ATTR_LEN /* 0x000d */
|
||||
#define ESP_GATT_ERR_UNLIKELY BTA_GATT_ERR_UNLIKELY /* 0x000e */
|
||||
#define ESP_GATT_INSUF_ENCRYPTION BTA_GATT_INSUF_ENCRYPTION /* 0x000f */
|
||||
#define ESP_GATT_UNSUPPORT_GRP_TYPE BTA_GATT_UNSUPPORT_GRP_TYPE /* 0x0010 */
|
||||
#define ESP_GATT_INSUF_RESOURCE BTA_GATT_INSUF_RESOURCE /* 0x0011 */
|
||||
|
||||
|
||||
#define ESP_GATT_NO_RESOURCES BTA_GATT_NO_RESOURCES /* 0x80 */
|
||||
#define ESP_GATT_INTERNAL_ERROR BTA_GATT_INTERNAL_ERROR /* 0x81 */
|
||||
#define ESP_GATT_WRONG_STATE BTA_GATT_WRONG_STATE /* 0x82 */
|
||||
#define ESP_GATT_DB_FULL BTA_GATT_DB_FULL /* 0x83 */
|
||||
#define ESP_GATT_BUSY BTA_GATT_BUSY /* 0x84 */
|
||||
#define ESP_GATT_ERROR BTA_GATT_ERROR /* 0x85 */
|
||||
#define ESP_GATT_CMD_STARTED BTA_GATT_CMD_STARTED /* 0x86 */
|
||||
#define ESP_GATT_ILLEGAL_PARAMETER BTA_GATT_ILLEGAL_PARAMETER /* 0x87 */
|
||||
#define ESP_GATT_PENDING BTA_GATT_PENDING /* 0x88 */
|
||||
#define ESP_GATT_AUTH_FAIL BTA_GATT_AUTH_FAIL /* 0x89 */
|
||||
#define ESP_GATT_MORE BTA_GATT_MORE /* 0x8a */
|
||||
#define ESP_GATT_INVALID_CFG BTA_GATT_INVALID_CFG /* 0x8b */
|
||||
#define ESP_GATT_SERVICE_STARTED BTA_GATT_SERVICE_STARTED /* 0x8c */
|
||||
#define ESP_GATT_ENCRYPED_MITM BTA_GATT_ENCRYPED_MITM /* GATT_SUCCESS */
|
||||
#define ESP_GATT_ENCRYPED_NO_MITM BTA_GATT_ENCRYPED_NO_MITM /* 0x8d */
|
||||
#define ESP_GATT_NOT_ENCRYPTED BTA_GATT_NOT_ENCRYPTED /* 0x8e */
|
||||
#define ESP_GATT_CONGESTED BTA_GATT_CONGESTED /* 0x8f */
|
||||
|
||||
#define ESP_GATT_DUP_REG BTA_GATT_DUP_REG /* 0x90 */
|
||||
#define ESP_GATT_ALREADY_OPEN BTA_GATT_ALREADY_OPEN /* 0x91 */
|
||||
#define ESP_GATT_CANCEL BTA_GATT_CANCEL /* 0x92 */
|
||||
|
||||
/* 0xE0 ~ 0xFC reserved for future use */
|
||||
#define ESP_GATT_CCC_CFG_ERR BTA_GATT_CCC_CFG_ERR /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */
|
||||
#define ESP_GATT_PRC_IN_PROGRESS BTA_GATT_PRC_IN_PROGRESS /* 0xFE Procedure Already in progress */
|
||||
#define ESP_GATT_OUT_OF_RANGE BTA_GATT_OUT_OF_RANGE /* 0xFFAttribute value out of range */
|
||||
|
||||
|
||||
typedef void (* esp_profile_cb_t)(uint32_t event, void *param);
|
||||
|
||||
#define API_BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == ESP_BLE_CONN_PARAM_UNDEF))
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
BLE_ADV_DATA_IDX,
|
||||
BLE_SCAN_RSP_DATA_IDX,
|
||||
ADV_SCAN_IDX_MAX
|
||||
};
|
||||
|
||||
/// Advertising mode
|
||||
enum api_adv_type
|
||||
{
|
||||
/// Mode in non-discoverable
|
||||
API_NON_DISCOVERABLE,
|
||||
/// Mode in general discoverable
|
||||
API_GEN_DISCOVERABLE,
|
||||
/// Mode in limited discoverable
|
||||
API_LIM_DISCOVERABLE,
|
||||
/// Broadcaster mode which is a non discoverable and non connectable mode.
|
||||
API_BROADCASTER_MODE,
|
||||
};
|
||||
|
||||
enum api_adv_filter
|
||||
{
|
||||
///Allow both scan and connection requests from anyone
|
||||
ADV_ALLOW_SCAN_ANY_CON_ANY = 0x00,
|
||||
///Allow both scan req from White List devices only and connection req from anyone
|
||||
ADV_ALLOW_SCAN_WLST_CON_ANY,
|
||||
///Allow both scan req from anyone and connection req from White List devices only
|
||||
ADV_ALLOW_SCAN_ANY_CON_WLST,
|
||||
///Allow scan and connection requests from White List devices only
|
||||
ADV_ALLOW_SCAN_WLST_CON_WLST,
|
||||
///Enumeration end value for advertising filter policy value check
|
||||
ADV_ALLOW_SCAN_END
|
||||
};
|
||||
|
||||
/// Own BD address source of the device
|
||||
enum api_own_addr_src
|
||||
{
|
||||
/// Public Address
|
||||
API_PUBLIC_ADDR,
|
||||
/// Provided random address
|
||||
API_PROVIDED_RND_ADDR,
|
||||
/// Provided static random address
|
||||
API_GEN_STATIC_RND_ADDR,
|
||||
/// Generated resolvable private random address
|
||||
API_GEN_RSLV_ADDR,
|
||||
/// Generated non-resolvable private random address
|
||||
API_GEN_NON_RSLV_ADDR,
|
||||
/// Provided Reconnection address
|
||||
API_PROVIDED_RECON_ADDR,
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *adv_name; //set the device name to be sent on the advertising
|
||||
tBTA_BLE_ADV_DATA ble_adv_data;
|
||||
}esp_ble_adv_data_cfg_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 adv_int_min;
|
||||
UINT16 adv_int_max;
|
||||
tBLE_BD_ADDR *p_dir_bda;
|
||||
}esp_ble_adv_params_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 adv_int_min;
|
||||
UINT16 adv_int_max;
|
||||
UINT8 adv_type;
|
||||
tBLE_ADDR_TYPE addr_type_own;
|
||||
tBTM_BLE_ADV_CHNL_MAP channel_map;
|
||||
tBTM_BLE_AFP adv_filter_policy;
|
||||
tBLE_BD_ADDR *p_dir_bda;
|
||||
}esp_ble_adv_params_all_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 scan_type;
|
||||
UINT16 scan_intv;
|
||||
UINT16 scan_win;
|
||||
UINT8 addr_type_own;
|
||||
UINT8 scan_fil_policy;
|
||||
}esp_ble_scan_params;
|
||||
|
||||
|
||||
extern void ble_config_adv_data(esp_ble_adv_data_cfg_t *adv_data,
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
|
||||
|
||||
extern void ble_set_scan_rsp(esp_ble_adv_data_cfg_t *scan_rsp_data,
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif ///__ESP_BT_DEFS_H__
|
||||
|
@@ -1,18 +0,0 @@
|
||||
#ifndef __ESP_GAP_API_H__
|
||||
#define __ESP_GAP_API_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_common.h"
|
||||
|
||||
enum {
|
||||
BT_SCAN_MODE_NONE,
|
||||
BT_SCAN_MODE_CONNECTABLE,
|
||||
BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE
|
||||
};
|
||||
typedef uint16_t bt_scan_mode_t;
|
||||
|
||||
esp_err_t esp_bt_gap_set_scan_mode(bt_scan_mode_t mode);
|
||||
|
||||
#endif /* __ESP_GAP_API_H__ */
|
321
components/bt/bluedroid/api/include/esp_gap_ble_api.h
Normal file
321
components/bt/bluedroid/api/include/esp_gap_ble_api.h
Normal file
@@ -0,0 +1,321 @@
|
||||
#ifndef __ESP_GAP_BLE_API_H__
|
||||
#define __ESP_GAP_BLE_API_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#define ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT 0
|
||||
#define ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT 1
|
||||
#define ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT 2
|
||||
#define ESP_GAP_BLE_SCAN_RESULT_EVT 3
|
||||
|
||||
typedef uint32_t esp_gap_ble_event_t;
|
||||
|
||||
/// Advertising mode
|
||||
typedef enum {
|
||||
/// Mode in non-discoverable
|
||||
ADV_TYPE_NON_DISCOVERABLE = 0,
|
||||
/// Mode in general discoverable
|
||||
ADV_TYPE_GEN_DISCOVERABLE,
|
||||
/// Mode in limited discoverable
|
||||
ADV_TYPE_LIM_DISCOVERABLE,
|
||||
/// Broadcaster mode which is a non discoverable and non connectable mode.
|
||||
ADV_TYPE_BROADCASTER_MODE,
|
||||
} esp_ble_adv_type_t;
|
||||
|
||||
typedef enum {
|
||||
ADV_CHNL_37 = 0x01,
|
||||
ADV_CHNL_38 = 0x02,
|
||||
ADV_CHNL_39 = 0x03,
|
||||
ADV_CHNL_ALL = 0x07,
|
||||
} esp_ble_adv_channel_t;
|
||||
|
||||
typedef enum {
|
||||
///Allow both scan and connection requests from anyone
|
||||
ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY = 0x00,
|
||||
///Allow both scan req from White List devices only and connection req from anyone
|
||||
ADV_FILTER_ALLOW_SCAN_WLST_CON_ANY,
|
||||
///Allow both scan req from anyone and connection req from White List devices only
|
||||
ADV_FILTER_ALLOW_SCAN_ANY_CON_WLST,
|
||||
///Allow scan and connection requests from White List devices only
|
||||
ADV_FILTER_ALLOW_SCAN_WLST_CON_WLST,
|
||||
///Enumeration end value for advertising filter policy value check
|
||||
} esp_ble_adv_filter_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint16_t adv_int_min;
|
||||
uint16_t adv_int_max;
|
||||
esp_ble_adv_type_t adv_type;
|
||||
esp_bd_addr_t own_addr;
|
||||
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;
|
||||
}esp_ble_adv_params_t;
|
||||
|
||||
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;
|
||||
} esp_ble_adv_data_t;
|
||||
|
||||
typedef enum {
|
||||
BLE_SCAN_TYPE_PASSIVE = 0x0,
|
||||
BLE_SCAN_TYPE_ACTIVE = 0x1,
|
||||
} esp_ble_scan_type_t;
|
||||
|
||||
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,
|
||||
} esp_ble_scan_filter_t;
|
||||
|
||||
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_params_t;
|
||||
|
||||
typedef struct {
|
||||
esp_bd_addr_t bda;
|
||||
uint16_t min_int;
|
||||
uint16_t max_int;
|
||||
uint16_t latency;
|
||||
uint16_t timeout;
|
||||
} esp_ble_conn_update_params_t;
|
||||
|
||||
typedef void (*esp_gap_ble_cb_t)(esp_gap_ble_event_t event, void *param);
|
||||
|
||||
/* esp_ble_gap_args_t */
|
||||
typedef struct {
|
||||
esp_ble_adv_data_t adv_data;
|
||||
esp_ble_adv_params_t adv_params;
|
||||
esp_ble_scan_params_t scan_params;
|
||||
esp_ble_conn_update_params_t conn_params;
|
||||
esp_bd_addr_t remote_device;
|
||||
esp_bd_addr_t rand_addr;
|
||||
uint32_t duration;
|
||||
uint16_t tx_data_length;
|
||||
bool privacy_enable;
|
||||
#define ESP_GAP_DEVICE_NAME_MAX (32)
|
||||
char device_name[ESP_GAP_DEVICE_NAME_MAX+1];
|
||||
} esp_ble_gap_args_t;
|
||||
|
||||
typedef enum {
|
||||
/* Search callback events */
|
||||
ESP_GAP_SEARCH_INQ_RES_EVT = 0, /* Inquiry result for a peer device. */
|
||||
ESP_GAP_SEARCH_INQ_CMPL_EVT = 1, /* Inquiry complete. */
|
||||
ESP_GAP_SEARCH_DISC_RES_EVT = 2, /* Discovery result for a peer device. */
|
||||
ESP_GAP_SEARCH_DISC_BLE_RES_EVT = 3, /* Discovery result for BLE GATT based servoce on a peer device. */
|
||||
ESP_GAP_SEARCH_DISC_CMPL_EVT = 4, /* Discovery complete. */
|
||||
ESP_GAP_SEARCH_DI_DISC_CMPL_EVT = 5, /* Discovery complete. */
|
||||
ESP_GAP_SEARCH_SEARCH_CANCEL_CMPL_EVT = 6, /* Search cancelled */
|
||||
} esp_gap_search_evt_t;
|
||||
|
||||
typedef union {
|
||||
//ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT 0
|
||||
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
|
||||
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
|
||||
struct ble_scan_param_cmpl_evt_param {
|
||||
esp_bt_status_t status;
|
||||
} scan_param_cmpl;
|
||||
//ESP_GAP_BLE_SCAN_RESULT_EVT 3
|
||||
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;
|
||||
int flag;
|
||||
int num_resps;
|
||||
} scan_rst;
|
||||
} esp_ble_gap_cb_param_t;
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gap_register_callback
|
||||
**
|
||||
** @brief This function is called to occur gap event, such as scan result
|
||||
**
|
||||
** @param[in] callback: callback function
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
||||
esp_err_t esp_ble_gap_register_callback(esp_profile_cb_t callback);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gap_config_adv_data
|
||||
**
|
||||
** @brief This function is called to override the BTA default ADV parameters.
|
||||
**
|
||||
** @param[in] adv_data: Pointer to User defined ADV data structure. This
|
||||
** memory space can not be freed until p_adv_data_cback
|
||||
** is received.
|
||||
** @param[in|out] adv_data_cback: set adv data complete callback.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gap_config_adv_data (esp_ble_adv_data_t *adv_data);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gap_set_scan_params
|
||||
**
|
||||
** @brief This function is called to set scan parameters
|
||||
**
|
||||
** @param[in] esp_ble_scan_params: Pointer to User defined scan_params data structure. This
|
||||
** memory space can not be freed until scan_param_setup_cback
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gap_set_scan_params(esp_ble_scan_params_t *scan_params);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gap_start_scanning
|
||||
**
|
||||
** @brief This procedure keep the device scanning the peer device whith advertising on the air
|
||||
**
|
||||
** @param[in] duration: Keeping the scaning time, the unit is second.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gap_start_scanning(uint32_t duration);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gap_start_advertising
|
||||
**
|
||||
** @brief This function is called to start advertising.
|
||||
**
|
||||
** @param[in] esp_ble_adv_params_all_t: ointer to User defined adv_params data structure.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gap_start_advertising (esp_ble_adv_params_t *adv_params);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_gap_ble_stop_advertising
|
||||
**
|
||||
** @brief This function is called to stop advertising.
|
||||
**
|
||||
** @param None
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gap_stop_advertising(void);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_update_conn_params
|
||||
**
|
||||
** @brief Update connection parameters, can only be used when connection is up.
|
||||
**
|
||||
** @param[in] param - connection update params
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gap_update_conn_params(esp_ble_conn_update_params_t *params);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gap_set_pkt_data_len
|
||||
**
|
||||
** @brief This function is to set maximum LE data packet size
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_data_length);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gap_set_rand_addr
|
||||
**
|
||||
** @brief This function set the random address for the appliction
|
||||
**
|
||||
** @param[in] rand_addr: the random address whith should be setting
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gap_config_local_privacy
|
||||
**
|
||||
** @brief Enable/disable privacy on the local device
|
||||
**
|
||||
** @param[in] privacy_enable - enable/disabe privacy on remote device.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gap_set_device_name
|
||||
**
|
||||
** @brief Set device name to the local device
|
||||
**
|
||||
** @param[in] name - device name.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gap_set_device_name(char *name);
|
||||
|
||||
#endif /* __ESP_GAP_BLE_API_H__ */
|
17
components/bt/bluedroid/api/include/esp_gap_bt_api.h
Normal file
17
components/bt/bluedroid/api/include/esp_gap_bt_api.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef __ESP_GAP_BT_API_H__
|
||||
#define __ESP_GAP_BT_API_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
typedef enum {
|
||||
BT_SCAN_MODE_NONE = 0,
|
||||
BT_SCAN_MODE_CONNECTABLE,
|
||||
BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE
|
||||
} bt_scan_mode_t;
|
||||
|
||||
esp_err_t esp_bt_gap_set_scan_mode(bt_scan_mode_t mode);
|
||||
|
||||
#endif /* __ESP_GAP_BT_API_H__ */
|
@@ -1,829 +0,0 @@
|
||||
#ifndef __ESP_GATT_API_H__
|
||||
#define __ESP_GATT_API_H__
|
||||
|
||||
#include "bt_types.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "bta_gatt_api.h"
|
||||
#include "bt_prf_sys.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_update_conn_params
|
||||
**
|
||||
** @brief Update connection parameters, can only be used when connection is up.
|
||||
**
|
||||
** @param[in] bd_addr - BD address of the peer
|
||||
** @param[in] min_int - minimum connection interval, [0x0004~ 0x4000]
|
||||
** @param[in] max_int - maximum connection interval, [0x0004~ 0x4000]
|
||||
** @param[in] latency - slave latency [0 ~ 500]
|
||||
** @param[in] timeout - supervision timeout [0x000a ~ 0xc80]
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_update_conn_params (BD_ADDR bd_addr, uint16_t min_int,
|
||||
uint16_t max_int, uint16_t latency, uint16_t timeout);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_set_pkt_data_len
|
||||
**
|
||||
** @brief This function is to set maximum LE data packet size
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_set_pkt_data_len (BD_ADDR remote_device, uint16_t tx_data_length);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_set_rand_addr
|
||||
**
|
||||
** @brief This function set the random address for the appliction
|
||||
**
|
||||
** @param[in] rand_addr: the random address whith should be setting
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_set_rand_addr (BD_ADDR rand_addr);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_config_local_privacy
|
||||
**
|
||||
** @brief Enable/disable privacy on the local device
|
||||
**
|
||||
** @param[in] privacy_enable - enable/disabe privacy on remote device.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_config_local_privacy (BOOLEAN privacy_enable);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** @function esp_gattc_disable
|
||||
** @brief This function is called by application to disable GATTC module
|
||||
**
|
||||
** @param NULL
|
||||
**
|
||||
** @return None.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_gattc_disable(void);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_app_register
|
||||
**
|
||||
** @brief This function is called to register application callbacks
|
||||
** with GATTC module.
|
||||
**
|
||||
** @param[in] app_uuid - applicaiton UUID
|
||||
** @param[in] client_cb - pointer to the application callback function.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gattc_app_register(esp_bt_uuid_t *app_uuid, esp_gattc_cb_t *client_cb);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_app_unregister
|
||||
**
|
||||
** @brief This function is called to unregister an application
|
||||
** from GATTC module.
|
||||
**
|
||||
** @param[in] client_if - client interface identifier.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gattc_app_unregister(esp_gattc_if_t client_if);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_conn
|
||||
**
|
||||
** @brief Open a direct connection or add a background auto connection
|
||||
** bd address
|
||||
**
|
||||
** @param[in] client_if: server interface.
|
||||
** @param[in] remote_bda: remote device BD address.
|
||||
** @param[in] is_direct: direct connection or background auto connection
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gattc_conn(esp_gattc_if_t client_if, BD_ADDR remote_bda, BOOLEAN is_direct);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_cancel_conn
|
||||
**
|
||||
** @brief Cancel a direct open connection or remove a background auto connection
|
||||
** bd address
|
||||
**
|
||||
** @param[in] client_if: server interface.
|
||||
** @param[in] remote_bda: remote device BD address.
|
||||
** @param[in] is_direct: direct connection or background auto connection
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gattc_cancel_conn (esp_gattc_if_t client_if, BD_ADDR remote_bda, BOOLEAN is_direct);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_close
|
||||
**
|
||||
** @brief Close a connection to a GATT server.
|
||||
**
|
||||
** @param[in] conn_id: connectino ID to be closed.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gattc_close (uint16_t conn_id);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_config_mtu
|
||||
**
|
||||
** @brief Configure the MTU size in the GATT channel. This can be done
|
||||
** only once per connection.
|
||||
**
|
||||
** @param[in] conn_id: connection ID.
|
||||
** mtu: desired MTU size to use.
|
||||
**
|
||||
** @return Command status code:
|
||||
** - @ref ESP_GATT_OK: If request succeeds
|
||||
** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the mtu value invalid
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_gatt_status_t esp_ble_gattc_config_mtu (uint16_t conn_id, uint16_t mtu);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_svc_search_req
|
||||
**
|
||||
** @brief This function is called to request a GATT service discovery
|
||||
** on a GATT server. This function report service search result
|
||||
** by a callback event, and followed by a service search complete
|
||||
** event.
|
||||
**
|
||||
** @param[in] conn_id: connection ID.
|
||||
** @param[in] srvc_uuid: a UUID of the service application is interested in.
|
||||
** If Null, discover for all services.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gattc_svc_search_req (uint16_t conn_id, esp_bt_uuid_t *srvc_uuid);
|
||||
|
||||
|
||||
/****************************************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_get_first_char
|
||||
**
|
||||
** @brief This function is called to find the first characteristic of the
|
||||
** service on the given server.
|
||||
**
|
||||
** @param[in] conn_id: connection ID which identify the server.
|
||||
** @param[in] srvc_id: the service ID of which the characteristic is belonged to.
|
||||
** @param[in] char_uuid_cond: Characteristic UUID, if NULL find the first available
|
||||
** characteristic.
|
||||
** @param[in] char_result: output parameter which will store the GATT
|
||||
** characteristic ID.
|
||||
** @param[in] property: output parameter to carry the characteristic property.
|
||||
**
|
||||
** @return Command status code:
|
||||
** - @ref ESP_GATT_OK: If request succeeds
|
||||
** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the srvc_id or char_result parameter is NULL.
|
||||
**
|
||||
*****************************************************************************************************/
|
||||
esp_gatt_status_t esp_ble_gattc_get_first_char (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_bt_uuid_t *char_uuid_cond,
|
||||
esp_gattc_char_id_t *char_result,
|
||||
esp_gatt_char_prop_t *property);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_get_first_char_descr
|
||||
**
|
||||
** @brief This function is called to find the first characteristic descriptor of the
|
||||
** characteristic on the given server.
|
||||
**
|
||||
** @param[in] conn_id: connection ID which identify the server.
|
||||
** @param[in] char_id: the characteristic ID of which the descriptor is belonged to.
|
||||
** @param[in] descr_uuid_cond: Characteristic Descr UUID, if NULL find the first available
|
||||
** characteristic.
|
||||
** @param[in] descr_result: output parameter which will store the GATT
|
||||
** characteristic descriptor ID.
|
||||
**
|
||||
** @return Command status code:
|
||||
** - @ref ESP_GATT_OK: If request succeeds
|
||||
** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the char_id or descr_result parameter is NULL.
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_gatt_status_t esp_ble_gattc_get_first_char_descr (uint16_t conn_id, esp_gattc_char_id_t *char_id,
|
||||
esp_bt_uuid_t *descr_uuid_cond,
|
||||
esp_gattc_char_descr_id_t *descr_result);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_get_next_inclu_srvc
|
||||
**
|
||||
** @brief This function is called to find the next included service of the
|
||||
** service on the given server.
|
||||
**
|
||||
** @param[in] conn_id: connection ID which identify the server.
|
||||
** @param[in] start_id: start the search from the next record
|
||||
** after the one identified by p_start_id.
|
||||
** @param[in] uuid_cond: Included service UUID, if NULL find the first available
|
||||
** included service.
|
||||
** @param[in] result: output parameter which will store the GATT ID
|
||||
** of the included service found.
|
||||
**
|
||||
** @return Command status code:
|
||||
** - @ref ESP_GATT_OK: If request succeeds
|
||||
** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the p_char_id or p_descr_result parameter is NULL.
|
||||
|
||||
*******************************************************************************/
|
||||
esp_gatt_status_t esp_ble_gattc_get_next_inclu_srvc (uint16_t conn_id,
|
||||
esp_gattc_incl_srvc_id_t *start_id,
|
||||
esp_bt_uuid_t *uuid_cond,
|
||||
esp_gattc_incl_srvc_id_t *result);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_get_next_char
|
||||
**
|
||||
** @brief This function is called to find the next characteristic of the
|
||||
** service on the given server.
|
||||
**
|
||||
** @param[in] conn_id: connection ID which identify the server.
|
||||
** @param[in] start_char_id: start the characteristic search from the next record
|
||||
** after the one identified by char_id.
|
||||
** @param[in] char_uuid_cond: Characteristic UUID, if NULL find the first available
|
||||
** characteristic.
|
||||
** @param[in] char_result: output parameter which will store the GATT
|
||||
** characteristic ID.
|
||||
** @param[in] property: output parameter to carry the characteristic property.
|
||||
**
|
||||
** @return Command status code:
|
||||
** - @ref ESP_GATT_OK: If request succeeds
|
||||
** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the start_char_id or char_result parameter is NULL.
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_gatt_status_t esp_ble_gattc_get_next_char (uint16_t conn_id,
|
||||
esp_gattc_char_id_t *start_char_id,
|
||||
esp_bt_uuid_t *char_uuid_cond,
|
||||
esp_gattc_char_id_t *char_result,
|
||||
esp_gatt_char_prop_t *property);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_get_next_char_descr
|
||||
**
|
||||
** @brief This function is called to find the next characteristic descriptor
|
||||
** of the characterisctic.
|
||||
**
|
||||
** @param[in] conn_id: connection ID which identify the server.
|
||||
** @param[in] start_descr_id: start the descriptor search from the next record
|
||||
** after the one identified by p_start_descr_id.
|
||||
** @param[in] descr_uuid_cond: Characteristic descriptor UUID, if NULL find
|
||||
** the first available characteristic descriptor.
|
||||
** @param[in] descr_result: output parameter which will store the GATT
|
||||
** characteristic descriptor ID.
|
||||
**
|
||||
** @return Command status code:
|
||||
** - @ref ESP_GATT_OK: If request succeeds
|
||||
** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the start_descr_id or descr_result parameter is NULL.
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_gatt_status_t esp_ble_gattc_get_next_char_descr (uint16_t conn_id,
|
||||
esp_gattc_char_descr_id_t *start_descr_id,
|
||||
esp_bt_uuid_t *descr_uuid_cond,
|
||||
esp_gattc_char_descr_id_t *descr_result);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_get_first_inclu_srvc
|
||||
**
|
||||
** @brief This function is called to find the first included service of the
|
||||
** service on the given server.
|
||||
**
|
||||
** @param[in] conn_id: connection ID which identify the server.
|
||||
** @param[in] srvc_id: the service ID of which the characteristic is belonged to.
|
||||
** @param[in] uuid_cond: Characteristic UUID, if NULL find the first available
|
||||
** characteristic.
|
||||
** @param[in] result: output parameter which will store the GATT ID
|
||||
** of the included service found.
|
||||
**
|
||||
** @return Command status code:
|
||||
** - @ref ESP_GATT_OK: If request succeeds
|
||||
** - @ref ESP_GATT_ILLEGAL_PARAMETER: If the srvc_id or result parameter is NULL.
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_gatt_status_t esp_ble_gattc_get_first_inclu_srvc (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_bt_uuid_t *uuid_cond, esp_gattc_incl_srvc_id_t *result);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_read_char
|
||||
**
|
||||
** @brief This function is called to read a service's characteristics of
|
||||
** the given characteritisc ID.
|
||||
**
|
||||
** @param[in] conn_id - connectino ID.
|
||||
** @param[in] char_id - characteritic ID to read.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gattc_read_char (uint16_t conn_id, esp_gattc_char_id_t *char_id,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_read_char_descr
|
||||
**
|
||||
** @brief This function is called to read a characteristics descriptor.
|
||||
**
|
||||
** @param[in] conn_id - connection ID.
|
||||
** @param[in] descr_id - characteritic descriptor ID to read.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gattc_read_char_descr (uint16_t conn_id,
|
||||
esp_gattc_char_descr_id_t *descr_id,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_read_multi
|
||||
**
|
||||
** @brief This function is called to read multiple characteristic or
|
||||
** characteristic descriptors.
|
||||
**
|
||||
** @param[in] conn_id - connectino ID.
|
||||
** @param[in] read_multi - pointer to the read multiple parameter.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gattc_read_multi (uint16_t conn_id, esp_gattc_multi_t *read_multi,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_write_char_val
|
||||
**
|
||||
** @brief This function is called to write characteristic value.
|
||||
**
|
||||
** @param[in] conn_id - connection ID.
|
||||
** @param[in] char_id - characteristic ID to write.
|
||||
** @param[in] write_type - type of write.
|
||||
** @param[in] len: length of the data to be written.
|
||||
** @param[in] value - the value to be written.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gattc_write_char_val ( uint16_t conn_id,
|
||||
esp_gattc_char_id_t *char_id,
|
||||
esp_gattc_write_type_t write_type,
|
||||
uint16_t len,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_write_char_descr
|
||||
**
|
||||
** @brief This function is called to write characteristic descriptor value.
|
||||
**
|
||||
** @param[in] conn_id - connection ID
|
||||
** @param[in] char_descr_id - characteristic descriptor ID to write.
|
||||
** @param[in] write_type - write type.
|
||||
** @param[in] data - the value to be written.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gattc_write_char_descr (uint16_t conn_id,
|
||||
esp_gattc_char_descr_id_t *char_descr_id,
|
||||
esp_gattc_write_type_t write_type,
|
||||
esp_gatt_unfmt_t *data,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_prepa_write
|
||||
**
|
||||
** @brief This function is called to prepare write a characteristic value.
|
||||
**
|
||||
** @param[in] conn_id - connection ID.
|
||||
** @param[in] char_id - GATT characteritic ID of the service.
|
||||
** @param[in] offset - offset of the write value.
|
||||
** @param[in] len: length of the data to be written.
|
||||
** @param[in] value - the value to be written.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gattc_prepa_write (uint16_t conn_id, esp_gattc_char_id_t *char_id,
|
||||
uint16_t offset, uint16_t len, uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_execu_write
|
||||
**
|
||||
** @brief This function is called to execute write a prepare write sequence.
|
||||
**
|
||||
** @param[in] conn_id - connection ID.
|
||||
** @param[in] is_execute - execute or cancel.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gattc_execu_write (uint16_t conn_id, BOOLEAN is_execute);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_send_ind_cfm
|
||||
**
|
||||
** @brief This function is called to send handle value confirmation.
|
||||
**
|
||||
** @param[in] conn_id - connection ID.
|
||||
** @param[in] char_id - characteristic ID to confirm.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gattc_send_ind_cfm (uint16_t conn_id, esp_gattc_char_id_t *char_id);
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_register_ntf
|
||||
**
|
||||
** @brief This function is called to register for notification of a service.
|
||||
**
|
||||
** @param[in] client_if - client interface.
|
||||
** @param[in] bda - target GATT server.
|
||||
** @param[in] char_id - pointer to GATT characteristic ID.
|
||||
**
|
||||
** @return OK if registration succeed, otherwise failed.
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_gatt_status_t esp_ble_gattc_register_ntf (esp_gattc_if_t client_if,
|
||||
BD_ADDR bda,
|
||||
esp_gattc_char_id_t *char_id);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_unregister_ntf
|
||||
**
|
||||
** @brief This function is called to de-register for notification of a service.
|
||||
**
|
||||
** @param[in] client_if - client interface.
|
||||
** @param[in] bda - target GATT server.
|
||||
** @param[in] char_id - pointer to GATT characteristic ID.
|
||||
**
|
||||
** @return OK if deregistration succeed, otherwise failed.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATT_STATUS esp_ble_gattc_unregister_ntf (esp_gattc_if_t client_if,
|
||||
BD_ADDR bda,
|
||||
esp_gattc_char_id_t *char_id);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_disale
|
||||
**
|
||||
** @brief This function is called to disable GATTS module
|
||||
**
|
||||
** @param[in] None.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gatts_disale(void);
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_app_register
|
||||
**
|
||||
** @brief This function is called to register application callbacks
|
||||
** with BTA GATTS module.
|
||||
**
|
||||
** @param[in] app_uuid - applicaiton UUID
|
||||
** @param[in] cback - pointer to the application callback function.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gatts_app_register(esp_bt_uuid_t *app_uuid, esp_gatts_cb_t *cback);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_app_unregister
|
||||
**
|
||||
** @brief un-register with GATT Server.
|
||||
**
|
||||
** @param[in] server_if: service interface id.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gatts_app_unregister(esp_gatts_if_t server_if);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_create_srvc
|
||||
**
|
||||
** @brief Create a service. When service creation is done, a callback
|
||||
** event BTA_GATTS_CREATE_SRVC_EVT is called to report status
|
||||
** and service ID to the profile. The service ID obtained in
|
||||
** the callback function needs to be used when adding included
|
||||
** service and characteristics/descriptors into the service.
|
||||
**
|
||||
** @param[in] server_if: Profile ID this service is belonged to.
|
||||
** @param[in] service_uuid: service UUID.
|
||||
** @param[in] inst: instance ID number of this service.
|
||||
** @param[in] num_handle: numble of handle requessted for this service.
|
||||
** @param[in] is_primary: is this service a primary one or not.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gatts_create_srvc(esp_gatts_if_t server_if, esp_bt_uuid_t *service_uuid, uint8_t inst,
|
||||
uint16_t num_handle, BOOLEAN is_primary);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_add_inclu_srvc
|
||||
**
|
||||
** @brief This function is called to add an included service. After included
|
||||
** service is included, a callback event BTA_GATTS_ADD_INCL_SRVC_EVT
|
||||
** is reported the included service ID.
|
||||
**
|
||||
** @param[in] service_id: service ID to which this included service is to
|
||||
** be added.
|
||||
** @param[in] included_service_id: the service ID to be included.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gatts_add_inclu_srvc (uint16_t service_id, uint16_t included_service_id);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_add_char
|
||||
**
|
||||
** @brief This function is called to add a characteristic into a service.
|
||||
**
|
||||
** @param[in] service_id: service ID to which this included service is to
|
||||
** be added.
|
||||
** @param[in] char_uuid : Characteristic UUID.
|
||||
** @param[in] perm : Characteristic value declaration attribute permission.
|
||||
** @param[in] property : Characteristic Properties
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gatts_add_char (uint16_t service_id, esp_bt_uuid_t *char_uuid,
|
||||
esp_gatt_perm_t perm, esp_gatt_char_prop_t property);
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_add_char_descr
|
||||
**
|
||||
** @brief This function is called to add characteristic descriptor. When
|
||||
** it's done, a callback event BTA_GATTS_ADD_DESCR_EVT is called
|
||||
** to report the status and an ID number for this descriptor.
|
||||
**
|
||||
** @param[in] service_id: service ID to which this charatceristic descriptor is to
|
||||
** be added.
|
||||
** @param[in] perm: descriptor access permission.
|
||||
** @param[in] descr_uuid: descriptor UUID.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gatts_add_char_descr (uint16_t service_id,
|
||||
esp_gatt_perm_t perm,
|
||||
esp_bt_uuid_t * descr_uuid);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_dele_srvc
|
||||
**
|
||||
** @brief This function is called to delete a service. When this is done,
|
||||
** a callback event BTA_GATTS_DELETE_EVT is report with the status.
|
||||
**
|
||||
** @param[in] service_id: service_id to be deleted.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gatts_dele_srvc (uint16_t service_id);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_start_srvc
|
||||
**
|
||||
** @brief This function is called to start a service.
|
||||
**
|
||||
** @param[in] service_id: the service ID to be started.
|
||||
** @param[in] sup_transport: supported trasnport.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gatts_start_srvc(uint16_t service_id);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_stop_srvc
|
||||
**
|
||||
** @brief This function is called to stop a service.
|
||||
**
|
||||
** @param[in] service_id - service to be topped.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gatts_stop_srvc(uint16_t service_id);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_hdl_val_indica
|
||||
**
|
||||
** @brief This function is called to read a characteristics descriptor.
|
||||
**
|
||||
** @param[in] bda - remote device bd address to indicate.
|
||||
** @param[in] attr_id - attribute ID to indicate.
|
||||
** @param[in] data_len - indicate data length.
|
||||
** @param[in] data: data to indicate.
|
||||
** @param[in] need_confirm - if this indication expects a confirmation or not.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gatts_hdl_val_indica (uint16_t conn_id, uint16_t attr_id, uint16_t data_len,
|
||||
uint8_t *data, BOOLEAN need_confirm);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_send_rsp
|
||||
**
|
||||
** @brief This function is called to send a response to a request.
|
||||
**
|
||||
** @param[in] conn_id - connection identifier.
|
||||
** @param[in] trans_id - transaction ID.
|
||||
** @param[in] status - response status
|
||||
** @param[in] msg - response data.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gatts_send_rsp (uint16_t conn_id, uint32_t trans_id,
|
||||
esp_gatt_status_t status, esp_gatts_rsp_t *msg);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_conn
|
||||
**
|
||||
** @brief Open a direct open connection or add a background auto connection
|
||||
** bd address
|
||||
**
|
||||
** @param[in] server_if: server interface.
|
||||
** @param[in] remote_bda: remote device BD address.
|
||||
** @param[in] is_direct: direct connection or background auto connection
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gatts_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BOOLEAN is_direct);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_cancel_conn
|
||||
**
|
||||
** @brief Cancel a direct open connection or remove a background auto connection
|
||||
** bd address
|
||||
**
|
||||
** @param[in] server_if: server interface.
|
||||
** @param[in] remote_bda: remote device BD address.
|
||||
** @param[in] is_direct: direct connection or background auto connection
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gatts_cancel_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BOOLEAN is_direct);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_close
|
||||
**
|
||||
** @brief Close a connection a remote device.
|
||||
**
|
||||
** @param[in] conn_id: connectino ID to be closed.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_ble_gatts_close(uint16_t conn_id);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_prf_app_register
|
||||
**
|
||||
** @brief This function is called to register application callbacks
|
||||
** with BTA GATTS module.
|
||||
**
|
||||
** @param[in] prf_id - the profile identification
|
||||
** @param[in] p_cback - pointer to the application callback function.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_prf_app_register(uint8_t prf_id, void *p_cback);
|
||||
|
||||
|
||||
#endif /* __ESP_GATT_API_H__ */
|
134
components/bt/bluedroid/api/include/esp_gatt_defs.h
Normal file
134
components/bt/bluedroid/api/include/esp_gatt_defs.h
Normal file
@@ -0,0 +1,134 @@
|
||||
#ifndef __ESP_GATT_DEFS_H__
|
||||
#define __ESP_GATT_DEFS_H__
|
||||
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
/* attribute request data from the client */
|
||||
#define ESP_GATT_PREP_WRITE_CANCEL 0x00
|
||||
#define ESP_GATT_PREP_WRITE_EXEC 0x01
|
||||
|
||||
/* Success code and error codes */
|
||||
typedef enum {
|
||||
ESP_GATT_OK = 0x0,
|
||||
ESP_GATT_INVALID_HANDLE = 0x01, /* 0x0001 */
|
||||
ESP_GATT_READ_NOT_PERMIT = 0x02, /* 0x0002 */
|
||||
ESP_GATT_WRITE_NOT_PERMIT = 0x03, /* 0x0003 */
|
||||
ESP_GATT_INVALID_PDU = 0x04, /* 0x0004 */
|
||||
ESP_GATT_INSUF_AUTHENTICATION = 0x05, /* 0x0005 */
|
||||
ESP_GATT_REQ_NOT_SUPPORTED = 0x06, /* 0x0006 */
|
||||
ESP_GATT_INVALID_OFFSET = 0x07, /* 0x0007 */
|
||||
ESP_GATT_INSUF_AUTHORIZATION = 0x08, /* 0x0008 */
|
||||
ESP_GATT_PREPARE_Q_FULL = 0x09, /* 0x0009 */
|
||||
ESP_GATT_NOT_FOUND = 0x0a, /* 0x000a */
|
||||
ESP_GATT_NOT_LONG = 0x0b, /* 0x000b */
|
||||
ESP_GATT_INSUF_KEY_SIZE = 0x0c, /* 0x000c */
|
||||
ESP_GATT_INVALID_ATTR_LEN = 0x0d, /* 0x000d */
|
||||
ESP_GATT_ERR_UNLIKELY = 0x0e, /* 0x000e */
|
||||
ESP_GATT_INSUF_ENCRYPTION = 0x0f, /* 0x000f */
|
||||
ESP_GATT_UNSUPPORT_GRP_TYPE = 0x10, /* 0x0010 */
|
||||
ESP_GATT_INSUF_RESOURCE = 0x11, /* 0x0011 */
|
||||
|
||||
ESP_GATT_NO_RESOURCES = 0x80, /* 0x80 */
|
||||
ESP_GATT_INTERNAL_ERROR = 0x81, /* 0x81 */
|
||||
ESP_GATT_WRONG_STATE = 0x82, /* 0x82 */
|
||||
ESP_GATT_DB_FULL = 0x83, /* 0x83 */
|
||||
ESP_GATT_BUSY = 0x84, /* 0x84 */
|
||||
ESP_GATT_ERROR = 0x85, /* 0x85 */
|
||||
ESP_GATT_CMD_STARTED = 0x86, /* 0x86 */
|
||||
ESP_GATT_ILLEGAL_PARAMETER = 0x87, /* 0x87 */
|
||||
ESP_GATT_PENDING = 0x88, /* 0x88 */
|
||||
ESP_GATT_AUTH_FAIL = 0x89, /* 0x89 */
|
||||
ESP_GATT_MORE = 0x8a, /* 0x8a */
|
||||
ESP_GATT_INVALID_CFG = 0x8b, /* 0x8b */
|
||||
ESP_GATT_SERVICE_STARTED = 0x8c, /* 0x8c */
|
||||
ESP_GATT_ENCRYPED_MITM = ESP_GATT_OK,
|
||||
ESP_GATT_ENCRYPED_NO_MITM = 0x8d, /* 0x8d */
|
||||
ESP_GATT_NOT_ENCRYPTED = 0x8e, /* 0x8e */
|
||||
ESP_GATT_CONGESTED = 0x8f, /* 0x8f */
|
||||
ESP_GATT_DUP_REG = 0x90, /* 0x90 */
|
||||
ESP_GATT_ALREADY_OPEN = 0x91, /* 0x91 */
|
||||
ESP_GATT_CANCEL = 0x92, /* 0x92 */
|
||||
|
||||
/* 0xE0 ~ 0xFC reserved for future use */
|
||||
ESP_GATT_CCC_CFG_ERR = 0xfd, /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */
|
||||
ESP_GATT_PRC_IN_PROGRESS = 0xfe, /* 0xFE Procedure Already in progress */
|
||||
ESP_GATT_OUT_OF_RANGE = 0xff, /* 0xFFAttribute value out of range */
|
||||
} esp_gatt_status_t;
|
||||
|
||||
typedef enum {
|
||||
ESP_GATT_CONN_UNKNOWN = 0,
|
||||
ESP_GATT_CONN_L2C_FAILURE = 1, /* general L2cap failure */
|
||||
ESP_GATT_CONN_TIMEOUT = 0x08, /* 0x08 connection timeout */
|
||||
ESP_GATT_CONN_TERMINATE_PEER_USER = 0x13, /* 0x13 connection terminate by peer user */
|
||||
ESP_GATT_CONN_TERMINATE_LOCAL_HOST = 0x16, /* 0x16 connectionterminated by local host */
|
||||
ESP_GATT_CONN_FAIL_ESTABLISH = 0x3e, /* 0x03E connection fail to establish */
|
||||
// ESP_GATT_CONN_LMP_TIMEOUT = 0x22, /* 0x22 connection fail for LMP response tout */
|
||||
ESP_GATT_CONN_CONN_CANCEL = 0x0100, /* 0x0100 L2CAP connection cancelled */
|
||||
ESP_GATT_CONN_NONE = 0x0101 /* 0x0101 no connection to cancel */
|
||||
} esp_gatt_reason_t;
|
||||
|
||||
typedef struct {
|
||||
esp_bt_uuid_t uuid;
|
||||
uint8_t inst_id;
|
||||
} esp_gatt_id_t;
|
||||
|
||||
typedef struct {
|
||||
esp_gatt_id_t id;
|
||||
uint8_t is_primary;
|
||||
} esp_gatt_srvc_id_t;
|
||||
|
||||
typedef enum {
|
||||
AUTH_REQ_NO_SCATTERNET, /* Device doesn't support scatternet, it might
|
||||
support "role switch during connection" for
|
||||
an incoming connection, when it already has
|
||||
another connection in master role */
|
||||
AUTH_REQ_PARTIAL_SCATTERNET, /* Device supports partial scatternet. It can have
|
||||
simulateous connection in Master and Slave roles
|
||||
for short period of time */
|
||||
AUTH_REQ_FULL_SCATTERNET /* Device can have simultaneous connection in master
|
||||
and slave roles */
|
||||
} esp_gatt_auth_req_t;
|
||||
|
||||
/* Attribute permissions
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_PERM_READ = (1 << 0), /* bit 0 - 0x0001 */
|
||||
ESP_GATT_PERM_READ_ENCRYPTED = (1 << 1), /* bit 1 - 0x0002 */
|
||||
ESP_GATT_PERM_READ_ENC_MITM = (1 << 2), /* bit 2 - 0x0004 */
|
||||
ESP_GATT_PERM_WRITE = (1 << 4), /* bit 4 - 0x0010 */
|
||||
ESP_GATT_PERM_WRITE_ENCRYPTED = (1 << 5), /* bit 5 - 0x0020 */
|
||||
ESP_GATT_PERM_WRITE_ENC_MITM = (1 << 6), /* bit 6 - 0x0040 */
|
||||
ESP_GATT_PERM_WRITE_SIGNED = (1 << 7), /* bit 7 - 0x0080 */
|
||||
ESP_GATT_PERM_WRITE_SIGNED_MITM = (1 << 8), /* bit 8 - 0x0100 */
|
||||
} esp_gatt_perm_t;
|
||||
|
||||
/* definition of characteristic properties */
|
||||
typedef enum {
|
||||
ESP_GATT_CHAR_PROP_BIT_BROADCAST = (1 << 0), /* 0x01 */
|
||||
ESP_GATT_CHAR_PROP_BIT_READ = (1 << 1), /* 0x02 */
|
||||
ESP_GATT_CHAR_PROP_BIT_WRITE_NR = (1 << 2), /* 0x04 */
|
||||
ESP_GATT_CHAR_PROP_BIT_WRITE = (1 << 3), /* 0x08 */
|
||||
ESP_GATT_CHAR_PROP_BIT_NOTIFY = (1 << 4), /* 0x10 */
|
||||
ESP_GATT_CHAR_PROP_BIT_INDICATE = (1 << 5), /* 0x20 */
|
||||
ESP_GATT_CHAR_PROP_BIT_AUTH = (1 << 6), /* 0x40 */
|
||||
ESP_GATT_CHAR_PROP_BIT_EXT_PROP = (1 << 7), /* 0x80 */
|
||||
} esp_gatt_char_prop_t;
|
||||
|
||||
#define ESP_GATT_MAX_ATTR_LEN 600
|
||||
typedef struct {
|
||||
uint8_t value[ESP_GATT_MAX_ATTR_LEN];
|
||||
uint16_t handle;
|
||||
uint16_t offset;
|
||||
uint16_t len;
|
||||
uint8_t auth_req;
|
||||
} esp_gatt_value_t;
|
||||
|
||||
/** GATT remote read request response type */
|
||||
typedef union {
|
||||
esp_gatt_value_t attr_value;
|
||||
uint16_t handle;
|
||||
} esp_gatt_rsp_t;
|
||||
|
||||
typedef uint32_t esp_gatt_if_t;
|
||||
|
||||
#endif /* __ESP_GATT_DEFS_H__ */
|
554
components/bt/bluedroid/api/include/esp_gattc_api.h
Normal file
554
components/bt/bluedroid/api/include/esp_gattc_api.h
Normal file
@@ -0,0 +1,554 @@
|
||||
#ifndef __ESP_GATTC_API_H__
|
||||
#define __ESP_GATTC_API_H__
|
||||
|
||||
#include "bt_types.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_gatt_defs.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
/* Client callback function events */
|
||||
#define ESP_GATTC_REG_EVT 0 /* GATT client is registered. */
|
||||
#define ESP_GATTC_UNREG_EVT 1 /* GATT client unregistered event */
|
||||
#define ESP_GATTC_OPEN_EVT 2 /* GATTC open request status event */
|
||||
#define ESP_GATTC_READ_CHAR_EVT 3 /* GATT read characteristic event */
|
||||
#define ESP_GATTC_WRITE_CHAR_EVT 4 /* GATT write characteristic or char descriptor event */
|
||||
#define ESP_GATTC_CLOSE_EVT 5 /* GATTC close request status event */
|
||||
#define ESP_GATTC_SEARCH_CMPL_EVT 6 /* GATT discovery complete event */
|
||||
#define ESP_GATTC_SEARCH_RES_EVT 7 /* GATT discovery result event */
|
||||
#define ESP_GATTC_READ_DESCR_EVT 8 /* GATT read characterisitc descriptor event */
|
||||
#define ESP_GATTC_WRITE_DESCR_EVT 9 /* GATT write characteristic descriptor event */
|
||||
#define ESP_GATTC_NOTIF_EVT 10 /* GATT attribute notification event */
|
||||
#define ESP_GATTC_PREP_WRITE_EVT 11 /* GATT prepare write event */
|
||||
#define ESP_GATTC_EXEC_EVT 12 /* execute write complete event */
|
||||
#define ESP_GATTC_ACL_EVT 13 /* ACL up event */
|
||||
#define ESP_GATTC_CANCEL_OPEN_EVT 14 /* cancel open event */
|
||||
#define ESP_GATTC_SRVC_CHG_EVT 15 /* service change event */
|
||||
#define ESP_GATTC_ENC_CMPL_CB_EVT 17 /* encryption complete callback event */
|
||||
#define ESP_GATTC_CFG_MTU_EVT 18 /* configure MTU complete event */
|
||||
#define ESP_GATTC_ADV_DATA_EVT 19 /* ADV data event */
|
||||
#define ESP_GATTC_MULT_ADV_ENB_EVT 20 /* Enable Multi ADV event */
|
||||
#define ESP_GATTC_MULT_ADV_UPD_EVT 21 /* Update parameter event */
|
||||
#define ESP_GATTC_MULT_ADV_DATA_EVT 22 /* Multi ADV data event */
|
||||
#define ESP_GATTC_MULT_ADV_DIS_EVT 23 /* Disable Multi ADV event */
|
||||
#define ESP_GATTC_CONGEST_EVT 24 /* Congestion event */
|
||||
#define ESP_GATTC_BTH_SCAN_ENB_EVT 25 /* Enable batch scan event */
|
||||
#define ESP_GATTC_BTH_SCAN_CFG_EVT 26 /* Config storage event */
|
||||
#define ESP_GATTC_BTH_SCAN_RD_EVT 27 /* Batch scan reports read event */
|
||||
#define ESP_GATTC_BTH_SCAN_THR_EVT 28 /* Batch scan threshold event */
|
||||
#define ESP_GATTC_BTH_SCAN_PARAM_EVT 29 /* Batch scan param event */
|
||||
#define ESP_GATTC_BTH_SCAN_DIS_EVT 30 /* Disable batch scan event */
|
||||
#define ESP_GATTC_SCAN_FLT_CFG_EVT 31 /* Scan filter config event */
|
||||
#define ESP_GATTC_SCAN_FLT_PARAM_EVT 32 /* Param filter event */
|
||||
#define ESP_GATTC_SCAN_FLT_STATUS_EVT 33 /* Filter status event */
|
||||
#define ESP_GATTC_ADV_VSC_EVT 34 /* ADV VSC event */
|
||||
|
||||
#define ESP_GATTC_GET_CHAR_EVT 35 /* get characteristic event */
|
||||
#define ESP_GATTC_GET_DESCR_EVT 36 /* get characteristic descriptor event */
|
||||
#define ESP_GATTC_GET_INCL_SRVC_EVT 37 /* get included service event */
|
||||
#define ESP_GATTC_REG_FOR_NOTIF_EVT 38 /* register for notification event */
|
||||
|
||||
|
||||
#define ESP_GATT_DEF_BLE_MTU_SIZE 23
|
||||
#define ESP_GATT_MAX_MTU_SIZE 517
|
||||
|
||||
|
||||
/* esp_ble_gattc_args_t */
|
||||
typedef struct {
|
||||
uint16_t app_id;
|
||||
uint16_t conn_id;
|
||||
uint16_t mtu;
|
||||
uint16_t len;
|
||||
uint16_t offset;
|
||||
esp_gatt_if_t gatt_if; /* internal is server_if or client_if */
|
||||
esp_gatt_srvc_id_t service_uuid;
|
||||
esp_gatt_srvc_id_t start_service_uuid;
|
||||
esp_gatt_id_t char_uuid;
|
||||
esp_gatt_id_t descr_uuid;
|
||||
esp_gatt_auth_req_t auth_req;
|
||||
esp_bd_addr_t remote_bda;
|
||||
esp_bt_uuid_t uuid;
|
||||
bool is_direct;
|
||||
bool is_execute;
|
||||
uint8_t value[ESP_GATT_MAX_ATTR_LEN];
|
||||
} esp_ble_gattc_args_t;
|
||||
|
||||
/* 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;
|
||||
|
||||
/* 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_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_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_GATTC_SEARCH_CMPL_EVT */
|
||||
struct gattc_search_cmpl_evt_param {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_status_t status;
|
||||
} search_cmpl;
|
||||
|
||||
/* ESP_GATTC_SEARCH_RES_EVT */
|
||||
struct gattc_search_res_evt_param {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_uuid;
|
||||
} search_res;
|
||||
|
||||
/* 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[ESP_GATT_MAX_ATTR_LEN];
|
||||
uint16_t value_type;
|
||||
uint16_t value_len;
|
||||
} read; /* 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_GATTC_EXEC_EVT */
|
||||
struct gattc_exec_cmpl_evt_param {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_status_t status;
|
||||
} exec_cmpl;
|
||||
|
||||
/* ESP_GATTC_NOTIF_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 value[ESP_GATT_MAX_ATTR_LEN];
|
||||
bool is_notify;
|
||||
} notify;
|
||||
|
||||
/* ESP_GATTC_SRVC_CHG_EVT*/
|
||||
struct gattc_srvc_chg_evt_param {
|
||||
esp_bd_addr_t remote_bda;
|
||||
} srvc_chg;
|
||||
|
||||
/* ESP_GATTC_CONGEST_EVT */
|
||||
struct gattc_congest_evt_param {
|
||||
uint16_t conn_id;
|
||||
bool congested;
|
||||
} congest;
|
||||
|
||||
/* 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_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_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_GATTC_REG_FOR_NOTIF_EVT, ESP_GATTC_UNREG_FOR_NOTIF_EVT */
|
||||
struct gattc_reg_for_notif_evt_param {
|
||||
uint16_t conn_id;
|
||||
bool registered;
|
||||
esp_gatt_status_t status;
|
||||
esp_gatt_srvc_id_t srvc_id;
|
||||
esp_gatt_id_t char_id;
|
||||
} reg_for_notif;
|
||||
|
||||
} esp_ble_gattc_cb_param_t;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_app_register_callback
|
||||
**
|
||||
** @brief This function is called to register application callbacks
|
||||
** with GATTC module.
|
||||
**
|
||||
** @param[in] callback - pointer to the application callback function.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_register_callback(esp_profile_cb_t callback);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_app_register
|
||||
**
|
||||
** @brief This function is called to register application callbacks
|
||||
** with GATTC module.
|
||||
**
|
||||
** @param[in] app_id : Application Identitfy (UUID), for different application
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_app_register(uint16_t app_id);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_app_unregister
|
||||
**
|
||||
** @brief This function is called to unregister an application
|
||||
** from GATTC module.
|
||||
**
|
||||
** @param[in] gatt_if - app identifier.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
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] is_direct: direct connection or background auto connection
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_open(esp_gatt_if_t gatt_if, esp_bd_addr_t remote_bda, bool is_direct);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_close
|
||||
**
|
||||
** @brief Close a connection to a GATT server.
|
||||
**
|
||||
** @param[in] conn_id: connectino ID to be closed.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_close (uint16_t conn_id);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_config_mtu
|
||||
**
|
||||
** @brief Configure the MTU size in the GATT channel. This can be done
|
||||
** only once per connection.
|
||||
**
|
||||
** @param[in] conn_id: connection ID.
|
||||
** mtu: desired MTU size to use.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_config_mtu (uint16_t conn_id, uint16_t mtu);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_search_service
|
||||
**
|
||||
** @brief This function is called to request a GATT service discovery
|
||||
** on a GATT server. This function report service search result
|
||||
** by a callback event, and followed by a service search complete
|
||||
** event.
|
||||
**
|
||||
** @param[in] conn_id: connection ID.
|
||||
** @param[in] filter_uuid: a UUID of the service application is interested in.
|
||||
** If Null, discover for all services.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_search_service(uint16_t conn_id, esp_bt_uuid_t *filter_uuid);
|
||||
|
||||
|
||||
/****************************************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_get_characteristic
|
||||
**
|
||||
** @brief This function is called to find the first characteristic of the
|
||||
** service on the given server.
|
||||
**
|
||||
** @param[in] conn_id: connection ID which identify the server.
|
||||
**
|
||||
** @param[in] srvc_id: serivce ID
|
||||
**
|
||||
** @param[in] start_char_id: the start characteristic ID
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*****************************************************************************************************/
|
||||
|
||||
esp_err_t esp_ble_gattc_get_characteristic(uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id, esp_gatt_id_t *start_char_id);
|
||||
|
||||
/****************************************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_get_descriptor
|
||||
**
|
||||
** @brief This function is called to find the descriptor of the
|
||||
** service on the given server.
|
||||
**
|
||||
** @param[in] conn_id: connection ID which identify the server.
|
||||
** @param[in] srvc_id: the service ID of which the characteristic is belonged to.
|
||||
** @param[in] char_id: Characteristic ID, if NULL find the first available
|
||||
** characteristic.
|
||||
** @param[in] start_descr_id: the sctart descriptor id
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*****************************************************************************************************/
|
||||
esp_err_t esp_ble_gattc_get_descriptor(uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id, esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *start_descr_id);
|
||||
|
||||
|
||||
/****************************************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_get_include_service
|
||||
**
|
||||
** @brief This function is called to find the first characteristic of the
|
||||
** service on the given server.
|
||||
**
|
||||
** @param[in] conn_id: connection ID which identify the server.
|
||||
** @param[in] srvc_id: the service ID of which the characteristic is belonged to.
|
||||
** @param[in] start_incl_srvc_id: the start include service id
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*****************************************************************************************************/
|
||||
|
||||
|
||||
esp_err_t esp_ble_gattc_get_included_service(uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id, esp_gatt_srvc_id_t *start_incl_srvc_id);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_read_char
|
||||
**
|
||||
** @brief This function is called to read a service's characteristics of
|
||||
** the given characteritisc ID.UTH_REQ_NO_SCATTERNET
|
||||
**
|
||||
** @param[in] conn_id - connectino ID.
|
||||
** @param[in] srvc_id - serivcie ID.
|
||||
** @param[in] char_id - characteritic ID to read.
|
||||
** @param[in] auth_req - authenticate request type
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_read_char (uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_read_char_descr
|
||||
**
|
||||
** @brief This function is called to read a characteristics descriptor.
|
||||
**
|
||||
** @param[in] conn_id - connection ID.
|
||||
** @param[in] srvc_id - serivcie ID.
|
||||
** @param[in] descr_id - characteritic descriptor ID to read.
|
||||
** @param[in] auth_req - authenticate request type
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_read_char_descr (uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_write_char
|
||||
**
|
||||
** @brief This function is called to write characteristic value.
|
||||
**
|
||||
** @param[in] conn_id - connection ID.
|
||||
** @param[in] srvc_id - serivcie ID.
|
||||
** @param[in] char_id - characteristic ID to write.
|
||||
** @param[in] len: length of the data to be written.
|
||||
** @param[in] value - the value to be written.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_write_char( uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
uint16_t len,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_write_char_descr
|
||||
**
|
||||
** @brief This function is called to write characteristic descriptor value.
|
||||
**
|
||||
** @param[in] conn_id - connection ID
|
||||
** @param[in] srvc_id - serivcie ID.
|
||||
** @param[in] char_id - characteristic ID.
|
||||
** @param[in] descr_id - characteristic descriptor ID to write.
|
||||
** @param[in] value - the value to be written.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_write_char_descr (uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
uint16_t len,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_prepare_write
|
||||
**
|
||||
** @brief This function is called to prepare write a characteristic value.
|
||||
**
|
||||
** @param[in] conn_id - connection ID.
|
||||
** @param[in] char_id - GATT characteritic ID of the service.
|
||||
** @param[in] offset - offset of the write value.
|
||||
** @param[in] len: length of the data to be written.
|
||||
** @param[in] value - the value to be written.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_prepare_write(uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
uint16_t offset,
|
||||
uint16_t len,
|
||||
uint8_t *data,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_execu_write
|
||||
**
|
||||
** @brief This function is called to execute write a prepare write sequence.
|
||||
**
|
||||
** @param[in] conn_id - connection ID.
|
||||
** @param[in] is_execute - execute or cancel.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_execute_write (uint16_t conn_id, bool is_execute);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_register_for_notify
|
||||
**
|
||||
** @brief This function is called to register for notification of a service.
|
||||
**
|
||||
** @param[in] gatt_if - gatt interface id.
|
||||
** @param[in] bda - target GATT server.
|
||||
** @param[in] srvc_id - pointer to GATT service ID.
|
||||
** @param[in] char_id - pointer to GATT characteristic ID.
|
||||
**
|
||||
** @return OK if registration succeed, otherwise failed.
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_gatt_status_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gatt_if,
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_unregister_ntf
|
||||
**
|
||||
** @brief This function is called to de-register for notification of a service.
|
||||
**
|
||||
** @param[in] gatt_if - gatt interface id.
|
||||
** @param[in] bda - target GATT server.
|
||||
** @param[in] srvc_id - pointer to GATT service ID.
|
||||
** @param[in] char_id - pointer to GATT characteristic ID.
|
||||
**
|
||||
** @return OK if deregistration succeed, otherwise failed.
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_gatt_status_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gatt_if,
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id);
|
||||
|
||||
|
||||
#endif /* __ESP_GATTC_API_H__ */
|
430
components/bt/bluedroid/api/include/esp_gatts_api.h
Normal file
430
components/bt/bluedroid/api/include/esp_gatts_api.h
Normal file
@@ -0,0 +1,430 @@
|
||||
#ifndef __ESP_GATTS_API_H__
|
||||
#define __ESP_GATTS_API_H__
|
||||
|
||||
#include "bt_types.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_gatt_defs.h"
|
||||
#include "bta_gatt_api.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
/* GATT Server Data Structure */
|
||||
/* Server callback function events */
|
||||
#define ESP_GATTS_REG_EVT 0
|
||||
#define ESP_GATTS_READ_EVT 1
|
||||
#define ESP_GATTS_WRITE_EVT 2
|
||||
#define ESP_GATTS_EXEC_WRITE_EVT 3
|
||||
#define ESP_GATTS_MTU_EVT 4
|
||||
#define ESP_GATTS_CONF_EVT 5
|
||||
#define ESP_GATTS_UNREG_EVT 6
|
||||
#define ESP_GATTS_CREATE_EVT 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_START_EVT 12
|
||||
#define ESP_GATTS_STOP_EVT 13
|
||||
#define ESP_GATTS_CONNECT_EVT 14
|
||||
#define ESP_GATTS_DISCONNECT_EVT 15
|
||||
#define ESP_GATTS_OPEN_EVT 16
|
||||
#define ESP_GATTS_CANCEL_OPEN_EVT 17
|
||||
#define ESP_GATTS_CLOSE_EVT 18
|
||||
#define ESP_GATTS_LISTEN_EVT 19
|
||||
#define ESP_GATTS_CONGEST_EVT 20
|
||||
/* following is extra event */
|
||||
#define ESP_GATTS_RESPONSE_EVT 21
|
||||
|
||||
/* esp_ble_gatts_args_t */
|
||||
typedef struct {
|
||||
esp_gatt_if_t gatt_if; /* internal is server_if or client_if */
|
||||
esp_gatt_srvc_id_t service_uuid;
|
||||
esp_gatt_id_t char_uuid;
|
||||
esp_gatt_id_t descr_uuid;
|
||||
esp_bt_uuid_t uuid;
|
||||
esp_gatt_rsp_t rsp;
|
||||
esp_gatt_perm_t perm;
|
||||
esp_gatt_char_prop_t property;
|
||||
esp_bd_addr_t remote_bda;
|
||||
esp_gatt_status_t status;
|
||||
uint16_t service_handle;
|
||||
uint16_t included_service_handle;
|
||||
uint16_t attr_handle;
|
||||
uint16_t num_handle;
|
||||
uint16_t conn_id;
|
||||
uint16_t trans_id;
|
||||
bool need_confirm;
|
||||
bool is_direct;
|
||||
uint16_t app_uuid;
|
||||
uint16_t data_len;
|
||||
uint8_t data[ESP_GATT_MAX_ATTR_LEN];
|
||||
} esp_ble_gatts_args_t;
|
||||
|
||||
|
||||
/* esp_ble_gatts_cb_param_t */
|
||||
typedef union {
|
||||
//ESP_GATTS_REG_EVT
|
||||
struct gatts_reg_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t app_id;
|
||||
} reg;
|
||||
// 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;
|
||||
// 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[ESP_GATT_MAX_ATTR_LEN];
|
||||
} write;
|
||||
// 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;
|
||||
#define ESP_GATT_PREP_WRITE_CANCEL 0x00
|
||||
#define ESP_GATT_PREP_WRITE_EXEC 0x01
|
||||
uint8_t exec_write_flag;
|
||||
} exec_write;
|
||||
// param for ESP_GATTS_MTU_EVT
|
||||
struct gatts_mtu_evt_param {
|
||||
uint16_t conn_id;
|
||||
uint16_t mtu;
|
||||
} mtu;
|
||||
// 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
|
||||
// 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; //uuid
|
||||
} create;
|
||||
// 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;
|
||||
// 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;
|
||||
// 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
|
||||
struct gatts_delete_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t service_handle; //handle
|
||||
} del;
|
||||
// param for ESP_GATTS_START_EVT
|
||||
struct gatts_start_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t service_handle; //handle
|
||||
} start;
|
||||
// param for ESP_GATTS_STOP_EVT
|
||||
struct gatts_stop_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t service_handle; //handle
|
||||
} stop;
|
||||
// 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;
|
||||
// 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;
|
||||
// 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;
|
||||
// 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;
|
||||
} esp_ble_gatts_cb_param_t;
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_register_callback
|
||||
**
|
||||
** @brief This function is called to register application callbacks
|
||||
** with BTA GATTS module.
|
||||
**
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_register_callback(esp_profile_cb_t callback);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_app_register
|
||||
**
|
||||
** @brief This function is called to register application identity
|
||||
**
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_app_register(uint16_t app_id);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_app_unregister
|
||||
**
|
||||
** @brief un-register with GATT Server.
|
||||
**
|
||||
** @param[in] gatt_if: gatt interface id.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_app_unregister(esp_gatt_if_t gatt_if);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_create_service
|
||||
**
|
||||
** @brief Create a service. When service creation is done, a callback
|
||||
** event BTA_GATTS_CREATE_SRVC_EVT is called to report status
|
||||
** and service ID to the profile. The service ID obtained in
|
||||
** the callback function needs to be used when adding included
|
||||
** service and characteristics/descriptors into the service.
|
||||
**
|
||||
** @param[in] gatt_if: gatt interface ID
|
||||
** @param[in] service_uuid: service UUID.
|
||||
** @param[in] num_handle: numble of handle requessted for this service.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_create_service(esp_gatt_if_t gatt_if,
|
||||
esp_gatt_srvc_id_t *service_uuid, uint16_t num_handle);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_add_include_service
|
||||
**
|
||||
** @brief This function is called to add an included service. After included
|
||||
** service is included, a callback event BTA_GATTS_ADD_INCL_SRVC_EVT
|
||||
** is reported the included service ID.
|
||||
**
|
||||
** @param[in] service_handle: service handle to which this included service is to
|
||||
** be added.
|
||||
** @param[in] included_service_handle: the service ID to be included.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_add_include_service(uint16_t service_handle, uint16_t included_service_handle);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_add_char
|
||||
**
|
||||
** @brief This function is called to add a characteristic into a service.
|
||||
**
|
||||
** @param[in] service_handle: service handle to which this included service is to
|
||||
** be added.
|
||||
** @param[in] char_uuid : Characteristic UUID.
|
||||
** @param[in] perm : Characteristic value declaration attribute permission.
|
||||
** @param[in] property : Characteristic Properties
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_add_char(uint16_t service_handle, esp_bt_uuid_t *char_uuid,
|
||||
esp_gatt_perm_t perm, esp_gatt_char_prop_t property);
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_add_char_descr
|
||||
**
|
||||
** @brief This function is called to add characteristic descriptor. When
|
||||
** it's done, a callback event BTA_GATTS_ADD_DESCR_EVT is called
|
||||
** to report the status and an ID number for this descriptor.
|
||||
**
|
||||
** @param[in] service_handle: service handle to which this charatceristic descriptor is to
|
||||
** be added.
|
||||
** @param[in] perm: descriptor access permission.
|
||||
** @param[in] descr_uuid: descriptor UUID.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_add_char_descr (uint16_t service_handle,
|
||||
esp_bt_uuid_t *descr_uuid,
|
||||
esp_gatt_perm_t perm);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_delete_service
|
||||
**
|
||||
** @brief This function is called to delete a service. When this is done,
|
||||
** a callback event BTA_GATTS_DELETE_EVT is report with the status.
|
||||
**
|
||||
** @param[in] service_handled: service_handle to be deleted.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_delete_service(uint16_t service_handle);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_start_service
|
||||
**
|
||||
** @brief This function is called to start a service.
|
||||
**
|
||||
** @param[in] service_handle: the service handle to be started.
|
||||
** @param[in] sup_transport: supported trasnport.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_start_service(uint16_t service_handle);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_stop_service
|
||||
**
|
||||
** @brief This function is called to stop a service.
|
||||
**
|
||||
** @param[in] service_handle - service to be topped.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_stop_service(uint16_t service_handle);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_send_indicate
|
||||
**
|
||||
** @brief This function is called to read a characteristics descriptor.
|
||||
**
|
||||
** @param[in] conn_id - connection id to indicate.
|
||||
** @param[in] attribute_handle - attribute handle to indicate.
|
||||
** @param[in] data_len - indicate data length.
|
||||
** @param[in] data: data to indicate.
|
||||
** @param[in] need_confirm - if this indication expects a confirmation or not.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_send_indicate(uint16_t conn_id, uint16_t attr_handle,
|
||||
uint16_t data_len, uint8_t *data, bool need_confirm);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_send_rsp
|
||||
**
|
||||
** @brief This function is called to send a response to a request.
|
||||
**
|
||||
** @param[in] conn_id - connection identifier.
|
||||
** @param[in] trans_id - transfe id
|
||||
** @param[in] status - response status
|
||||
** @param[in] rsp - response data.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_send_response(uint16_t conn_id, uint32_t trans_id,
|
||||
esp_gatt_status_t status, esp_gatt_rsp_t *rsp);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_open
|
||||
**
|
||||
** @brief Open a direct open connection or add a background auto connection
|
||||
** bd address
|
||||
**
|
||||
** @param[in] gatt_if: application ID.
|
||||
** @param[in] remote_bda: remote device BD address.
|
||||
** @param[in] is_direct: direct connection or background auto connection
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_open(esp_gatt_if_t gatt_if, esp_bd_addr_t remote_bda, bool is_direct);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gatts_close
|
||||
**
|
||||
** @brief Close a connection a remote device.
|
||||
**
|
||||
** @param[in] conn_id: connectino ID to be closed.
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_close(uint16_t conn_id);
|
||||
|
||||
|
||||
#endif /* __ESP_GATTS_API_H__ */
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_common.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "bta_sdp_api.h"
|
||||
#include "bt_sdp.h"
|
||||
|
||||
|
Reference in New Issue
Block a user