From 304deb005d13128d5907e7ef85df94d2fa56abf3 Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Wed, 17 May 2023 12:18:33 +0800 Subject: [PATCH 1/5] esp_hid: fixed ble hid battery level setting --- components/esp_hid/src/ble_hidd.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/components/esp_hid/src/ble_hidd.c b/components/esp_hid/src/ble_hidd.c index f3e1a97b39..5b8c980366 100644 --- a/components/esp_hid/src/ble_hidd.c +++ b/components/esp_hid/src/ble_hidd.c @@ -834,12 +834,14 @@ static esp_err_t esp_ble_hidd_dev_battery_set(void *devp, uint8_t level) return ESP_OK; } - ret = esp_ble_gatts_send_indicate(dev->bat_svc.gatt_if, dev->conn_id, dev->bat_level_handle, 1, &dev->bat_level, dev->bat_ccc.indicate_enable); - if (ret) { - ESP_LOGE(TAG, "esp_ble_gatts_send_indicate failed: %d", ret); - return ESP_FAIL; + if (dev->bat_ccc.notify_enable) { + ret = esp_ble_gatts_send_indicate(dev->bat_svc.gatt_if, dev->conn_id, dev->bat_level_handle, 1, &dev->bat_level, false); + if (ret) { + ESP_LOGE(TAG, "esp_ble_gatts_send_notify failed: %d", ret); + return ESP_FAIL; + } } - WAIT_CB(dev); + return ESP_OK; } From 8aad58043154430309bcd9753678a0f10ee021c5 Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Thu, 1 Jun 2023 17:37:20 +0800 Subject: [PATCH 2/5] bluedroid: fixed default extended connection params --- .../bt/host/bluedroid/stack/l2cap/l2c_ble.c | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c b/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c index 80415d04ae..e485f70e49 100644 --- a/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c +++ b/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c @@ -35,11 +35,35 @@ #if (BLE_INCLUDED == TRUE) #if (BLE_50_FEATURE_SUPPORT == TRUE) -const tHCI_ExtConnParams ext_conn_params = { +#define EXT_CONN_INT_DEF_1M MAX(((MAX_ACL_CONNECTIONS + 1) * 4), 12) +#define EXT_CONN_INT_DEF_2M MAX(((MAX_ACL_CONNECTIONS + 1) * 2), 12) +#define EXT_CONN_INT_DEF_CODED (320) // 306-> 362Kbps + +const static tHCI_ExtConnParams ext_conn_params_1m_phy = { .scan_interval = 0x40, .scan_window = 0x40, - .conn_interval_min = 320, // 306-> 362Kbps - .conn_interval_max = 320, + .conn_interval_min = EXT_CONN_INT_DEF_1M, + .conn_interval_max = EXT_CONN_INT_DEF_1M, + .conn_latency = 0, + .sup_timeout = 600, + .min_ce_len = 0, + .max_ce_len = 0, +}; +const static tHCI_ExtConnParams ext_conn_params_2m_phy = { + .scan_interval = 0x40, + .scan_window = 0x40, + .conn_interval_min = EXT_CONN_INT_DEF_2M, + .conn_interval_max = EXT_CONN_INT_DEF_2M, + .conn_latency = 0, + .sup_timeout = 600, + .min_ce_len = 0, + .max_ce_len = 0, +}; +const static tHCI_ExtConnParams ext_conn_params_coded_phy = { + .scan_interval = 0x40, + .scan_window = 0x40, + .conn_interval_min = EXT_CONN_INT_DEF_CODED, + .conn_interval_max = EXT_CONN_INT_DEF_CODED, .conn_latency = 0, .sup_timeout = 600, .min_ce_len = 0, @@ -929,9 +953,9 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb) if (p_dev_rec->ext_conn_params.phy_mask == BLE_PHY_NO_PREF) { L2CAP_TRACE_WARNING("No extend connection parameters set, use default parameters"); aux_conn.init_phy_mask = BLE_PHY_PREF_MASK; - memcpy(&aux_conn.params[0], &ext_conn_params, sizeof(tHCI_ExtConnParams)); - memcpy(&aux_conn.params[1], &ext_conn_params, sizeof(tHCI_ExtConnParams)); - memcpy(&aux_conn.params[2], &ext_conn_params, sizeof(tHCI_ExtConnParams)); + memcpy(&aux_conn.params[0], &ext_conn_params_1m_phy, sizeof(tHCI_ExtConnParams)); + memcpy(&aux_conn.params[1], &ext_conn_params_2m_phy, sizeof(tHCI_ExtConnParams)); + memcpy(&aux_conn.params[2], &ext_conn_params_coded_phy, sizeof(tHCI_ExtConnParams)); } else { aux_conn.init_phy_mask = p_dev_rec->ext_conn_params.phy_mask; memcpy(&aux_conn.params[0], &p_dev_rec->ext_conn_params.phy_1m_conn_params, sizeof(tHCI_ExtConnParams)); From bff2748b35dba5d7f230fcb8edf919b56e4d19d7 Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Fri, 16 Jun 2023 17:55:44 +0800 Subject: [PATCH 3/5] Revert "bluedroid: report disconnect event after BLE link closed" This reverts commit a7c1fd9f609657fc4829928eb06c37adc9ab2bb3. --- .../bt/host/bluedroid/bta/dm/bta_dm_act.c | 2 +- .../bluedroid/stack/include/stack/l2c_api.h | 13 -------- .../bt/host/bluedroid/stack/l2cap/l2c_api.c | 30 ------------------- 3 files changed, 1 insertion(+), 44 deletions(-) diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c index 172c48af1b..78973718ed 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c @@ -5057,7 +5057,7 @@ void bta_dm_ble_update_conn_params (tBTA_DM_MSG *p_data) *******************************************************************************/ void bta_dm_ble_disconnect (tBTA_DM_MSG *p_data) { - L2CA_BleDisconnect(p_data->ble_disconnect.remote_bda); + L2CA_RemoveFixedChnl(L2CAP_ATT_CID, p_data->ble_disconnect.remote_bda); } /******************************************************************************* diff --git a/components/bt/host/bluedroid/stack/include/stack/l2c_api.h b/components/bt/host/bluedroid/stack/include/stack/l2c_api.h index dc942f2310..58d2a13797 100644 --- a/components/bt/host/bluedroid/stack/include/stack/l2c_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/l2c_api.h @@ -1211,19 +1211,6 @@ extern BOOLEAN L2CA_EnableUpdateBleConnParams (BD_ADDR rem_bda, BOOLEAN enable); ** *******************************************************************************/ extern UINT8 L2CA_GetBleConnRole (BD_ADDR bd_addr); - -/******************************************************************************* -** -** Function L2CA_BleDisconnect -** -** Description This function use to disconnect LE connection. -** -** Parameters BD Address of remote -** -** Returns TRUE if disconnect successfully. -** -*******************************************************************************/ -extern BOOLEAN L2CA_BleDisconnect (BD_ADDR rem_bda); #endif /* (BLE_INCLUDED == TRUE) */ /******************************************************************************* diff --git a/components/bt/host/bluedroid/stack/l2cap/l2c_api.c b/components/bt/host/bluedroid/stack/l2cap/l2c_api.c index bdd8cb8601..2db8fd539d 100644 --- a/components/bt/host/bluedroid/stack/l2cap/l2c_api.c +++ b/components/bt/host/bluedroid/stack/l2cap/l2c_api.c @@ -1949,36 +1949,6 @@ BOOLEAN L2CA_RemoveFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda) return (TRUE); } -#if BLE_INCLUDED == TRUE -BOOLEAN L2CA_BleDisconnect (BD_ADDR rem_bda) -{ - tL2C_LCB *p_lcb; - tGATT_TCB *p_tcb; - - p_lcb = l2cu_find_lcb_by_bd_addr (rem_bda, BT_TRANSPORT_LE); - if (p_lcb == NULL) { - return FALSE; - } - - if (p_lcb->link_state != LST_CONNECTED) { - return FALSE; - } - - p_lcb->disc_reason = HCI_ERR_CONN_CAUSE_LOCAL_HOST; - p_lcb->link_state = LST_DISCONNECTING; - btsnd_hcic_disconnect (p_lcb->handle, HCI_ERR_PEER_USER); - - p_tcb = gatt_find_tcb_by_addr(rem_bda, BT_TRANSPORT_LE); - if (p_tcb == NULL) { - return FALSE; - } - - gatt_set_ch_state(p_tcb, GATT_CH_CLOSING); - - return TRUE; -} -#endif - /******************************************************************************* ** ** Function L2CA_SetFixedChannelTout From ea39667b844761c11a589ba21cc2ae0c52ebd020 Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Fri, 16 Jun 2023 18:02:30 +0800 Subject: [PATCH 4/5] Fixed crash when controller initialization fails due to insufficient memory --- components/bt/controller/lib_esp32c3_family | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/controller/lib_esp32c3_family b/components/bt/controller/lib_esp32c3_family index b3a4d45b03..a6828c0d52 160000 --- a/components/bt/controller/lib_esp32c3_family +++ b/components/bt/controller/lib_esp32c3_family @@ -1 +1 @@ -Subproject commit b3a4d45b039e740ff5d40bbba884902d117723cd +Subproject commit a6828c0d52130382d0e6f98a2363a8ead2334251 From 7c916516a87162f03ca620a69e5e0d43acc98382 Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Sun, 11 Jun 2023 11:42:36 +0800 Subject: [PATCH 5/5] Update bt-lib for esp32 1 Fixed disconnection delay on peripheral when slave latency is not zero 2 Fixed LLCP info init for central and peripheral 3 Fixed sent cmd status evt twice when process disconnect cmd --- components/bt/controller/lib_esp32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/controller/lib_esp32 b/components/bt/controller/lib_esp32 index 26b2361bf7..7c757d49c4 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit 26b2361bf7569eb46b68eebdf9f634ef4ed17660 +Subproject commit 7c757d49c407e31c50d17c0d917c65c95fe3b6cc