mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-06-30 20:40:59 +02:00
Update IDF to c4e65d6
This commit is contained in:
@ -665,6 +665,12 @@
|
||||
#define L2CAP_CLIENT_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
/* The maximum number of simultaneous applications that can register with LE L2CAP. */
|
||||
#ifndef BLE_MAX_L2CAP_CLIENTS
|
||||
#define BLE_MAX_L2CAP_CLIENTS 15
|
||||
#endif
|
||||
|
||||
|
||||
/* The maximum number of simultaneous links that L2CAP can support. Up to 7*/
|
||||
#ifndef MAX_ACL_CONNECTIONS
|
||||
#define MAX_L2CAP_LINKS 5
|
||||
|
@ -406,6 +406,12 @@ typedef tBTM_SET_PKT_DATA_LENGTH_CBACK tBTA_SET_PKT_DATA_LENGTH_CBACK;
|
||||
|
||||
typedef tBTM_SET_LOCAL_PRIVACY_CBACK tBTA_SET_LOCAL_PRIVACY_CBACK;
|
||||
|
||||
typedef tBTM_CMPL_CB tBTA_CMPL_CB;
|
||||
|
||||
typedef tBTM_TX_POWER_RESULTS tBTA_TX_POWER_RESULTS;
|
||||
|
||||
typedef tBTM_RSSI_RESULTS tBTA_RSSI_RESULTS;
|
||||
|
||||
/* advertising channel map */
|
||||
#define BTA_BLE_ADV_CHNL_37 BTM_BLE_ADV_CHNL_37
|
||||
#define BTA_BLE_ADV_CHNL_38 BTM_BLE_ADV_CHNL_38
|
||||
@ -1404,6 +1410,12 @@ extern void BTA_DisableTestMode(void);
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmSetDeviceName(char *p_name);
|
||||
|
||||
extern void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr);
|
||||
|
||||
extern void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb);
|
||||
|
||||
extern void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_CMPL_CB *cmpl_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmSetVisibility
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "bta_api.h"
|
||||
#include "gatt_api.h"
|
||||
#include "list.h"
|
||||
|
||||
#ifndef BTA_GATT_INCLUDED
|
||||
#warning BTA_GATT_INCLUDED not defined
|
||||
@ -43,6 +44,34 @@
|
||||
#define BTA_GATT_DEBUG FALSE
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTGATT_DB_PRIMARY_SERVICE,
|
||||
BTGATT_DB_SECONDARY_SERVICE,
|
||||
BTGATT_DB_CHARACTERISTIC,
|
||||
BTGATT_DB_DESCRIPTOR,
|
||||
BTGATT_DB_INCLUDED_SERVICE,
|
||||
}bt_gatt_db_attribute_type_t;
|
||||
|
||||
typedef enum {
|
||||
GATT_OP_GET_SVC_BY_UUID,
|
||||
GATT_OP_GET_ALL_CHAR,
|
||||
GATT_OP_GET_ALL_DESCRI,
|
||||
GATT_OP_GET_CHAR_BY_UUID,
|
||||
GATT_OP_GET_DESCRI_BY_UUID,
|
||||
GATT_OP_GET_DESCRI_BY_HANDLE,
|
||||
GATT_OP_GET_INCLUDE_SVC,
|
||||
}bt_gatt_get_db_op_t;
|
||||
|
||||
typedef struct {
|
||||
bt_gatt_db_attribute_type_t type;
|
||||
UINT16 attribute_handle;
|
||||
UINT16 start_handle;
|
||||
UINT16 end_handle;
|
||||
UINT16 id;
|
||||
UINT8 properties;
|
||||
bt_uuid_t uuid;
|
||||
}btgatt_db_element_t;
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
*****************************************************************************/
|
||||
@ -104,7 +133,7 @@ typedef struct {
|
||||
#define BTA_GATT_APP_RSP GATT_APP_RSP /* 0xE1 */
|
||||
//Error caused by customer application or stack bug
|
||||
#define BTA_GATT_UNKNOWN_ERROR GATT_UNKNOWN_ERROR /* 0XEF */
|
||||
|
||||
/* 0xE0 ~ 0xFC reserved for future use */
|
||||
#define BTA_GATT_CCC_CFG_ERR GATT_CCC_CFG_ERR /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */
|
||||
#define BTA_GATT_PRC_IN_PROGRESS GATT_PRC_IN_PROGRESS /* 0xFE Procedure Already in progress */
|
||||
#define BTA_GATT_OUT_OF_RANGE GATT_OUT_OF_RANGE /* 0xFFAttribute value out of range */
|
||||
@ -213,41 +242,13 @@ typedef struct {
|
||||
BOOLEAN is_primary;
|
||||
} tBTA_GATT_SRVC_ID;
|
||||
|
||||
typedef struct {
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_ID char_id;
|
||||
} tBTA_GATTC_CHAR_ID;
|
||||
|
||||
typedef struct {
|
||||
tBTA_GATTC_CHAR_ID char_id;
|
||||
tBTA_GATT_ID descr_id;
|
||||
} tBTA_GATTC_CHAR_DESCR_ID;
|
||||
|
||||
typedef struct {
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_SRVC_ID incl_svc_id;
|
||||
} tBTA_GATTC_INCL_SVC_ID;
|
||||
|
||||
#define BTA_GATT_TYPE_CHAR 0
|
||||
#define BTA_GATT_TYPE_CHAR_DESCR 1
|
||||
typedef UINT8 tBTA_GATT_ID_TYPE;
|
||||
|
||||
typedef struct {
|
||||
tBTA_GATT_ID_TYPE id_type;
|
||||
union {
|
||||
tBTA_GATTC_CHAR_ID char_id;
|
||||
tBTA_GATTC_CHAR_DESCR_ID char_descr_id;
|
||||
|
||||
} id_value;
|
||||
} tBTA_GATTC_ATTR_ID;
|
||||
|
||||
#define BTA_GATTC_MULTI_MAX GATT_MAX_READ_MULTI_HANDLES
|
||||
|
||||
typedef struct {
|
||||
UINT8 num_attr;
|
||||
tBTA_GATTC_ATTR_ID id_list[BTA_GATTC_MULTI_MAX];
|
||||
|
||||
} tBTA_GATTC_MULTI;
|
||||
UINT16 handles[BTA_GATTC_MULTI_MAX];
|
||||
}tBTA_GATTC_MULTI;
|
||||
|
||||
/* relate to ESP_GATT_xxx in esp_gatt_def.h */
|
||||
#define BTA_GATT_AUTH_REQ_NONE GATT_AUTH_REQ_NONE
|
||||
@ -275,44 +276,28 @@ typedef struct {
|
||||
UINT8 id;
|
||||
UINT8 prop; /* used when attribute type is characteristic */
|
||||
BOOLEAN is_primary; /* used when attribute type is service */
|
||||
} tBTA_GATTC_NV_ATTR;
|
||||
UINT16 incl_srvc_handle; /* used when attribute type is included service */
|
||||
}tBTA_GATTC_NV_ATTR;
|
||||
|
||||
/* callback data structure */
|
||||
typedef struct {
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATTC_IF client_if;
|
||||
// btla-specific ++
|
||||
tBT_UUID app_uuid;
|
||||
// btla-specific --
|
||||
} tBTA_GATTC_REG;
|
||||
|
||||
typedef struct {
|
||||
UINT8 num_pres_fmt; /* number of presentation format aggregated*/
|
||||
tBTA_GATTC_CHAR_DESCR_ID pre_format[BTA_GATTC_MULTI_MAX];
|
||||
} tBTA_GATT_CHAR_AGGRE_VALUE;
|
||||
|
||||
typedef union {
|
||||
tBTA_GATT_CHAR_AGGRE_VALUE aggre_value;
|
||||
tBTA_GATT_UNFMT unformat;
|
||||
|
||||
} tBTA_GATT_READ_VAL;
|
||||
}tBTA_GATTC_REG;
|
||||
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_ID char_id;
|
||||
tBTA_GATT_ID descr_type;
|
||||
tBTA_GATT_READ_VAL *p_value;
|
||||
} tBTA_GATTC_READ;
|
||||
UINT16 handle;
|
||||
tBTA_GATT_UNFMT *p_value;
|
||||
}tBTA_GATTC_READ;
|
||||
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_ID char_id;
|
||||
tBTA_GATT_ID descr_type;
|
||||
} tBTA_GATTC_WRITE;
|
||||
UINT16 handle;
|
||||
}tBTA_GATTC_WRITE;
|
||||
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
@ -326,8 +311,10 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
tBTA_GATT_SRVC_ID service_uuid;
|
||||
} tBTA_GATTC_SRVC_RES;
|
||||
UINT16 start_handle;
|
||||
UINT16 end_handle;
|
||||
tBTA_GATT_ID service_uuid;
|
||||
}tBTA_GATTC_SRVC_RES;
|
||||
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
@ -355,8 +342,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
BD_ADDR bda;
|
||||
tBTA_GATTC_CHAR_ID char_id;
|
||||
tBTA_GATT_ID descr_type;
|
||||
UINT16 handle;
|
||||
UINT16 len;
|
||||
UINT8 value[BTA_GATT_MAX_ATTR_LEN];
|
||||
BOOLEAN is_notify;
|
||||
@ -367,14 +353,12 @@ typedef struct {
|
||||
BOOLEAN congested; /* congestion indicator */
|
||||
} tBTA_GATTC_CONGEST;
|
||||
|
||||
// btla-specific ++
|
||||
typedef struct {
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATTC_IF client_if;
|
||||
UINT16 conn_id;
|
||||
BD_ADDR remote_bda;
|
||||
} tBTA_GATTC_OPEN_CLOSE;
|
||||
// btla-specific --
|
||||
}tBTA_GATTC_OPEN_CLOSE;
|
||||
|
||||
typedef struct {
|
||||
tBTA_GATTC_IF client_if;
|
||||
@ -395,6 +379,8 @@ typedef struct {
|
||||
BD_ADDR remote_bda;
|
||||
} tBTA_GATTC_DISCONNECT;
|
||||
|
||||
|
||||
|
||||
typedef union {
|
||||
tBTA_GATT_STATUS status;
|
||||
|
||||
@ -541,33 +527,26 @@ typedef struct {
|
||||
typedef struct {
|
||||
tBTA_GATTS_IF server_if;
|
||||
tBTA_GATT_STATUS status;
|
||||
// btla-specific ++
|
||||
tBT_UUID uuid;
|
||||
// btla-specific --
|
||||
} tBTA_GATTS_REG_OPER;
|
||||
}tBTA_GATTS_REG_OPER;
|
||||
|
||||
|
||||
typedef struct {
|
||||
tBTA_GATTS_IF server_if;
|
||||
UINT16 service_id;
|
||||
// btla-specific ++
|
||||
UINT16 svc_instance;
|
||||
BOOLEAN is_primary;
|
||||
tBTA_GATT_STATUS status;
|
||||
tBT_UUID uuid;
|
||||
// btla-specific --
|
||||
} tBTA_GATTS_CREATE;
|
||||
}tBTA_GATTS_CREATE;
|
||||
|
||||
typedef struct {
|
||||
tBTA_GATTS_IF server_if;
|
||||
UINT16 service_id;
|
||||
UINT16 attr_id;
|
||||
tBTA_GATT_STATUS status;
|
||||
// btla-specific ++
|
||||
tBT_UUID char_uuid;
|
||||
// btla-specific --
|
||||
} tBTA_GATTS_ADD_RESULT;
|
||||
|
||||
}tBTA_GATTS_ADD_RESULT;
|
||||
typedef struct{
|
||||
tBTA_GATTS_IF server_if;
|
||||
UINT16 service_id;
|
||||
@ -614,7 +593,6 @@ typedef struct {
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATTS_IF server_if;
|
||||
} tBTA_GATTS_CANCEL_OPEN;
|
||||
|
||||
/* GATTS callback data */
|
||||
typedef union {
|
||||
tBTA_GATTS_REG_OPER reg_oper;
|
||||
@ -648,6 +626,41 @@ typedef void (tBTA_GATTS_ENB_CBACK)(tBTA_GATT_STATUS status);
|
||||
|
||||
/* Server callback function */
|
||||
typedef void (tBTA_GATTS_CBACK)(tBTA_GATTS_EVT event, tBTA_GATTS *p_data);
|
||||
typedef struct
|
||||
{
|
||||
tBT_UUID uuid;
|
||||
BOOLEAN is_primary;
|
||||
UINT16 handle;
|
||||
UINT16 s_handle;
|
||||
UINT16 e_handle;
|
||||
list_t *characteristics; /* list of tBTA_GATTC_CHARACTERISTIC */
|
||||
list_t *included_svc; /* list of tBTA_GATTC_INCLUDED_SVC */
|
||||
} __attribute__((packed)) tBTA_GATTC_SERVICE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tBT_UUID uuid;
|
||||
UINT16 handle;
|
||||
tBTA_GATT_CHAR_PROP properties;
|
||||
tBTA_GATTC_SERVICE *service; /* owning service*/
|
||||
list_t *descriptors; /* list of tBTA_GATTC_DESCRIPTOR */
|
||||
} __attribute__((packed)) tBTA_GATTC_CHARACTERISTIC;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tBT_UUID uuid;
|
||||
UINT16 handle;
|
||||
tBTA_GATTC_CHARACTERISTIC *characteristic; /* owning characteristic */
|
||||
} __attribute__((packed)) tBTA_GATTC_DESCRIPTOR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tBT_UUID uuid;
|
||||
UINT16 handle;
|
||||
UINT16 incl_srvc_s_handle;
|
||||
tBTA_GATTC_SERVICE *owning_service; /* owning service*/
|
||||
tBTA_GATTC_SERVICE *included_service;
|
||||
} __attribute__((packed)) tBTA_GATTC_INCLUDED_SVC;
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
@ -770,175 +783,114 @@ extern void BTA_GATTC_ServiceSearchRequest(UINT16 conn_id, tBT_UUID *p_srvc_uuid
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_GetFirstChar
|
||||
** Function BTA_GATTC_GetServices
|
||||
**
|
||||
** Description This function is called to find the first charatceristic of the
|
||||
** service on the given server.
|
||||
** Description This function is called to find the services on the given server.
|
||||
**
|
||||
** Parameters conn_id: connection ID which identify the server.
|
||||
** p_srvc_id: the service ID of which the characteristic is belonged to.
|
||||
** p_char_uuid_cond: Characteristic UUID, if NULL find the first available
|
||||
** characteristic.
|
||||
** p_char_result: output parameter which will store the GATT
|
||||
** characteristic ID.
|
||||
** p_property: output parameter to carry the characteristic property.
|
||||
**
|
||||
** Returns returns status.
|
||||
** Returns returns list_t of tBTA_GATTC_SERVICE or NULL.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GATTC_GetFirstChar (UINT16 conn_id,
|
||||
tBTA_GATT_SRVC_ID *p_srvc_id,
|
||||
tBT_UUID *p_char_uuid_cond,
|
||||
tBTA_GATTC_CHAR_ID *p_char_result,
|
||||
tBTA_GATT_CHAR_PROP *p_property);
|
||||
extern const list_t* BTA_GATTC_GetServices(UINT16 conn_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_GetNextChar
|
||||
** Function BTA_GATTC_GetCharacteristic
|
||||
**
|
||||
** Description This function is called to find the next charatceristic of the
|
||||
** service on the given server.
|
||||
** Description This function is called to find the characteristic on the given server.
|
||||
**
|
||||
** Parameters conn_id: connection ID which identify the server.
|
||||
** p_start_char_id: start the characteristic search from the next record
|
||||
** after the one identified by char_id.
|
||||
** p_char_uuid_cond: Characteristic UUID, if NULL find the first available
|
||||
** characteristic.
|
||||
** p_char_result: output parameter which will store the GATT
|
||||
** characteristic ID.
|
||||
** p_property: output parameter, characteristic property.
|
||||
** handle: characteristic handle
|
||||
**
|
||||
** Returns returns status.
|
||||
** Returns returns pointer to tBTA_GATTC_CHARACTERISTIC or NULL.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GATTC_GetNextChar (UINT16 conn_id,
|
||||
tBTA_GATTC_CHAR_ID *p_start_char_id,
|
||||
tBT_UUID *p_char_uuid_cond,
|
||||
tBTA_GATTC_CHAR_ID *p_char_result,
|
||||
tBTA_GATT_CHAR_PROP *p_property);
|
||||
extern const tBTA_GATTC_CHARACTERISTIC* BTA_GATTC_GetCharacteristic(UINT16 conn_id, UINT16 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_GetFirstCharDescr
|
||||
** Function BTA_GATTC_GetDescriptor
|
||||
**
|
||||
** Description This function is called to find the first charatceristic descriptor of the
|
||||
** charatceristic on the given server.
|
||||
** Description This function is called to find the characteristic on the given server.
|
||||
**
|
||||
** Parameters conn_id: connection ID which identify the server.
|
||||
** p_char_id: the characteristic ID of which the descriptor is belonged to.
|
||||
** p_descr_uuid_cond: Characteristic Descr UUID, if NULL find the first available
|
||||
** characteristic.
|
||||
** p_descr_result: output parameter which will store the GATT
|
||||
** characteristic descriptor ID.
|
||||
** handle: descriptor handle
|
||||
**
|
||||
** Returns returns status.
|
||||
** Returns returns pointer to tBTA_GATTC_DESCRIPTOR or NULL.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GATTC_GetFirstCharDescr (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
|
||||
tBT_UUID *p_descr_uuid_cond,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_descr_result);
|
||||
extern const tBTA_GATTC_DESCRIPTOR* BTA_GATTC_GetDescriptor(UINT16 conn_id, UINT16 handle);
|
||||
|
||||
extern void BTA_GATTC_GetServiceWithUUID(UINT16 conn_id, tBT_UUID *svc_uuid,
|
||||
btgatt_db_element_t **db, int *count);
|
||||
|
||||
extern void BTA_GATTC_GetAllChar(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle,
|
||||
btgatt_db_element_t **db, int *count);
|
||||
|
||||
extern void BTA_GATTC_GetAllDescriptor(UINT16 conn_id, UINT16 char_handle,
|
||||
btgatt_db_element_t **db, int *count);
|
||||
|
||||
extern void BTA_GATTC_GetCharByUUID(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, tBT_UUID char_uuid,
|
||||
btgatt_db_element_t **db, int *count);
|
||||
|
||||
extern void BTA_GATTC_GetDescrByUUID(UINT16 conn_id, uint16_t start_handle, uint16_t end_handle,
|
||||
tBT_UUID char_uuid, tBT_UUID descr_uuid,
|
||||
btgatt_db_element_t **db, int *count);
|
||||
|
||||
extern void BTA_GATTC_GetDescrByCharHandle(UINT16 conn_id, UINT16 char_handle, tBT_UUID descr_uuid,
|
||||
btgatt_db_element_t **db, int *count);
|
||||
|
||||
extern void BTA_GATTC_GetIncludeService(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle,
|
||||
tBT_UUID *incl_uuid, btgatt_db_element_t **db, int *count);
|
||||
|
||||
extern void BTA_GATTC_GetDBSize(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, int *count);
|
||||
|
||||
extern void BTA_GATTC_GetDBSizeByType(UINT16 conn_id, bt_gatt_db_attribute_type_t type,
|
||||
UINT16 start_handle, UINT16 end_handle, UINT16 char_handle, int *count);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_GetNextCharDescr
|
||||
** Function BTA_GATTC_GetGattDb
|
||||
**
|
||||
** Description This function is called to find the next charatceristic of the
|
||||
** service on the given server.
|
||||
** Description This function is called to get gatt db.
|
||||
**
|
||||
** Parameters conn_id: connection ID which identify the server.
|
||||
** p_start_descr_id: start the characteristic search from the next record
|
||||
** after the one identified by p_start_descr_id.
|
||||
** p_descr_uuid_cond: Characteristic descriptor UUID, if NULL find
|
||||
** the first available characteristic descriptor.
|
||||
** p_descr_result: output parameter which will store the GATT
|
||||
** characteristic descriptor ID.
|
||||
**
|
||||
** Returns returns status.
|
||||
** db: output parameter which will contain gatt db copy.
|
||||
** Caller is responsible for freeing it.
|
||||
** count: number of elements in db.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GATTC_GetNextCharDescr (UINT16 conn_id,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_start_descr_id,
|
||||
tBT_UUID *p_descr_uuid_cond,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_descr_result);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_GetFirstIncludedService
|
||||
**
|
||||
** Description This function is called to find the first included service of the
|
||||
** service on the given server.
|
||||
**
|
||||
** Parameters conn_id: connection ID which identify the server.
|
||||
** p_srvc_id: the service ID of which the included service is belonged to.
|
||||
** p_uuid_cond: include service UUID, if NULL find the first available
|
||||
** included service.
|
||||
** p_result: output parameter which will store the GATT ID
|
||||
** of the included service found.
|
||||
**
|
||||
** Returns returns status.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GATTC_GetFirstIncludedService(UINT16 conn_id,
|
||||
tBTA_GATT_SRVC_ID *p_srvc_id,
|
||||
tBT_UUID *p_uuid_cond,
|
||||
tBTA_GATTC_INCL_SVC_ID *p_result);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_GetNextIncludedService
|
||||
**
|
||||
** Description This function is called to find the next included service of the
|
||||
** service on the given server.
|
||||
**
|
||||
** Parameters conn_id: connection ID which identify the server.
|
||||
** p_start_id: start the search from the next record
|
||||
** after the one identified by p_start_id.
|
||||
** p_uuid_cond: Included service UUID, if NULL find the first available
|
||||
** included service.
|
||||
** p_result: output parameter which will store the GATT ID
|
||||
** of the included service found.
|
||||
**
|
||||
** Returns returns status.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GATTC_GetNextIncludedService(UINT16 conn_id,
|
||||
tBTA_GATTC_INCL_SVC_ID *p_start_id,
|
||||
tBT_UUID *p_uuid_cond,
|
||||
tBTA_GATTC_INCL_SVC_ID *p_result);
|
||||
extern void BTA_GATTC_GetGattDb(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle,
|
||||
btgatt_db_element_t **db, int *count);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_ReadCharacteristic
|
||||
**
|
||||
** Description This function is called to read a service's characteristics of
|
||||
** the given characteritisc ID.
|
||||
** Description This function is called to read a characteristics value
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** p_char_id - characteritic ID to read.
|
||||
** Parameters conn_id - connectino ID.
|
||||
** handle - characteritic handle to read.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTC_ReadCharacteristic (UINT16 conn_id,
|
||||
tBTA_GATTC_CHAR_ID *p_char_id,
|
||||
tBTA_GATT_AUTH_REQ auth_req);
|
||||
void BTA_GATTC_ReadCharacteristic(UINT16 conn_id, UINT16 handle, tBTA_GATT_AUTH_REQ auth_req);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_ReadCharDescr
|
||||
**
|
||||
** Description This function is called to read a characteristics descriptor.
|
||||
** Description This function is called to read a descriptor value.
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** p_char_descr_id - characteritic descriptor ID to read.
|
||||
** handle - descriptor handle to read.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTC_ReadCharDescr (UINT16 conn_id,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_char_descr_id,
|
||||
tBTA_GATT_AUTH_REQ auth_req);
|
||||
void BTA_GATTC_ReadCharDescr (UINT16 conn_id, UINT16 handle, tBTA_GATT_AUTH_REQ auth_req);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -947,40 +899,40 @@ extern void BTA_GATTC_ReadCharDescr (UINT16 conn_id,
|
||||
** Description This function is called to write characteristic value.
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** p_char_id - characteristic ID to write.
|
||||
** write_type - type of write.
|
||||
** handle - characteristic handle to write.
|
||||
** write_type - type of write.
|
||||
** len: length of the data to be written.
|
||||
** p_value - the value to be written.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTC_WriteCharValue (UINT16 conn_id,
|
||||
tBTA_GATTC_CHAR_ID *p_char_id,
|
||||
tBTA_GATTC_WRITE_TYPE write_type,
|
||||
UINT16 len,
|
||||
UINT8 *p_value,
|
||||
tBTA_GATT_AUTH_REQ auth_req);
|
||||
void BTA_GATTC_WriteCharValue ( UINT16 conn_id,
|
||||
UINT16 handle,
|
||||
tBTA_GATTC_WRITE_TYPE write_type,
|
||||
UINT16 len,
|
||||
UINT8 *p_value,
|
||||
tBTA_GATT_AUTH_REQ auth_req);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_WriteCharDescr
|
||||
**
|
||||
** Description This function is called to write characteristic descriptor value.
|
||||
** Description This function is called to write descriptor value.
|
||||
**
|
||||
** Parameters conn_id - connection ID
|
||||
** p_char_descr_id - characteristic descriptor ID to write.
|
||||
** write_type - type of write.
|
||||
** handle - descriptor handle to write.
|
||||
** write_type - type of write.
|
||||
** p_value - the value to be written.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_char_descr_id,
|
||||
tBTA_GATTC_WRITE_TYPE write_type,
|
||||
tBTA_GATT_UNFMT *p_data,
|
||||
tBTA_GATT_AUTH_REQ auth_req);
|
||||
void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
|
||||
UINT16 handle,
|
||||
tBTA_GATTC_WRITE_TYPE write_type,
|
||||
tBTA_GATT_UNFMT *p_data,
|
||||
tBTA_GATT_AUTH_REQ auth_req);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -989,12 +941,12 @@ extern void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
|
||||
** Description This function is called to send handle value confirmation.
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** p_char_id - characteristic ID to confrim.
|
||||
** handle - characteristic handle to confirm.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTC_SendIndConfirm (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id);
|
||||
extern void BTA_GATTC_SendIndConfirm (UINT16 conn_id, UINT16 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -1002,17 +954,16 @@ extern void BTA_GATTC_SendIndConfirm (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char
|
||||
**
|
||||
** Description This function is called to register for notification of a service.
|
||||
**
|
||||
** Parameters client_if - client interface.
|
||||
** remote_bda - target GATT server.
|
||||
** p_char_id - pointer to GATT characteristic ID.
|
||||
** Parameters client_if - client interface.
|
||||
** remote_bda - target GATT server.
|
||||
** handle - GATT characteristic handle.
|
||||
**
|
||||
** Returns OK if registration succeed, otherwise failed.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if,
|
||||
BD_ADDR remote_bda,
|
||||
tBTA_GATTC_CHAR_ID *p_char_id);
|
||||
|
||||
BD_ADDR remote_bda,
|
||||
UINT16 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -1022,14 +973,14 @@ extern tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF c
|
||||
**
|
||||
** Parameters client_if - client interface.
|
||||
** remote_bda - target GATT server.
|
||||
** p_char_id - pointer to a GATT characteristic ID.
|
||||
** handle - GATT characteristic handle.
|
||||
**
|
||||
** Returns OK if deregistration succeed, otherwise failed.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF client_if,
|
||||
BD_ADDR remote_bda,
|
||||
tBTA_GATTC_CHAR_ID *p_char_id);
|
||||
BD_ADDR remote_bda,
|
||||
UINT16 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -1038,16 +989,16 @@ extern tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF
|
||||
** Description This function is called to prepare write a characteristic value.
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** p_char_id - GATT characteritic ID of the service.
|
||||
** handle - GATT characteritic handle.
|
||||
** offset - offset of the write value.
|
||||
** len: length of the data to be written.
|
||||
** len - length of the data to be written.
|
||||
** p_value - the value to be written.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTC_PrepareWrite (UINT16 conn_id,
|
||||
tBTA_GATTC_CHAR_ID *p_char_id,
|
||||
UINT16 handle,
|
||||
UINT16 offset,
|
||||
UINT16 len,
|
||||
UINT8 *p_value,
|
||||
@ -1069,7 +1020,7 @@ extern void BTA_GATTC_PrepareWrite (UINT16 conn_id,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTC_PrepareWriteCharDescr (UINT16 conn_id,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_char_descr_id,
|
||||
UINT16 handle,
|
||||
UINT16 offset,
|
||||
tBTA_GATT_UNFMT *p_data,
|
||||
tBTA_GATT_AUTH_REQ auth_req);
|
||||
@ -1360,9 +1311,9 @@ extern void BTA_GATTS_StopService(UINT16 service_id);
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id,
|
||||
UINT16 data_len,
|
||||
UINT8 *p_data,
|
||||
BOOLEAN need_confirm);
|
||||
UINT16 data_len,
|
||||
UINT8 *p_data,
|
||||
BOOLEAN need_confirm);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -58,12 +58,6 @@ enum {
|
||||
BTA_GATTC_OP_CMPL_EVT,
|
||||
BTA_GATTC_INT_DISCONN_EVT,
|
||||
|
||||
/* for cache loading/saving */
|
||||
BTA_GATTC_START_CACHE_EVT,
|
||||
BTA_GATTC_CI_CACHE_OPEN_EVT,
|
||||
BTA_GATTC_CI_CACHE_LOAD_EVT,
|
||||
BTA_GATTC_CI_CACHE_SAVE_EVT,
|
||||
|
||||
BTA_GATTC_INT_START_IF_EVT,
|
||||
BTA_GATTC_API_REG_EVT,
|
||||
BTA_GATTC_API_DEREG_EVT,
|
||||
@ -74,6 +68,8 @@ enum {
|
||||
};
|
||||
typedef UINT16 tBTA_GATTC_INT_EVT;
|
||||
|
||||
#define BTA_GATTC_SERVICE_CHANGED_LEN 4
|
||||
|
||||
/* max client application GATTC can support */
|
||||
#ifndef BTA_GATTC_CL_MAX
|
||||
#define BTA_GATTC_CL_MAX 3 // 32
|
||||
@ -95,7 +91,7 @@ typedef UINT16 tBTA_GATTC_INT_EVT;
|
||||
#endif
|
||||
|
||||
#define BTA_GATTC_WRITE_PREPARE GATT_WRITE_PREPARE
|
||||
|
||||
#define BTA_GATTC_INVALID_HANDLE 0
|
||||
|
||||
/* internal strucutre for GATTC register API */
|
||||
typedef struct {
|
||||
@ -125,17 +121,15 @@ typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN;
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_AUTH_REQ auth_req;
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_ID char_id;
|
||||
tBTA_GATT_ID *p_descr_type;
|
||||
UINT16 handle;
|
||||
tBTA_GATTC_EVT cmpl_evt;
|
||||
} tBTA_GATTC_API_READ;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_AUTH_REQ auth_req;
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_ID char_id;
|
||||
tBTA_GATT_ID *p_descr_type;
|
||||
UINT16 handle;
|
||||
tBTA_GATTC_EVT cmpl_evt;
|
||||
tBTA_GATTC_WRITE_TYPE write_type;
|
||||
UINT16 offset;
|
||||
UINT16 len;
|
||||
@ -149,8 +143,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_ID char_id;
|
||||
UINT16 handle;
|
||||
} tBTA_GATTC_API_CONFIRM;
|
||||
|
||||
typedef tGATT_CL_COMPLETE tBTA_GATTC_CMPL;
|
||||
@ -171,8 +164,8 @@ typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_AUTH_REQ auth_req;
|
||||
UINT8 num_attr;
|
||||
tBTA_GATTC_ATTR_ID *p_id_list;
|
||||
} tBTA_GATTC_API_READ_MULTI;
|
||||
UINT16 handles[GATT_MAX_READ_MULTI_HANDLES];
|
||||
}tBTA_GATTC_API_READ_MULTI;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
@ -215,9 +208,6 @@ typedef union {
|
||||
tBTA_GATTC_API_READ_MULTI api_read_multi;
|
||||
tBTA_GATTC_API_CFG_MTU api_mtu;
|
||||
tBTA_GATTC_OP_CMPL op_cmpl;
|
||||
tBTA_GATTC_CI_EVT ci_open;
|
||||
tBTA_GATTC_CI_EVT ci_save;
|
||||
tBTA_GATTC_CI_LOAD ci_load;
|
||||
tBTA_GATTC_INT_CONN int_conn;
|
||||
tBTA_GATTC_ENC_CMPL enc_cmpl;
|
||||
|
||||
@ -230,43 +220,13 @@ typedef union {
|
||||
|
||||
|
||||
/* GATT server cache on the client */
|
||||
typedef union {
|
||||
UINT8 uuid128[LEN_UUID_128];
|
||||
UINT16 uuid16;
|
||||
} tBTA_GATTC_UUID;
|
||||
|
||||
typedef struct gattc_attr_cache {
|
||||
tBTA_GATTC_UUID *p_uuid;
|
||||
struct gattc_attr_cache *p_next;
|
||||
UINT16 uuid_len;
|
||||
UINT16 attr_handle;
|
||||
UINT8 inst_id;
|
||||
tBTA_GATT_CHAR_PROP property; /* if characteristic, it is char property;
|
||||
if included service, flag primary,
|
||||
if descriptor, not used */
|
||||
tBTA_GATTC_ATTR_TYPE attr_type;
|
||||
// btla-specific ++
|
||||
} __attribute__((packed)) tBTA_GATTC_CACHE_ATTR;
|
||||
// btla-specific --
|
||||
|
||||
typedef struct gattc_svc_cache {
|
||||
tBTA_GATT_SRVC_ID service_uuid;
|
||||
tBTA_GATTC_CACHE_ATTR *p_attr;
|
||||
tBTA_GATTC_CACHE_ATTR *p_last_attr;
|
||||
UINT16 s_handle;
|
||||
UINT16 e_handle;
|
||||
struct gattc_svc_cache *p_next;
|
||||
tBTA_GATTC_CACHE_ATTR *p_cur_char;
|
||||
// btla-specific ++
|
||||
} __attribute__((packed)) tBTA_GATTC_CACHE;
|
||||
// btla-specific --
|
||||
|
||||
typedef struct {
|
||||
tBT_UUID uuid;
|
||||
UINT16 s_handle;
|
||||
UINT16 e_handle;
|
||||
// this field is set only for characteristic
|
||||
UINT16 char_decl_handle;
|
||||
BOOLEAN is_primary;
|
||||
UINT8 srvc_inst_id;
|
||||
tBTA_GATT_CHAR_PROP property;
|
||||
} tBTA_GATTC_ATTR_REC;
|
||||
|
||||
@ -299,11 +259,7 @@ typedef struct {
|
||||
|
||||
UINT8 state;
|
||||
|
||||
tBTA_GATTC_CACHE *p_srvc_cache;
|
||||
tBTA_GATTC_CACHE *p_cur_srvc;
|
||||
fixed_queue_t *cache_buffer; /* buffer queue used for storing the cache data */
|
||||
UINT8 *p_free; /* starting point to next available byte */
|
||||
UINT16 free_byte; /* number of available bytes in server cache buffer */
|
||||
list_t *p_srvc_cache; /* list of tBTA_GATTC_SERVICE */
|
||||
UINT8 update_count; /* indication received */
|
||||
UINT8 num_clcb; /* number of associated CLCB */
|
||||
|
||||
@ -314,7 +270,7 @@ typedef struct {
|
||||
UINT8 next_avail_idx;
|
||||
UINT8 total_srvc;
|
||||
UINT8 total_char;
|
||||
|
||||
UINT16 total_attr;
|
||||
UINT8 srvc_hdl_chg; /* service handle change indication pending */
|
||||
UINT16 attr_index; /* cahce NV saving/loading attribute index */
|
||||
|
||||
@ -328,8 +284,8 @@ typedef struct {
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATTC_CHAR_ID char_id;
|
||||
} tBTA_GATTC_NOTIF_REG;
|
||||
UINT16 handle;
|
||||
}tBTA_GATTC_NOTIF_REG;
|
||||
|
||||
typedef struct {
|
||||
tBTA_GATTC_CBACK *p_cback;
|
||||
@ -403,11 +359,7 @@ typedef struct {
|
||||
|
||||
tBTA_GATTC_CLCB clcb[BTA_GATTC_CLCB_MAX];
|
||||
tBTA_GATTC_SERV known_server[BTA_GATTC_KNOWN_SR_MAX];
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
tSDP_DISCOVERY_DB *p_sdp_db;
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
UINT16 sdp_conn_id;
|
||||
} tBTA_GATTC_CB;
|
||||
}tBTA_GATTC_CB;
|
||||
|
||||
typedef enum {
|
||||
SERVICE_CHANGE_CCC_WRITTEN_SUCCESS = 0,
|
||||
@ -474,10 +426,7 @@ extern void bta_gattc_confirm(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_execute(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_ci_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_ci_load(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_ci_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_ci_save(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_cache_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_ignore_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_restart_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_msg);
|
||||
extern void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg);
|
||||
@ -509,20 +458,13 @@ extern tBTA_GATTC_CLCB *bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA *p_msg);
|
||||
|
||||
extern BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
|
||||
extern UINT16 bta_gattc_id2handle(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_SRVC_ID *p_service_id, tBTA_GATT_ID *p_char_id, tBTA_GATT_ID *p_descr_uuid);
|
||||
extern BOOLEAN bta_gattc_handle2id(tBTA_GATTC_SERV *p_srcb, UINT16 handle, tBTA_GATT_SRVC_ID *service_id, tBTA_GATT_ID *char_id, tBTA_GATT_ID *p_type);
|
||||
extern BOOLEAN bta_gattc_uuid_compare (tBT_UUID *p_src, tBT_UUID *p_tar, BOOLEAN is_precise);
|
||||
extern void bta_gattc_pack_attr_uuid(tBTA_GATTC_CACHE_ATTR *p_attr, tBT_UUID *p_uuid);
|
||||
extern BOOLEAN bta_gattc_uuid_compare (const tBT_UUID *p_src, const tBT_UUID *p_tar, BOOLEAN is_precise);
|
||||
extern BOOLEAN bta_gattc_check_notif_registry(tBTA_GATTC_RCB *p_clreg, tBTA_GATTC_SERV *p_srcb, tBTA_GATTC_NOTIFY *p_notify);
|
||||
extern tBTA_GATT_STATUS bta_gattc_pack_read_cb_data(tBTA_GATTC_SERV *p_srcb, tBT_UUID *p_descr_uuid, tGATT_VALUE *p_attr, tBTA_GATT_READ_VAL *p_value);
|
||||
extern BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR_PTR remote_bda, BOOLEAN add, BOOLEAN is_listen);
|
||||
extern BOOLEAN bta_gattc_check_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR remote_bda, UINT8 role);
|
||||
extern UINT8 bta_gattc_num_reg_app(void);
|
||||
extern void bta_gattc_clear_notif_registration(UINT16 conn_id);
|
||||
extern tBTA_GATTC_SERV *bta_gattc_find_srvr_cache(BD_ADDR bda);
|
||||
extern BOOLEAN bta_gattc_charid_compare(tBTA_GATTC_CHAR_ID *p_src, tBTA_GATTC_CHAR_ID *p_tar);
|
||||
extern BOOLEAN bta_gattc_srvcid_compare(tBTA_GATT_SRVC_ID *p_src, tBTA_GATT_SRVC_ID *p_tar);
|
||||
extern void bta_gattc_cpygattid(tBTA_GATT_ID *p_des, tBTA_GATT_ID *p_src);
|
||||
extern void bta_gattc_clear_notif_registration(tBTA_GATTC_SERV *p_srcb, UINT16 conn_id, UINT16 start_handle, UINT16 end_handle);
|
||||
extern tBTA_GATTC_SERV * bta_gattc_find_srvr_cache(BD_ADDR bda);
|
||||
|
||||
/* discovery functions */
|
||||
extern void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_DISC_RES *p_data);
|
||||
@ -530,17 +472,41 @@ extern void bta_gattc_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type
|
||||
extern tBTA_GATT_STATUS bta_gattc_discover_procedure(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
|
||||
extern tBTA_GATT_STATUS bta_gattc_discover_pri_service(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
|
||||
extern void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid);
|
||||
extern tBTA_GATT_STATUS bta_gattc_query_cache(UINT16 conn_id, UINT8 query_type, tBTA_GATT_SRVC_ID *p_srvc_id,
|
||||
tBTA_GATT_ID *p_start_rec, tBT_UUID *p_uuid_cond,
|
||||
tBTA_GATT_ID *p_output, void *p_param);
|
||||
extern tBTA_GATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV *p_srvc_cb);
|
||||
extern void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srcv, UINT16 num_attr, tBTA_GATTC_NV_ATTR *p_attr, UINT16 attr_index);
|
||||
extern BOOLEAN bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id);
|
||||
extern const list_t* bta_gattc_get_services(UINT16 conn_id);
|
||||
extern const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle(UINT16 conn_id, UINT16 handle);
|
||||
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle);
|
||||
extern tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic(UINT16 conn_id, UINT16 handle);
|
||||
extern tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor(UINT16 conn_id, UINT16 handle);
|
||||
extern void bta_gattc_get_db_size_handle(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, int *count);
|
||||
extern void bta_gattc_get_db_size_with_type_handle(UINT16 conn_id, bt_gatt_db_attribute_type_t type,
|
||||
UINT16 start_handle, UINT16 end_handle, UINT16 char_handle, int *count);
|
||||
extern void bta_gattc_get_service_with_uuid(UINT16 conn_id, tBT_UUID *svc_uuid,
|
||||
btgatt_db_element_t **svc_db,
|
||||
int *count);
|
||||
|
||||
extern void bta_gattc_get_db_with_opration(UINT16 conn_id,
|
||||
bt_gatt_get_db_op_t op,
|
||||
UINT16 char_handle,
|
||||
tBT_UUID *incl_uuid,
|
||||
tBT_UUID *char_uuid,
|
||||
tBT_UUID *descr_uuid,
|
||||
UINT16 start_handle, UINT16 end_handle,
|
||||
btgatt_db_element_t **char_db,
|
||||
int *count);
|
||||
|
||||
extern void bta_gattc_get_gatt_db(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, btgatt_db_element_t **db, int *count);
|
||||
|
||||
extern tBTA_GATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV *p_srvc_cb);
|
||||
extern void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srcv, UINT16 num_attr, tBTA_GATTC_NV_ATTR *attr);
|
||||
extern void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id);
|
||||
extern void bta_gattc_reset_discover_st(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_STATUS status);
|
||||
|
||||
extern tBTA_GATTC_CONN *bta_gattc_conn_alloc(BD_ADDR remote_bda);
|
||||
extern tBTA_GATTC_CONN *bta_gattc_conn_find(BD_ADDR remote_bda);
|
||||
extern tBTA_GATTC_CONN *bta_gattc_conn_find_alloc(BD_ADDR remote_bda);
|
||||
extern BOOLEAN bta_gattc_conn_dealloc(BD_ADDR remote_bda);
|
||||
|
||||
extern bool bta_gattc_cache_load(tBTA_GATTC_CLCB *p_clcb);
|
||||
extern void bta_gattc_cache_reset(BD_ADDR server_bda);
|
||||
|
||||
#endif /* BTA_GATTC_INT_H */
|
||||
|
@ -23,52 +23,25 @@
|
||||
#define BTC_LE_LOCAL_KEY_DHK (1<<2)
|
||||
#define BTC_LE_LOCAL_KEY_ER (1<<3)
|
||||
|
||||
#define BTC_BLE_STORAGE_DEV_TYPE_STR "DevType"
|
||||
#define BTC_BLE_STORAGE_ADDR_TYPE_STR "AddrType"
|
||||
#define BTC_BLE_STORAGE_LINK_KEY_STR "LinkKey"
|
||||
#define BTC_BLE_STORAGE_LE_KEY_PENC_STR "LE_KEY_PENC"
|
||||
#define BTC_BLE_STORAGE_LE_KEY_PID_STR "LE_KEY_PID"
|
||||
#define BTC_BLE_STORAGE_LE_KEY_PCSRK_STR "LE_KEY_PCSRK"
|
||||
#define BTC_BLE_STORAGE_LE_KEY_LENC_STR "LE_KEY_LENC"
|
||||
#define BTC_BLE_STORAGE_LE_KEY_LID_STR "LE_KEY_LID"
|
||||
#define BTC_BLE_STORAGE_LE_KEY_LCSRK_STR "LE_KEY_LCSRK"
|
||||
|
||||
#define BTC_BLE_STORAGE_LOCAL_ADAPTER_STR "Adapter"
|
||||
#define BTC_BLE_STORAGE_LE_LOCAL_KEY_IR_STR "LE_LOCAL_KEY_IR"
|
||||
#define BTC_BLE_STORAGE_LE_LOCAL_KEY_IRK_STR "LE_LOCAL_KEY_IRK"
|
||||
#define BTC_BLE_STORAGE_LE_LOCAL_KEY_DHK_STR "LE_LOCAL_KEY_DHK"
|
||||
#define BTC_BLE_STORAGE_LE_LOCAL_KEY_ER_STR "LE_LOCAL_KEY_ER"
|
||||
|
||||
/************************************************************************************
|
||||
** Local type definitions
|
||||
************************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t num_devices;
|
||||
bt_bdaddr_t devices[BTM_SEC_MAX_DEVICE_RECORDS];
|
||||
} btc_bonded_devices_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool is_penc_key_rcvd;
|
||||
tBTM_LE_PENC_KEYS penc_key; /* received peer encryption key */
|
||||
bool is_pcsrk_key_rcvd;
|
||||
tBTM_LE_PCSRK_KEYS pcsrk_key; /* received peer device SRK */
|
||||
bool is_pid_key_rcvd;
|
||||
tBTM_LE_PID_KEYS pid_key; /* peer device ID key */
|
||||
bool is_lenc_key_rcvd;
|
||||
tBTM_LE_LENC_KEYS lenc_key; /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
|
||||
bool is_lcsrk_key_rcvd;
|
||||
tBTM_LE_LCSRK_KEYS lcsrk_key; /* local device CSRK = d1(ER,DIV,1)*/
|
||||
bool is_lidk_key_rcvd; /* local identity key received */
|
||||
} btc_dm_ble_cb_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bt_bdaddr_t static_bdaddr;
|
||||
BD_ADDR bd_addr;
|
||||
btc_dm_ble_cb_t ble;
|
||||
} btc_dm_pairing_cb_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t ir[BT_OCTET16_LEN];
|
||||
uint8_t irk[BT_OCTET16_LEN];
|
||||
uint8_t dhk[BT_OCTET16_LEN];
|
||||
}btc_dm_local_key_id_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool is_er_rcvd;
|
||||
uint8_t er[BT_OCTET16_LEN];
|
||||
bool is_id_keys_rcvd;
|
||||
btc_dm_local_key_id_t id_keys; /* ID kyes */
|
||||
}btc_dm_local_key_cb_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BT_OCTET16 sp_c;
|
||||
@ -77,63 +50,37 @@ typedef struct
|
||||
} btc_dm_oob_cb_t;
|
||||
|
||||
|
||||
extern btc_dm_pairing_cb_t pairing_cb;
|
||||
extern btc_dm_local_key_cb_t ble_local_key_cb;
|
||||
extern btc_bonded_devices_t bonded_devices;
|
||||
void btc_storage_save(void);
|
||||
|
||||
bt_status_t btc_storage_load_bonded_ble_devices(void);
|
||||
bt_status_t btc_storage_add_ble_bonding_key( bt_bdaddr_t *remote_bd_addr, char *key, uint8_t key_type, uint8_t key_length);
|
||||
|
||||
bt_status_t btc_get_bonded_ble_devices_list(esp_ble_bond_dev_t *bond_dev);
|
||||
|
||||
bt_status_t btc_in_fetch_bonded_ble_devices(int add);
|
||||
|
||||
void btc_dm_remove_ble_bonding_keys(void);
|
||||
|
||||
bt_status_t btc_storage_add_ble_bonding_key( bt_bdaddr_t *remote_bd_addr,
|
||||
char *key,
|
||||
uint8_t key_type,
|
||||
uint8_t key_length);
|
||||
|
||||
bool btc_compare_le_key_value(const uint8_t key_type, const size_t key_len, const tBTA_LE_KEY_VALUE *key_vaule,
|
||||
bt_bdaddr_t bd_addr);
|
||||
|
||||
void btc_save_ble_bonding_keys(void);
|
||||
|
||||
bt_status_t btc_in_fetch_bonded_ble_device(const char *remote_bd_addr, int add,
|
||||
btc_bonded_devices_t *p_bonded_devices);
|
||||
|
||||
bt_status_t btc_storage_get_ble_bonding_key(bt_bdaddr_t *remote_bd_addr,
|
||||
uint8_t key_type,
|
||||
char *key_value,
|
||||
int key_length);
|
||||
|
||||
bool btc_storage_compare_address_key_value(bt_bdaddr_t *remote_bd_addr,
|
||||
uint8_t key_type, void *key_value, int key_length);
|
||||
bt_status_t btc_storage_add_ble_local_key(char *key,
|
||||
uint8_t key_type,
|
||||
uint8_t key_length);
|
||||
bt_status_t btc_storage_get_ble_bonding_key(bt_bdaddr_t *remote_bd_addr, uint8_t key_type, char *key_value, int key_length);
|
||||
|
||||
bt_status_t btc_storage_remove_ble_bonding_keys(bt_bdaddr_t *remote_bd_addr);
|
||||
|
||||
bt_status_t btc_storage_clear_bond_devices(void);
|
||||
bool btc_storage_compare_address_key_value(bt_bdaddr_t *remote_bd_addr, uint8_t key_type, void *key_value, int key_length);
|
||||
|
||||
bt_status_t btc_storage_add_ble_local_key(char *key, uint8_t key_type, uint8_t key_length);
|
||||
|
||||
bt_status_t btc_storage_remove_ble_local_keys(void);
|
||||
|
||||
bt_status_t btc_storage_get_ble_local_key(uint8_t key_type,
|
||||
char *key_value,
|
||||
int key_len);
|
||||
bt_status_t btc_storage_get_ble_local_key(uint8_t key_type, char *key_value, int key_len);
|
||||
|
||||
bt_status_t btc_storage_get_remote_addr_type(bt_bdaddr_t *remote_bd_addr,
|
||||
int *addr_type);
|
||||
bt_status_t btc_storage_get_remote_addr_type(bt_bdaddr_t *remote_bd_addr, int *addr_type);
|
||||
|
||||
bt_status_t btc_storage_set_remote_addr_type(bt_bdaddr_t *remote_bd_addr, uint8_t addr_type, bool flush);
|
||||
|
||||
bt_status_t btc_storage_remove_remote_addr_type(bt_bdaddr_t *remote_bd_addr, bool flush);
|
||||
|
||||
bt_status_t btc_storage_set_ble_dev_type(bt_bdaddr_t *bd_addr, bool flush);
|
||||
|
||||
bt_status_t btc_storage_remove_ble_dev_type(bt_bdaddr_t *remote_bd_addr, bool flush);
|
||||
|
||||
bt_status_t btc_storage_load_bonded_ble_devices(void);
|
||||
|
||||
bt_status_t btc_storage_get_bonded_ble_devices_list(esp_ble_bond_dev_t *bond_dev, int dev_num);
|
||||
|
||||
int btc_storage_get_num_ble_bond_devices(void);
|
||||
|
||||
bt_status_t btc_storage_set_remote_addr_type(bt_bdaddr_t *remote_bd_addr,
|
||||
uint8_t addr_type);
|
||||
|
||||
void btc_dm_load_ble_local_keys(void);
|
||||
|
||||
void btc_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET16 er,
|
||||
tBTA_BLE_LOCAL_ID_KEYS *p_id_keys);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#endif ///__BTC_BLE_STORAGE_H__
|
||||
#endif ///__BTC_BLE_STORAGE_H__
|
||||
|
@ -20,8 +20,6 @@
|
||||
|
||||
#include "bt_types.h"
|
||||
|
||||
#define BTC_LE_DEV_TYPE "DevType"
|
||||
|
||||
typedef struct btc_config_section_iter_t btc_config_section_iter_t;
|
||||
|
||||
bool btc_config_init(void);
|
||||
@ -46,7 +44,6 @@ const btc_config_section_iter_t *btc_config_section_end(void);
|
||||
const btc_config_section_iter_t *btc_config_section_next(const btc_config_section_iter_t *section);
|
||||
const char *btc_config_section_name(const btc_config_section_iter_t *section);
|
||||
|
||||
void btc_config_save(void);
|
||||
void btc_config_flush(void);
|
||||
int btc_config_clear(void);
|
||||
|
||||
@ -55,4 +52,7 @@ bool btc_get_address_type(const BD_ADDR bd_addr, int *p_addr_type);
|
||||
bool btc_compare_address_key_value(const char *section, char *key_type, void *key_value, int key_length);
|
||||
bool btc_get_device_type(const BD_ADDR bd_addr, int *p_device_type);
|
||||
|
||||
void btc_config_lock(void);
|
||||
void btc_config_unlock(void);
|
||||
|
||||
#endif
|
||||
|
@ -29,6 +29,45 @@ typedef union {
|
||||
tBTA_DM_SEC sec;
|
||||
} btc_dm_sec_args_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool is_penc_key_rcvd;
|
||||
tBTM_LE_PENC_KEYS penc_key; /* received peer encryption key */
|
||||
bool is_pcsrk_key_rcvd;
|
||||
tBTM_LE_PCSRK_KEYS pcsrk_key; /* received peer device SRK */
|
||||
bool is_pid_key_rcvd;
|
||||
tBTM_LE_PID_KEYS pid_key; /* peer device ID key */
|
||||
bool is_lenc_key_rcvd;
|
||||
tBTM_LE_LENC_KEYS lenc_key; /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
|
||||
bool is_lcsrk_key_rcvd;
|
||||
tBTM_LE_LCSRK_KEYS lcsrk_key; /* local device CSRK = d1(ER,DIV,1)*/
|
||||
bool is_lidk_key_rcvd; /* local identity key received */
|
||||
} btc_dm_ble_cb_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bt_bdaddr_t static_bdaddr;
|
||||
BD_ADDR bd_addr;
|
||||
btc_dm_ble_cb_t ble;
|
||||
} btc_dm_pairing_cb_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t ir[BT_OCTET16_LEN];
|
||||
uint8_t irk[BT_OCTET16_LEN];
|
||||
uint8_t dhk[BT_OCTET16_LEN];
|
||||
} btc_dm_local_key_id_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool is_er_rcvd;
|
||||
uint8_t er[BT_OCTET16_LEN];
|
||||
bool is_id_keys_rcvd;
|
||||
btc_dm_local_key_id_t id_keys; /* ID kyes */
|
||||
} btc_dm_local_key_cb_t;
|
||||
|
||||
|
||||
|
||||
// void btc_dm_call_handler(btc_msg_t *msg);
|
||||
void btc_dm_sec_evt(tBTA_DM_SEC_EVT event, tBTA_DM_SEC *data);
|
||||
void btc_dm_sec_cb_handler(btc_msg_t *msg);
|
||||
@ -37,4 +76,11 @@ void btc_dm_sec_arg_deep_copy(btc_msg_t *msg, void *dst, void *src);
|
||||
bt_status_t btc_dm_enable_service(tBTA_SERVICE_ID service_id);
|
||||
bt_status_t btc_dm_disable_service(tBTA_SERVICE_ID service_id);
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
void btc_dm_load_ble_local_keys(void);
|
||||
|
||||
void btc_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET16 er,
|
||||
tBTA_BLE_LOCAL_ID_KEYS *p_id_keys);
|
||||
#endif
|
||||
|
||||
#endif /* __BTC_DM_H__ */
|
||||
|
@ -31,9 +31,12 @@ typedef enum {
|
||||
BTC_GAP_BLE_ACT_SET_PKT_DATA_LEN,
|
||||
BTC_GAP_BLE_ACT_SET_RAND_ADDRESS,
|
||||
BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY,
|
||||
BTC_GAP_BLE_ACT_UPDATE_WHITE_LIST,
|
||||
BTC_GAP_BLE_ACT_SET_CONN_PARAMS,
|
||||
BTC_GAP_BLE_ACT_SET_DEV_NAME,
|
||||
BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW,
|
||||
BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW,
|
||||
BTC_GAP_BLE_ACT_READ_RSSI,
|
||||
BTC_GAP_BLE_SET_ENCRYPTION_EVT,
|
||||
BTC_GAP_BLE_SET_SECURITY_PARAM_EVT,
|
||||
BTC_GAP_BLE_SECURITY_RSP_EVT,
|
||||
@ -41,8 +44,6 @@ typedef enum {
|
||||
BTC_GAP_BLE_CONFIRM_REPLY_EVT,
|
||||
BTC_GAP_BLE_DISCONNECT_EVT,
|
||||
BTC_GAP_BLE_REMOVE_BOND_DEV_EVT,
|
||||
BTC_GAP_BLE_CLEAR_BOND_DEV_EVT,
|
||||
BTC_GAP_BLE_GET_BOND_DEV_EVT,
|
||||
} btc_gap_ble_act_t;
|
||||
|
||||
/* btc_ble_gap_args_t */
|
||||
@ -81,7 +82,25 @@ typedef union {
|
||||
//BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY,
|
||||
struct cfg_local_privacy_args {
|
||||
bool privacy_enable;
|
||||
} cfg_local_privacy;
|
||||
} cfg_local_privacy;
|
||||
//BTC_GAP_BLE_ACT_UPDATE_WHITE_LIST
|
||||
struct update_white_list_args {
|
||||
bool add_remove;
|
||||
esp_bd_addr_t remote_bda;
|
||||
}update_white_list;
|
||||
//BTC_GAP_BLE_ACT_SET_CONN_PARAMS
|
||||
struct set_conn_params_args {
|
||||
esp_bd_addr_t bd_addr;
|
||||
uint16_t min_conn_int;
|
||||
uint16_t max_conn_int;
|
||||
uint16_t slave_latency;
|
||||
uint16_t supervision_tout;
|
||||
}set_conn_params;
|
||||
//BTC_GAP_BLE_ACT_SET_DEV_NAME,
|
||||
struct set_dev_name_args {
|
||||
#define ESP_GAP_DEVICE_NAME_MAX (32)
|
||||
char device_name[ESP_GAP_DEVICE_NAME_MAX + 1];
|
||||
} set_dev_name;
|
||||
//BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW,
|
||||
struct config_adv_data_raw_args {
|
||||
uint8_t *raw_adv;
|
||||
@ -127,11 +146,15 @@ typedef union {
|
||||
struct remove_bond_device_args {
|
||||
esp_bd_addr_t bd_addr;
|
||||
} remove_bond_device;
|
||||
//BTC_GAP_BLE_ACT_READ_RSSI
|
||||
struct read_rssi_args {
|
||||
esp_bd_addr_t remote_addr;
|
||||
} read_rssi;
|
||||
} btc_ble_gap_args_t;
|
||||
|
||||
void btc_gap_ble_call_handler(btc_msg_t *msg);
|
||||
void btc_gap_ble_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_get_whitelist_size(uint16_t *length);
|
||||
void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
void btc_gap_ble_arg_deep_free(btc_msg_t *msg);
|
||||
void btc_gap_ble_cb_deep_free(btc_msg_t *msg);
|
||||
|
@ -27,13 +27,8 @@ typedef enum {
|
||||
BTC_GATTC_ACT_CLOSE,
|
||||
BTC_GATTC_ACT_CFG_MTU,
|
||||
BTC_GATTC_ACT_SEARCH_SERVICE,
|
||||
BTC_GATTC_ACT_GET_FIRST_CHAR,
|
||||
BTC_GATTC_ACT_GET_NEXT_CHAR,
|
||||
BTC_GATTC_ACT_GET_FIRST_DESCR,
|
||||
BTC_GATTC_ACT_GET_NEXT_DESCR,
|
||||
BTC_GATTC_ACT_GET_FIRST_INCL_SERVICE,
|
||||
BTC_GATTC_ACT_GET_NEXT_INCL_SERVICE,
|
||||
BTC_GATTC_ACT_READ_CHAR,
|
||||
BTC_GATTC_ACT_READ_MULTIPLE_CHAR,
|
||||
BTC_GATTC_ACT_READ_CHAR_DESCR,
|
||||
BTC_GATTC_ACT_WRITE_CHAR,
|
||||
BTC_GATTC_ACT_WRITE_CHAR_DESCR,
|
||||
@ -75,82 +70,67 @@ typedef union {
|
||||
bool filter_uuid_enable;
|
||||
esp_bt_uuid_t filter_uuid;
|
||||
} search_srvc;
|
||||
//BTC_GATTC_ACT_GET_FIRST_CHAR,
|
||||
struct get_first_char_arg {
|
||||
//BTC_GATTC_ACT_GET_CHAR,
|
||||
struct get_char_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
} get_first_char;
|
||||
//BTC_GATTC_ACT_GET_NEXT_CHAR,
|
||||
struct get_next_char_arg {
|
||||
uint16_t handle;
|
||||
} get_char;
|
||||
//BTC_GATTC_ACT_GET_DESCR,
|
||||
struct get_descr_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
} get_next_char;
|
||||
//BTC_GATTC_ACT_GET_FIRST_DESCR,
|
||||
struct get_first_descr_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
} get_first_descr;
|
||||
//BTC_GATTC_ACT_GET_NEXT_DESCR,
|
||||
struct get_next_descr_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
esp_gatt_id_t descr_id;
|
||||
} get_next_descr;
|
||||
uint16_t handle;
|
||||
} get_descr;
|
||||
//BTC_GATTC_ACT_GET_FIRST_INCL_SERVICE,
|
||||
struct get_first_incl_srvc_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
uint16_t handle;
|
||||
} get_first_incl_srvc;
|
||||
//BTC_GATTC_ACT_GET_NEXT_INCL_SERVICE,
|
||||
struct get_next_incl_srvc_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_srvc_id_t start_service_id;
|
||||
uint16_t handle;
|
||||
} get_next_incl_srvc;
|
||||
//BTC_GATTC_ACT_READ_CHAR,
|
||||
struct read_char_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
uint16_t handle;
|
||||
esp_gatt_auth_req_t auth_req;
|
||||
} read_char;
|
||||
//BTC_GATTC_ACT_READ_MULTIPLE_CHAR
|
||||
struct read_multiple_arg {
|
||||
uint16_t conn_id;
|
||||
uint8_t num_attr;
|
||||
uint16_t handles[ESP_GATT_MAX_READ_MULTI_HANDLES];
|
||||
esp_gatt_auth_req_t auth_req;
|
||||
} read_multiple;
|
||||
//BTC_GATTC_ACT_READ_CHAR_DESCR,
|
||||
struct read_descr_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
esp_gatt_id_t descr_id;
|
||||
uint16_t handle;
|
||||
esp_gatt_auth_req_t auth_req;
|
||||
} read_descr;
|
||||
//BTC_GATTC_ACT_WRITE_CHAR,
|
||||
struct write_char_arg {
|
||||
uint16_t conn_id;
|
||||
uint16_t value_len;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
uint16_t handle;
|
||||
uint8_t *value;
|
||||
esp_gatt_write_type_t write_type;
|
||||
esp_gatt_write_type_t write_type;
|
||||
esp_gatt_auth_req_t auth_req;
|
||||
} write_char;
|
||||
//BTC_GATTC_ACT_WRITE_CHAR_DESCR,
|
||||
struct write_descr_arg {
|
||||
uint16_t conn_id;
|
||||
uint16_t value_len;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
esp_gatt_id_t descr_id;
|
||||
uint16_t handle;
|
||||
uint8_t *value;
|
||||
esp_gatt_write_type_t write_type;
|
||||
esp_gatt_write_type_t write_type;
|
||||
esp_gatt_auth_req_t auth_req;
|
||||
} write_descr;
|
||||
//BTC_GATTC_ACT_PREPARE_WRITE,
|
||||
struct prep_write_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
uint16_t handle;
|
||||
uint16_t offset;
|
||||
uint16_t value_len;
|
||||
uint8_t *value;
|
||||
@ -159,9 +139,7 @@ typedef union {
|
||||
//BTC_GATTC_ACT_PREPARE_WRITE_CHAR_DESCR,
|
||||
struct prep_write_descr_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
esp_gatt_id_t descr_id;
|
||||
uint16_t handle;
|
||||
uint16_t offset;
|
||||
uint16_t value_len;
|
||||
uint8_t *value;
|
||||
@ -176,15 +154,13 @@ typedef union {
|
||||
struct reg_for_notify_arg {
|
||||
esp_gatt_if_t gattc_if;
|
||||
esp_bd_addr_t remote_bda;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
uint16_t handle;
|
||||
} reg_for_notify;
|
||||
//BTC_GATTC_ACT_UNREG_FOR_NOTIFY
|
||||
struct unreg_for_notify_arg {
|
||||
esp_gatt_if_t gattc_if;
|
||||
esp_bd_addr_t remote_bda;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
uint16_t handle;
|
||||
} unreg_for_notify;
|
||||
//BTC_GATTC_ACT_CACHE_REFRESH,
|
||||
struct cache_refresh_arg {
|
||||
@ -195,5 +171,56 @@ typedef union {
|
||||
void btc_gattc_call_handler(btc_msg_t *msg);
|
||||
void btc_gattc_cb_handler(btc_msg_t *msg);
|
||||
void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
esp_gatt_status_t btc_ble_gattc_get_service(uint16_t conn_id, esp_bt_uuid_t *svc_uuid,
|
||||
esp_gattc_service_elem_t *result,
|
||||
uint16_t *count, uint16_t offset);
|
||||
esp_gatt_status_t btc_ble_gattc_get_all_char(uint16_t conn_id,
|
||||
uint16_t start_handle,
|
||||
uint16_t end_handle,
|
||||
esp_gattc_char_elem_t *result,
|
||||
uint16_t *count, uint16_t offset);
|
||||
esp_gatt_status_t btc_ble_gattc_get_all_descr(uint16_t conn_id,
|
||||
uint16_t char_handle,
|
||||
esp_gattc_descr_elem_t *result,
|
||||
uint16_t *count, uint16_t offset);
|
||||
esp_gatt_status_t btc_ble_gattc_get_char_by_uuid(uint16_t conn_id,
|
||||
uint16_t start_handle,
|
||||
uint16_t end_handle,
|
||||
esp_bt_uuid_t char_uuid,
|
||||
esp_gattc_char_elem_t *result,
|
||||
uint16_t *count);
|
||||
esp_gatt_status_t btc_ble_gattc_get_descr_by_uuid(uint16_t conn_id,
|
||||
uint16_t start_handle,
|
||||
uint16_t end_handle,
|
||||
esp_bt_uuid_t char_uuid,
|
||||
esp_bt_uuid_t descr_uuid,
|
||||
esp_gattc_descr_elem_t *result,
|
||||
uint16_t *count);
|
||||
|
||||
esp_gatt_status_t btc_ble_gattc_get_descr_by_char_handle(uint16_t conn_id,
|
||||
uint16_t char_handle,
|
||||
esp_bt_uuid_t descr_uuid,
|
||||
esp_gattc_descr_elem_t *result,
|
||||
uint16_t *count);
|
||||
|
||||
esp_gatt_status_t btc_ble_gattc_get_include_service(uint16_t conn_id,
|
||||
uint16_t start_handle,
|
||||
uint16_t end_handle,
|
||||
esp_bt_uuid_t *incl_uuid,
|
||||
esp_gattc_incl_svc_elem_t *result,
|
||||
uint16_t *count);
|
||||
|
||||
esp_gatt_status_t btc_ble_gattc_get_attr_count(uint16_t conn_id,
|
||||
esp_gatt_db_attr_type_t type,
|
||||
uint16_t start_handle,
|
||||
uint16_t end_handle,
|
||||
uint16_t char_handle,
|
||||
uint16_t *count);
|
||||
|
||||
esp_gatt_status_t btc_ble_gattc_get_db(uint16_t conn_id, uint16_t start_handle, uint16_t end_handle,
|
||||
esp_gattc_db_elem_t *db, uint16_t *count);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* __BTC_GATTC_H__ */
|
||||
|
@ -19,6 +19,12 @@
|
||||
#include "bt_defs.h"
|
||||
#include "bt_types.h"
|
||||
|
||||
|
||||
#define BTC_STORAGE_DEV_CLASS_STR "DevClass"
|
||||
#define BTC_STORAGE_LINK_KEY_STR "LinkKey" /* same as the ble */
|
||||
#define BTC_STORAGE_LINK_KEY_TYPE_STR "LinkKeyType"
|
||||
#define BTC_STORAGE_PIN_LENGTH_STR "PinLength"
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_storage_add_bonded_device
|
||||
|
@ -2833,6 +2833,11 @@ tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb);
|
||||
tBTM_STATUS BTM_ReadTxPower (BD_ADDR remote_bda,
|
||||
tBT_TRANSPORT transport, tBTM_CMPL_CB *p_cb);
|
||||
|
||||
tBTM_STATUS BTM_BleReadAdvTxPower(tBTM_CMPL_CB *p_cb);
|
||||
|
||||
void BTM_BleGetWhiteListSize(uint16_t *length);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_ReadLinkQuality
|
||||
|
@ -416,6 +416,15 @@ void btm_sco_chk_pend_rolechange (UINT16 hci_handle);
|
||||
** Define structure for Security Service Record.
|
||||
** A record exists for each service registered with the Security Manager
|
||||
*/
|
||||
#define BTM_SEC_OUT_FLAGS (BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT | BTM_SEC_OUT_AUTHORIZE)
|
||||
#define BTM_SEC_IN_FLAGS (BTM_SEC_IN_AUTHENTICATE | BTM_SEC_IN_ENCRYPT | BTM_SEC_IN_AUTHORIZE)
|
||||
|
||||
#define BTM_SEC_OUT_LEVEL4_FLAGS (BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT | \
|
||||
BTM_SEC_OUT_MITM | BTM_SEC_MODE4_LEVEL4)
|
||||
|
||||
#define BTM_SEC_IN_LEVEL4_FLAGS (BTM_SEC_IN_AUTHENTICATE | BTM_SEC_IN_ENCRYPT | \
|
||||
BTM_SEC_IN_MITM | BTM_SEC_MODE4_LEVEL4)
|
||||
|
||||
typedef struct {
|
||||
UINT32 mx_proto_id; /* Service runs over this multiplexer protocol */
|
||||
UINT32 orig_mx_chan_id; /* Channel on the multiplexer protocol */
|
||||
@ -878,6 +887,15 @@ typedef struct{
|
||||
}tBTM_CallbackFunc;
|
||||
|
||||
extern tBTM_CallbackFunc conn_param_update_cb;
|
||||
/* security action for L2CAP COC channels */
|
||||
#define BTM_SEC_OK 1
|
||||
#define BTM_SEC_ENCRYPT 2 /* encrypt the link with current key */
|
||||
#define BTM_SEC_ENCRYPT_NO_MITM 3 /* unauthenticated encryption or better */
|
||||
#define BTM_SEC_ENCRYPT_MITM 4 /* authenticated encryption */
|
||||
#define BTM_SEC_ENC_PENDING 5 /* wait for link encryption pending */
|
||||
|
||||
typedef UINT8 tBTM_SEC_ACTION;
|
||||
|
||||
/*
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@ -1082,6 +1100,10 @@ BOOLEAN btm_sec_is_a_bonded_dev (BD_ADDR bda);
|
||||
void btm_consolidate_dev(tBTM_SEC_DEV_REC *p_target_rec);
|
||||
BOOLEAN btm_sec_is_le_capable_dev (BD_ADDR bda);
|
||||
BOOLEAN btm_ble_init_pseudo_addr (tBTM_SEC_DEV_REC *p_dev_rec, BD_ADDR new_pseudo_addr);
|
||||
extern BOOLEAN btm_ble_start_sec_check(BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_originator,
|
||||
tBTM_SEC_CALLBACK *p_callback, void *p_ref_data);
|
||||
extern tBTM_SEC_SERV_REC *btm_sec_find_first_serv (CONNECTION_TYPE conn_type, UINT16 psm);
|
||||
|
||||
#endif /* BLE_INCLUDED */
|
||||
|
||||
tINQ_DB_ENT *btm_inq_db_new (BD_ADDR p_bda);
|
||||
|
@ -66,8 +66,13 @@ typedef uint8_t esp_link_key[ESP_BT_OCTET16_LEN]; /* Link Key */
|
||||
/// Default GATT interface id
|
||||
#define ESP_DEFAULT_GATT_IF 0xff
|
||||
|
||||
/// Default BLE connection param, if the value doesn't be overwritten
|
||||
#define ESP_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */
|
||||
#define ESP_BLE_CONN_INT_MIN 0x0006 /*!< relate to BTM_BLE_CONN_INT_MIN in btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_INT_MAX 0x0C80 /*!< relate to BTM_BLE_CONN_INT_MAX in btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_LATENCY_MAX 500 /*!< relate to ESP_BLE_CONN_LATENCY_MAX in btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_SUP_TOUT_MIN 0x000A /*!< relate to BTM_BLE_CONN_SUP_TOUT_MIN in btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_SUP_TOUT_MAX 0x0C80 /*!< relate to ESP_BLE_CONN_SUP_TOUT_MAX in btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */ /* relate to ESP_BLE_CONN_PARAM_UNDEF in btm_ble_api.h */
|
||||
#define ESP_BLE_SCAN_PARAM_UNDEF 0xffffffff /* relate to ESP_BLE_SCAN_PARAM_UNDEF in btm_ble_api.h */
|
||||
|
||||
/// Check the param is valid or not
|
||||
#define ESP_BLE_IS_VALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == ESP_BLE_CONN_PARAM_UNDEF))
|
||||
|
@ -68,7 +68,6 @@ typedef uint8_t esp_ble_auth_req_t; /*!< combination of the above bit
|
||||
#define ESP_IO_CAP_KBDISP 4 /*!< Keyboard display */ /* relate to BTM_IO_CAP_KBDISP in btm_api.h */
|
||||
typedef uint8_t esp_ble_io_cap_t; /*!< combination of the io capability */
|
||||
|
||||
|
||||
/// GAP BLE callback event type
|
||||
typedef enum {
|
||||
ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT = 0, /*!< When advertising data set complete, the event comes */
|
||||
@ -97,6 +96,7 @@ typedef enum {
|
||||
ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT, /*!< When remove the bond device complete, the event comes */
|
||||
ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT, /*!< When clear the bond device clear complete, the event comes */
|
||||
ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT, /*!< When get the bond device list complete, the event comes */
|
||||
ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT, /*!< When read the rssi complete, the event comes */
|
||||
ESP_GAP_BLE_EVT_MAX,
|
||||
} esp_gap_ble_cb_event_t;
|
||||
|
||||
@ -569,7 +569,7 @@ typedef union {
|
||||
*/
|
||||
struct ble_local_privacy_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the set local privacy operation success status */
|
||||
} local_privacy_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT */
|
||||
} local_privacy_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT
|
||||
*/
|
||||
@ -591,6 +591,15 @@ typedef union {
|
||||
uint8_t dev_num; /*!< Indicate the get number device in the bond list */
|
||||
esp_ble_bond_dev_t *bond_dev; /*!< the pointer to the bond device Structure */
|
||||
}get_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_read_rssi_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the read adv tx power operation success status */
|
||||
int8_t rssi; /*!< The ble remote device rssi value, the range is from -127 to 20, the unit is dbm,
|
||||
if the RSSI cannot be read, the RSSI metric shall be set to 127. */
|
||||
esp_bd_addr_t remote_addr; /*!< The remote device address */
|
||||
} read_rssi_cmpl; /*!< Event parameter of ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT */
|
||||
} esp_ble_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
@ -742,6 +751,48 @@ esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr);
|
||||
*/
|
||||
esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable);
|
||||
|
||||
/**
|
||||
* @brief Add or remove device from white list
|
||||
*
|
||||
* @param[in] add_remove: the value is true if added the ble device to the white list, and false remove to the white list.
|
||||
* @param[in] remote_bda: the remote device address add/remove from the white list.
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_update_whitelist(bool add_remove, esp_bd_addr_t remote_bda);
|
||||
|
||||
/**
|
||||
* @brief Get the whitelist size in the controller
|
||||
*
|
||||
* @param[out] length: the white list length.
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_get_whitelist_size(uint16_t *length);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set the preferred connection
|
||||
* parameters when default connection parameter is not desired before connecting.
|
||||
* This API can only be used in the master role.
|
||||
*
|
||||
* @param[in] bd_addr: BD address of the peripheral
|
||||
* @param[in] min_conn_int: minimum preferred connection interval
|
||||
* @param[in] max_conn_int: maximum preferred connection interval
|
||||
* @param[in] slave_latency: preferred slave latency
|
||||
* @param[in] supervision_tout: preferred supervision timeout
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_set_prefer_conn_params(esp_bd_addr_t bd_addr,
|
||||
uint16_t min_conn_int, uint16_t max_conn_int,
|
||||
uint16_t slave_latency, uint16_t supervision_tout);
|
||||
|
||||
/**
|
||||
* @brief Set device name to the local device
|
||||
@ -796,7 +847,20 @@ esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_l
|
||||
*/
|
||||
esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_data_len);
|
||||
|
||||
/**
|
||||
* @brief This function is called to read the RSSI of remote device.
|
||||
* The address of link policy results are returned in the gap callback function with
|
||||
* ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT event.
|
||||
*
|
||||
* @param[in] remote_addr : The remote connection device address.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr);
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
/**
|
||||
* @brief Set a GAP security parameter value. Overrides the default value.
|
||||
*
|
||||
@ -879,24 +943,32 @@ esp_err_t esp_ble_confirm_reply(esp_bd_addr_t bd_addr, bool accept);
|
||||
esp_err_t esp_ble_remove_bond_device(esp_bd_addr_t bd_addr);
|
||||
|
||||
/**
|
||||
* @brief Removes all of the device from the security database list of
|
||||
* peer device. It manages unpairing event while connected.
|
||||
* @brief Get the device number from the security database list of peer device.
|
||||
* It will return the device bonded number immediately.
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
* @return - >= 0 : bonded devices number.
|
||||
* - < 0 : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_clear_bond_device_list(void);
|
||||
int esp_ble_get_bond_device_num(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the device from the security database list of peer device.
|
||||
* It will return the device bonded information from the ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT event.
|
||||
* It will return the device bonded information immediately.
|
||||
* @param[inout] dev_num: Indicate the dev_list array(buffer) size as input.
|
||||
* If dev_num is large enough, it means the actual number as output.
|
||||
* Suggest that dev_num value equal to esp_ble_get_bond_device_num().
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
* @param[out] dev_list: an array(buffer) of `esp_ble_bond_dev_t` type. Use for storing the bonded devices address.
|
||||
* The dev_list should be allocated by who call this API.
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_get_bond_device_list(void);
|
||||
esp_err_t esp_ble_get_bond_device_list(int *dev_num, esp_ble_bond_dev_t *dev_list);
|
||||
|
||||
#endif /* #if (SMP_INCLUDED == TRUE) */
|
||||
|
||||
/**
|
||||
* @brief This function is to disconnect the physical connection of the peer device
|
||||
|
@ -27,6 +27,7 @@ extern "C" {
|
||||
#define ESP_GATT_ILLEGAL_HANDLE 0
|
||||
/// GATT attribute max handle
|
||||
#define ESP_GATT_ATTR_HANDLE_MAX 100
|
||||
#define ESP_GATT_MAX_READ_MULTI_HANDLES 10 /* Max attributes to read in one request */
|
||||
|
||||
|
||||
/**@{
|
||||
@ -294,12 +295,12 @@ typedef uint8_t esp_gatt_char_prop_t;
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t uuid_length; /*!< UUID length */
|
||||
uint8_t *uuid_p; /*!< UUID value */
|
||||
uint16_t perm; /*!< Attribute permission */
|
||||
uint16_t max_length; /*!< Maximum length of the element*/
|
||||
uint16_t length; /*!< Current length of the element*/
|
||||
uint8_t *value; /*!< Element value array*/
|
||||
uint16_t uuid_length; /*!< UUID length */
|
||||
uint8_t *uuid_p; /*!< UUID value */
|
||||
uint16_t perm; /*!< Attribute permission */
|
||||
uint16_t max_length; /*!< Maximum length of the element*/
|
||||
uint16_t length; /*!< Current length of the element*/
|
||||
uint8_t *value; /*!< Element value array*/
|
||||
} esp_attr_desc_t;
|
||||
|
||||
|
||||
@ -313,8 +314,8 @@ typedef struct
|
||||
/**
|
||||
* @brief if auto_rsp set to ESP_GATT_RSP_BY_APP, means the response of Write/Read operation will by replied by application.
|
||||
if auto_rsp set to ESP_GATT_AUTO_RSP, means the response of Write/Read operation will be replied by GATT stack automatically.
|
||||
*/
|
||||
uint8_t auto_rsp;
|
||||
*/
|
||||
uint8_t auto_rsp;
|
||||
} esp_attr_control_t;
|
||||
|
||||
|
||||
@ -323,8 +324,8 @@ typedef struct
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
esp_attr_control_t attr_control; /*!< The attribute control type*/
|
||||
esp_attr_desc_t att_desc; /*!< The attribute type*/
|
||||
esp_attr_control_t attr_control; /*!< The attribute control type */
|
||||
esp_attr_desc_t att_desc; /*!< The attribute type */
|
||||
} esp_gatts_attr_db_t;
|
||||
|
||||
|
||||
@ -333,9 +334,9 @@ typedef struct
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t attr_max_len; /*!< attribute max value length */
|
||||
uint16_t attr_len; /*!< attribute current value length */
|
||||
uint8_t *attr_value; /*!< the pointer to attribute value */
|
||||
uint16_t attr_max_len; /*!< attribute max value length */
|
||||
uint16_t attr_len; /*!< attribute current value length */
|
||||
uint8_t *attr_value; /*!< the pointer to attribute value */
|
||||
} esp_attr_value_t;
|
||||
|
||||
|
||||
@ -344,22 +345,19 @@ typedef struct
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t start_hdl; /*!< Gatt start handle value of included service */
|
||||
uint16_t end_hdl; /*!< Gatt end handle value of included service */
|
||||
uint16_t uuid; /*!< Gatt attribute value UUID of included service */
|
||||
} esp_gatts_incl_svc_desc_t; /*!< Gatt include service entry element */
|
||||
uint16_t start_hdl; /*!< Gatt start handle value of included service */
|
||||
uint16_t end_hdl; /*!< Gatt end handle value of included service */
|
||||
uint16_t uuid; /*!< Gatt attribute value UUID of included service */
|
||||
} esp_gatts_incl_svc_desc_t; /*!< Gatt include service entry element */
|
||||
|
||||
/**
|
||||
* @brief Gatt include 128 bit service entry element
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t start_hdl; /*!< Gatt start handle value of included 128 bit service */
|
||||
uint16_t end_hdl; /*!< Gatt end handle value of included 128 bit service */
|
||||
} esp_gatts_incl128_svc_desc_t; /*!< Gatt include 128 bit service entry element */
|
||||
|
||||
|
||||
|
||||
uint16_t start_hdl; /*!< Gatt start handle value of included 128 bit service */
|
||||
uint16_t end_hdl; /*!< Gatt end handle value of included 128 bit service */
|
||||
} esp_gatts_incl128_svc_desc_t; /*!< Gatt include 128 bit service entry element */
|
||||
|
||||
/// Gatt attribute value
|
||||
typedef struct {
|
||||
@ -388,6 +386,75 @@ typedef enum {
|
||||
|
||||
typedef uint8_t esp_gatt_if_t; /*!< Gatt interface type, different application on GATT client use different gatt_if */
|
||||
|
||||
/**
|
||||
* @brief the type of attribute element
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_DB_PRIMARY_SERVICE, /*!< Gattc primary service attribute type in the cache */
|
||||
ESP_GATT_DB_SECONDARY_SERVICE, /*!< Gattc secondary service attribute type in the cache */
|
||||
ESP_GATT_DB_CHARACTERISTIC, /*!< Gattc characteristic attribute type in the cache */
|
||||
ESP_GATT_DB_DESCRIPTOR, /*!< Gattc characteristic descriptor attribute type in the cache */
|
||||
ESP_GATT_DB_INCLUDED_SERVICE, /*!< Gattc include service attribute type in the cache */
|
||||
ESP_GATT_DB_ALL, /*!< Gattc all the attribute (primary service & secondary service & include service & char & descriptor) type in the cache */
|
||||
} esp_gatt_db_attr_type_t; /*!< Gattc attribute type element */
|
||||
|
||||
/**
|
||||
* @brief read multiple attribute
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t num_attr; /*!< The number of the attribute */
|
||||
uint16_t handles[ESP_GATT_MAX_READ_MULTI_HANDLES]; /*!< The handles list */
|
||||
} esp_gattc_multi_t; /*!< The gattc multiple read element */
|
||||
|
||||
/**
|
||||
* @brief data base attribute element
|
||||
*/
|
||||
typedef struct {
|
||||
esp_gatt_db_attr_type_t type; /*!< The attribute type */
|
||||
uint16_t attribute_handle; /*!< The attribute handle, it's valid for all of the type */
|
||||
uint16_t start_handle; /*!< The service start handle, it's valid only when the type = ESP_GATT_DB_PRIMARY_SERVICE or ESP_GATT_DB_SECONDARY_SERVICE */
|
||||
uint16_t end_handle; /*!< The service end handle, it's valid only when the type = ESP_GATT_DB_PRIMARY_SERVICE or ESP_GATT_DB_SECONDARY_SERVICE */
|
||||
esp_gatt_char_prop_t properties; /*!< The characteristic properties, it's valid only when the type = ESP_GATT_DB_CHARACTERISTIC */
|
||||
esp_bt_uuid_t uuid; /*!< The attribute uuid, it's valid for all of the type */
|
||||
} esp_gattc_db_elem_t; /*!< The gattc service data base element in the cache */
|
||||
|
||||
/**
|
||||
* @brief service element
|
||||
*/
|
||||
typedef struct {
|
||||
bool is_primary; /*!< The service flag, ture if the service is primary service, else is secondly service */
|
||||
uint16_t start_handle; /*!< The start handle of the service */
|
||||
uint16_t end_handle; /*!< The end handle of the service */
|
||||
esp_bt_uuid_t uuid; /*!< The uuid of the service */
|
||||
} esp_gattc_service_elem_t; /*!< The gattc service element */
|
||||
|
||||
/**
|
||||
* @brief characteristic element
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t char_handle; /*!< The characteristic handle */
|
||||
esp_gatt_char_prop_t properties; /*!< The characteristic properties */
|
||||
esp_bt_uuid_t uuid; /*!< The characteristic uuid */
|
||||
} esp_gattc_char_elem_t; /*!< The gattc characteristic element */
|
||||
|
||||
/**
|
||||
* @brief descriptor element
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t handle; /*!< The characteristic descriptor handle */
|
||||
esp_bt_uuid_t uuid; /*!< The characteristic descriptor uuid */
|
||||
} esp_gattc_descr_elem_t; /*!< The gattc descriptor type element */
|
||||
|
||||
/**
|
||||
* @brief include service element
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t handle; /*!< The include service current attribute handle */
|
||||
uint16_t incl_srvc_s_handle; /*!< The start hanlde of the service which has been included */
|
||||
esp_bt_uuid_t uuid; /*!< The include service uuid */
|
||||
} esp_gattc_incl_svc_elem_t; /*!< The gattc inclue service element */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -59,9 +59,6 @@ typedef enum {
|
||||
ESP_GATTC_SCAN_FLT_PARAM_EVT = 32, /*!< When Scan filter parameters are set, the event comes */
|
||||
ESP_GATTC_SCAN_FLT_STATUS_EVT = 33, /*!< When Scan filter status is reported, the event comes */
|
||||
ESP_GATTC_ADV_VSC_EVT = 34, /*!< When advertising vendor spec content event is reported, the event comes */
|
||||
ESP_GATTC_GET_CHAR_EVT = 35, /*!< When characteristic is got from GATT server, the event comes */
|
||||
ESP_GATTC_GET_DESCR_EVT = 36, /*!< When characteristic descriptor is got from GATT server, the event comes */
|
||||
ESP_GATTC_GET_INCL_SRVC_EVT = 37, /*!< When included service is got from GATT server, the event comes */
|
||||
ESP_GATTC_REG_FOR_NOTIFY_EVT = 38, /*!< When register for notification of a service completes, the event comes */
|
||||
ESP_GATTC_UNREG_FOR_NOTIFY_EVT = 39, /*!< When unregister for notification of a service completes, the event comes */
|
||||
ESP_GATTC_CONNECT_EVT = 40, /*!< When the ble physical connection is set up, the event comes */
|
||||
@ -74,57 +71,59 @@ typedef enum {
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* @brief ESP_GATTC_REG_EVT
|
||||
*/
|
||||
struct gattc_reg_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t app_id; /*!< Application id which input in register API */
|
||||
} reg; /*!< Gatt client callback param of ESP_GATTC_REG_EVT */
|
||||
* @brief ESP_GATTC_REG_EVT
|
||||
*/
|
||||
struct gattc_reg_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t app_id; /*!< Application id which input in register API */
|
||||
} reg; /*!< Gatt client callback param of ESP_GATTC_REG_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_OPEN_EVT
|
||||
*/
|
||||
struct gattc_open_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
uint16_t mtu; /*!< MTU size */
|
||||
} open; /*!< Gatt client callback param of ESP_GATTC_OPEN_EVT */
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
uint16_t mtu; /*!< MTU size */
|
||||
} open; /*!< Gatt client callback param of ESP_GATTC_OPEN_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_CLOSE_EVT
|
||||
*/
|
||||
struct gattc_close_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
esp_gatt_conn_reason_t reason; /*!< The reason of gatt connection close */
|
||||
} close; /*!< Gatt client callback param of ESP_GATTC_CLOSE_EVT */
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
esp_gatt_conn_reason_t reason; /*!< The reason of gatt connection close */
|
||||
} close; /*!< Gatt client callback param of ESP_GATTC_CLOSE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_CFG_MTU_EVT
|
||||
*/
|
||||
struct gattc_cfg_mtu_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
uint16_t mtu; /*!< MTU size */
|
||||
} cfg_mtu; /*!< Gatt client callback param of ESP_GATTC_CFG_MTU_EVT */
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
uint16_t mtu; /*!< MTU size */
|
||||
} cfg_mtu; /*!< Gatt client callback param of ESP_GATTC_CFG_MTU_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_SEARCH_CMPL_EVT
|
||||
*/
|
||||
struct gattc_search_cmpl_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
} search_cmpl; /*!< Gatt client callback param of ESP_GATTC_SEARCH_CMPL_EVT */
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
} search_cmpl; /*!< Gatt client callback param of ESP_GATTC_SEARCH_CMPL_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_SEARCH_RES_EVT
|
||||
*/
|
||||
struct gattc_search_res_evt_param {
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
} search_res; /*!< Gatt client callback param of ESP_GATTC_SEARCH_RES_EVT */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
uint16_t start_handle; /*!< Service start handle */
|
||||
uint16_t end_handle; /*!< Service end handle */
|
||||
esp_gatt_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
} search_res; /*!< Gatt client callback param of ESP_GATTC_SEARCH_RES_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_READ_CHAR_EVT, ESP_GATTC_READ_DESCR_EVT
|
||||
@ -133,17 +132,8 @@ typedef union {
|
||||
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
esp_gatt_id_t descr_id; /*!< Descriptor id, include descriptor uuid and other information */
|
||||
uint16_t handle; /*!< Characteristic handle */
|
||||
uint8_t *value; /*!< Characteristic value */
|
||||
uint16_t value_type; /*!< Characteristic value type, there is two value for this type:
|
||||
ESP_GATTC_READ_VALUE_TYPE_VALUE(0x0000) and
|
||||
ESP_GATTC_READ_VALUE_TYPE_AGG_FORMAT(0x2905).
|
||||
If the value is ESP_GATTC_READ_VALUE_TYPE_VALUE means it is a generally
|
||||
value type, and if is the type of ESP_GATTC_READ_VALUE_TYPE_AGG_FORMAT,
|
||||
the unit of the value will indicate in the Characteristic
|
||||
aggregate format descriptor */
|
||||
uint16_t value_len; /*!< Characteristic value length */
|
||||
} read; /*!< Gatt client callback param of ESP_GATTC_READ_CHAR_EVT */
|
||||
|
||||
@ -151,99 +141,60 @@ typedef union {
|
||||
* @brief ESP_GATTC_WRITE_CHAR_EVT, ESP_GATTC_PREP_WRITE_EVT, ESP_GATTC_WRITE_DESCR_EVT
|
||||
*/
|
||||
struct gattc_write_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
esp_gatt_id_t descr_id; /*!< Descriptor id, include descriptor uuid and other information */
|
||||
} write; /*!< Gatt client callback param of ESP_GATTC_WRITE_DESCR_EVT */
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
uint16_t handle; /*!< The Characteristic or descriptor handle */
|
||||
} write; /*!< Gatt client callback param of ESP_GATTC_WRITE_DESCR_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_EXEC_EVT
|
||||
*/
|
||||
struct gattc_exec_cmpl_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
} exec_cmpl; /*!< Gatt client callback param of ESP_GATTC_EXEC_EVT */
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
} exec_cmpl; /*!< Gatt client callback param of ESP_GATTC_EXEC_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_NOTIFY_EVT
|
||||
*/
|
||||
struct gattc_notify_evt_param {
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
esp_gatt_id_t descr_id; /*!< Descriptor id, include descriptor uuid and other information */
|
||||
uint16_t value_len; /*!< Notify attribute value */
|
||||
uint8_t *value; /*!< Notify attribute value */
|
||||
bool is_notify; /*!< True means notify, false means indicate */
|
||||
} notify; /*!< Gatt client callback param of ESP_GATTC_NOTIFY_EVT */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
uint16_t handle; /*!< The Characteristic or descriptor handle */
|
||||
uint16_t value_len; /*!< Notify attribute value */
|
||||
uint8_t *value; /*!< Notify attribute value */
|
||||
bool is_notify; /*!< True means notify, false means indicate */
|
||||
} notify; /*!< Gatt client callback param of ESP_GATTC_NOTIFY_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_SRVC_CHG_EVT
|
||||
*/
|
||||
struct gattc_srvc_chg_evt_param {
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
} srvc_chg; /*!< Gatt client callback param of ESP_GATTC_SRVC_CHG_EVT */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
} srvc_chg; /*!< Gatt client callback param of ESP_GATTC_SRVC_CHG_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_CONGEST_EVT
|
||||
*/
|
||||
struct gattc_congest_evt_param {
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
bool congested; /*!< Congested or not */
|
||||
} congest; /*!< Gatt client callback param of ESP_GATTC_CONGEST_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_GET_CHAR_EVT
|
||||
*/
|
||||
struct gattc_get_char_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
esp_gatt_char_prop_t char_prop; /*!< Characteristic property */
|
||||
} get_char; /*!< Gatt client callback param of ESP_GATTC_GET_CHAR_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_GET_DESCR_EVT
|
||||
*/
|
||||
struct gattc_get_descr_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
esp_gatt_id_t descr_id; /*!< Descriptor id, include descriptor uuid and other information */
|
||||
} get_descr; /*!< Gatt client callback param of ESP_GATTC_GET_DESCR_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_GET_INCL_SRVC_EVT
|
||||
*/
|
||||
struct gattc_get_incl_srvc_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_srvc_id_t incl_srvc_id;/*!< Included service id, include service uuid and other information */
|
||||
} get_incl_srvc; /*!< Gatt client callback param of ESP_GATTC_GET_INCL_SRVC_EVT */
|
||||
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
bool congested; /*!< Congested or not */
|
||||
} congest; /*!< Gatt client callback param of ESP_GATTC_CONGEST_EVT */
|
||||
/**
|
||||
* @brief ESP_GATTC_REG_FOR_NOTIFY_EVT
|
||||
*/
|
||||
struct gattc_reg_for_notify_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
} reg_for_notify; /*!< Gatt client callback param of ESP_GATTC_REG_FOR_NOTIFY_EVT */
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t handle; /*!< The characteristic or descriptor handle */
|
||||
} reg_for_notify; /*!< Gatt client callback param of ESP_GATTC_REG_FOR_NOTIFY_EVT */
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief ESP_GATTC_UNREG_FOR_NOTIFY_EVT
|
||||
*/
|
||||
struct gattc_unreg_for_notify_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
} unreg_for_notify; /*!< Gatt client callback param of ESP_GATTC_UNREG_FOR_NOTIFY_EVT */
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t handle; /*!< The characteristic or descriptor handle */
|
||||
} unreg_for_notify; /*!< Gatt client callback param of ESP_GATTC_UNREG_FOR_NOTIFY_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_CONNECT_EVT
|
||||
@ -263,7 +214,7 @@ typedef union {
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
} disconnect; /*!< Gatt client callback param of ESP_GATTC_DISCONNECT_EVT */
|
||||
|
||||
} esp_ble_gattc_cb_param_t; /*!< GATT client callback parameter union type */
|
||||
} esp_ble_gattc_cb_param_t; /*!< GATT client callback parameter union type */
|
||||
|
||||
/**
|
||||
* @brief GATT Client callback function type
|
||||
@ -383,76 +334,233 @@ esp_err_t esp_ble_gattc_send_mtu_req (esp_gatt_if_t gattc_if, uint16_t conn_id);
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_search_service(esp_gatt_if_t gattc_if, uint16_t conn_id, esp_bt_uuid_t *filter_uuid);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to find the first characteristic of the
|
||||
* service on the given server.
|
||||
* @brief Find all the service with the given service uuid in the gattc cache, if the svc_uuid is NULL, find all the service.
|
||||
* Note: It just get service from local cache, won't get from remote devices. If want to get it from remote device, need
|
||||
* to used the esp_ble_gattc_search_service.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id: connection ID which identify the server.
|
||||
* @param[in] srvc_id: service ID
|
||||
* @param[in] start_char_id: the start characteristic ID
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_get_characteristic(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *start_char_id);
|
||||
|
||||
/**
|
||||
* @brief This function is called to find the descriptor of the
|
||||
* service on the given server.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @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 start descriptor id
|
||||
* @param[in] svc_uuid: the pointer to the service uuid.
|
||||
* @param[out] result: The pointer to the service whith has been found in the gattc cache.
|
||||
* @param[inout] count: input the number of service want to find,
|
||||
* it will output the number of service has been found in the gattc cache with the given service uuid.
|
||||
* @param[in] offset: Offset of the service position to get.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_get_descriptor(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *start_descr_id);
|
||||
|
||||
esp_gatt_status_t esp_ble_gattc_get_service(esp_gatt_if_t gattc_if, uint16_t conn_id, esp_bt_uuid_t *svc_uuid,
|
||||
esp_gattc_service_elem_t *result, uint16_t *count, uint16_t offset);
|
||||
|
||||
/**
|
||||
* @brief This function is called to find the first characteristic of the
|
||||
* service on the given server.
|
||||
* @brief Find all the characteristic with the given service in the gattc cache
|
||||
* Note: It just get characteristic from local cache, won't get from remote devices.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @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
|
||||
* @param[in] start_handle: the attribute start handle.
|
||||
* @param[in] end_handle: the attribute end handle
|
||||
* @param[out] result: The pointer to the charateristic in the service.
|
||||
* @param[inout] count: input the number of characteristic want to find,
|
||||
* it will output the number of characteristic has been found in the gattc cache with the given service.
|
||||
* @param[in] offset: Offset of the characteristic position to get.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_get_included_service(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_srvc_id_t *start_incl_srvc_id);
|
||||
esp_gatt_status_t esp_ble_gattc_get_all_char(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
uint16_t start_handle,
|
||||
uint16_t end_handle,
|
||||
esp_gattc_char_elem_t *result,
|
||||
uint16_t *count, uint16_t offset);
|
||||
|
||||
/**
|
||||
* @brief Find all the descriptor with the given characteristic in the gattc cache
|
||||
* Note: It just get descriptor from local cache, won't get from remote devices.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id: connection ID which identify the server.
|
||||
* @param[in] char_handle: the given characteristic handle
|
||||
* @param[out] result: The pointer to the descriptor in the characteristic.
|
||||
* @param[inout] count: input the number of descriptor want to find,
|
||||
* it will output the number of descriptor has been found in the gattc cache with the given characteristic.
|
||||
* @param[in] offset: Offset of the descriptor position to get.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_gatt_status_t esp_ble_gattc_get_all_descr(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
uint16_t char_handle,
|
||||
esp_gattc_descr_elem_t *result,
|
||||
uint16_t *count, uint16_t offset);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Find the characteristic with the given characteristic uuid in the gattc cache
|
||||
* Note: It just get characteristic from local cache, won't get from remote devices.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id: connection ID which identify the server.
|
||||
* @param[in] start_handle: the attribute start handle
|
||||
* @param[in] end_handle: the attribute end handle
|
||||
* @param[in] char_uuid: the characteristic uuid
|
||||
* @param[out] result: The pointer to the characteristic in the service.
|
||||
* @param[inout] count: input the number of characteristic want to find,
|
||||
* it will output the number of characteristic has been found in the gattc cache with the given service.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_gatt_status_t esp_ble_gattc_get_char_by_uuid(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
uint16_t start_handle,
|
||||
uint16_t end_handle,
|
||||
esp_bt_uuid_t char_uuid,
|
||||
esp_gattc_char_elem_t *result,
|
||||
uint16_t *count);
|
||||
|
||||
/**
|
||||
* @brief Find the descriptor with the given characteristic uuid in the gattc cache
|
||||
* Note: It just get descriptor from local cache, won't get from remote devices.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id: connection ID which identify the server.
|
||||
* @param[in] start_handle: the attribute start handle
|
||||
* @param[in] end_handle: the attribute end handle
|
||||
* @param[in] char_uuid: the characteristic uuid.
|
||||
* @param[in] descr_uuid: the descriptor uuid.
|
||||
* @param[out] result: The pointer to the descriptor in the given characteristic.
|
||||
* @param[inout] count: input the number of descriptor want to find,
|
||||
* it will output the number of descriptor has been found in the gattc cache with the given characteristic.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_gatt_status_t esp_ble_gattc_get_descr_by_uuid(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
uint16_t start_handle,
|
||||
uint16_t end_handle,
|
||||
esp_bt_uuid_t char_uuid,
|
||||
esp_bt_uuid_t descr_uuid,
|
||||
esp_gattc_descr_elem_t *result,
|
||||
uint16_t *count);
|
||||
|
||||
/**
|
||||
* @brief Find the descriptor with the given characteristic handle in the gattc cache
|
||||
* Note: It just get descriptor from local cache, won't get from remote devices.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id: connection ID which identify the server.
|
||||
* @param[in] char_handle: the characteristic handle.
|
||||
* @param[in] descr_uuid: the descriptor uuid.
|
||||
* @param[out] result: The pointer to the descriptor in the given characteristic.
|
||||
* @param[inout] count: input the number of descriptor want to find,
|
||||
* it will output the number of descriptor has been found in the gattc cache with the given characteristic.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_gatt_status_t esp_ble_gattc_get_descr_by_char_handle(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
uint16_t char_handle,
|
||||
esp_bt_uuid_t descr_uuid,
|
||||
esp_gattc_descr_elem_t *result,
|
||||
uint16_t *count);
|
||||
|
||||
/**
|
||||
* @brief Find the include service with the given service handle in the gattc cache
|
||||
* Note: It just get include service from local cache, won't get from remote devices.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id: connection ID which identify the server.
|
||||
* @param[in] start_handle: the attribute start handle
|
||||
* @param[in] end_handle: the attribute end handle
|
||||
* @param[in] incl_uuid: the include service uuid
|
||||
* @param[out] result: The pointer to the include service in the given service.
|
||||
* @param[inout] count: input the number of include service want to find,
|
||||
* it will output the number of include service has been found in the gattc cache with the given service.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_gatt_status_t esp_ble_gattc_get_include_service(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
uint16_t start_handle,
|
||||
uint16_t end_handle,
|
||||
esp_bt_uuid_t *incl_uuid,
|
||||
esp_gattc_incl_svc_elem_t *result,
|
||||
uint16_t *count);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Find the attribute count with the given service or characteristic in the gattc cache
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id: connection ID which identify the server.
|
||||
* @param[in] type: the attribute type.
|
||||
* @param[in] start_handle: the attribute start handle, if the type is ESP_GATT_DB_DESCRIPTOR, this parameter should be ignore
|
||||
* @param[in] end_handle: the attribute end handle, if the type is ESP_GATT_DB_DESCRIPTOR, this parameter should be ignore
|
||||
* @param[in] char_handle: the characteristic handle, this parameter valid when the type is ESP_GATT_DB_DESCRIPTOR. If the type
|
||||
* isn't ESP_GATT_DB_DESCRIPTOR, this parameter should be ignore.
|
||||
* @param[out] count: output the number of attribute has been found in the gattc cache with the given attribute type.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_gatt_status_t esp_ble_gattc_get_attr_count(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_db_attr_type_t type,
|
||||
uint16_t start_handle,
|
||||
uint16_t end_handle,
|
||||
uint16_t char_handle,
|
||||
uint16_t *count);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the GATT database.
|
||||
* Note: It just get attribute data base from local cache, won't get from remote devices.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] start_handle: the attribute start handle
|
||||
* @param[in] end_handle: the attribute end handle
|
||||
* @param[in] conn_id: connection ID which identify the server.
|
||||
* @param[in] db: output parameter which will contain the GATT database copy.
|
||||
* Caller is responsible for freeing it.
|
||||
* @param[in] count: number of elements in database.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_gatt_status_t esp_ble_gattc_get_db(esp_gatt_if_t gattc_if, uint16_t conn_id, uint16_t start_handle, uint16_t end_handle,
|
||||
esp_gattc_db_elem_t *db, uint16_t *count);
|
||||
|
||||
/**
|
||||
* @brief This function is called to read a service's characteristics of
|
||||
* the given characteristic ID
|
||||
* the given characteristic handle
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id : connection ID.
|
||||
* @param[in] srvc_id : service ID.
|
||||
* @param[in] char_id : characteristic ID to read.
|
||||
* @param[in] handle : characteritic handle to read.
|
||||
* @param[in] auth_req : authenticate request type
|
||||
*
|
||||
* @return
|
||||
@ -460,11 +568,28 @@ esp_err_t esp_ble_gattc_get_included_service(esp_gatt_if_t gattc_if,
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_read_char (esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
esp_err_t esp_ble_gattc_read_char (esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
uint16_t handle,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
/**
|
||||
* @brief This function is called to read multiple characteristic or
|
||||
* characteristic descriptors.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id : connection ID.
|
||||
* @param[in] read_multi : pointer to the read multiple parameter.
|
||||
* @param[in] auth_req : authenticate request type
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_read_multiple(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id, esp_gattc_multi_t *read_multi,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
/**
|
||||
@ -472,9 +597,7 @@ esp_err_t esp_ble_gattc_read_char (esp_gatt_if_t gattc_if,
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id : connection ID.
|
||||
* @param[in] srvc_id : service ID.
|
||||
* @param[in] char_id : characteristic ID to read.
|
||||
* @param[in] descr_id : characteristic descriptor ID to read.
|
||||
* @param[in] handle : descriptor handle to read.
|
||||
* @param[in] auth_req : authenticate request type
|
||||
*
|
||||
* @return
|
||||
@ -483,11 +606,9 @@ esp_err_t esp_ble_gattc_read_char (esp_gatt_if_t gattc_if,
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_read_char_descr (esp_gatt_if_t gattc_if,
|
||||
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);
|
||||
uint16_t conn_id,
|
||||
uint16_t handle,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
/**
|
||||
@ -495,8 +616,7 @@ esp_err_t esp_ble_gattc_read_char_descr (esp_gatt_if_t gattc_if,
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id : connection ID.
|
||||
* @param[in] srvc_id : service ID.
|
||||
* @param[in] char_id : characteristic ID to write.
|
||||
* @param[in] handle : characteristic handle to write.
|
||||
* @param[in] value_len: length of the value to be written.
|
||||
* @param[in] value : the value to be written.
|
||||
* @param[in] write_type : the type of attribute write operation.
|
||||
@ -509,11 +629,10 @@ esp_err_t esp_ble_gattc_read_char_descr (esp_gatt_if_t gattc_if,
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_write_char( esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
uint16_t handle,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_write_type_t write_type,
|
||||
esp_gatt_write_type_t write_type,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
@ -522,9 +641,7 @@ esp_err_t esp_ble_gattc_write_char( esp_gatt_if_t gattc_if,
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id : connection ID
|
||||
* @param[in] srvc_id : service ID.
|
||||
* @param[in] char_id : characteristic ID.
|
||||
* @param[in] descr_id : characteristic descriptor ID to write.
|
||||
* @param[in] handle : descriptor hadle to write.
|
||||
* @param[in] value_len: length of the value to be written.
|
||||
* @param[in] value : the value to be written.
|
||||
* @param[in] write_type : the type of attribute write operation.
|
||||
@ -537,9 +654,7 @@ esp_err_t esp_ble_gattc_write_char( esp_gatt_if_t gattc_if,
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
|
||||
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 handle,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_write_type_t write_type,
|
||||
@ -551,8 +666,7 @@ esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id : connection ID.
|
||||
* @param[in] srvc_id : service ID.
|
||||
* @param[in] char_id : GATT characteristic ID of the service.
|
||||
* @param[in] handle : charateristic handle to prepare write.
|
||||
* @param[in] offset : offset of the write value.
|
||||
* @param[in] value_len: length of the value to be written.
|
||||
* @param[in] value : the value to be written.
|
||||
@ -563,10 +677,9 @@ esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_prepare_write(esp_gatt_if_t gattc_if,
|
||||
esp_err_t esp_ble_gattc_prepare_write(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
uint16_t handle,
|
||||
uint16_t offset,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
@ -578,9 +691,7 @@ esp_err_t esp_ble_gattc_prepare_write(esp_gatt_if_t gattc_if,
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id : connection ID.
|
||||
* @param[in] srvc_id : service ID.
|
||||
* @param[in] char_id : GATT characteristic ID of the service.
|
||||
* @param[in] descr_id : characteristic descriptor ID to write.
|
||||
* @param[in] handle : characteristic descriptor hanlde to prepare write.
|
||||
* @param[in] offset : offset of the write value.
|
||||
* @param[in] value_len: length of the value to be written.
|
||||
* @param[in] value : the value to be written.
|
||||
@ -593,9 +704,7 @@ esp_err_t esp_ble_gattc_prepare_write(esp_gatt_if_t gattc_if,
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_prepare_write_char_descr(esp_gatt_if_t gattc_if,
|
||||
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 handle,
|
||||
uint16_t offset,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
@ -622,8 +731,7 @@ esp_err_t esp_ble_gattc_execute_write (esp_gatt_if_t gattc_if, uint16_t conn_id,
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] server_bda : target GATT server.
|
||||
* @param[in] srvc_id : pointer to GATT service ID.
|
||||
* @param[in] char_id : pointer to GATT characteristic ID.
|
||||
* @param[in] handle : GATT characteristic handle.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: registration succeeds
|
||||
@ -631,9 +739,8 @@ esp_err_t esp_ble_gattc_execute_write (esp_gatt_if_t gattc_if, uint16_t conn_id,
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id);
|
||||
esp_bd_addr_t server_bda,
|
||||
uint16_t handle);
|
||||
|
||||
|
||||
/**
|
||||
@ -641,8 +748,7 @@ esp_err_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] server_bda : target GATT server.
|
||||
* @param[in] srvc_id : pointer to GATT service ID.
|
||||
* @param[in] char_id : pointer to GATT characteristic ID.
|
||||
* @param[in] handle : GATT characteristic handle.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: unregister succeeds
|
||||
@ -650,9 +756,8 @@ esp_err_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id);
|
||||
esp_bd_addr_t server_bda,
|
||||
uint16_t handle);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include "bt_types.h"
|
||||
#include "allocator.h"
|
||||
#include "fixed_queue.h"
|
||||
#include "osi.h"
|
||||
#include "future.h"
|
||||
///// LEGACY DEFINITIONS /////
|
||||
|
@ -124,6 +124,8 @@ typedef UINT8 tL2CAP_CHNL_DATA_RATE;
|
||||
*/
|
||||
#define L2C_INVALID_PSM(psm) (((psm) & 0x0101) != 0x0001)
|
||||
#define L2C_IS_VALID_PSM(psm) (((psm) & 0x0101) == 0x0001)
|
||||
#define L2C_IS_VALID_LE_PSM(psm) (((psm) > 0x0000) && ((psm) < 0x0100))
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Type Definitions
|
||||
@ -164,6 +166,17 @@ typedef struct {
|
||||
UINT16 flags; /* bit 0: 0-no continuation, 1-continuation */
|
||||
} tL2CAP_CFG_INFO;
|
||||
|
||||
/* Define a structure to hold the configuration parameter for LE L2CAP connection
|
||||
** oriented channels.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
UINT16 mtu;
|
||||
UINT16 mps;
|
||||
UINT16 credits;
|
||||
} tL2CAP_LE_CFG_INFO;
|
||||
|
||||
|
||||
/* L2CAP channel configured field bitmap */
|
||||
#define L2CAP_CH_CFG_MASK_MTU 0x0001
|
||||
#define L2CAP_CH_CFG_MASK_QOS 0x0002
|
||||
@ -486,6 +499,72 @@ extern BOOLEAN L2CA_DisconnectReq (UINT16 cid);
|
||||
extern BOOLEAN L2CA_DisconnectRsp (UINT16 cid);
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function L2CA_RegisterLECoc
|
||||
**
|
||||
** Description Other layers call this function to register for L2CAP
|
||||
** Connection Oriented Channel.
|
||||
**
|
||||
** Returns PSM to use or zero if error. Typically, the PSM returned
|
||||
** is the same as was passed in, but for an outgoing-only
|
||||
** connection to a dynamic PSM, a "virtual" PSM is returned
|
||||
** and should be used in the calls to L2CA_ConnectLECocReq()
|
||||
** and BTM_SetSecurityLevel().
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 L2CA_RegisterLECoc (UINT16 psm, tL2CAP_APPL_INFO *p_cb_info);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function L2CA_DeregisterLECoc
|
||||
**
|
||||
** Description Other layers call this function to deregister for L2CAP
|
||||
** Connection Oriented Channel.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void L2CA_DeregisterLECoc (UINT16 psm);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function L2CA_ConnectLECocReq
|
||||
**
|
||||
** Description Higher layers call this function to create an L2CAP LE COC.
|
||||
** Note that the connection is not established at this time, but
|
||||
** connection establishment gets started. The callback function
|
||||
** will be invoked when connection establishes or fails.
|
||||
**
|
||||
** Returns the CID of the connection, or 0 if it failed to start
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 L2CA_ConnectLECocReq (UINT16 psm, BD_ADDR p_bd_addr, tL2CAP_LE_CFG_INFO *p_cfg);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function L2CA_ConnectLECocRsp
|
||||
**
|
||||
** Description Higher layers call this function to accept an incoming
|
||||
** L2CAP LE COC connection, for which they had gotten an connect
|
||||
** indication callback.
|
||||
**
|
||||
** Returns TRUE for success, FALSE for failure
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN L2CA_ConnectLECocRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, UINT16 result,
|
||||
UINT16 status, tL2CAP_LE_CFG_INFO *p_cfg);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function L2CA_GetPeerLECocConfig
|
||||
**
|
||||
** Description Get peers configuration for LE Connection Oriented Channel.
|
||||
**
|
||||
** Return value: TRUE if peer is connected
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN L2CA_GetPeerLECocConfig (UINT16 lcid, tL2CAP_LE_CFG_INFO* peer_cfg);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -34,6 +34,17 @@
|
||||
|
||||
#define L2CAP_MIN_MTU 48 /* Minimum acceptable MTU is 48 bytes */
|
||||
|
||||
/* LE credit based L2CAP connection parameters */
|
||||
#define L2CAP_LE_MIN_MTU 23
|
||||
#define L2CAP_LE_MIN_MPS 23
|
||||
#define L2CAP_LE_MAX_MPS 65533
|
||||
#define L2CAP_LE_MIN_CREDIT 0
|
||||
#define L2CAP_LE_MAX_CREDIT 65535
|
||||
#define L2CAP_LE_DEFAULT_MTU 512
|
||||
#define L2CAP_LE_DEFAULT_MPS 23
|
||||
#define L2CAP_LE_DEFAULT_CREDIT 1
|
||||
|
||||
|
||||
/* Timeouts. Since L2CAP works off a 1-second list, all are in seconds.
|
||||
*/
|
||||
#define L2CAP_LINK_ROLE_SWITCH_TOUT 10 /* 10 seconds */
|
||||
@ -240,6 +251,17 @@ typedef struct {
|
||||
tL2CAP_APPL_INFO api;
|
||||
} tL2C_RCB;
|
||||
|
||||
typedef void (tL2CAP_SEC_CBACK) (BD_ADDR bd_addr, tBT_TRANSPORT trasnport,
|
||||
void *p_ref_data, tBTM_STATUS result);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 psm;
|
||||
tBT_TRANSPORT transport;
|
||||
BOOLEAN is_originator;
|
||||
tL2CAP_SEC_CBACK *p_callback;
|
||||
void *p_ref_data;
|
||||
}tL2CAP_SEC_DATA;
|
||||
|
||||
#ifndef L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA
|
||||
#define L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA 100
|
||||
@ -252,6 +274,8 @@ typedef struct {
|
||||
typedef struct t_l2c_ccb {
|
||||
BOOLEAN in_use; /* TRUE when in use, FALSE when not */
|
||||
tL2C_CHNL_STATE chnl_state; /* Channel state */
|
||||
tL2CAP_LE_CFG_INFO local_conn_cfg; /* Our config for ble conn oriented channel */
|
||||
tL2CAP_LE_CFG_INFO peer_conn_cfg; /* Peer device config ble conn oriented channel */
|
||||
|
||||
struct t_l2c_ccb *p_next_ccb; /* Next CCB in the chain */
|
||||
struct t_l2c_ccb *p_prev_ccb; /* Previous CCB in the chain */
|
||||
@ -400,7 +424,8 @@ typedef struct t_l2c_linkcb {
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
tBLE_ADDR_TYPE ble_addr_type;
|
||||
UINT16 tx_data_len; /* tx data length used in data length extension */
|
||||
|
||||
fixed_queue_t *le_sec_pending_q; /* LE coc channels waiting for security check completion */
|
||||
UINT8 sec_act;
|
||||
#define L2C_BLE_CONN_UPDATE_DISABLE 0x1 /* disable update connection parameters */
|
||||
#define L2C_BLE_NEW_CONN_PARAM 0x2 /* new connection parameter to be set */
|
||||
#define L2C_BLE_UPDATE_PENDING 0x4 /* waiting for connection update finished */
|
||||
@ -488,6 +513,7 @@ typedef struct {
|
||||
UINT16 ble_round_robin_quota; /* Round-robin link quota */
|
||||
UINT16 ble_round_robin_unacked; /* Round-robin unacked */
|
||||
BOOLEAN ble_check_round_robin; /* Do a round robin check */
|
||||
tL2C_RCB ble_rcb_pool[BLE_MAX_L2CAP_CLIENTS]; /* Registration info pool */
|
||||
#endif
|
||||
|
||||
tL2CA_ECHO_DATA_CB *p_echo_data_cb; /* Echo data callback */
|
||||
@ -632,6 +658,12 @@ BOOLEAN l2c_ucd_process_event(tL2C_CCB *p_ccb, UINT16 event, void *p_data);
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
extern void l2cu_send_peer_ble_par_req (tL2C_LCB *p_lcb, UINT16 min_int, UINT16 max_int, UINT16 latency, UINT16 timeout);
|
||||
extern void l2cu_send_peer_ble_par_rsp (tL2C_LCB *p_lcb, UINT16 reason, UINT8 rem_id);
|
||||
extern void l2cu_reject_ble_connection (tL2C_LCB *p_lcb, UINT8 rem_id, UINT16 result);
|
||||
extern void l2cu_send_peer_ble_credit_based_conn_res (tL2C_CCB *p_ccb, UINT16 result);
|
||||
extern void l2cu_send_peer_ble_credit_based_conn_req (tL2C_CCB *p_ccb);
|
||||
extern void l2cu_send_peer_ble_flow_control_credit(tL2C_CCB *p_ccb, UINT16 credit_value);
|
||||
extern void l2cu_send_peer_ble_credit_based_disconn_req(tL2C_CCB *p_ccb);
|
||||
|
||||
#endif
|
||||
|
||||
extern BOOLEAN l2cu_initialize_fixed_ccb (tL2C_LCB *p_lcb, UINT16 fixed_cid, tL2CAP_FCR_OPTS *p_fcr);
|
||||
@ -649,6 +681,9 @@ extern void l2cu_send_feature_req (tL2C_CCB *p_ccb);
|
||||
extern tL2C_RCB *l2cu_allocate_rcb (UINT16 psm);
|
||||
extern tL2C_RCB *l2cu_find_rcb_by_psm (UINT16 psm);
|
||||
extern void l2cu_release_rcb (tL2C_RCB *p_rcb);
|
||||
extern tL2C_RCB *l2cu_allocate_ble_rcb (UINT16 psm);
|
||||
extern tL2C_RCB *l2cu_find_ble_rcb_by_psm (UINT16 psm);
|
||||
|
||||
|
||||
extern UINT8 l2cu_process_peer_cfg_req (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
|
||||
extern void l2cu_process_peer_cfg_rsp (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
|
||||
@ -748,6 +783,13 @@ extern void l2cble_process_conn_update_evt (UINT16 handle, UINT8 status, UINT16
|
||||
UINT16 conn_latency, UINT16 conn_timeout);
|
||||
extern void l2cble_get_conn_param_format_err_from_contoller(UINT8 status, UINT16 handle);
|
||||
|
||||
extern void l2cble_credit_based_conn_req (tL2C_CCB *p_ccb);
|
||||
extern void l2cble_credit_based_conn_res (tL2C_CCB *p_ccb, UINT16 result);
|
||||
extern void l2cble_send_peer_disc_req(tL2C_CCB *p_ccb);
|
||||
extern void l2cble_send_flow_control_credit(tL2C_CCB *p_ccb, UINT16 credit_value);
|
||||
extern BOOLEAN l2ble_sec_access_req(BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_originator, tL2CAP_SEC_CBACK *p_callback, void *p_ref_data);
|
||||
|
||||
|
||||
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
|
||||
extern void l2cble_process_rc_param_request_evt(UINT16 handle, UINT16 int_min, UINT16 int_max,
|
||||
UINT16 latency, UINT16 timeout);
|
||||
|
@ -41,6 +41,10 @@
|
||||
|
||||
#define L2CAP_CMD_BLE_UPDATE_REQ 0x12
|
||||
#define L2CAP_CMD_BLE_UPDATE_RSP 0x13
|
||||
#define L2CAP_CMD_BLE_CREDIT_BASED_CONN_REQ 0x14
|
||||
#define L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES 0x15
|
||||
#define L2CAP_CMD_BLE_FLOW_CTRL_CREDIT 0x16
|
||||
|
||||
|
||||
|
||||
/* Define some packet and header lengths
|
||||
@ -70,6 +74,11 @@
|
||||
#define L2CAP_CMD_BLE_UPD_REQ_LEN 8 /* Min and max interval, latency, tout */
|
||||
#define L2CAP_CMD_BLE_UPD_RSP_LEN 2 /* Result */
|
||||
|
||||
#define L2CAP_CMD_BLE_CREDIT_BASED_CONN_REQ_LEN 10 /* LE_PSM, SCID, MTU, MPS, Init Credit */
|
||||
#define L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES_LEN 10 /* DCID, MTU, MPS, Init credit, Result */
|
||||
#define L2CAP_CMD_BLE_FLOW_CTRL_CREDIT_LEN 4 /* CID, Credit */
|
||||
|
||||
|
||||
|
||||
/* Define the packet boundary flags
|
||||
*/
|
||||
|
@ -78,6 +78,7 @@ typedef enum {
|
||||
ESP_BT_CONTROLLER_STATUS_IDLE = 0,
|
||||
ESP_BT_CONTROLLER_STATUS_INITED,
|
||||
ESP_BT_CONTROLLER_STATUS_ENABLED,
|
||||
ESP_BT_CONTROLLER_STATUS_SHUTDOWN,
|
||||
ESP_BT_CONTROLLER_STATUS_NUM,
|
||||
} esp_bt_controller_status_t;
|
||||
|
||||
@ -102,11 +103,10 @@ typedef enum {
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL6 = 6, /*!< For connection handle 6 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL7 = 7, /*!< For connection handle 7 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL8 = 8, /*!< For connection handle 8 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL9 = 9, /*!< For connection handle 9 */
|
||||
ESP_BLE_PWR_TYPE_ADV = 10, /*!< For advertising */
|
||||
ESP_BLE_PWR_TYPE_SCAN = 11, /*!< For scan */
|
||||
ESP_BLE_PWR_TYPE_DEFAULT = 12, /*!< For default, if not set other, it will use default value */
|
||||
ESP_BLE_PWR_TYPE_NUM = 13, /*!< TYPE numbers */
|
||||
ESP_BLE_PWR_TYPE_ADV = 9, /*!< For advertising */
|
||||
ESP_BLE_PWR_TYPE_SCAN = 10, /*!< For scan */
|
||||
ESP_BLE_PWR_TYPE_DEFAULT = 11, /*!< For default, if not set other, it will use default value */
|
||||
ESP_BLE_PWR_TYPE_NUM = 12, /*!< TYPE numbers */
|
||||
} esp_ble_power_type_t;
|
||||
|
||||
/**
|
||||
@ -159,20 +159,20 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg);
|
||||
esp_err_t esp_bt_controller_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Enable BT controller
|
||||
* @brief Enable BT controller.
|
||||
* Due to a known issue, you cannot call esp_bt_controller_enable() a second time
|
||||
* to change the controller mode dynamically. To change controller mode, call
|
||||
* esp_bt_controller_disable() and then call esp_bt_controller_enable() with the new mode.
|
||||
* @param mode : the mode(BLE/BT/BTDM) to enable.
|
||||
* Now only support BTDM.
|
||||
* @return ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Disable BT controller
|
||||
* @param mode : the mode(BLE/BT/BTDM) to disable.
|
||||
* Now only support BTDM.
|
||||
* @return ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_bt_controller_disable(esp_bt_mode_t mode);
|
||||
esp_err_t esp_bt_controller_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Get BT controller is initialised/de-initialised/enabled/disabled
|
||||
@ -208,6 +208,36 @@ void esp_vhci_host_send_packet(uint8_t *data, uint16_t len);
|
||||
*/
|
||||
void esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback);
|
||||
|
||||
/** @brief esp_bt_controller_mem_release
|
||||
* release the memory by mode, if never use the bluetooth mode
|
||||
* it can release the .bbs, .data and other section to heap.
|
||||
* The total size is about 70k bytes.
|
||||
*
|
||||
* If esp_bt_controller_enable(mode) has already been called, calling
|
||||
* esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) will automatically
|
||||
* release all memory which is not needed for the currently enabled
|
||||
* Bluetooth controller mode.
|
||||
*
|
||||
* For example, calling esp_bt_controller_enable(ESP_BT_MODE_BLE) then
|
||||
* esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) will enable BLE modes
|
||||
* and release memory only used by BT Classic. Also, call esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT)
|
||||
* is the same.
|
||||
*
|
||||
* Note that once BT controller memory is released, the process cannot be reversed.
|
||||
* If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
|
||||
* then do not call this function.
|
||||
*
|
||||
* If user never use bluetooth controller, could call esp_bt_controller_mem_release(ESP_BT_MODE_BTDM)
|
||||
* before esp_bt_controller_init or after esp_bt_controller_deinit.
|
||||
*
|
||||
* For example, user only use bluetooth to config SSID and PASSWORD of WIFI, after config, will never use bluetooth.
|
||||
* Then, could call esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) after esp_bt_controller_deinit.
|
||||
*
|
||||
* @param mode : the mode want to release memory
|
||||
* @return ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -54,6 +54,7 @@
|
||||
#define CONFIG_ULP_COPROC_RESERVE_MEM 512
|
||||
#define CONFIG_ESPTOOLPY_BAUD 921600
|
||||
#define CONFIG_INT_WDT_CHECK_CPU1 1
|
||||
#define CONFIG_FLASHMODE_DIO 1
|
||||
#define CONFIG_ESPTOOLPY_AFTER_RESET 1
|
||||
#define CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED 1
|
||||
#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-"
|
||||
@ -95,7 +96,6 @@
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL 1
|
||||
#define CONFIG_TIMER_QUEUE_LENGTH 10
|
||||
#define CONFIG_MAKE_WARN_UNDEFINED_VARIABLES 1
|
||||
#define CONFIG_BOOTLOADER_SPI_WP_PIN 7
|
||||
#define CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM 0
|
||||
#define CONFIG_MBEDTLS_CCM_C 1
|
||||
#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20
|
||||
@ -121,7 +121,6 @@
|
||||
#define CONFIG_PARTITION_TABLE_SINGLE_APP 1
|
||||
#define CONFIG_ESP32_WIFI_RX_BA_WIN 6
|
||||
#define CONFIG_MBEDTLS_X509_CSR_PARSE_C 1
|
||||
#define CONFIG_FLASHMODE_QIO 1
|
||||
#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA 1
|
||||
#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 2048
|
||||
#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 2000
|
||||
|
@ -269,6 +269,20 @@ esp_err_t uart_set_line_inverse(uart_port_t uart_num, uint32_t inverse_mask);
|
||||
*/
|
||||
esp_err_t uart_set_hw_flow_ctrl(uart_port_t uart_num, uart_hw_flowcontrol_t flow_ctrl, uint8_t rx_thresh);
|
||||
|
||||
/**
|
||||
* @brief Set software flow control.
|
||||
*
|
||||
* @param uart_num UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
* @param enable switch on or off
|
||||
* @param rx_thresh_xon low water mark
|
||||
* @param rx_thresh_xoff high water mark
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t uart_set_sw_flow_ctrl(uart_port_t uart_num, bool enable, uint8_t rx_thresh_xon, uint8_t rx_thresh_xoff);
|
||||
|
||||
/**
|
||||
* @brief Get hardware flow control mode
|
||||
*
|
||||
@ -587,7 +601,7 @@ int uart_write_bytes_with_break(uart_port_t uart_num, const char* src, size_t si
|
||||
int uart_read_bytes(uart_port_t uart_num, uint8_t* buf, uint32_t length, TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief UART ring buffer flush
|
||||
* @brief UART ring buffer flush. This will discard all data in the UART RX buffer.
|
||||
*
|
||||
* @param uart_num UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
*
|
||||
|
@ -27,6 +27,10 @@ void esp_dport_access_int_init(void);
|
||||
void esp_dport_access_int_pause(void);
|
||||
void esp_dport_access_int_resume(void);
|
||||
|
||||
//This routine does not stop the dport routines in any way that is recoverable. Please
|
||||
//only call in case of panic().
|
||||
void esp_dport_access_int_abort(void);
|
||||
|
||||
#if defined(BOOTLOADER_BUILD) || defined(CONFIG_FREERTOS_UNICORE) || !defined(ESP_PLATFORM)
|
||||
#define DPORT_STALL_OTHER_CPU_START()
|
||||
#define DPORT_STALL_OTHER_CPU_END()
|
||||
|
315
tools/sdk/include/esp32/esp_now.h
Normal file
315
tools/sdk/include/esp32/esp_now.h
Normal file
@ -0,0 +1,315 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_NOW_H__
|
||||
#define __ESP_NOW_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup WiFi_APIs WiFi Related APIs
|
||||
* @brief WiFi APIs
|
||||
*/
|
||||
|
||||
/** @addtogroup WiFi_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** \defgroup ESPNOW_APIs ESPNOW APIs
|
||||
* @brief ESP32 ESPNOW APIs
|
||||
*
|
||||
*/
|
||||
|
||||
/** @addtogroup ESPNOW_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define ESP_ERR_ESPNOW_BASE (ESP_ERR_WIFI_BASE + 101) /*!< ESPNOW error number base. */
|
||||
#define ESP_ERR_ESPNOW_NOT_INIT (ESP_ERR_ESPNOW_BASE) /*!< ESPNOW is not initialized. */
|
||||
#define ESP_ERR_ESPNOW_ARG (ESP_ERR_ESPNOW_BASE + 1) /*!< Invalid argument */
|
||||
#define ESP_ERR_ESPNOW_NO_MEM (ESP_ERR_ESPNOW_BASE + 2) /*!< Out of memory */
|
||||
#define ESP_ERR_ESPNOW_FULL (ESP_ERR_ESPNOW_BASE + 3) /*!< ESPNOW peer list is full */
|
||||
#define ESP_ERR_ESPNOW_NOT_FOUND (ESP_ERR_ESPNOW_BASE + 4) /*!< ESPNOW peer is not found */
|
||||
#define ESP_ERR_ESPNOW_INTERNAL (ESP_ERR_ESPNOW_BASE + 5) /*!< Internal error */
|
||||
#define ESP_ERR_ESPNOW_EXIST (ESP_ERR_ESPNOW_BASE + 6) /*!< ESPNOW peer has existed */
|
||||
|
||||
#define ESP_NOW_ETH_ALEN 6 /*!< Length of ESPNOW peer MAC address */
|
||||
#define ESP_NOW_KEY_LEN 16 /*!< Length of ESPNOW peer local master key */
|
||||
|
||||
#define ESP_NOW_MAX_TOTAL_PEER_NUM 20 /*!< Maximum number of ESPNOW total peers */
|
||||
#define ESP_NOW_MAX_ENCRYPT_PEER_NUM 6 /*!< Maximum number of ESPNOW encrypted peers */
|
||||
|
||||
#define ESP_NOW_MAX_DATA_LEN 250 /*!< Maximum length of ESPNOW data which is sent very time */
|
||||
|
||||
/**
|
||||
* @brief Status of sending ESPNOW data .
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_NOW_SEND_SUCCESS = 0, /**< Send ESPNOW data successfully */
|
||||
ESP_NOW_SEND_FAIL, /**< Send ESPNOW data fail */
|
||||
} esp_now_send_status_t;
|
||||
|
||||
/**
|
||||
* @brief ESPNOW peer information parameters.
|
||||
*/
|
||||
typedef struct esp_now_peer_info {
|
||||
uint8_t peer_addr[ESP_NOW_ETH_ALEN]; /**< ESPNOW peer MAC address that is also the MAC address of station or softap */
|
||||
uint8_t lmk[ESP_NOW_KEY_LEN]; /**< ESPNOW peer local master key that is used to encrypt data */
|
||||
uint8_t channel; /**< Wi-Fi channel that peer uses to send/receive ESPNOW data. If the value is 0,
|
||||
use the current channel which station or softap is on. Otherwise, it must be
|
||||
set as the channel that station or softap is on. */
|
||||
wifi_interface_t ifidx; /**< Wi-Fi interface that peer uses to send/receive ESPNOW data */
|
||||
bool encrypt; /**< ESPNOW data that this peer sends/receives is encrypted or not */
|
||||
void *priv; /**< ESPNOW peer private data */
|
||||
} esp_now_peer_info_t;
|
||||
|
||||
/**
|
||||
* @brief Number of ESPNOW peers which exist currently.
|
||||
*/
|
||||
typedef struct esp_now_peer_num {
|
||||
int total_num; /**< Total number of ESPNOW peers, maximum value is ESP_NOW_MAX_TOTAL_PEER_NUM */
|
||||
int encrypt_num; /**< Number of encrypted ESPNOW peers, maximum value is ESP_NOW_MAX_ENCRYPT_PEER_NUM */
|
||||
} esp_now_peer_num_t;
|
||||
|
||||
/**
|
||||
* @brief Callback function of receiving ESPNOW data
|
||||
* @param mac_addr peer MAC address
|
||||
* @param data received data
|
||||
* @param data_len length of received data
|
||||
*/
|
||||
typedef void (*esp_now_recv_cb_t)(const uint8_t *mac_addr, const uint8_t *data, int data_len);
|
||||
|
||||
/**
|
||||
* @brief Callback function of sending ESPNOW data
|
||||
* @param mac_addr peer MAC address
|
||||
* @param status status of sending ESPNOW data (succeed or fail)
|
||||
*/
|
||||
typedef void (*esp_now_send_cb_t)(const uint8_t *mac_addr, esp_now_send_status_t status);
|
||||
|
||||
/**
|
||||
* @brief Initialize ESPNOW function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_INTERNAL : Internal error
|
||||
*/
|
||||
esp_err_t esp_now_init(void);
|
||||
|
||||
/**
|
||||
* @brief De-initialize ESPNOW function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
*/
|
||||
esp_err_t esp_now_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Get the version of ESPNOW
|
||||
*
|
||||
* @param version ESPNOW version
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_now_get_version(uint32_t *version);
|
||||
|
||||
/**
|
||||
* @brief Register callback function of receiving ESPNOW data
|
||||
*
|
||||
* @param cb callback function of receiving ESPNOW data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_INTERNAL : internal error
|
||||
*/
|
||||
esp_err_t esp_now_register_recv_cb(esp_now_recv_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Unregister callback function of receiving ESPNOW data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
*/
|
||||
esp_err_t esp_now_unregister_recv_cb(void);
|
||||
|
||||
/**
|
||||
* @brief Register callback function of sending ESPNOW data
|
||||
*
|
||||
* @param cb callback function of sending ESPNOW data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_INTERNAL : internal error
|
||||
*/
|
||||
esp_err_t esp_now_register_send_cb(esp_now_send_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Unregister callback function of sending ESPNOW data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
*/
|
||||
esp_err_t esp_now_unregister_send_cb(void);
|
||||
|
||||
/**
|
||||
* @brief Send ESPNOW data
|
||||
*
|
||||
* @attention 1. If peer_addr is not NULL, send data to the peer whose MAC address matches peer_addr
|
||||
* @attention 2. If peer_addr is NULL, send data to all of the peers that are added to the peer list
|
||||
* @attention 3. The maximum length of data must be less than ESP_NOW_MAX_DATA_LEN
|
||||
* @attention 4. The buffer pointed to by data argument does not need to be valid after esp_now_send returns
|
||||
*
|
||||
* @param peer_addr peer MAC address
|
||||
* @param data data to send
|
||||
* @param len length of data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_INTERNAL : internal error
|
||||
* - ESP_ERR_ESPNOW_NO_MEM : out of memory
|
||||
* - ESP_ERR_ESPNOW_NOT_FOUND : peer is not found
|
||||
*/
|
||||
esp_err_t esp_now_send(const uint8_t *peer_addr, const uint8_t *data, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Add a peer to peer list
|
||||
*
|
||||
* @param peer peer information
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_FULL : peer list is full
|
||||
* - ESP_ERR_ESPNOW_NO_MEM : out of memory
|
||||
* - ESP_ERR_ESPNOW_EXIST : peer has existed
|
||||
*/
|
||||
esp_err_t esp_now_add_peer(const esp_now_peer_info_t *peer);
|
||||
|
||||
/**
|
||||
* @brief Delete a peer from peer list
|
||||
*
|
||||
* @param peer_addr peer MAC address
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_NOT_FOUND : peer is not found
|
||||
*/
|
||||
esp_err_t esp_now_del_peer(const uint8_t *peer_addr);
|
||||
|
||||
/**
|
||||
* @brief Modify a peer
|
||||
*
|
||||
* @param peer peer information
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_FULL : peer list is full
|
||||
*/
|
||||
esp_err_t esp_now_mod_peer(const esp_now_peer_info_t *peer);
|
||||
|
||||
/**
|
||||
* @brief Get a peer whose MAC address matches peer_addr from peer list
|
||||
*
|
||||
* @param peer_addr peer MAC address
|
||||
* @param peer peer information
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_NOT_FOUND : peer is not found
|
||||
*/
|
||||
esp_err_t esp_now_get_peer(const uint8_t *peer_addr, esp_now_peer_info_t *peer);
|
||||
|
||||
/**
|
||||
* @brief Fetch a peer from peer list
|
||||
*
|
||||
* @param from_head fetch from head of list or not
|
||||
* @param peer peer information
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_NOT_FOUND : peer is not found
|
||||
*/
|
||||
esp_err_t esp_now_fetch_peer(bool from_head, esp_now_peer_info_t *peer);
|
||||
|
||||
/**
|
||||
* @brief Peer exists or not
|
||||
*
|
||||
* @param peer_addr peer MAC address
|
||||
*
|
||||
* @return
|
||||
* - true : peer exists
|
||||
* - false : peer not exists
|
||||
*/
|
||||
bool esp_now_is_peer_exist(const uint8_t *peer_addr);
|
||||
|
||||
/**
|
||||
* @brief Get the number of peers
|
||||
*
|
||||
* @param num number of peers
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_now_get_peer_num(esp_now_peer_num_t *num);
|
||||
|
||||
/**
|
||||
* @brief Set the primary master key
|
||||
*
|
||||
* @param pmk primary master key
|
||||
*
|
||||
* @attention 1. primary master key is used to encrypt local master key
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_now_set_pmk(const uint8_t *pmk);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_NOW_H__ */
|
@ -39,6 +39,12 @@ esp_err_t esp_spiram_init();
|
||||
bool esp_spiram_test();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add the initialized SPI RAM to the heap allocator.
|
||||
*/
|
||||
esp_err_t esp_spiram_add_to_heapalloc();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the size of the attached SPI RAM chip selected in menuconfig
|
||||
*
|
||||
|
@ -132,6 +132,16 @@ typedef struct {
|
||||
uint32_t reserved:31; /**< bit: 1..31 reserved */
|
||||
} wifi_ap_record_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_FAST_SCAN = 0, /**< Do fast scan, scan will end after find SSID match AP */
|
||||
WIFI_ALL_CHANNEL_SCAN, /**< All channel scan, scan will end after scan all the channel */
|
||||
}wifi_scan_method_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_CONNECT_AP_BY_SIGNAL = 0, /**< Sort match AP in scan list by RSSI */
|
||||
WIFI_CONNECT_AP_BY_SECURITY, /**< Sort match AP in scan list by security mode */
|
||||
}wifi_sort_method_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_PS_NONE, /**< No power save */
|
||||
WIFI_PS_MODEM, /**< Modem power save */
|
||||
@ -161,9 +171,11 @@ typedef struct {
|
||||
typedef struct {
|
||||
uint8_t ssid[32]; /**< SSID of target AP*/
|
||||
uint8_t password[64]; /**< password of target AP*/
|
||||
wifi_scan_method_t scan_method; /**< do all channel scan or fast scan */
|
||||
bool bssid_set; /**< whether set MAC address of target AP or not. Generally, station_config.bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.*/
|
||||
uint8_t bssid[6]; /**< MAC address of target AP*/
|
||||
uint8_t channel; /**< channel of target AP. Set to 1~13 to scan starting from the specified channel before connecting to AP. If the channel of AP is unknown, set it to 0.*/
|
||||
wifi_sort_method_t sort_method; /**< sort the connect AP in the list by rssi or security mode */
|
||||
} wifi_sta_config_t;
|
||||
|
||||
typedef union {
|
||||
|
@ -269,9 +269,7 @@ extern void vPortCleanUpTCB ( void *pxTCB );
|
||||
#define configXT_BOARD 1 /* Board mode */
|
||||
#define configXT_SIMULATOR 0
|
||||
|
||||
#if CONFIG_ESP32_ENABLE_COREDUMP
|
||||
#define configENABLE_TASK_SNAPSHOT 1
|
||||
#endif
|
||||
|
||||
#if CONFIG_SYSVIEW_ENABLE
|
||||
#ifndef __ASSEMBLER__
|
||||
|
@ -30,7 +30,8 @@
|
||||
#define MALLOC_CAP_PID5 (1<<7) ///< Memory must be mapped to PID5 memory space (PIDs are not currently used)
|
||||
#define MALLOC_CAP_PID6 (1<<8) ///< Memory must be mapped to PID6 memory space (PIDs are not currently used)
|
||||
#define MALLOC_CAP_PID7 (1<<9) ///< Memory must be mapped to PID7 memory space (PIDs are not currently used)
|
||||
#define MALLOC_CAP_SPISRAM (1<<10) ///< Memory must be in SPI SRAM
|
||||
#define MALLOC_CAP_SPIRAM (1<<10) ///< Memory must be in SPI RAM
|
||||
#define MALLOC_CAP_INTERNAL (1<<11) ///< Memory must be internal; specifically it should not disappear when flash/spiram cache is switched off
|
||||
#define MALLOC_CAP_INVALID (1<<31) ///< Memory can't be used / list end marker
|
||||
|
||||
/**
|
||||
@ -48,6 +49,7 @@
|
||||
*/
|
||||
void *heap_caps_malloc(size_t size, uint32_t caps);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Free memory previously allocated via heap_caps_malloc() or heap_caps_realloc().
|
||||
*
|
||||
|
@ -95,6 +95,62 @@ uint32_t esp_log_early_timestamp(void);
|
||||
*/
|
||||
void esp_log_write(esp_log_level_t level, const char* tag, const char* format, ...) __attribute__ ((format (printf, 3, 4)));
|
||||
|
||||
#include "esp_log_internal.h"
|
||||
|
||||
/**
|
||||
* @brief Log a buffer of hex bytes at specified level, seprated into 16 bytes each line.
|
||||
*
|
||||
* @param tag description tag
|
||||
*
|
||||
* @param buffer Pointer to the buffer array
|
||||
*
|
||||
* @param buff_len length of buffer in bytes
|
||||
*
|
||||
* @param level level of the log
|
||||
*
|
||||
*/
|
||||
#define ESP_LOG_BUFFER_HEX_LEVEL( tag, buffer, buff_len, level ) do {\
|
||||
if ( LOG_LOCAL_LEVEL >= level ) esp_log_buffer_hex_internal( tag, buffer, buff_len, level ); } while(0)
|
||||
|
||||
/**
|
||||
* @brief Log a buffer of characters at specified level, seprated into 16 bytes each line. Buffer should contain only printable characters.
|
||||
*
|
||||
* @param tag description tag
|
||||
*
|
||||
* @param buffer Pointer to the buffer array
|
||||
*
|
||||
* @param buff_len length of buffer in bytes
|
||||
*
|
||||
* @param level level of the log
|
||||
*
|
||||
*/
|
||||
#define ESP_LOG_BUFFER_CHAR_LEVEL( tag, buffer, buff_len, level ) do {\
|
||||
if ( LOG_LOCAL_LEVEL >= level ) esp_log_buffer_char_internal( tag, buffer, buff_len, level ); } while(0)
|
||||
|
||||
/**
|
||||
* @brief Dump a buffer to the log at specified level.
|
||||
*
|
||||
* The dump log shows just like the one below:
|
||||
*
|
||||
* W (195) log_example: 0x3ffb4280 45 53 50 33 32 20 69 73 20 67 72 65 61 74 2c 20 |ESP32 is great, |
|
||||
* W (195) log_example: 0x3ffb4290 77 6f 72 6b 69 6e 67 20 61 6c 6f 6e 67 20 77 69 |working along wi|
|
||||
* W (205) log_example: 0x3ffb42a0 74 68 20 74 68 65 20 49 44 46 2e 00 |th the IDF..|
|
||||
*
|
||||
* It is highly recommend to use terminals with over 102 text width.
|
||||
*
|
||||
* @param tag description tag
|
||||
*
|
||||
* @param buffer Pointer to the buffer array
|
||||
*
|
||||
* @param buff_len length of buffer in bytes
|
||||
*
|
||||
* @param level level of the log
|
||||
*/
|
||||
#define ESP_LOG_BUFFER_HEXDUMP( tag, buffer, buff_len, level ) do {\
|
||||
if ( LOG_LOCAL_LEVEL >= level ) esp_log_buffer_hexdump_internal( tag, buffer, buff_len, level); } while(0)
|
||||
|
||||
|
||||
#if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO)
|
||||
/**
|
||||
* @brief Log a buffer of hex bytes at Info level
|
||||
*
|
||||
@ -104,8 +160,10 @@ void esp_log_write(esp_log_level_t level, const char* tag, const char* format, .
|
||||
*
|
||||
* @param buff_len length of buffer in bytes
|
||||
*
|
||||
* @see ``esp_log_buffer_hex_level``
|
||||
*
|
||||
*/
|
||||
void esp_log_buffer_hex(const char *tag, const void *buffer, uint16_t buff_len);
|
||||
#define ESP_LOG_BUFFER_HEX(tag, buffer, buff_len) ESP_LOG_BUFFER_HEX_LEVEL( tag, buffer, buff_len, ESP_LOG_INFO )
|
||||
|
||||
/**
|
||||
* @brief Log a buffer of characters at Info level. Buffer should contain only printable characters.
|
||||
@ -116,8 +174,20 @@ void esp_log_buffer_hex(const char *tag, const void *buffer, uint16_t buff_len);
|
||||
*
|
||||
* @param buff_len length of buffer in bytes
|
||||
*
|
||||
* @see ``esp_log_buffer_char_level``
|
||||
*
|
||||
*/
|
||||
void esp_log_buffer_char(const char *tag, const void *buffer, uint16_t buff_len);
|
||||
#define ESP_LOG_BUFFER_CHAR(tag, buffer, buff_len) ESP_LOG_BUFFER_CHAR_LEVEL( tag, buffer, buff_len, ESP_LOG_INFO )
|
||||
|
||||
#else
|
||||
#define ESP_LOG_BUFFER_HEX(tag, buffer, buff_len) {}
|
||||
#define ESP_LOG_BUFFER_CHAR(tag, buffer, buff_len) {}
|
||||
#endif
|
||||
|
||||
//to be back compatible
|
||||
#define esp_log_buffer_hex ESP_LOG_BUFFER_HEX
|
||||
#define esp_log_buffer_char ESP_LOG_BUFFER_CHAR
|
||||
|
||||
|
||||
#if CONFIG_LOG_COLORS
|
||||
#define LOG_COLOR_BLACK "30"
|
||||
@ -190,6 +260,32 @@ void esp_log_buffer_char(const char *tag, const void *buffer, uint16_t buff_len)
|
||||
#define ESP_LOGV( tag, format, ... ) ESP_EARLY_LOGV(tag, format, ##__VA_ARGS__)
|
||||
#endif // BOOTLOADER_BUILD
|
||||
|
||||
/** runtime macro to output logs at a speicfied level.
|
||||
*
|
||||
* @param tag tag of the log, which can be used to change the log level by ``esp_log_level_set`` at runtime.
|
||||
*
|
||||
* @param level level of the output log.
|
||||
*
|
||||
* @param format format of the output log. see ``printf``
|
||||
*
|
||||
* @param ... variables to be replaced into the log. see ``printf``
|
||||
*
|
||||
* @see ``printf``
|
||||
*/
|
||||
#define ESP_LOG_LEVEL(level, tag, format, ...) do {\
|
||||
if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }\
|
||||
else if (level==ESP_LOG_WARN ) { esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }\
|
||||
else if (level==ESP_LOG_DEBUG ) { esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }\
|
||||
else if (level==ESP_LOG_VERBOSE ) { esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }\
|
||||
else { esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }}while(0)
|
||||
|
||||
/** runtime macro to output logs at a speicfied level. Also check the level with ``LOG_LOCAL_LEVEL``.
|
||||
*
|
||||
* @see ``printf``, ``ESP_LOG_LEVEL``
|
||||
*/
|
||||
#define ESP_LOG_LEVEL_LOCAL(level, tag, format, ...) do {\
|
||||
if ( LOG_LOCAL_LEVEL >= level ) ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); } while(0);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
24
tools/sdk/include/log/esp_log_internal.h
Normal file
24
tools/sdk/include/log/esp_log_internal.h
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_LOG_INTERNAL_H__
|
||||
#define __ESP_LOG_INTERNAL_H__
|
||||
|
||||
//these two functions do not check level versus ESP_LOCAL_LEVEL, this should be done in esp_log.h
|
||||
void esp_log_buffer_hex_internal(const char *tag, const void *buffer, uint16_t buff_len, esp_log_level_t level);
|
||||
void esp_log_buffer_char_internal(const char *tag, const void *buffer, uint16_t buff_len, esp_log_level_t level);
|
||||
void esp_log_buffer_hexdump_internal( const char *tag, const void *buffer, uint16_t buff_len, esp_log_level_t log_level);
|
||||
|
||||
#endif
|
||||
|
@ -59,11 +59,6 @@ struct dhcps_pool{
|
||||
u32_t lease_timer;
|
||||
};
|
||||
|
||||
typedef struct _list_node{
|
||||
void *pnode;
|
||||
struct _list_node *pnext;
|
||||
}list_node;
|
||||
|
||||
typedef u32_t dhcps_time_t;
|
||||
typedef u8_t dhcps_offer_t;
|
||||
|
||||
|
@ -24,7 +24,7 @@ extern "C" {
|
||||
* @brief Initialize the default NVS partition.
|
||||
*
|
||||
* This API initialises the default NVS partition. The default NVS partition
|
||||
* is the one that is labelled "nvs" in the partition table.
|
||||
* is the one that is labeled "nvs" in the partition table.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK if storage was successfully initialized.
|
||||
@ -38,7 +38,7 @@ esp_err_t nvs_flash_init(void);
|
||||
/**
|
||||
* @brief Initialize NVS flash storage for the specified partition.
|
||||
*
|
||||
* @param[in] partition_name Name (label) of the partition. Note that internally a reference to
|
||||
* @param[in] partition_label Label of the partition. Note that internally a reference to
|
||||
* passed value is kept and it should be accessible for future operations
|
||||
*
|
||||
* @return
|
||||
@ -48,7 +48,30 @@ esp_err_t nvs_flash_init(void);
|
||||
* - ESP_ERR_NOT_FOUND if specified partition is not found in the partition table
|
||||
* - one of the error codes from the underlying flash storage driver
|
||||
*/
|
||||
esp_err_t nvs_flash_init_partition(const char *partition_name);
|
||||
esp_err_t nvs_flash_init_partition(const char *partition_label);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize NVS storage for the default NVS partition
|
||||
*
|
||||
* Default NVS partition is the partition with "nvs" label in the partition table.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success (storage was deinitialized)
|
||||
* - ESP_ERR_NVS_NOT_INITIALIZED if the storage was not initialized prior to this call
|
||||
*/
|
||||
esp_err_t nvs_flash_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize NVS storage for the given NVS partition
|
||||
*
|
||||
* @param[in] partition_label Label of the partition
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NVS_NOT_INITIALIZED if the storage for given partition was not
|
||||
* initialized prior to this call
|
||||
*/
|
||||
esp_err_t nvs_flash_deinit_partition(const char* partition_label);
|
||||
|
||||
/**
|
||||
* @brief Erase the default NVS partition
|
||||
|
@ -274,12 +274,12 @@
|
||||
//}}
|
||||
|
||||
/* Overall memory map */
|
||||
#define SOC_DROM_LOW 0x3F400000
|
||||
#define SOC_DROM_HIGH 0x3F800000
|
||||
#define SOC_IROM_LOW 0x400D0000
|
||||
#define SOC_IROM_HIGH 0x40400000
|
||||
#define SOC_IRAM_LOW 0x40080000
|
||||
#define SOC_IRAM_HIGH 0x400A0000
|
||||
#define SOC_DROM_LOW 0x3F400000
|
||||
#define SOC_DROM_HIGH 0x3F800000
|
||||
#define SOC_RTC_IRAM_LOW 0x400C0000
|
||||
#define SOC_RTC_IRAM_HIGH 0x400C2000
|
||||
#define SOC_RTC_DATA_LOW 0x50000000
|
||||
@ -295,6 +295,10 @@
|
||||
#define SOC_DMA_LOW 0x3FFAE000
|
||||
#define SOC_DMA_HIGH 0x40000000
|
||||
|
||||
// Region of memory that is byte-accessible. See esp_ptr_byte_accesible().
|
||||
#define SOC_BYTE_ACCESSIBLE_LOW 0x3FFAE000
|
||||
#define SOC_BYTE_ACCESSIBLE_HIGH 0x40000000
|
||||
|
||||
//Interrupt hardware source table
|
||||
//This table is decided by hardware, don't touch this.
|
||||
#define ETS_WIFI_MAC_INTR_SOURCE 0/**< interrupt of WiFi MAC, level*/
|
||||
|
@ -18,6 +18,10 @@
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Configuration structure for esp_vfs_spiffs_register
|
||||
*/
|
||||
@ -91,4 +95,8 @@ esp_err_t esp_spiffs_format(const char* partition_label);
|
||||
*/
|
||||
esp_err_t esp_spiffs_info(const char* partition_label, size_t *total_bytes, size_t *used_bytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_SPIFFS_H_ */
|
||||
|
@ -24,27 +24,27 @@
|
||||
#define SPIFFS_TAG "SPIFFS"
|
||||
|
||||
// Set generic spiffs debug output call.
|
||||
#if CONGIG_SPIFFS_DBG
|
||||
#if CONFIG_SPIFFS_DBG
|
||||
#define SPIFFS_DBG(...) ESP_LOGD(SPIFFS_TAG, __VA_ARGS__)
|
||||
#else
|
||||
#define SPIFFS_DBG(...)
|
||||
#endif
|
||||
#if CONGIG_SPIFFS_API_DBG
|
||||
#if CONFIG_SPIFFS_API_DBG
|
||||
#define SPIFFS_API_DBG(...) ESP_LOGD(SPIFFS_TAG, __VA_ARGS__)
|
||||
#else
|
||||
#define SPIFFS_API_DBG(...)
|
||||
#endif
|
||||
#if CONGIG_SPIFFS_DBG
|
||||
#if CONFIG_SPIFFS_DBG
|
||||
#define SPIFFS_GC_DBG(...) ESP_LOGD(SPIFFS_TAG, __VA_ARGS__)
|
||||
#else
|
||||
#define SPIFFS_GC_DBG(...)
|
||||
#endif
|
||||
#if CONGIG_SPIFFS_CACHE_DBG
|
||||
#if CONFIG_SPIFFS_CACHE_DBG
|
||||
#define SPIFFS_CACHE_DBG(...) ESP_LOGD(SPIFFS_TAG, __VA_ARGS__)
|
||||
#else
|
||||
#define SPIFFS_CACHE_DBG(...)
|
||||
#endif
|
||||
#if CONGIG_SPIFFS_CHECK_DBG
|
||||
#if CONFIG_SPIFFS_CHECK_DBG
|
||||
#define SPIFFS_CHECK_DBG(...) ESP_LOGD(SPIFFS_TAG, __VA_ARGS__)
|
||||
#else
|
||||
#define SPIFFS_CHECK_DBG(...)
|
||||
|
Reference in New Issue
Block a user