From 38945f54e1db90d2c6dfeb1a6ff0e913ac367c2c Mon Sep 17 00:00:00 2001 From: zwj Date: Thu, 22 Sep 2022 22:01:58 +0800 Subject: [PATCH 1/4] allow bluedroid host to report adv_ind separately --- components/bt/host/bluedroid/Kconfig.in | 2 +- .../bt/host/bluedroid/stack/btm/btm_ble_gap.c | 29 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/components/bt/host/bluedroid/Kconfig.in b/components/bt/host/bluedroid/Kconfig.in index 276f818858f..8311b07db56 100644 --- a/components/bt/host/bluedroid/Kconfig.in +++ b/components/bt/host/bluedroid/Kconfig.in @@ -1023,7 +1023,7 @@ config BT_SMP_ENABLE config BT_BLE_ACT_SCAN_REP_ADV_SCAN bool "Report adv data and scan response individually when BLE active scan" - depends on BT_BLUEDROID_ENABLED && (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY) + depends on BT_BLUEDROID_ENABLED && BT_BLE_ENABLED default n help Originally, when doing BLE active scan, Bluedroid will not report adv to application layer 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 2b17741b399..f8624b3f1bf 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c @@ -3673,21 +3673,20 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt 0x04 Scan Response (SCAN_RSP) 0x05-0xFF Reserved for future use */ - //if scan duplicate is enabled, the adv packet without scan response is allowed to report to higher layer - if(p_le_inq_cb->scan_duplicate_filter == BTM_BLE_SCAN_DUPLICATE_ENABLE) { - /* - Bluedroid will put the advertising packet and scan response into a packet and send it to the higher layer. - If two advertising packets are not with the same address, or can't be combined into a packet, then the first advertising - packet will be discarded. So we added the following judgment: - 1. For different addresses, send the last advertising packet to higher layer - 2. For same address and same advertising type (not scan response), send the last advertising packet to higher layer - 3. For same address and scan response, do nothing - */ - int same_addr = memcmp(bda, p_le_inq_cb->adv_addr, BD_ADDR_LEN); - if (same_addr != 0 || (same_addr == 0 && evt_type != BTM_BLE_SCAN_RSP_EVT)) { - btm_ble_process_last_adv_pkt(); - } - } + // The adv packet without scan response is allowed to report to higher layer + /* + Bluedroid will put the advertising packet and scan response into a packet and send it to the higher layer. + If two advertising packets are not with the same address, or can't be combined into a packet, then the first advertising + packet will be discarded. So we added the following judgment: + 1. For different addresses, send the last advertising packet to higher layer + 2. For same address and same advertising type (not scan response), send the last advertising packet to higher layer + 3. For same address and scan response, do nothing + */ + int same_addr = memcmp(bda, p_le_inq_cb->adv_addr, BD_ADDR_LEN); + if (same_addr != 0 || (same_addr == 0 && evt_type != BTM_BLE_SCAN_RSP_EVT)) { + btm_ble_process_last_adv_pkt(); + } + p_i = btm_inq_db_find (bda); From 858b869bb63b4595d4b5daa01cd2ea58dc367155 Mon Sep 17 00:00:00 2001 From: zwj Date: Fri, 30 Sep 2022 15:07:24 +0800 Subject: [PATCH 2/4] Fixed ESP32 BLE assert(32 0) --- 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 eac5f091636..6ca6561fe52 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit eac5f0916361e7809af4b65144a8a7f0cc44b9c8 +Subproject commit 6ca6561fe525171cbb96eb9d98b7db91137982dc From 8005e6f0d5962c076790f221e080c81fd4182141 Mon Sep 17 00:00:00 2001 From: zhiweijian Date: Mon, 24 Oct 2022 19:51:34 +0800 Subject: [PATCH 3/4] Fixed BLE lld_per_adv.c line 401 assert on esp32c3 --- 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 83020b58a19..25bc757fd09 160000 --- a/components/bt/controller/lib_esp32c3_family +++ b/components/bt/controller/lib_esp32c3_family @@ -1 +1 @@ -Subproject commit 83020b58a19cae4ebf3d231755027100952d2fa5 +Subproject commit 25bc757fd0933e2d5dd448ca29db3d3136debe78 From 2dfdea8b5022dae4a7f1139f4fa62ce77803ad49 Mon Sep 17 00:00:00 2001 From: zhiweijian Date: Mon, 24 Oct 2022 20:10:48 +0800 Subject: [PATCH 4/4] update ble tx power level mapping --- components/bt/controller/esp32c3/Kconfig.in | 36 +++++++++---------- .../bt/include/esp32c3/include/esp_bt.h | 32 ++++++++--------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/components/bt/controller/esp32c3/Kconfig.in b/components/bt/controller/esp32c3/Kconfig.in index 9d15c45359c..6465e9236ff 100644 --- a/components/bt/controller/esp32c3/Kconfig.in +++ b/components/bt/controller/esp32c3/Kconfig.in @@ -138,8 +138,6 @@ choice BT_CTRL_DFT_TX_POWER_LEVEL help Specify default Tx power level - config BT_CTRL_DFT_TX_POWER_LEVEL_N27 - bool "-27dBm" config BT_CTRL_DFT_TX_POWER_LEVEL_N24 bool "-24dBm" config BT_CTRL_DFT_TX_POWER_LEVEL_N21 @@ -170,26 +168,28 @@ choice BT_CTRL_DFT_TX_POWER_LEVEL bool "+15dBm" config BT_CTRL_DFT_TX_POWER_LEVEL_P18 bool "+18dBm" + config BT_CTRL_DFT_TX_POWER_LEVEL_P21 + bool "+21dBm" endchoice config BT_CTRL_DFT_TX_POWER_LEVEL_EFF int - default 0 if BT_CTRL_DFT_TX_POWER_LEVEL_N27 - default 1 if BT_CTRL_DFT_TX_POWER_LEVEL_N24 - default 2 if BT_CTRL_DFT_TX_POWER_LEVEL_N21 - default 3 if BT_CTRL_DFT_TX_POWER_LEVEL_N18 - default 4 if BT_CTRL_DFT_TX_POWER_LEVEL_N15 - default 5 if BT_CTRL_DFT_TX_POWER_LEVEL_N12 - default 6 if BT_CTRL_DFT_TX_POWER_LEVEL_N9 - default 7 if BT_CTRL_DFT_TX_POWER_LEVEL_N6 - default 8 if BT_CTRL_DFT_TX_POWER_LEVEL_N3 - default 9 if BT_CTRL_DFT_TX_POWER_LEVEL_N0 - default 10 if BT_CTRL_DFT_TX_POWER_LEVEL_P3 - default 11 if BT_CTRL_DFT_TX_POWER_LEVEL_P6 - default 12 if BT_CTRL_DFT_TX_POWER_LEVEL_P9 - default 13 if BT_CTRL_DFT_TX_POWER_LEVEL_P12 - default 14 if BT_CTRL_DFT_TX_POWER_LEVEL_P15 - default 15 if BT_CTRL_DFT_TX_POWER_LEVEL_P18 + default 0 if BT_CTRL_DFT_TX_POWER_LEVEL_N24 + default 1 if BT_CTRL_DFT_TX_POWER_LEVEL_N21 + default 2 if BT_CTRL_DFT_TX_POWER_LEVEL_N18 + default 3 if BT_CTRL_DFT_TX_POWER_LEVEL_N15 + default 4 if BT_CTRL_DFT_TX_POWER_LEVEL_N12 + default 5 if BT_CTRL_DFT_TX_POWER_LEVEL_N9 + default 6 if BT_CTRL_DFT_TX_POWER_LEVEL_N6 + default 7 if BT_CTRL_DFT_TX_POWER_LEVEL_N3 + default 8 if BT_CTRL_DFT_TX_POWER_LEVEL_N0 + default 9 if BT_CTRL_DFT_TX_POWER_LEVEL_P3 + default 10 if BT_CTRL_DFT_TX_POWER_LEVEL_P6 + default 11 if BT_CTRL_DFT_TX_POWER_LEVEL_P9 + default 12 if BT_CTRL_DFT_TX_POWER_LEVEL_P12 + default 13 if BT_CTRL_DFT_TX_POWER_LEVEL_P15 + default 14 if BT_CTRL_DFT_TX_POWER_LEVEL_P18 + default 15 if BT_CTRL_DFT_TX_POWER_LEVEL_P21 default 0 config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP diff --git a/components/bt/include/esp32c3/include/esp_bt.h b/components/bt/include/esp32c3/include/esp_bt.h index 6250979e94d..0b73f0ba3d1 100644 --- a/components/bt/include/esp32c3/include/esp_bt.h +++ b/components/bt/include/esp32c3/include/esp_bt.h @@ -290,22 +290,22 @@ typedef enum { * @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm). */ typedef enum { - ESP_PWR_LVL_N27 = 0, /*!< Corresponding to -27dbm */ - ESP_PWR_LVL_N24 = 1, /*!< Corresponding to -24dbm */ - ESP_PWR_LVL_N21 = 2, /*!< Corresponding to -21dbm */ - ESP_PWR_LVL_N18 = 3, /*!< Corresponding to -18dbm */ - ESP_PWR_LVL_N15 = 4, /*!< Corresponding to -15dbm */ - ESP_PWR_LVL_N12 = 5, /*!< Corresponding to -12dbm */ - ESP_PWR_LVL_N9 = 6, /*!< Corresponding to -9dbm */ - ESP_PWR_LVL_N6 = 7, /*!< Corresponding to -6dbm */ - ESP_PWR_LVL_N3 = 8, /*!< Corresponding to -3dbm */ - ESP_PWR_LVL_N0 = 9, /*!< Corresponding to 0dbm */ - ESP_PWR_LVL_P3 = 10, /*!< Corresponding to +3dbm */ - ESP_PWR_LVL_P6 = 11, /*!< Corresponding to +6dbm */ - ESP_PWR_LVL_P9 = 12, /*!< Corresponding to +9dbm */ - ESP_PWR_LVL_P12 = 13, /*!< Corresponding to +12dbm */ - ESP_PWR_LVL_P15 = 14, /*!< Corresponding to +15dbm */ - ESP_PWR_LVL_P18 = 15, /*!< Corresponding to +18dbm */ + ESP_PWR_LVL_N24 = 0, /*!< Corresponding to -24dbm */ + ESP_PWR_LVL_N21 = 1, /*!< Corresponding to -21dbm */ + ESP_PWR_LVL_N18 = 2, /*!< Corresponding to -18dbm */ + ESP_PWR_LVL_N15 = 3, /*!< Corresponding to -15dbm */ + ESP_PWR_LVL_N12 = 4, /*!< Corresponding to -12dbm */ + ESP_PWR_LVL_N9 = 5, /*!< Corresponding to -9dbm */ + ESP_PWR_LVL_N6 = 6, /*!< Corresponding to -6dbm */ + ESP_PWR_LVL_N3 = 7, /*!< Corresponding to -3dbm */ + ESP_PWR_LVL_N0 = 8, /*!< Corresponding to 0dbm */ + ESP_PWR_LVL_P3 = 9, /*!< Corresponding to +3dbm */ + ESP_PWR_LVL_P6 = 10, /*!< Corresponding to +6dbm */ + ESP_PWR_LVL_P9 = 11, /*!< Corresponding to +9dbm */ + ESP_PWR_LVL_P12 = 12, /*!< Corresponding to +12dbm */ + ESP_PWR_LVL_P15 = 13, /*!< Corresponding to +15dbm */ + ESP_PWR_LVL_P18 = 14, /*!< Corresponding to +18dbm */ + ESP_PWR_LVL_P21 = 15, /*!< Corresponding to +21dbm */ ESP_PWR_LVL_INVALID = 0xFF, /*!< Indicates an invalid value */ } esp_power_level_t;