]> granicus.if.org Git - esp-idf/commitdiff
compoent/bt:Fixed the BT/BLE statck bug from bluedroid7.1.1
authorYulong <huangyulong@espressif.com>
Fri, 28 Apr 2017 09:31:57 +0000 (05:31 -0400)
committerYulong <huangyulong@espressif.com>
Fri, 28 Apr 2017 09:31:57 +0000 (05:31 -0400)
components/bt/bluedroid/bta/dm/bta_dm_act.c
components/bt/bluedroid/bta/gatt/bta_gattc_act.c
components/bt/bluedroid/main/bte_main.c
components/bt/bluedroid/stack/btm/btm_dev.c
components/bt/bluedroid/stack/gatt/gatt_sr.c
components/bt/bluedroid/stack/include/btm_api.h
components/bt/bluedroid/stack/smp/smp_act.c

index cd0a7c4cc836afc6ec3019f25758a936bbdb4ff8..a3e5cf3d43210632bb0c921c561828684e54a0b4 100644 (file)
@@ -3414,6 +3414,7 @@ static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr)
             BTM_IsAclConnectionUp(remote_bd_addr, BT_TRANSPORT_BR_EDR)) {
         APPL_TRACE_DEBUG("%s ACL is not down. Schedule for  Dev Removal when ACL closes",
                          __FUNCTION__);
+        BTM_SecClearSecurityFlags (remote_bd_addr);
         for (index = 0; index < bta_dm_cb.device_list.count; index ++) {
             if (!bdcmp( bta_dm_cb.device_list.peer_device[index].peer_bdaddr, remote_bd_addr)) {
                 break;
index 41008cb2d6c0540a9c6406c46ba544e5b55afdd6..dbf490f8cc921084493e588ec973baaab460c33c 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "bta_gattc_int.h"
 #include "l2c_api.h"
+#include "l2c_int.h"
 
 #if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
 #include "bta_hh_int.h"
@@ -978,8 +979,11 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
     /* get any queued command to proceed */
     else if (p_q_cmd != NULL) {
         p_clcb->p_q_cmd = NULL;
-
-        bta_gattc_sm_execute(p_clcb, p_q_cmd->hdr.event, p_q_cmd);
+         /* execute pending operation of link block still present */
+        if (l2cu_find_lcb_by_bd_addr(p_clcb->p_srcb->server_bda, 
+            BT_TRANSPORT_LE) != NULL) {
+            bta_gattc_sm_execute(p_clcb, p_q_cmd->hdr.event, p_q_cmd);
+        }
         /* if the command executed requeued the cmd, we don't
          * want to free the underlying buffer that's being
          * referenced by p_clcb->p_q_cmd
index 1b74d558fdb9e34e0464fd1c97f9901ec8e30eda..6221983688031ec3596e51b74fb455e75c8587b0 100644 (file)
@@ -144,10 +144,6 @@ int bte_main_boot_entry(bluedroid_init_done_cb_t cb)
     //data_dispatcher_register_default(hci->event_dispatcher, btu_hci_msg_queue);
     hci->set_data_queue(btu_hci_msg_queue);
 
-#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
-    //bte_load_ble_conf(BTE_BLE_STACK_CONF_FILE);
-#endif
-
     //Enbale HCI
     bte_main_enable();
 
index cf445d1239c4c9cef61276e958e870f986d13533..b86f861a47f1576a586b21fca2f373d8b620568b 100644 (file)
@@ -196,6 +196,26 @@ BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr)
     return TRUE;
 }
 
+/*******************************************************************************
+**
+** Function         BTM_SecClearSecurityFlags
+**
+** Description      Reset the security flags (mark as not-paired) for a given
+**                  remove device.
+**
+*******************************************************************************/
+extern void BTM_SecClearSecurityFlags (BD_ADDR bd_addr)
+{
+    tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev(bd_addr);
+    if (p_dev_rec == NULL)
+        return;
+
+    p_dev_rec->sec_flags = 0;
+    p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
+    p_dev_rec->sm4 = BTM_SM4_UNKNOWN;
+}
+
+
 /*******************************************************************************
 **
 ** Function         BTM_SecReadDevName
index a35c3717c6c18f485976a67c341a89294b91d2bd..c22f6007184d284dae9ee93ab3b75ba9a8a38201 100644 (file)
@@ -1183,6 +1183,11 @@ void gatt_attr_process_prepare_write (tGATT_TCB *p_tcb, UINT8 i_rcb, UINT16 hand
     tGATT_PREPARE_WRITE_RECORD *prepare_record = NULL;
     memset(&sr_data, 0, sizeof(tGATTS_DATA));
 
+    if (len < 2) {
+        GATT_TRACE_ERROR("%s: Prepare write request was invalid - missing offset, sending error response", __func__);
+        gatt_send_error_rsp(p_tcb, GATT_INVALID_PDU, op_code, handle, FALSE);
+        return;
+    }
     //get offset from p_data
     STREAM_TO_UINT16(offset, p);
     len -= 2;
index 5f3d5e4227d9b25f8c646344a823065089cd15d2..5a0d6fa46bd91504e5a22bb878b6f323075c9709 100644 (file)
@@ -3691,6 +3691,17 @@ UINT8 *BTM_ReadOobData(UINT8 *p_data, UINT8 eir_tag, UINT8 *p_len);
 //extern
 char *BTM_SecReadDevName (BD_ADDR bd_addr);
 
+/*******************************************************************************
+**
+** Function         BTM_SecClearSecurityFlags
+**
+** Description      Reset the security flags (mark as not-paired) for a given
+**                  remove device.
+**
+*******************************************************************************/
+extern void BTM_SecClearSecurityFlags (BD_ADDR bd_addr);
+
+
 
 /*****************************************************************************
 **  POWER MANAGEMENT FUNCTIONS
index a3f0f9f0b15b2a9dae369405968832e20880d0f3..7dc09faeb01850e30862d292404420ec879c8146 100644 (file)
@@ -1362,8 +1362,6 @@ void smp_br_send_pair_response(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
 void smp_pairing_cmpl(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
 {
     if (p_cb->total_tx_unacked == 0) {
-        /* update connection parameter to remote preferred */
-        L2CA_EnableUpdateBleConnParams(p_cb->pairing_bda, TRUE);
         /* process the pairing complete */
         smp_proc_pairing_cmpl(p_cb);
     }
@@ -1401,7 +1399,10 @@ void smp_idle_terminate(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
 *******************************************************************************/
 void smp_fast_conn_param(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
 {
-    /* disable connection parameter update */
+    /* Disable L2CAP connection parameter updates while bonding since
+       some peripherals are not able to revert to fast connection parameters
+       during the start of service discovery. Connection paramter updates
+       get enabled again once service discovery completes. */
     L2CA_EnableUpdateBleConnParams(p_cb->pairing_bda, FALSE);
 }