From a3717515a263db7896c21e3fd1a97bf794b9d1ca Mon Sep 17 00:00:00 2001 From: island Date: Tue, 18 Apr 2017 15:23:38 +0800 Subject: [PATCH] component/bt: Fix memory leakage, connection fail bugs - Fix memory leakage while deregisting gatt app - Fix Android connection failed problem - Fix service_uuid_len error in adv data --- components/bt/bluedroid/include/bt_target.h | 2 +- components/bt/bluedroid/stack/btm/btm_acl.c | 10 ++++++---- components/bt/bluedroid/stack/gatt/gatt_utils.c | 1 + .../main/gatts_table_creat_demo.c | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/components/bt/bluedroid/include/bt_target.h b/components/bt/bluedroid/include/bt_target.h index e684a0ecf4..21fa74ce2f 100644 --- a/components/bt/bluedroid/include/bt_target.h +++ b/components/bt/bluedroid/include/bt_target.h @@ -687,7 +687,7 @@ /* The maximum number of simultaneous links that L2CAP can support. Up to 7*/ #ifndef MAX_ACL_CONNECTIONS -#define MAX_L2CAP_LINKS 3 +#define MAX_L2CAP_LINKS 5 #else #define MAX_L2CAP_LINKS MAX_ACL_CONNECTIONS #endif diff --git a/components/bt/bluedroid/stack/btm/btm_acl.c b/components/bt/bluedroid/stack/btm/btm_acl.c index 269737447f..13a5f7baa6 100644 --- a/components/bt/bluedroid/stack/btm/btm_acl.c +++ b/components/bt/bluedroid/stack/btm/btm_acl.c @@ -300,13 +300,15 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn, &p->active_remote_addr_type); #endif - if (HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(controller_get_interface()->get_features_ble()->as_array) - && link_role == HCI_ROLE_MASTER) { - + if (link_role == HCI_ROLE_MASTER) { btsnd_hcic_ble_read_remote_feat(p->hci_handle); } else if (HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(controller_get_interface()->get_features_ble()->as_array) && link_role == HCI_ROLE_SLAVE) { - //do nothing in this case for fix the android7.0 cann't sent security request issue + /* In the original Bluedroid version, slave need to send LL_SLAVE_FEATURE_REQ(call btsnd_hcic_ble_read_remote_feat) + * to remote device if it has not received ll_feature_req. + * Delete it to resolve Android 7.0 incompatible problem. But it may cause that slave + * can't get remote device's feature if it doesn't receive ll_feature_req.*/ + l2cble_notify_le_connection(bda); } else { btm_establish_continue(p); } diff --git a/components/bt/bluedroid/stack/gatt/gatt_utils.c b/components/bt/bluedroid/stack/gatt/gatt_utils.c index fb8d51aec2..a43f4ad32e 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_utils.c +++ b/components/bt/bluedroid/stack/gatt/gatt_utils.c @@ -458,6 +458,7 @@ void gatt_free_srvc_db_buffer_app_id(tBT_UUID *p_app_id) for (i = 0; i < GATT_MAX_SR_PROFILES; i ++, p_elem ++) { if (memcmp(p_app_id, &p_elem->asgn_range.app_uuid128, sizeof(tBT_UUID)) == 0) { + gatt_free_attr_value_buffer(p_elem); while (!GKI_queue_is_empty(&p_elem->svc_db.svc_buffer)) { GKI_freebuf (GKI_dequeue (&p_elem->svc_db.svc_buffer)); } diff --git a/examples/bluetooth/gatt_server_service_table/main/gatts_table_creat_demo.c b/examples/bluetooth/gatt_server_service_table/main/gatts_table_creat_demo.c index 291d9f5941..c23bd6383c 100644 --- a/examples/bluetooth/gatt_server_service_table/main/gatts_table_creat_demo.c +++ b/examples/bluetooth/gatt_server_service_table/main/gatts_table_creat_demo.c @@ -70,7 +70,7 @@ static esp_ble_adv_data_t heart_rate_adv_config = { .p_manufacturer_data = NULL, //&test_manufacturer[0], .service_data_len = 0, .p_service_data = NULL, - .service_uuid_len = 32, + .service_uuid_len = sizeof(heart_rate_service_uuid), .p_service_uuid = heart_rate_service_uuid, .flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT), };