From 5fff471b50a761f6a0b294a9784735f9e7ec342f Mon Sep 17 00:00:00 2001 From: zwj Date: Wed, 7 Dec 2022 11:37:22 +0800 Subject: [PATCH 1/7] Fixed some memory was not released after bluetooth controller initialization failed on ESP32 --- components/bt/controller/esp32/bt.c | 46 +++++++++++++---------------- components/bt/controller/lib_esp32 | 2 +- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/components/bt/controller/esp32/bt.c b/components/bt/controller/esp32/bt.c index 83f1011ae6..b9d1a31746 100644 --- a/components/bt/controller/esp32/bt.c +++ b/components/bt/controller/esp32/bt.c @@ -325,6 +325,7 @@ static void *customer_queue_create_hlevel_wrapper(uint32_t queue_len, uint32_t i #endif /* CONFIG_BTDM_CTRL_HLI */ static void interrupt_l3_disable(void); static void interrupt_l3_restore(void); +static void bt_controller_deinit_internal(void); /* Local variable definition *************************************************************************** @@ -1576,26 +1577,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) return ESP_OK; error: -#ifdef CONFIG_PM_ENABLE - if (!s_btdm_allow_light_sleep) { - if (s_light_sleep_pm_lock != NULL) { - esp_pm_lock_delete(s_light_sleep_pm_lock); - s_light_sleep_pm_lock = NULL; - } - } - if (s_pm_lock != NULL) { - esp_pm_lock_delete(s_pm_lock); - s_pm_lock = NULL; - } - if (s_btdm_slp_tmr != NULL) { - esp_timer_delete(s_btdm_slp_tmr); - s_btdm_slp_tmr = NULL; - } -#endif - if (s_wakeup_req_sem) { - semphr_delete_wrapper(s_wakeup_req_sem); - s_wakeup_req_sem = NULL; - } + + bt_controller_deinit_internal(); + return err; } @@ -1607,6 +1591,13 @@ esp_err_t esp_bt_controller_deinit(void) btdm_controller_deinit(); + bt_controller_deinit_internal(); + + return ESP_OK; +} + +static void bt_controller_deinit_internal(void) +{ periph_module_disable(PERIPH_BT_MODULE); #ifdef CONFIG_PM_ENABLE @@ -1628,11 +1619,16 @@ esp_err_t esp_bt_controller_deinit(void) s_pm_lock_acquired = false; #endif - semphr_delete_wrapper(s_wakeup_req_sem); - s_wakeup_req_sem = NULL; - free(osi_funcs_p); - osi_funcs_p = NULL; + if (s_wakeup_req_sem) { + semphr_delete_wrapper(s_wakeup_req_sem); + s_wakeup_req_sem = NULL; + } + + if (osi_funcs_p) { + free(osi_funcs_p); + osi_funcs_p = NULL; + } btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE; @@ -1642,8 +1638,6 @@ esp_err_t esp_bt_controller_deinit(void) esp_bt_power_domain_off(); esp_phy_modem_deinit(); - - return ESP_OK; } static void bt_controller_shutdown(void* arg) diff --git a/components/bt/controller/lib_esp32 b/components/bt/controller/lib_esp32 index dbaeb136ca..9c5686aaa3 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit dbaeb136cacf8c7d071f838c1053f90299f57720 +Subproject commit 9c5686aaa35436d255459312b14fb0da339c656a From 0b8f0e5456a8c25cc053c832396a95c110317fc5 Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Mon, 19 Dec 2022 16:50:34 +0800 Subject: [PATCH 2/7] update bt-lib for ESP32 1 change default TX power to 9 dBm 2 fixed disconnect reason 0x1f (unspecified error) 3 fixed connection timeout due to terminate ind has not been acknowledged --- 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 9c5686aaa3..bdb57a2c5e 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit 9c5686aaa35436d255459312b14fb0da339c656a +Subproject commit bdb57a2c5e4bd6a5d7f34417b280680ce700605e From c656e7ec0745ec908d7f3307cbda0c20076e4d0c Mon Sep 17 00:00:00 2001 From: zwj Date: Thu, 8 Dec 2022 11:54:26 +0800 Subject: [PATCH 3/7] Fixed some memory was not released after bluetooth controller initialization failed on ESP32-C3 and ESP32-S3 --- components/bt/controller/esp32c3/bt.c | 115 ++++++-------------- components/bt/controller/esp32s3/bt.c | 114 ++++++------------- components/bt/controller/lib_esp32c3_family | 2 +- 3 files changed, 72 insertions(+), 159 deletions(-) diff --git a/components/bt/controller/esp32c3/bt.c b/components/bt/controller/esp32c3/bt.c index 410f63f6f0..5d98444792 100644 --- a/components/bt/controller/esp32c3/bt.c +++ b/components/bt/controller/esp32c3/bt.c @@ -314,6 +314,8 @@ static void btdm_slp_tmr_callback(void *arg); static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end); +static void bt_controller_deinit_internal(void); + /* Local variable definition *************************************************************************** */ @@ -1272,73 +1274,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) return ESP_OK; error: - if (s_lp_stat.phy_enabled) { - esp_phy_disable(); - s_lp_stat.phy_enabled = 0; - } - do { - // deinit low power control resources -#ifdef CONFIG_PM_ENABLE - if (s_lp_cntl.no_light_sleep) { - if (s_light_sleep_pm_lock != NULL) { - esp_pm_lock_delete(s_light_sleep_pm_lock); - s_light_sleep_pm_lock = NULL; - } - } - if (s_pm_lock != NULL) { - esp_pm_lock_delete(s_pm_lock); - s_pm_lock = NULL; - s_lp_stat.pm_lock_released = 0; - } + bt_controller_deinit_internal(); -#endif - if (s_lp_cntl.wakeup_timer_required && s_btdm_slp_tmr != NULL) { - esp_timer_delete(s_btdm_slp_tmr); - s_btdm_slp_tmr = NULL; - } - -#if CONFIG_MAC_BB_PD - if (s_lp_cntl.mac_bb_pd) { - btdm_deep_sleep_mem_deinit(); - s_lp_cntl.mac_bb_pd = 0; - } -#endif - if (s_lp_cntl.enable) { - btdm_vnd_offload_task_deregister(BTDM_VND_OL_SIG_WAKEUP_TMR); - if (s_wakeup_req_sem != NULL) { - semphr_delete_wrapper(s_wakeup_req_sem); - s_wakeup_req_sem = NULL; - } - } - - if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL) { -#ifdef CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP - if (s_lp_cntl.main_xtal_pu) { - ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_OFF)); - s_lp_cntl.main_xtal_pu = 0; - } -#endif - btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW); - btdm_lpclk_set_div(0); -#if CONFIG_SW_COEXIST_ENABLE - coex_update_lpclk_interval(); -#endif - } - - btdm_lpcycle_us = 0; - } while (0); - -#if CONFIG_MAC_BB_PD - esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb); - - esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb); -#endif - - if (osi_funcs_p != NULL) { - free(osi_funcs_p); - osi_funcs_p = NULL; - } return err; } @@ -1349,31 +1287,47 @@ esp_err_t esp_bt_controller_deinit(void) } btdm_controller_deinit(); + + bt_controller_deinit_internal(); + + return ESP_OK; +} + +static void bt_controller_deinit_internal(void) +{ periph_module_disable(PERIPH_BT_MODULE); if (s_lp_stat.phy_enabled) { esp_phy_disable(); s_lp_stat.phy_enabled = 0; - } else { - assert(0); } // deinit low power control resources do { + #if CONFIG_MAC_BB_PD - btdm_deep_sleep_mem_deinit(); + if (s_lp_cntl.mac_bb_pd) { + btdm_deep_sleep_mem_deinit(); + s_lp_cntl.mac_bb_pd = 0; + } #endif #ifdef CONFIG_PM_ENABLE if (s_lp_cntl.no_light_sleep) { - esp_pm_lock_delete(s_light_sleep_pm_lock); - s_light_sleep_pm_lock = NULL; + if (s_light_sleep_pm_lock != NULL) { + esp_pm_lock_delete(s_light_sleep_pm_lock); + s_light_sleep_pm_lock = NULL; + } + } + + if (s_pm_lock != NULL) { + esp_pm_lock_delete(s_pm_lock); + s_pm_lock = NULL; + s_lp_stat.pm_lock_released = 0; } - esp_pm_lock_delete(s_pm_lock); - s_pm_lock = NULL; - s_lp_stat.pm_lock_released = 0; #endif + if (s_lp_cntl.wakeup_timer_required) { if (s_lp_stat.wakeup_timer_started) { esp_timer_stop(s_btdm_slp_tmr); @@ -1385,10 +1339,12 @@ esp_err_t esp_bt_controller_deinit(void) if (s_lp_cntl.enable) { btdm_vnd_offload_task_deregister(BTDM_VND_OL_SIG_WAKEUP_TMR); - - semphr_delete_wrapper(s_wakeup_req_sem); - s_wakeup_req_sem = NULL; + if (s_wakeup_req_sem != NULL) { + semphr_delete_wrapper(s_wakeup_req_sem); + s_wakeup_req_sem = NULL; + } } + if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL) { #ifdef CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP if (s_lp_cntl.main_xtal_pu) { @@ -1417,11 +1373,12 @@ esp_err_t esp_bt_controller_deinit(void) #endif esp_phy_modem_deinit(); - free(osi_funcs_p); - osi_funcs_p = NULL; + if (osi_funcs_p != NULL) { + free(osi_funcs_p); + osi_funcs_p = NULL; + } btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE; - return ESP_OK; } esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode) diff --git a/components/bt/controller/esp32s3/bt.c b/components/bt/controller/esp32s3/bt.c index 4941487700..9e625dc05b 100644 --- a/components/bt/controller/esp32s3/bt.c +++ b/components/bt/controller/esp32s3/bt.c @@ -318,6 +318,8 @@ static void btdm_slp_tmr_callback(void *arg); static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end); +static void bt_controller_deinit_internal(void); + /* Local variable definition *************************************************************************** */ @@ -1318,73 +1320,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) return ESP_OK; error: - if (s_lp_stat.phy_enabled) { - esp_phy_disable(); - s_lp_stat.phy_enabled = 0; - } - do { - // deinit low power control resources -#ifdef CONFIG_PM_ENABLE - if (s_lp_cntl.no_light_sleep) { - if (s_light_sleep_pm_lock != NULL) { - esp_pm_lock_delete(s_light_sleep_pm_lock); - s_light_sleep_pm_lock = NULL; - } - } - if (s_pm_lock != NULL) { - esp_pm_lock_delete(s_pm_lock); - s_pm_lock = NULL; - s_lp_stat.pm_lock_released = 0; - } + bt_controller_deinit_internal(); -#endif - if (s_lp_cntl.wakeup_timer_required && s_btdm_slp_tmr != NULL) { - esp_timer_delete(s_btdm_slp_tmr); - s_btdm_slp_tmr = NULL; - } - -#if CONFIG_MAC_BB_PD - if (s_lp_cntl.mac_bb_pd) { - btdm_deep_sleep_mem_deinit(); - s_lp_cntl.mac_bb_pd = 0; - } -#endif - if (s_lp_cntl.enable) { - btdm_vnd_offload_task_deregister(BTDM_VND_OL_SIG_WAKEUP_TMR); - if (s_wakeup_req_sem != NULL) { - semphr_delete_wrapper(s_wakeup_req_sem); - s_wakeup_req_sem = NULL; - } - } - - if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL) { -#ifdef CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP - if (s_lp_cntl.main_xtal_pu) { - ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_OFF)); - s_lp_cntl.main_xtal_pu = 0; - } -#endif - btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW); - btdm_lpclk_set_div(0); -#if CONFIG_SW_COEXIST_ENABLE - coex_update_lpclk_interval(); -#endif - } - - btdm_lpcycle_us = 0; - } while (0); - -#if CONFIG_MAC_BB_PD - esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb); - - esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb); -#endif - - if (osi_funcs_p != NULL) { - free(osi_funcs_p); - osi_funcs_p = NULL; - } return err; } @@ -1395,31 +1333,47 @@ esp_err_t esp_bt_controller_deinit(void) } btdm_controller_deinit(); + + bt_controller_deinit_internal(); + + return ESP_OK; +} + +static void bt_controller_deinit_internal(void) +{ periph_module_disable(PERIPH_BT_MODULE); if (s_lp_stat.phy_enabled) { esp_phy_disable(); s_lp_stat.phy_enabled = 0; - } else { - assert(0); } // deinit low power control resources do { + #if CONFIG_MAC_BB_PD - btdm_deep_sleep_mem_deinit(); + if (s_lp_cntl.mac_bb_pd) { + btdm_deep_sleep_mem_deinit(); + s_lp_cntl.mac_bb_pd = 0; + } #endif #ifdef CONFIG_PM_ENABLE if (s_lp_cntl.no_light_sleep) { - esp_pm_lock_delete(s_light_sleep_pm_lock); - s_light_sleep_pm_lock = NULL; + if (s_light_sleep_pm_lock != NULL) { + esp_pm_lock_delete(s_light_sleep_pm_lock); + s_light_sleep_pm_lock = NULL; + } + } + + if (s_pm_lock != NULL) { + esp_pm_lock_delete(s_pm_lock); + s_pm_lock = NULL; + s_lp_stat.pm_lock_released = 0; } - esp_pm_lock_delete(s_pm_lock); - s_pm_lock = NULL; - s_lp_stat.pm_lock_released = 0; #endif + if (s_lp_cntl.wakeup_timer_required) { if (s_lp_stat.wakeup_timer_started) { esp_timer_stop(s_btdm_slp_tmr); @@ -1431,9 +1385,10 @@ esp_err_t esp_bt_controller_deinit(void) if (s_lp_cntl.enable) { btdm_vnd_offload_task_deregister(BTDM_VND_OL_SIG_WAKEUP_TMR); - - semphr_delete_wrapper(s_wakeup_req_sem); - s_wakeup_req_sem = NULL; + if (s_wakeup_req_sem != NULL) { + semphr_delete_wrapper(s_wakeup_req_sem); + s_wakeup_req_sem = NULL; + } } if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL) { @@ -1464,11 +1419,12 @@ esp_err_t esp_bt_controller_deinit(void) #endif esp_phy_modem_deinit(); - free(osi_funcs_p); - osi_funcs_p = NULL; + if (osi_funcs_p != NULL) { + free(osi_funcs_p); + osi_funcs_p = NULL; + } btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE; - return ESP_OK; } esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode) diff --git a/components/bt/controller/lib_esp32c3_family b/components/bt/controller/lib_esp32c3_family index 79152b5190..723f44c70c 160000 --- a/components/bt/controller/lib_esp32c3_family +++ b/components/bt/controller/lib_esp32c3_family @@ -1 +1 @@ -Subproject commit 79152b519023f26462498f3ef8805cff2a80e193 +Subproject commit 723f44c70ceea734bb9075b3c59993103d1dac23 From e95d7202ced12c852e754624106bd662671fab6a Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Mon, 12 Dec 2022 19:25:13 +0800 Subject: [PATCH 4/7] update bt lib for ESP32-C3 and ESP32-S3 1 fixed privacy error for directed adv 2 fixed multi periodic adv sync failed in air --- 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 723f44c70c..84ebcda82a 160000 --- a/components/bt/controller/lib_esp32c3_family +++ b/components/bt/controller/lib_esp32c3_family @@ -1 +1 @@ -Subproject commit 723f44c70ceea734bb9075b3c59993103d1dac23 +Subproject commit 84ebcda82aa5886d2a0b939dec1dbc62aa1c11c7 From e7ee437bcfe11180141a49bb2868f82f471e43a4 Mon Sep 17 00:00:00 2001 From: zwj Date: Tue, 13 Dec 2022 16:51:51 +0800 Subject: [PATCH 5/7] Update bt lib for ESP32-C3 and ESP32-S3 - Add config to set duplicate scan list refresh period - overwrite the oldest device infor if the list is full - Fixed duplicate scan period is not accurate --- components/bt/controller/esp32c3/Kconfig.in | 16 ++++++++++++++++ components/bt/controller/esp32s3/Kconfig.in | 16 ++++++++++++++++ components/bt/controller/lib_esp32c3_family | 2 +- components/bt/include/esp32c3/include/esp_bt.h | 10 +++++++++- components/bt/include/esp32s3/include/esp_bt.h | 10 +++++++++- 5 files changed, 51 insertions(+), 3 deletions(-) diff --git a/components/bt/controller/esp32c3/Kconfig.in b/components/bt/controller/esp32c3/Kconfig.in index 75969aeca6..efd72857f7 100644 --- a/components/bt/controller/esp32c3/Kconfig.in +++ b/components/bt/controller/esp32c3/Kconfig.in @@ -280,6 +280,22 @@ config BT_CTRL_SCAN_DUPL_CACHE_SIZE Maximum number of devices which can be recorded in scan duplicate filter. When the maximum amount of device in the filter is reached, the cache will be refreshed. +config BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD + int "Duplicate scan list refresh period" + depends on BT_CTRL_BLE_SCAN_DUPL + range 0 1000 + default 0 + help + If the period value is non-zero, the controller will periodically clear the device information + stored in the scan duuplicate filter. If it is 0, the scan duuplicate filter will not be cleared + until the scanning is disabled. Duplicate advertisements for this period should not be sent to the + Host in advertising report events. + There are two scenarios where the ADV packet will be repeatedly reported: + 1. The duplicate scan cache is full, the controller will delete the oldest device information and + add new device information. + 2. When the refresh period is up, the controller will clear all device information and start filtering + again. + config BT_CTRL_BLE_MESH_SCAN_DUPL_EN bool "Special duplicate scan mechanism for BLE Mesh scan" depends on BT_CTRL_BLE_SCAN_DUPL diff --git a/components/bt/controller/esp32s3/Kconfig.in b/components/bt/controller/esp32s3/Kconfig.in index fd594e3c09..663e63b90b 100644 --- a/components/bt/controller/esp32s3/Kconfig.in +++ b/components/bt/controller/esp32s3/Kconfig.in @@ -297,6 +297,22 @@ config BT_CTRL_SCAN_DUPL_CACHE_SIZE Maximum number of devices which can be recorded in scan duplicate filter. When the maximum amount of device in the filter is reached, the cache will be refreshed. +config BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD + int "Duplicate scan list refresh period" + depends on BT_CTRL_BLE_SCAN_DUPL + range 0 1000 + default 0 + help + If the period value is non-zero, the controller will periodically clear the device information + stored in the scan duuplicate filter. If it is 0, the scan duuplicate filter will not be cleared + until the scanning is disabled. Duplicate advertisements for this period should not be sent to the + Host in advertising report events. + There are two scenarios where the ADV packet will be repeatedly reported: + 1. The duplicate scan cache is full, the controller will delete the oldest device information and + add new device information. + 2. When the refresh period is up, the controller will clear all device information and start filtering + again. + config BT_CTRL_BLE_MESH_SCAN_DUPL_EN bool "Special duplicate scan mechanism for BLE Mesh scan" depends on BT_CTRL_BLE_SCAN_DUPL diff --git a/components/bt/controller/lib_esp32c3_family b/components/bt/controller/lib_esp32c3_family index 84ebcda82a..bba9af9259 160000 --- a/components/bt/controller/lib_esp32c3_family +++ b/components/bt/controller/lib_esp32c3_family @@ -1 +1 @@ -Subproject commit 84ebcda82aa5886d2a0b939dec1dbc62aa1c11c7 +Subproject commit bba9af9259e0999ef246426d31a793fe0a3ff4db diff --git a/components/bt/include/esp32c3/include/esp_bt.h b/components/bt/include/esp32c3/include/esp_bt.h index b1608d841e..ff7ab70a59 100644 --- a/components/bt/include/esp32c3/include/esp_bt.h +++ b/components/bt/include/esp32c3/include/esp_bt.h @@ -18,7 +18,7 @@ extern "C" { #endif #define ESP_BT_CTRL_CONFIG_MAGIC_VAL 0x5A5AA5A5 -#define ESP_BT_CTRL_CONFIG_VERSION 0x02209230 +#define ESP_BT_CTRL_CONFIG_VERSION 0x02212090 #define ESP_BT_HCI_TL_MAGIC_VALUE 0xfadebead #define ESP_BT_HCI_TL_VERSION 0x00010000 @@ -129,6 +129,12 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status); #define MESH_DUPLICATE_SCAN_CACHE_SIZE 0 #endif +#ifndef CONFIG_BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD +#define DUPL_SCAN_CACHE_REFRESH_PERIOD 0 +#else +#define DUPL_SCAN_CACHE_REFRESH_PERIOD CONFIG_BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD +#endif + #ifdef CONFIG_BT_CTRL_AGC_RECORRECT_EN #define BT_CTRL_AGC_RECORRECT_EN CONFIG_BT_CTRL_AGC_RECORRECT_EN #else @@ -188,6 +194,7 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status); .hw_recorrect_en = AGC_RECORRECT_EN, \ .cca_thresh = CONFIG_BT_CTRL_HW_CCA_VAL, \ .scan_backoff_upperlimitmax = BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \ + .dup_list_refresh_period = DUPL_SCAN_CACHE_REFRESH_PERIOD, \ } #else @@ -256,6 +263,7 @@ typedef struct { uint8_t hw_recorrect_en; uint8_t cca_thresh; /*!< cca threshold*/ uint16_t scan_backoff_upperlimitmax; /*!< scan backoff upperlimitmax value */ + uint16_t dup_list_refresh_period; /*!< duplicate scan list refresh time */ } esp_bt_controller_config_t; /** diff --git a/components/bt/include/esp32s3/include/esp_bt.h b/components/bt/include/esp32s3/include/esp_bt.h index b8e6905190..61d5b2c751 100644 --- a/components/bt/include/esp32s3/include/esp_bt.h +++ b/components/bt/include/esp32s3/include/esp_bt.h @@ -18,7 +18,7 @@ extern "C" { #endif #define ESP_BT_CTRL_CONFIG_MAGIC_VAL 0x5A5AA5A5 -#define ESP_BT_CTRL_CONFIG_VERSION 0x02209230 +#define ESP_BT_CTRL_CONFIG_VERSION 0x02212090 #define ESP_BT_HCI_TL_MAGIC_VALUE 0xfadebead #define ESP_BT_HCI_TL_VERSION 0x00010000 @@ -129,6 +129,12 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status); #define MESH_DUPLICATE_SCAN_CACHE_SIZE 0 #endif +#ifndef CONFIG_BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD +#define DUPL_SCAN_CACHE_REFRESH_PERIOD 0 +#else +#define DUPL_SCAN_CACHE_REFRESH_PERIOD CONFIG_BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD +#endif + #ifdef CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX #define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX #else @@ -187,6 +193,7 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status); .hw_recorrect_en = AGC_RECORRECT_EN, \ .cca_thresh = CONFIG_BT_CTRL_HW_CCA_VAL, \ .scan_backoff_upperlimitmax = BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \ + .dup_list_refresh_period = DUPL_SCAN_CACHE_REFRESH_PERIOD, \ } #else @@ -255,6 +262,7 @@ typedef struct { uint8_t hw_recorrect_en; uint8_t cca_thresh; /*!< cca threshold*/ uint16_t scan_backoff_upperlimitmax; /*!< scan backoff upperlimitmax value */ + uint16_t dup_list_refresh_period; /*!< duplicate scan list refresh time */ } esp_bt_controller_config_t; /** From 0733694f1f1f0e307538549adb1085694b300554 Mon Sep 17 00:00:00 2001 From: zwj Date: Thu, 15 Dec 2022 15:10:52 +0800 Subject: [PATCH 6/7] Update bt lib for ESP32 - Add config to set duplicate scan list refresh period - overwrite the oldest device infor if the list is full - Fixed duplicate scan period is not accurate --- components/bt/controller/esp32/Kconfig.in | 16 ++++++++++++++++ components/bt/controller/esp32c3/Kconfig.in | 2 +- components/bt/controller/esp32s3/Kconfig.in | 2 +- components/bt/controller/lib_esp32 | 2 +- components/bt/include/esp32/include/esp_bt.h | 10 +++++++++- 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/components/bt/controller/esp32/Kconfig.in b/components/bt/controller/esp32/Kconfig.in index 44c95c2864..f9a505cf25 100644 --- a/components/bt/controller/esp32/Kconfig.in +++ b/components/bt/controller/esp32/Kconfig.in @@ -353,6 +353,22 @@ config BTDM_SCAN_DUPL_CACHE_SIZE Maximum number of devices which can be recorded in scan duplicate filter. When the maximum amount of device in the filter is reached, the cache will be refreshed. +config BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD + int "Duplicate scan list refresh period (seconds)" + depends on BTDM_BLE_SCAN_DUPL + range 0 1000 + default 0 + help + If the period value is non-zero, the controller will periodically clear the device information + stored in the scan duuplicate filter. If it is 0, the scan duuplicate filter will not be cleared + until the scanning is disabled. Duplicate advertisements for this period should not be sent to the + Host in advertising report events. + There are two scenarios where the ADV packet will be repeatedly reported: + 1. The duplicate scan cache is full, the controller will delete the oldest device information and + add new device information. + 2. When the refresh period is up, the controller will clear all device information and start filtering + again. + config BTDM_BLE_MESH_SCAN_DUPL_EN bool "Special duplicate scan mechanism for BLE Mesh scan" depends on BTDM_BLE_SCAN_DUPL diff --git a/components/bt/controller/esp32c3/Kconfig.in b/components/bt/controller/esp32c3/Kconfig.in index efd72857f7..1821f154c9 100644 --- a/components/bt/controller/esp32c3/Kconfig.in +++ b/components/bt/controller/esp32c3/Kconfig.in @@ -281,7 +281,7 @@ config BT_CTRL_SCAN_DUPL_CACHE_SIZE When the maximum amount of device in the filter is reached, the cache will be refreshed. config BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD - int "Duplicate scan list refresh period" + int "Duplicate scan list refresh period (seconds)" depends on BT_CTRL_BLE_SCAN_DUPL range 0 1000 default 0 diff --git a/components/bt/controller/esp32s3/Kconfig.in b/components/bt/controller/esp32s3/Kconfig.in index 663e63b90b..ac4aadd1e3 100644 --- a/components/bt/controller/esp32s3/Kconfig.in +++ b/components/bt/controller/esp32s3/Kconfig.in @@ -298,7 +298,7 @@ config BT_CTRL_SCAN_DUPL_CACHE_SIZE When the maximum amount of device in the filter is reached, the cache will be refreshed. config BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD - int "Duplicate scan list refresh period" + int "Duplicate scan list refresh period (seconds)" depends on BT_CTRL_BLE_SCAN_DUPL range 0 1000 default 0 diff --git a/components/bt/controller/lib_esp32 b/components/bt/controller/lib_esp32 index bdb57a2c5e..d4a224c5d6 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit bdb57a2c5e4bd6a5d7f34417b280680ce700605e +Subproject commit d4a224c5d682d6b5a76542c6918b6a59dd0b2f8c diff --git a/components/bt/include/esp32/include/esp_bt.h b/components/bt/include/esp32/include/esp_bt.h index f78a5a88d6..69c9658f0b 100644 --- a/components/bt/include/esp32/include/esp_bt.h +++ b/components/bt/include/esp32/include/esp_bt.h @@ -49,7 +49,7 @@ extern "C" { #endif //CONFIG_BT_ENABLED -#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20200622 +#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20221207 /** * @brief Bluetooth mode for controller enable/disable @@ -127,6 +127,12 @@ the adv packet will be discarded until the memory is restored. */ #define MESH_DUPLICATE_SCAN_CACHE_SIZE 0 #endif +#ifdef CONFIG_BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD +#define SCAN_DUPL_CACHE_REFRESH_PERIOD CONFIG_BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD +#else +#define SCAN_DUPL_CACHE_REFRESH_PERIOD 0 +#endif + #if defined(CONFIG_BTDM_CTRL_MODE_BLE_ONLY) #define BTDM_CONTROLLER_MODE_EFF ESP_BT_MODE_BLE #elif defined(CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY) @@ -182,6 +188,7 @@ the adv packet will be discarded until the memory is restored. */ .pcm_role = CONFIG_BTDM_CTRL_PCM_ROLE_EFF, \ .pcm_polar = CONFIG_BTDM_CTRL_PCM_POLAR_EFF, \ .hli = BTDM_CTRL_HLI, \ + .dup_list_refresh_period = SCAN_DUPL_CACHE_REFRESH_PERIOD, \ .magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \ } @@ -224,6 +231,7 @@ typedef struct { uint8_t pcm_role; /*!< PCM role (master & slave)*/ uint8_t pcm_polar; /*!< PCM polar trig (falling clk edge & rising clk edge) */ bool hli; /*!< Using high level interrupt or not */ + uint16_t dup_list_refresh_period; /*!< Duplicate scan list refresh period */ uint32_t magic; /*!< Magic number */ } esp_bt_controller_config_t; From 16f9add4f6bfea8b8cebd44a6f39c4d2c6bddfc2 Mon Sep 17 00:00:00 2001 From: zhiweijian Date: Thu, 8 Dec 2022 11:03:04 +0800 Subject: [PATCH 7/7] Remove `-Wno-format` compile option for bluedroid BLE examples --- .../bluedroid/ble/ble_ancs/main/CMakeLists.txt | 1 - .../bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs.c | 7 ++++--- .../bluedroid/ble/ble_ancs/main/ble_ancs_demo.c | 7 ++++--- .../ble/ble_compatibility_test/main/CMakeLists.txt | 2 -- .../main/ble_compatibility_test.c | 6 +++--- .../bluedroid/ble/ble_eddystone/main/CMakeLists.txt | 1 - .../ble/ble_eddystone/main/esp_eddystone_demo.c | 7 ++++--- .../bluedroid/ble/ble_spp_client/main/CMakeLists.txt | 1 - .../ble/ble_spp_client/main/spp_client_demo.c | 2 +- .../throughput_client/main/CMakeLists.txt | 1 - .../main/example_ble_client_throughput.c | 5 +++-- .../throughput_server/main/CMakeLists.txt | 1 - .../main/example_ble_server_throughput.c | 7 ++++--- .../ble/gatt_security_client/main/CMakeLists.txt | 1 - .../main/example_ble_sec_gattc_demo.c | 7 ++++--- .../ble/gatt_security_server/main/CMakeLists.txt | 1 - .../main/example_ble_sec_gatts_demo.c | 7 ++++--- .../bluedroid/ble/gatt_server/main/CMakeLists.txt | 1 - .../bluedroid/ble/gatt_server/main/gatts_demo.c | 11 ++++++----- .../ble_50/ble50_security_client/main/CMakeLists.txt | 1 - .../ble50_security_client/main/ble50_sec_gattc_demo.c | 7 ++++--- .../ble_50/ble50_security_server/main/CMakeLists.txt | 1 - .../ble50_security_server/main/ble50_sec_gatts_demo.c | 5 +++-- 23 files changed, 44 insertions(+), 46 deletions(-) diff --git a/examples/bluetooth/bluedroid/ble/ble_ancs/main/CMakeLists.txt b/examples/bluetooth/bluedroid/ble/ble_ancs/main/CMakeLists.txt index 00068244f3..18d14d5b56 100644 --- a/examples/bluetooth/bluedroid/ble/ble_ancs/main/CMakeLists.txt +++ b/examples/bluetooth/bluedroid/ble/ble_ancs/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "ble_ancs_demo.c" "ble_ancs.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs.c b/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs.c index c113c0d20a..f635a7c592 100644 --- a/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs.c +++ b/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs.c @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ #include #include +#include #include "esp_log.h" #include "ble_ancs.h" @@ -113,7 +114,7 @@ void esp_receive_apple_notification_source(uint8_t *message, uint16_t message_le char *Cidstr = CategoryID_to_String(CategoryID); uint8_t CategoryCount = message[3]; uint32_t NotificationUID = (message[4]) | (message[5]<< 8) | (message[6]<< 16) | (message[7] << 24); - ESP_LOGI(BLE_ANCS_TAG, "EventID:%s EventFlags:0x%x CategoryID:%s CategoryCount:%d NotificationUID:%d", EventIDS, EventFlags, Cidstr, CategoryCount, NotificationUID); + ESP_LOGI(BLE_ANCS_TAG, "EventID:%s EventFlags:0x%x CategoryID:%s CategoryCount:%d NotificationUID:%" PRIu32, EventIDS, EventFlags, Cidstr, CategoryCount, NotificationUID); } void esp_receive_apple_data_source(uint8_t *message, uint16_t message_len) @@ -129,7 +130,7 @@ void esp_receive_apple_data_source(uint8_t *message, uint16_t message_len) uint32_t NotificationUID = (message[1]) | (message[2]<< 8) | (message[3]<< 16) | (message[4] << 24); uint32_t remian_attr_len = message_len - 5; uint8_t *attrs = &message[5]; - ESP_LOGI(BLE_ANCS_TAG, "recevice Notification Attributes response Command_id %d NotificationUID %d", Command_id, NotificationUID); + ESP_LOGI(BLE_ANCS_TAG, "recevice Notification Attributes response Command_id %d NotificationUID %" PRIu32, Command_id, NotificationUID); while(remian_attr_len > 0) { uint8_t AttributeID = attrs[0]; uint16_t len = attrs[1] | (attrs[2] << 8); diff --git a/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c b/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c index 5ea10ad3a5..1e0c0aa243 100644 --- a/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c @@ -1,9 +1,10 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/event_groups.h" @@ -280,7 +281,7 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param /* The app will receive this evt when the IO has DisplayYesNO capability and the peer device IO also has DisplayYesNo capability. show the passkey number to the user to confirm it with the number displayed by peer device. */ esp_ble_confirm_reply(param->ble_security.ble_req.bd_addr, true); - ESP_LOGI(BLE_ANCS_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%d", param->ble_security.key_notif.passkey); + ESP_LOGI(BLE_ANCS_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%" PRIu32, param->ble_security.key_notif.passkey); break; case ESP_GAP_BLE_SEC_REQ_EVT: /* send the positive(true) security response to the peer device to accept the security request. @@ -289,7 +290,7 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param break; case ESP_GAP_BLE_PASSKEY_NOTIF_EVT: ///the app will receive this evt when the IO has Output capability and the peer device IO has Input capability. ///show the passkey number to the user to input it in the peer device. - ESP_LOGI(BLE_ANCS_TAG, "The passkey Notify number:%06d", param->ble_security.key_notif.passkey); + ESP_LOGI(BLE_ANCS_TAG, "The passkey Notify number:%06" PRIu32, param->ble_security.key_notif.passkey); break; case ESP_GAP_BLE_AUTH_CMPL_EVT: { esp_log_buffer_hex("addr", param->ble_security.auth_cmpl.bd_addr, ESP_BD_ADDR_LEN); diff --git a/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/CMakeLists.txt b/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/CMakeLists.txt index 205172b718..1989ce57b3 100644 --- a/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/CMakeLists.txt +++ b/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/CMakeLists.txt @@ -1,4 +1,2 @@ idf_component_register(SRCS "ble_compatibility_test.c" INCLUDE_DIRS ".") - -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/ble_compatibility_test.c b/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/ble_compatibility_test.c index e2bf64d6a1..82fb7aad1c 100644 --- a/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/ble_compatibility_test.c +++ b/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/ble_compatibility_test.c @@ -10,7 +10,7 @@ * *********************************************************************************/ - +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/event_groups.h" @@ -337,7 +337,7 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param case ESP_GAP_BLE_NC_REQ_EVT: /* The app will receive this event when the IO has DisplayYesNO capability and the peer device IO also has DisplayYesNo capability. show the passkey number to the user to confirm it with the number displayed by peer device. */ - ESP_LOGI(EXAMPLE_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%d", param->ble_security.key_notif.passkey); + ESP_LOGI(EXAMPLE_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%" PRIu32, param->ble_security.key_notif.passkey); break; case ESP_GAP_BLE_SEC_REQ_EVT: /* send the positive(true) security response to the peer device to accept the security request. @@ -346,7 +346,7 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param break; case ESP_GAP_BLE_PASSKEY_NOTIF_EVT: ///the app will receive this evt when the IO has Output capability and the peer device IO has Input capability. ///show the passkey number to the user to input it in the peer device. - ESP_LOGI(EXAMPLE_TAG, "The passkey notify number:%d", param->ble_security.key_notif.passkey); + ESP_LOGI(EXAMPLE_TAG, "The passkey notify number:%06" PRIu32, param->ble_security.key_notif.passkey); break; case ESP_GAP_BLE_KEY_EVT: //shows the ble key info share with peer device to the user. diff --git a/examples/bluetooth/bluedroid/ble/ble_eddystone/main/CMakeLists.txt b/examples/bluetooth/bluedroid/ble/ble_eddystone/main/CMakeLists.txt index 0820e85fc6..8290fc6305 100644 --- a/examples/bluetooth/bluedroid/ble/ble_eddystone/main/CMakeLists.txt +++ b/examples/bluetooth/bluedroid/ble/ble_eddystone/main/CMakeLists.txt @@ -1,4 +1,3 @@ idf_component_register(SRCS "esp_eddystone_api.c" "esp_eddystone_demo.c" INCLUDE_DIRS "") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/bluetooth/bluedroid/ble/ble_eddystone/main/esp_eddystone_demo.c b/examples/bluetooth/bluedroid/ble/ble_eddystone/main/esp_eddystone_demo.c index 76c1025dc2..71ce556515 100644 --- a/examples/bluetooth/bluedroid/ble/ble_eddystone/main/esp_eddystone_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_eddystone/main/esp_eddystone_demo.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -14,6 +14,7 @@ #include #include #include +#include #include "esp_bt.h" #include "nvs_flash.h" @@ -67,8 +68,8 @@ static void esp_eddystone_show_inform(const esp_eddystone_result_t* res) ESP_LOGI(DEMO_TAG, "version: %d", res->inform.tlm.version); ESP_LOGI(DEMO_TAG, "battery voltage: %d mV", res->inform.tlm.battery_voltage); ESP_LOGI(DEMO_TAG, "beacon temperature in degrees Celsius: %6.1f", res->inform.tlm.temperature); - ESP_LOGI(DEMO_TAG, "adv pdu count since power-up: %d", res->inform.tlm.adv_count); - ESP_LOGI(DEMO_TAG, "time since power-up: %d s", (res->inform.tlm.time)/10); + ESP_LOGI(DEMO_TAG, "adv pdu count since power-up: %" PRIu32, res->inform.tlm.adv_count); + ESP_LOGI(DEMO_TAG, "time since power-up: %" PRIu32 " s", (res->inform.tlm.time)/10); break; } default: diff --git a/examples/bluetooth/bluedroid/ble/ble_spp_client/main/CMakeLists.txt b/examples/bluetooth/bluedroid/ble/ble_spp_client/main/CMakeLists.txt index de64acbead..5fa00fb626 100644 --- a/examples/bluetooth/bluedroid/ble/ble_spp_client/main/CMakeLists.txt +++ b/examples/bluetooth/bluedroid/ble/ble_spp_client/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "spp_client_demo.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c b/examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c index fc70c1b391..39d1b3438c 100644 --- a/examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c @@ -218,7 +218,7 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par } //the unit of the duration is second uint32_t duration = 0xFFFF; - ESP_LOGI(GATTC_TAG, "Enable Ble Scan:during time 0x%04X minutes.",duration); + ESP_LOGI(GATTC_TAG, "Enable Ble Scan:during time %04" PRIx32 " minutes.",duration); esp_ble_gap_start_scanning(duration); break; } diff --git a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/CMakeLists.txt b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/CMakeLists.txt index e9b577ac2d..4695587a07 100644 --- a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/CMakeLists.txt +++ b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "example_ble_client_throughput.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c index a85f5787fd..acfcaafbe3 100644 --- a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c +++ b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -14,6 +14,7 @@ #include #include #include +#include #include "nvs.h" #include "nvs_flash.h" @@ -490,7 +491,7 @@ static void throughput_client_task(void *param) if (start_time) { current_time = esp_timer_get_time(); bit_rate = notify_len * SECOND_TO_USECOND / (current_time - start_time); - ESP_LOGI(GATTC_TAG, "Notify Bit rate = %d Byte/s, = %d bit/s, time = %ds", + ESP_LOGI(GATTC_TAG, "Notify Bit rate = %" PRIu32 " Byte/s, = %" PRIu32 " bit/s, time = %ds", bit_rate, bit_rate<<3, (int)((current_time - start_time) / SECOND_TO_USECOND)); } else { ESP_LOGI(GATTC_TAG, "Notify Bit rate = 0 Byte/s, = 0 bit/s"); diff --git a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/CMakeLists.txt b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/CMakeLists.txt index ff7aa19f33..419488adc3 100644 --- a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/CMakeLists.txt +++ b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "example_ble_server_throughput.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/example_ble_server_throughput.c b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/example_ble_server_throughput.c index 39ecae341a..ecaa44f144 100644 --- a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/example_ble_server_throughput.c +++ b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/example_ble_server_throughput.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -13,6 +13,7 @@ #include #include #include +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/event_groups.h" @@ -376,7 +377,7 @@ static void gatts_profile_a_event_handler(esp_gatts_cb_event_t event, esp_gatt_i esp_ble_gatts_create_service(gatts_if, &gl_profile_tab[PROFILE_A_APP_ID].service_id, GATTS_NUM_HANDLE_TEST_A); break; case ESP_GATTS_READ_EVT: { - ESP_LOGI(GATTS_TAG, "GATT_READ_EVT, conn_id %d, trans_id %d, handle %d\n", param->read.conn_id, param->read.trans_id, param->read.handle); + ESP_LOGI(GATTS_TAG, "GATT_READ_EVT, conn_id %d, trans_id %" PRIu32 ", handle %d\n", param->read.conn_id, param->read.trans_id, param->read.handle); esp_gatt_rsp_t rsp; memset(&rsp, 0, sizeof(esp_gatt_rsp_t)); rsp.attr_value.handle = param->read.handle; @@ -391,7 +392,7 @@ static void gatts_profile_a_event_handler(esp_gatts_cb_event_t event, esp_gatt_i } case ESP_GATTS_WRITE_EVT: { #if (CONFIG_EXAMPLE_GATTS_NOTIFY_THROUGHPUT) - ESP_LOGI(GATTS_TAG, "GATT_WRITE_EVT, conn_id %d, trans_id %d, handle %d", param->write.conn_id, param->write.trans_id, param->write.handle); + ESP_LOGI(GATTS_TAG, "GATT_WRITE_EVT, conn_id %d, trans_id %" PRIu32 ", handle %d", param->write.conn_id, param->write.trans_id, param->write.handle); if (!param->write.is_prep){ ESP_LOGI(GATTS_TAG, "GATT_WRITE_EVT, value len %d, value :", param->write.len); esp_log_buffer_hex(GATTS_TAG, param->write.value, param->write.len); diff --git a/examples/bluetooth/bluedroid/ble/gatt_security_client/main/CMakeLists.txt b/examples/bluetooth/bluedroid/ble/gatt_security_client/main/CMakeLists.txt index 256eb6722c..9101064d3d 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_security_client/main/CMakeLists.txt +++ b/examples/bluetooth/bluedroid/ble/gatt_security_client/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "example_ble_sec_gattc_demo.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c b/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c index bb3e08cc14..013a69dc3a 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -18,6 +18,7 @@ #include #include #include +#include #include "nvs.h" #include "nvs_flash.h" @@ -407,11 +408,11 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par /* The app will receive this evt when the IO has DisplayYesNO capability and the peer device IO also has DisplayYesNo capability. show the passkey number to the user to confirm it with the number displayed by peer device. */ esp_ble_confirm_reply(param->ble_security.ble_req.bd_addr, true); - ESP_LOGI(GATTC_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%d", param->ble_security.key_notif.passkey); + ESP_LOGI(GATTC_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%" PRIu32, param->ble_security.key_notif.passkey); break; case ESP_GAP_BLE_PASSKEY_NOTIF_EVT: ///the app will receive this evt when the IO has Output capability and the peer device IO has Input capability. ///show the passkey number to the user to input it in the peer device. - ESP_LOGI(GATTC_TAG, "The passkey Notify number:%06d", param->ble_security.key_notif.passkey); + ESP_LOGI(GATTC_TAG, "The passkey Notify number:%06" PRIu32, param->ble_security.key_notif.passkey); break; case ESP_GAP_BLE_KEY_EVT: //shows the ble key info share with peer device to the user. diff --git a/examples/bluetooth/bluedroid/ble/gatt_security_server/main/CMakeLists.txt b/examples/bluetooth/bluedroid/ble/gatt_security_server/main/CMakeLists.txt index e91eef453d..f890f38d40 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_security_server/main/CMakeLists.txt +++ b/examples/bluetooth/bluedroid/ble/gatt_security_server/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "example_ble_sec_gatts_demo.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c b/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c index f3e665205a..5eeac671d7 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c @@ -1,9 +1,10 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/event_groups.h" @@ -327,7 +328,7 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param /* The app will receive this evt when the IO has DisplayYesNO capability and the peer device IO also has DisplayYesNo capability. show the passkey number to the user to confirm it with the number displayed by peer device. */ esp_ble_confirm_reply(param->ble_security.ble_req.bd_addr, true); - ESP_LOGI(GATTS_TABLE_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%d", param->ble_security.key_notif.passkey); + ESP_LOGI(GATTS_TABLE_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%" PRIu32, param->ble_security.key_notif.passkey); break; case ESP_GAP_BLE_SEC_REQ_EVT: /* send the positive(true) security response to the peer device to accept the security request. @@ -336,7 +337,7 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param break; case ESP_GAP_BLE_PASSKEY_NOTIF_EVT: ///the app will receive this evt when the IO has Output capability and the peer device IO has Input capability. ///show the passkey number to the user to input it in the peer device. - ESP_LOGI(GATTS_TABLE_TAG, "The passkey Notify number:%06d", param->ble_security.key_notif.passkey); + ESP_LOGI(GATTS_TABLE_TAG, "The passkey Notify number:%06" PRIu32, param->ble_security.key_notif.passkey); break; case ESP_GAP_BLE_KEY_EVT: //shows the ble key info share with peer device to the user. diff --git a/examples/bluetooth/bluedroid/ble/gatt_server/main/CMakeLists.txt b/examples/bluetooth/bluedroid/ble/gatt_server/main/CMakeLists.txt index df8ece30e3..379d4659ab 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_server/main/CMakeLists.txt +++ b/examples/bluetooth/bluedroid/ble/gatt_server/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "gatts_demo.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/bluetooth/bluedroid/ble/gatt_server/main/gatts_demo.c b/examples/bluetooth/bluedroid/ble/gatt_server/main/gatts_demo.c index 1bb5a29053..2b422b3858 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_server/main/gatts_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_server/main/gatts_demo.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -17,6 +17,7 @@ #include #include #include +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/event_groups.h" @@ -336,7 +337,7 @@ static void gatts_profile_a_event_handler(esp_gatts_cb_event_t event, esp_gatt_i esp_ble_gatts_create_service(gatts_if, &gl_profile_tab[PROFILE_A_APP_ID].service_id, GATTS_NUM_HANDLE_TEST_A); break; case ESP_GATTS_READ_EVT: { - ESP_LOGI(GATTS_TAG, "GATT_READ_EVT, conn_id %d, trans_id %d, handle %d\n", param->read.conn_id, param->read.trans_id, param->read.handle); + ESP_LOGI(GATTS_TAG, "GATT_READ_EVT, conn_id %d, trans_id %" PRIu32 ", handle %d\n", param->read.conn_id, param->read.trans_id, param->read.handle); esp_gatt_rsp_t rsp; memset(&rsp, 0, sizeof(esp_gatt_rsp_t)); rsp.attr_value.handle = param->read.handle; @@ -350,7 +351,7 @@ static void gatts_profile_a_event_handler(esp_gatts_cb_event_t event, esp_gatt_i break; } case ESP_GATTS_WRITE_EVT: { - ESP_LOGI(GATTS_TAG, "GATT_WRITE_EVT, conn_id %d, trans_id %d, handle %d", param->write.conn_id, param->write.trans_id, param->write.handle); + ESP_LOGI(GATTS_TAG, "GATT_WRITE_EVT, conn_id %d, trans_id %" PRIu32 ", handle %d", param->write.conn_id, param->write.trans_id, param->write.handle); if (!param->write.is_prep){ ESP_LOGI(GATTS_TAG, "GATT_WRITE_EVT, value len %d, value :", param->write.len); esp_log_buffer_hex(GATTS_TAG, param->write.value, param->write.len); @@ -508,7 +509,7 @@ static void gatts_profile_b_event_handler(esp_gatts_cb_event_t event, esp_gatt_i esp_ble_gatts_create_service(gatts_if, &gl_profile_tab[PROFILE_B_APP_ID].service_id, GATTS_NUM_HANDLE_TEST_B); break; case ESP_GATTS_READ_EVT: { - ESP_LOGI(GATTS_TAG, "GATT_READ_EVT, conn_id %d, trans_id %d, handle %d\n", param->read.conn_id, param->read.trans_id, param->read.handle); + ESP_LOGI(GATTS_TAG, "GATT_READ_EVT, conn_id %d, trans_id %" PRIu32 ", handle %d\n", param->read.conn_id, param->read.trans_id, param->read.handle); esp_gatt_rsp_t rsp; memset(&rsp, 0, sizeof(esp_gatt_rsp_t)); rsp.attr_value.handle = param->read.handle; @@ -522,7 +523,7 @@ static void gatts_profile_b_event_handler(esp_gatts_cb_event_t event, esp_gatt_i break; } case ESP_GATTS_WRITE_EVT: { - ESP_LOGI(GATTS_TAG, "GATT_WRITE_EVT, conn_id %d, trans_id %d, handle %d\n", param->write.conn_id, param->write.trans_id, param->write.handle); + ESP_LOGI(GATTS_TAG, "GATT_WRITE_EVT, conn_id %d, trans_id %" PRIu32 ", handle %d\n", param->write.conn_id, param->write.trans_id, param->write.handle); if (!param->write.is_prep){ ESP_LOGI(GATTS_TAG, "GATT_WRITE_EVT, value len %d, value :", param->write.len); esp_log_buffer_hex(GATTS_TAG, param->write.value, param->write.len); diff --git a/examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/CMakeLists.txt b/examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/CMakeLists.txt index 0f3ab3dc64..ac38069c88 100644 --- a/examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/CMakeLists.txt +++ b/examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "ble50_sec_gattc_demo.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/ble50_sec_gattc_demo.c b/examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/ble50_sec_gattc_demo.c index 789e4f4407..b08e6c8177 100644 --- a/examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/ble50_sec_gattc_demo.c +++ b/examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/ble50_sec_gattc_demo.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -18,6 +18,7 @@ #include #include #include +#include #include "nvs.h" #include "nvs_flash.h" @@ -450,11 +451,11 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par /* The app will receive this evt when the IO has DisplayYesNO capability and the peer device IO also has DisplayYesNo capability. show the passkey number to the user to confirm it with the number displayed by peer device. */ esp_ble_confirm_reply(param->ble_security.ble_req.bd_addr, true); - ESP_LOGI(GATTC_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%d", param->ble_security.key_notif.passkey); + ESP_LOGI(GATTC_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%" PRIu32, param->ble_security.key_notif.passkey); break; case ESP_GAP_BLE_PASSKEY_NOTIF_EVT: ///the app will receive this evt when the IO has Output capability and the peer device IO has Input capability. ///show the passkey number to the user to input it in the peer device. - ESP_LOGI(GATTC_TAG, "The passkey Notify number:%06d", param->ble_security.key_notif.passkey); + ESP_LOGI(GATTC_TAG, "The passkey Notify number:%06" PRIu32, param->ble_security.key_notif.passkey); break; case ESP_GAP_BLE_KEY_EVT: //shows the ble key info share with peer device to the user. diff --git a/examples/bluetooth/bluedroid/ble_50/ble50_security_server/main/CMakeLists.txt b/examples/bluetooth/bluedroid/ble_50/ble50_security_server/main/CMakeLists.txt index e85f895b5f..940c38d0b3 100644 --- a/examples/bluetooth/bluedroid/ble_50/ble50_security_server/main/CMakeLists.txt +++ b/examples/bluetooth/bluedroid/ble_50/ble50_security_server/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "ble50_sec_gatts_demo.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/bluetooth/bluedroid/ble_50/ble50_security_server/main/ble50_sec_gatts_demo.c b/examples/bluetooth/bluedroid/ble_50/ble50_security_server/main/ble50_sec_gatts_demo.c index b3ac9f7160..2584702c92 100644 --- a/examples/bluetooth/bluedroid/ble_50/ble50_security_server/main/ble50_sec_gatts_demo.c +++ b/examples/bluetooth/bluedroid/ble_50/ble50_security_server/main/ble50_sec_gatts_demo.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/event_groups.h" @@ -291,7 +292,7 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param /* The app will receive this evt when the IO has DisplayYesNO capability and the peer device IO also has DisplayYesNo capability. show the passkey number to the user to confirm it with the number displayed by peer device. */ esp_ble_confirm_reply(param->ble_security.ble_req.bd_addr, true); - ESP_LOGI(GATTS_TABLE_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%d", param->ble_security.key_notif.passkey); + ESP_LOGI(GATTS_TABLE_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%" PRIu32, param->ble_security.key_notif.passkey); break; case ESP_GAP_BLE_SEC_REQ_EVT: /* send the positive(true) security response to the peer device to accept the security request. @@ -300,7 +301,7 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param break; case ESP_GAP_BLE_PASSKEY_NOTIF_EVT: ///the app will receive this evt when the IO has Output capability and the peer device IO has Input capability. ///show the passkey number to the user to input it in the peer device. - ESP_LOGI(GATTS_TABLE_TAG, "The passkey Notify number:%06d", param->ble_security.key_notif.passkey); + ESP_LOGI(GATTS_TABLE_TAG, "The passkey Notify number:%06" PRIu32, param->ble_security.key_notif.passkey); break; case ESP_GAP_BLE_KEY_EVT: //shows the ble key info share with peer device to the user.