From e3df7d97a7a81020901ae7a2b28515dd198ff995 Mon Sep 17 00:00:00 2001 From: Tian Hao Date: Sun, 24 Jun 2018 16:38:05 +0800 Subject: [PATCH] esp32: fix coex bug 1. fix BLE connection missing in coex mode 2. modify other parameters to make coex priority more reasonable 3. fix modem sleep procedure trap cause Wifi disable RF when BT is working. Such cause that BR/EDR is difficult to be connected, BLE connection stability decrease and so on. 4. modify BR/EDR coexist duration to imrove BR/EDR connect success ratio. 5. Due to the hardware coexist bug, BLE scan interval/window should be less than 0x100(about 160ms). Therefore, it will cause BLE cannot scan any advertising packet while WiFi have higher priority behaviour(such like RX beacon, scan, TX/RX VO packets and etc.). --- components/bt/bt.c | 15 ++++++++++++--- components/bt/lib | 2 +- components/esp32/include/esp_phy_init.h | 4 ++++ components/esp32/lib | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/components/bt/bt.c b/components/bt/bt.c index f3960136b..71b2e28b7 100644 --- a/components/bt/bt.c +++ b/components/bt/bt.c @@ -915,7 +915,14 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode) esp_phy_load_cal_and_init(PHY_BT_MODULE); - if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) { + if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_NONE) { + //Just register to sleep module, make the modem sleep modules check BT sleep status when sleep enter. + //Thus, it will prevent WIFI from disabling RF when BT is not in sleep but is using RF. + esp_modem_sleep_register(MODEM_BLE_MODULE); + esp_modem_sleep_register(MODEM_CLASSIC_BT_MODULE); + esp_modem_sleep_exit(MODEM_BLE_MODULE); + esp_modem_sleep_exit(MODEM_CLASSIC_BT_MODULE); + } else if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) { esp_modem_sleep_register(MODEM_BLE_MODULE); esp_modem_sleep_register(MODEM_CLASSIC_BT_MODULE); } else if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_EVED) { @@ -933,7 +940,8 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode) ret = btdm_controller_enable(mode); if (ret) { - if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) { + if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_NONE + || btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) { esp_modem_sleep_deregister(MODEM_BLE_MODULE); esp_modem_sleep_deregister(MODEM_CLASSIC_BT_MODULE); } else if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_EVED) { @@ -973,7 +981,8 @@ esp_err_t esp_bt_controller_disable(void) } if (ret == ESP_BT_MODE_IDLE) { - if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) { + if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_NONE + || btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) { esp_modem_sleep_deregister(MODEM_BLE_MODULE); esp_modem_sleep_deregister(MODEM_CLASSIC_BT_MODULE); } else if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_EVED) { diff --git a/components/bt/lib b/components/bt/lib index e0740ac07..48b2459bc 160000 --- a/components/bt/lib +++ b/components/bt/lib @@ -1 +1 @@ -Subproject commit e0740ac07b0939bcfc089e580df460ed3cdd950c +Subproject commit 48b2459bcb4b9b6d6c64b93a1b8c6c70e25dfbd7 diff --git a/components/esp32/include/esp_phy_init.h b/components/esp32/include/esp_phy_init.h index 7a453bfcf..f06375d1a 100644 --- a/components/esp32/include/esp_phy_init.h +++ b/components/esp32/include/esp_phy_init.h @@ -202,6 +202,10 @@ esp_err_t esp_modem_sleep_exit(modem_sleep_module_t module); /** * @brief Register module to make it be able to require to enter/exit modem sleep + * Although the module has no sleep function, as long as the module use RF, + * it must call esp_modem_sleep_regsiter. Otherwise, other modules with sleep + * function will disable RF without checking the module which doesn't call + * esp_modem_sleep_regsiter. */ esp_err_t esp_modem_sleep_register(modem_sleep_module_t module); diff --git a/components/esp32/lib b/components/esp32/lib index 534a9b141..0bfda8bbf 160000 --- a/components/esp32/lib +++ b/components/esp32/lib @@ -1 +1 @@ -Subproject commit 534a9b14101af90231d40a4f94924d67bc848d5f +Subproject commit 0bfda8bbf6a804298b357614f5f215248c36bce3