kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'bugfix/fix_ble_bugs' into 'master'
Fix some BLE bugs in bluedroid host See merge request espressif/esp-idf!26448pull/12486/head
commit
ea81f4c4a3
|
@ -279,20 +279,19 @@ choice BT_CTRL_SCAN_DUPL_TYPE
|
|||
config BT_CTRL_SCAN_DUPL_TYPE_DEVICE
|
||||
bool "Scan Duplicate By Device Address"
|
||||
help
|
||||
This way is to use advertiser address filtering. The adv packet of the same address is only
|
||||
allowed to be reported once
|
||||
Advertising packets with the same address, address type, and advertising type are reported once.
|
||||
|
||||
config BT_CTRL_SCAN_DUPL_TYPE_DATA
|
||||
bool "Scan Duplicate By Advertising Data"
|
||||
help
|
||||
This way is to use advertising data filtering. All same advertising data only allow to be reported
|
||||
once even though they are from different devices.
|
||||
Advertising packets with identical advertising data, address type, and advertising type
|
||||
are reported only once, even if they originate from different devices.
|
||||
|
||||
config BT_CTRL_SCAN_DUPL_TYPE_DATA_DEVICE
|
||||
bool "Scan Duplicate By Device Address And Advertising Data"
|
||||
help
|
||||
This way is to use advertising data and device address filtering. All different adv packets with
|
||||
the same address are allowed to be reported.
|
||||
Advertising packets with the same address, advertising data, address type,
|
||||
and advertising type are reported only once.
|
||||
endchoice
|
||||
|
||||
config BT_CTRL_SCAN_DUPL_TYPE
|
||||
|
|
|
@ -470,8 +470,7 @@ esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_d
|
|||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (raw_data == NULL
|
||||
|| (raw_data_len <= 0 || raw_data_len > ESP_BLE_SCAN_RSP_DATA_LEN_MAX)) {
|
||||
if ((raw_data_len != 0 && raw_data == NULL) || raw_data_len > ESP_BLE_ADV_DATA_LEN_MAX) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
|
|
|
@ -495,11 +495,11 @@ void bta_gatts_add_char_descr(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_
|
|||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gatts_add_char_descr
|
||||
** Function bta_gatts_set_attr_value
|
||||
**
|
||||
** Description action function to add characteristic descriptor.
|
||||
** Description This function is used to set the attribute value.
|
||||
**
|
||||
** Returns none.
|
||||
** Returns None.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gatts_set_attr_value(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg)
|
||||
|
@ -526,8 +526,23 @@ void bta_gatts_set_attr_value(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_
|
|||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gatts_get_attr_value
|
||||
**
|
||||
** Description This function retrieves the attribute value associated with
|
||||
** the given attribute handle.
|
||||
**
|
||||
** Returns tGATT_STATUS - GATT status indicating success or failure in
|
||||
** retrieving the attribute value.
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
||||
tGATT_STATUS bta_gatts_get_attr_value(UINT16 attr_handle, UINT16 *length, UINT8 **value)
|
||||
{
|
||||
if (GATTS_GetAttributeValueInternal(attr_handle, length, value) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return GATTS_GetAttributeValue(attr_handle, length, value);
|
||||
}
|
||||
|
|
|
@ -473,10 +473,18 @@ tBTM_STATUS btm_ble_remove_resolving_list_entry(tBTM_SEC_DEV_REC *p_dev_rec)
|
|||
|
||||
tBTM_STATUS st = BTM_NO_RESOURCES;
|
||||
if (controller_get_interface()->supports_ble_privacy()) {
|
||||
#if CONTROLLER_RPA_LIST_ENABLE
|
||||
if (btsnd_hcic_ble_rm_device_resolving_list(p_dev_rec->ble.static_addr_type,
|
||||
p_dev_rec->ble.static_addr)) {
|
||||
st = BTM_CMD_STARTED;
|
||||
}
|
||||
#else
|
||||
// do nothing
|
||||
/* It will cause that scanner doesn't send scan request to advertiser
|
||||
* which has sent IRK to us and we have stored the IRK in controller.
|
||||
* It is a hardware limitation. The preliminary solution is not to
|
||||
* send key to the controller, but to resolve the random address in host. */
|
||||
#endif
|
||||
} else {
|
||||
UINT8 param[20] = {0};
|
||||
UINT8 *p = param;
|
||||
|
|
|
@ -781,7 +781,7 @@ tGATT_STATUS GATTS_SetAttributeValue(UINT16 attr_handle, UINT16 length, UINT8 *v
|
|||
**
|
||||
** Function GATTS_GetAttributeValue
|
||||
**
|
||||
** Description This function sends to set the attribute value .
|
||||
** Description This function sends to get the attribute value .
|
||||
**
|
||||
** Parameter attr_handle: the attribute handle
|
||||
** length:the attribute value length in the database
|
||||
|
@ -807,6 +807,26 @@ tGATT_STATUS GATTS_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 *
|
|||
status = gatts_get_attribute_value(&p_decl->svc_db, attr_handle, length, value);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GATTS_GetAttributeValueInternal
|
||||
**
|
||||
** Description This function sends to get the attribute value of internal gatt and gap service.
|
||||
**
|
||||
** Parameter attr_handle: the attribute handle
|
||||
** length:the attribute value length in the database
|
||||
** value: the attribute value out put
|
||||
*
|
||||
**
|
||||
** Returns tGATT_STATUS - GATT status indicating success or failure in
|
||||
** retrieving the attribute value.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tGATT_STATUS GATTS_GetAttributeValueInternal(UINT16 attr_handle, UINT16 *length, UINT8 **value)
|
||||
{
|
||||
return gatts_get_attr_value_internal(attr_handle, length, value);
|
||||
}
|
||||
#endif ///GATTS_INCLUDED == TRUE
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#define BLE_GATT_CL_SUPP_FEAT_BITMASK 0x07
|
||||
|
||||
#define GATTP_MAX_NUM_INC_SVR 0
|
||||
#define GATTP_MAX_CHAR_NUM 4
|
||||
#define GATTP_MAX_CHAR_NUM 5
|
||||
#define GATTP_MAX_ATTR_NUM (GATTP_MAX_CHAR_NUM * 2 + GATTP_MAX_NUM_INC_SVR + 1)
|
||||
#define GATTP_MAX_CHAR_VALUE_SIZE 50
|
||||
|
||||
|
@ -205,18 +205,6 @@ tGATT_STATUS gatt_proc_read (UINT16 conn_id, tGATTS_REQ_TYPE type, tGATT_READ_RE
|
|||
|
||||
p_rsp->attr_value.handle = p_data->handle;
|
||||
|
||||
/* handle request for reading service changed */
|
||||
if (p_data->handle == gatt_cb.handle_of_h_r) {
|
||||
status = GATTS_GetAttributeValue(p_data->handle, &len, &value);
|
||||
if(status == GATT_SUCCESS && len > 0 && value) {
|
||||
if(len > GATT_MAX_ATTR_LEN) {
|
||||
len = GATT_MAX_ATTR_LEN;
|
||||
}
|
||||
p_rsp->attr_value.len = len;
|
||||
memcpy(p_rsp->attr_value.value, value, len);
|
||||
}
|
||||
}
|
||||
|
||||
/* handle request for reading client supported features */
|
||||
if (p_data->handle == gatt_cb.handle_of_cl_supported_feat) {
|
||||
if (tcb == NULL) {
|
||||
|
@ -224,7 +212,7 @@ tGATT_STATUS gatt_proc_read (UINT16 conn_id, tGATTS_REQ_TYPE type, tGATT_READ_RE
|
|||
}
|
||||
p_rsp->attr_value.len = 1;
|
||||
memcpy(p_rsp->attr_value.value, &tcb->cl_supp_feat, 1);
|
||||
status = GATT_SUCCESS;
|
||||
return GATT_SUCCESS;
|
||||
}
|
||||
|
||||
/* handle request for reading database hash */
|
||||
|
@ -232,16 +220,25 @@ tGATT_STATUS gatt_proc_read (UINT16 conn_id, tGATTS_REQ_TYPE type, tGATT_READ_RE
|
|||
p_rsp->attr_value.len = BT_OCTET16_LEN;
|
||||
memcpy(p_rsp->attr_value.value, gatt_cb.database_hash, BT_OCTET16_LEN);
|
||||
gatt_sr_update_cl_status(tcb, true);
|
||||
status = GATT_SUCCESS;
|
||||
return GATT_SUCCESS;
|
||||
}
|
||||
|
||||
/* handle request for reading server supported features */
|
||||
if (p_data->handle == gatt_cb.handle_of_sr_supported_feat) {
|
||||
p_rsp->attr_value.len = 1;
|
||||
memcpy(p_rsp->attr_value.value, &gatt_cb.gatt_sr_supported_feat_mask, 1);
|
||||
status = GATT_SUCCESS;
|
||||
return GATT_SUCCESS;
|
||||
}
|
||||
|
||||
/* handle request for reading service changed des and the others */
|
||||
status = GATTS_GetAttributeValue(p_data->handle, &len, &value);
|
||||
if(status == GATT_SUCCESS && len > 0 && value) {
|
||||
if(len > GATT_MAX_ATTR_LEN) {
|
||||
len = GATT_MAX_ATTR_LEN;
|
||||
}
|
||||
p_rsp->attr_value.len = len;
|
||||
memcpy(p_rsp->attr_value.value, value, len);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
@ -780,7 +780,7 @@ tGATT_STATUS gatts_set_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
|
|||
** Returns Status of the operation.
|
||||
**
|
||||
*******************************************************************************/
|
||||
static tGATT_STATUS gatts_get_attr_value_internal(UINT16 attr_handle, UINT16 *length, UINT8 **value)
|
||||
tGATT_STATUS gatts_get_attr_value_internal(UINT16 attr_handle, UINT16 *length, UINT8 **value)
|
||||
{
|
||||
UINT8 i;
|
||||
tGATT_READ_REQ read_req;
|
||||
|
@ -788,6 +788,17 @@ static tGATT_STATUS gatts_get_attr_value_internal(UINT16 attr_handle, UINT16 *le
|
|||
tGATT_SR_REG *p_rcb = gatt_cb.sr_reg;
|
||||
UINT8 service_uuid[LEN_UUID_128] = {0};
|
||||
|
||||
if (length == NULL){
|
||||
GATT_TRACE_ERROR("gatts_get_attr_value_internal Fail:length is NULL.\n");
|
||||
return GATT_INVALID_PDU;
|
||||
}
|
||||
|
||||
if (value == NULL){
|
||||
GATT_TRACE_ERROR("gatts_get_attr_value_internal Fail:value is NULL.\n");
|
||||
*length = 0;
|
||||
return GATT_INVALID_PDU;
|
||||
}
|
||||
|
||||
// find the service by handle
|
||||
for (i = 0; i < GATT_MAX_SR_PROFILES; i++, p_rcb++) {
|
||||
if (p_rcb->in_use && p_rcb->s_hdl <= attr_handle && p_rcb->e_hdl >= attr_handle) {
|
||||
|
@ -868,10 +879,6 @@ tGATT_STATUS gatts_get_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
|
|||
return GATT_INVALID_PDU;
|
||||
}
|
||||
|
||||
if (gatts_get_attr_value_internal(attr_handle, length, value) == GATT_SUCCESS) {
|
||||
return GATT_SUCCESS;
|
||||
}
|
||||
|
||||
p_cur = (tGATT_ATTR16 *) p_db->p_attr_list;
|
||||
|
||||
while (p_cur != NULL) {
|
||||
|
|
|
@ -754,7 +754,7 @@ extern UINT16 gatts_add_char_descr (tGATT_SVC_DB *p_db, tGATT_PERM perm,
|
|||
|
||||
extern tGATT_STATUS gatts_set_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
|
||||
UINT16 length, UINT8 *value);
|
||||
|
||||
extern tGATT_STATUS gatts_get_attr_value_internal(UINT16 attr_handle, UINT16 *length, UINT8 **value);
|
||||
extern tGATT_STATUS gatts_get_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
|
||||
UINT16 *length, UINT8 **value);
|
||||
extern BOOLEAN gatts_is_auto_response(UINT16 attr_handle);
|
||||
|
|
|
@ -943,7 +943,7 @@ tGATT_STATUS GATTS_SetAttributeValue(UINT16 attr_handle, UINT16 length, UINT8 *v
|
|||
*******************************************************************************/
|
||||
tGATT_STATUS GATTS_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 **value);
|
||||
|
||||
|
||||
tGATT_STATUS GATTS_GetAttributeValueInternal(UINT16 attr_handle, UINT16 *length, UINT8 **value);
|
||||
|
||||
/*******************************************************************************/
|
||||
/* GATT Profile Client Functions */
|
||||
|
|
|
@ -977,7 +977,7 @@ esp_err_t esp_ble_hidd_dev_init(esp_hidd_dev_t *dev_p, const esp_hid_device_conf
|
|||
.queue_size = 5,
|
||||
.task_name = "ble_hidd_events",
|
||||
.task_priority = uxTaskPriorityGet(NULL),
|
||||
.task_stack_size = 2048,
|
||||
.task_stack_size = 4096,
|
||||
.task_core_id = tskNO_AFFINITY
|
||||
};
|
||||
ret = esp_event_loop_create(&event_task_args, &s_dev->event_loop_handle);
|
||||
|
|
Ładowanie…
Reference in New Issue