From b345e89b4a9474e4b00d92fdc99abc6a91255521 Mon Sep 17 00:00:00 2001 From: cjin Date: Thu, 25 Aug 2022 21:15:35 +0800 Subject: [PATCH 1/4] fix on data len change cmd malfunction --- components/bt/host/bluedroid/stack/btm/btm_ble_gap.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c index 329ecd3e60..2b17741b39 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c @@ -4301,10 +4301,11 @@ void btm_ble_read_remote_features_complete(UINT8 *p) btsnd_hcic_rmt_ver_req (p_acl_cb->hci_handle); } else{ + uint16_t data_length = controller_get_interface()->get_ble_default_data_packet_length(); + uint16_t data_txtime = controller_get_interface()->get_ble_default_data_packet_txtime(); if (p_acl_cb->transport == BT_TRANSPORT_LE) { - if (HCI_LE_DATA_LEN_EXT_SUPPORTED(p_acl_cb->peer_le_features)) { - uint16_t data_length = controller_get_interface()->get_ble_default_data_packet_length(); - uint16_t data_txtime = controller_get_interface()->get_ble_default_data_packet_txtime(); + if (HCI_LE_DATA_LEN_EXT_SUPPORTED(p_acl_cb->peer_le_features) && + (p_acl_cb->data_length_params.tx_len != data_length)) { p_acl_cb->data_len_updating = true; btsnd_hcic_ble_set_data_length(p_acl_cb->hci_handle, data_length, data_txtime); } From 872baad9b9971ec1986516a8f51cd2514ae8d89d Mon Sep 17 00:00:00 2001 From: cjin Date: Thu, 25 Aug 2022 21:16:04 +0800 Subject: [PATCH 2/4] mbuf copy hci data error fix --- components/bt/controller/esp32c2/bt.c | 6 ++---- components/bt/host/bluedroid/hci/hci_hal_h4.c | 15 +++++---------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index 1b42a55ffa..70867dc47a 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -307,11 +307,9 @@ void esp_vhci_host_send_packet(uint8_t *data, uint16_t len) } if (*(data) == DATA_TYPE_ACL) { - struct os_mbuf *om = os_msys_get_pkthdr(0, ACL_DATA_MBUF_LEADINGSPCAE); + struct os_mbuf *om = os_msys_get_pkthdr(len, ACL_DATA_MBUF_LEADINGSPCAE); assert(om); - memcpy(om->om_data, &data[1], len - 1); - om->om_len = len - 1; - OS_MBUF_PKTHDR(om)->omp_len = len - 1; + os_mbuf_append(om, &data[1], len - 1); ble_hci_trans_hs_acl_tx(om); } diff --git a/components/bt/host/bluedroid/hci/hci_hal_h4.c b/components/bt/host/bluedroid/hci/hci_hal_h4.c index b99bd429e5..1bf02aa1e3 100644 --- a/components/bt/host/bluedroid/hci/hci_hal_h4.c +++ b/components/bt/host/bluedroid/hci/hci_hal_h4.c @@ -598,7 +598,7 @@ ble_hs_hci_rx_evt(uint8_t *hci_ev, void *arg) if(esp_bluedroid_get_status() == ESP_BLUEDROID_STATUS_UNINITIALIZED) { return 0; } - uint8_t len = hci_ev[1] + 3; + uint16_t len = hci_ev[1] + 3; uint8_t *data = (uint8_t *)malloc(len); data[0] = 0x04; memcpy(&data[1], hci_ev, len - 1); @@ -608,22 +608,17 @@ ble_hs_hci_rx_evt(uint8_t *hci_ev, void *arg) return 0; } -static void *trans_om; -void hci_trans_free_mbuf(void) -{ - os_mbuf_free_chain(trans_om); -} + int ble_hs_rx_data(struct os_mbuf *om, void *arg) { - uint8_t len = om->om_len + 1; + uint16_t len = om->om_len + 1; uint8_t *data = (uint8_t *)malloc(len); data[0] = 0x02; - memcpy(&data[1], om->om_data, len - 1); + os_mbuf_copydata(om, 0, len - 1, &data[1]); host_recv_pkt_cb(data, len); - trans_om = om; free(data); - hci_trans_free_mbuf(); + os_mbuf_free_chain(om); return 0; } From 42a07cf16b4adf7ad2e6164f239ff128332c7119 Mon Sep 17 00:00:00 2001 From: cjin Date: Thu, 8 Sep 2022 15:44:31 +0800 Subject: [PATCH 3/4] fix err using rpa for confirmation calculation --- components/bt/host/bluedroid/stack/btm/btm_ble.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble.c b/components/bt/host/bluedroid/stack/btm/btm_ble.c index 6cac0fd793..962a3ef961 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble.c @@ -1990,7 +1990,7 @@ void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced) } #if (BLE_PRIVACY_SPT == TRUE ) peer_addr_type = bda_type; - match = btm_identity_addr_to_random_pseudo (bda, &bda_type, TRUE); + match = btm_identity_addr_to_random_pseudo (bda, &bda_type, FALSE); /* possiblly receive connection complete with resolvable random on slave role while the device has been paired */ From 8e348c3f63dc3f66734331040a522c61ea6dafe5 Mon Sep 17 00:00:00 2001 From: cjin Date: Tue, 6 Sep 2022 21:35:51 +0800 Subject: [PATCH 4/4] update ble controller lib for bugfix on esp32c2 --- components/bt/controller/lib_esp32c2/esp32c2-bt-lib | 2 +- components/bt/include/esp32c2/include/esp_bt.h | 2 +- components/esp_rom/esp32c2/ld/esp32c2.rom.ld | 11 ----------- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib index 09e1db0eec..c039a68dcf 160000 --- a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib +++ b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib @@ -1 +1 @@ -Subproject commit 09e1db0eec6bc41d1742c9ab3ebba3884f9277f1 +Subproject commit c039a68dcf49082c37318568b2e147b61265e772 diff --git a/components/bt/include/esp32c2/include/esp_bt.h b/components/bt/include/esp32c2/include/esp_bt.h index a428321f11..6489741282 100644 --- a/components/bt/include/esp32c2/include/esp_bt.h +++ b/components/bt/include/esp32c2/include/esp_bt.h @@ -145,7 +145,7 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type */ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle); -#define CONFIG_VERSION 0x20220729 +#define CONFIG_VERSION 0x20220824 #define CONFIG_MAGIC 0x5A5AA5A5 /** diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld index 531a345a01..6254205e5a 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld @@ -1137,7 +1137,6 @@ r_ble_lll_aux_scan_cb = 0x400014b8; r_ble_lll_aux_scan_drop = 0x400014bc; r_ble_lll_aux_scan_drop_event_cb = 0x400014c0; r_ble_lll_calc_us_convert_tick_unit = 0x400014c4; -r_ble_lll_conn_append_tx_buffer = 0x400014c8; r_ble_lll_conn_can_send_next_pdu = 0x400014cc; r_ble_lll_conn_check_opcode_matched = 0x400014d0; r_ble_lll_conn_coex_dpc_process = 0x400014d4; @@ -1172,7 +1171,6 @@ r_ble_lll_conn_reset_pending_sched = 0x4000155c; r_ble_lll_conn_rx_pkt_isr = 0x40001560; r_ble_lll_conn_sched_next_anchor = 0x40001564; r_ble_lll_conn_sched_next_event = 0x40001568; -r_ble_lll_conn_set_slave_flow_control = 0x4000156c; r_ble_lll_conn_sm_new = 0x40001574; r_ble_lll_conn_sm_npl_deinit = 0x40001578; r_ble_lll_conn_sm_npl_init = 0x4000157c; @@ -1224,21 +1222,13 @@ r_ble_lll_per_adv_coex_dpc_update_on_scheduled = 0x4000163c; r_ble_lll_per_adv_coex_dpc_update_on_start = 0x40001640; r_ble_lll_reset = 0x40001644; r_ble_lll_rfmgmt_controller_sleep_en = 0x40001648; -r_ble_lll_rfmgmt_deinit = 0x4000164c; -r_ble_lll_rfmgmt_disable = 0x40001650; -r_ble_lll_rfmgmt_enable = 0x40001654; r_ble_lll_rfmgmt_enable_now = 0x40001658; -r_ble_lll_rfmgmt_init = 0x4000165c; r_ble_lll_rfmgmt_is_enabled = 0x40001660; -r_ble_lll_rfmgmt_release = 0x40001664; r_ble_lll_rfmgmt_release_ev = 0x40001668; -r_ble_lll_rfmgmt_reset = 0x4000166c; r_ble_lll_rfmgmt_scan_changed = 0x40001670; r_ble_lll_rfmgmt_sched_changed = 0x40001674; r_ble_lll_rfmgmt_set_sleep_cb = 0x40001678; r_ble_lll_rfmgmt_ticks_to_enabled = 0x4000167c; -r_ble_lll_rfmgmt_timer_exp = 0x40001680; -r_ble_lll_rfmgmt_timer_reschedule = 0x40001684; r_ble_lll_rx_pdu_in = 0x40001688; r_ble_lll_rx_pkt_in = 0x4000168c; r_ble_lll_rx_pkt_isr = 0x40001690; @@ -1410,7 +1400,6 @@ r_get_peer_irk_offset = 0x40001958; r_get_peer_rpa_offset = 0x4000195c; r_hal_rtc_intr_init = 0x40001960; r_hal_rtc_irq_handler = 0x40001964; -r_hal_timer_deinit = 0x40001968; r_hal_timer_disable_irq = 0x4000196c; r_hal_timer_env_init = 0x40001970; r_hal_timer_process = 0x40001978;