diff --git a/components/bt/Kconfig b/components/bt/Kconfig index f5c8b6fbe..793196ae1 100644 --- a/components/bt/Kconfig +++ b/components/bt/Kconfig @@ -289,8 +289,8 @@ menu Bluetooth config BTDM_CONTROLLER_FULL_SCAN_SUPPORTED bool "BLE full scan feature supported" - depends on BTDM_CONTROLLER_MODE_BLE_ONLY - default n + depends on BTDM_CONTROLLER_MODE_BLE_ONLY || BTDM_CONTROLLER_MODE_BTDM + default y help The full scan function is mainly used to provide BLE scan performance. This is required for scenes with high scan performance requirements, such as BLE Mesh scenes. diff --git a/components/bt/bluedroid/bta/av/bta_av_aact.c b/components/bt/bluedroid/bta/av/bta_av_aact.c index 27970a990..88cb8e442 100644 --- a/components/bt/bluedroid/bta/av/bta_av_aact.c +++ b/components/bt/bluedroid/bta/av/bta_av_aact.c @@ -41,6 +41,7 @@ #if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE) #include "bta/bta_ar_api.h" #endif +#include "bta/bta_api.h" /***************************************************************************** ** Constants @@ -528,8 +529,21 @@ static void bta_av_proc_stream_evt(UINT8 handle, BD_ADDR bd_addr, UINT8 event, t /* look up application event */ if ((p_data == NULL) || (p_data->hdr.err_code == 0)) { p_msg->hdr.event = bta_av_stream_evt_ok[event]; + if (p_msg->hdr.event == BTA_AV_STR_START_OK_EVT) { + BTA_DmCoexEventTrigger(BTA_COEX_EVT_STREAMING_STARTED); + } else if (p_msg->hdr.event == BTA_AV_STR_START_FAIL_EVT || + p_msg->hdr.event == BTA_AV_STR_SUSPEND_CFM_EVT || + p_msg->hdr.event == BTA_AV_STR_CLOSE_EVT) { + BTA_DmCoexEventTrigger(BTA_COEX_EVT_STREAMING_STOPPED); + } } else { p_msg->hdr.event = bta_av_stream_evt_fail[event]; + if (p_msg->hdr.event == BTA_AV_STR_START_FAIL_EVT || + p_msg->hdr.event == BTA_AV_STR_START_OK_EVT || + p_msg->hdr.event == BTA_AV_STR_SUSPEND_CFM_EVT || + p_msg->hdr.event == BTA_AV_STR_CLOSE_EVT) { + BTA_DmCoexEventTrigger(BTA_COEX_EVT_STREAMING_STOPPED); + } } p_msg->initiator = FALSE; diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index 5ded9a7f9..6b7d211a0 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -693,7 +693,6 @@ void bta_dm_set_visibility(tBTA_DM_MSG *p_data) if (p_data->set_visibility.pair_mode != BTA_DM_IGNORE || p_data->set_visibility.conn_paired_only != BTA_DM_IGNORE) { BTM_SetPairableMode((BOOLEAN)(!(bta_dm_cb.disable_pair_mode)), bta_dm_cb.conn_paired_only); } - } /******************************************************************************* @@ -3094,6 +3093,7 @@ static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data) p_msg->transport = p_data->conn.transport; p_msg->handle = p_data->conn.handle; #endif + BTA_DmCoexEventTrigger(BTA_COEX_EVT_ACL_CONNECTED); break; case BTM_BL_DISCN_EVT: bdcpy(p_msg->bd_addr, p_data->discn.p_bda); @@ -3101,6 +3101,7 @@ static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data) p_msg->transport = p_data->discn.transport; p_msg->handle = p_data->discn.handle; #endif + BTA_DmCoexEventTrigger(BTA_COEX_EVT_ACL_DISCONNECTED); break; case BTM_BL_UPDATE_EVT: p_msg->busy_level = p_data->update.busy_level; diff --git a/components/bt/bluedroid/bta/dm/bta_dm_main.c b/components/bt/bluedroid/bta/dm/bta_dm_main.c index 0f45dfbe9..782d55055 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_main.c @@ -28,6 +28,7 @@ #include "osi/allocator.h" #include +#include "esp_coexist.h" /***************************************************************************** ** Constants and types @@ -452,3 +453,33 @@ BOOLEAN bta_dm_search_sm_execute(BT_HDR *p_msg) return TRUE; } +void BTA_DmCoexEventTrigger(uint32_t event) +{ + switch(event) { + case BTA_COEX_EVT_SCAN_STARTED: + case BTA_COEX_EVT_SCAN_STOPPED: + case BTA_COEX_EVT_SNIFF_ENTER: + case BTA_COEX_EVT_SNIFF_EXIT: + case BTA_COEX_EVT_A2DP_PAUSED_ENTER: + case BTA_COEX_EVT_A2DP_PAUSED_EXIT: + break; + case BTA_COEX_EVT_ACL_CONNECTED: + esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_STREAMING); + esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_PAUSED); + break; + case BTA_COEX_EVT_ACL_DISCONNECTED: + esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_STREAMING); + esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_PAUSED); + break; + case BTA_COEX_EVT_STREAMING_STARTED: + esp_coex_status_bit_set(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_STREAMING); + esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_PAUSED); + break; + case BTA_COEX_EVT_STREAMING_STOPPED: + esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_STREAMING); + esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_PAUSED); + break; + default: + break; + } +} \ No newline at end of file diff --git a/components/bt/bluedroid/bta/include/bta/bta_api.h b/components/bt/bluedroid/bta/include/bta/bta_api.h index f384edeb4..8e5f0d2eb 100644 --- a/components/bt/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/bluedroid/bta/include/bta/bta_api.h @@ -1375,6 +1375,7 @@ typedef UINT8 tBTA_DM_LINK_TYPE; #define ALLOW_ALL_FILTER 0x00 #define LOWEST_RSSI_VALUE 129 + /***************************************************************************** ** External Function Declarations *****************************************************************************/ @@ -2601,6 +2602,21 @@ extern void BTA_VendorInit (void); *******************************************************************************/ extern void BTA_VendorCleanup (void); +enum { + BTA_COEX_EVT_SCAN_STARTED = 1, + BTA_COEX_EVT_SCAN_STOPPED, + BTA_COEX_EVT_ACL_CONNECTED, + BTA_COEX_EVT_ACL_DISCONNECTED, + BTA_COEX_EVT_STREAMING_STARTED, + BTA_COEX_EVT_STREAMING_STOPPED, + BTA_COEX_EVT_SNIFF_ENTER, + BTA_COEX_EVT_SNIFF_EXIT, + BTA_COEX_EVT_A2DP_PAUSED_ENTER, + BTA_COEX_EVT_A2DP_PAUSED_EXIT, +}; + +extern void BTA_DmCoexEventTrigger(uint32_t event); + #endif #ifdef __cplusplus diff --git a/components/bt/bluedroid/stack/include/stack/btm_ble_api.h b/components/bt/bluedroid/stack/include/stack/btm_ble_api.h index 7e6feb39b..6ac146a38 100644 --- a/components/bt/bluedroid/stack/include/stack/btm_ble_api.h +++ b/components/bt/bluedroid/stack/include/stack/btm_ble_api.h @@ -105,7 +105,7 @@ typedef UINT8 tBTM_BLE_SFP; #endif /* adv parameter boundary values */ -#define BTM_BLE_ADV_INT_MIN 0x0020 +#define BTM_BLE_ADV_INT_MIN 0x0010 #define BTM_BLE_ADV_INT_MAX 0x4000 /* Full scan boundary values */ diff --git a/components/bt/lib b/components/bt/lib index e8fce0677..5b3a571bf 160000 --- a/components/bt/lib +++ b/components/bt/lib @@ -1 +1 @@ -Subproject commit e8fce0677dda661d23d96d09c4a7bc1578e4ac48 +Subproject commit 5b3a571bfc58b5f05a09046f3fe02c08141df517 diff --git a/components/esp32/Kconfig b/components/esp32/Kconfig index ebd378e45..02053e1af 100644 --- a/components/esp32/Kconfig +++ b/components/esp32/Kconfig @@ -1065,37 +1065,6 @@ menu Wi-Fi If only Bluetooth is used, it is recommended to disable this option to reduce binary file size. - choice SW_COEXIST_PREFERENCE - prompt "WiFi/Bluetooth coexistence performance preference" - depends on SW_COEXIST_ENABLE - default SW_COEXIST_PREFERENCE_BALANCE - help - Choose Bluetooth/WiFi/Balance for different preference. - If choose WiFi, it will make WiFi performance better. Such, keep WiFi Audio more fluent. - If choose Bluetooth, it will make Bluetooth performance better. Such, keep Bluetooth(A2DP) Audio more - fluent. - If choose Balance, the performance of WiFi and bluetooth will be balance. It's default. Normally, just - choose balance, the A2DP audio can play fluently, too. - Except config preference in menuconfig, you can also call esp_coex_preference_set() dynamically. - - config SW_COEXIST_PREFERENCE_WIFI - bool "WiFi" - - config SW_COEXIST_PREFERENCE_BT - bool "Bluetooth(include BR/EDR and BLE)" - - config SW_COEXIST_PREFERENCE_BALANCE - bool "Balance" - - endchoice - - config SW_COEXIST_PREFERENCE_VALUE - int - depends on SW_COEXIST_ENABLE - default 0 if SW_COEXIST_PREFERENCE_WIFI - default 1 if SW_COEXIST_PREFERENCE_BT - default 2 if SW_COEXIST_PREFERENCE_BALANCE - config ESP32_WIFI_STATIC_RX_BUFFER_NUM int "Max number of WiFi static RX buffers" range 2 25 if !WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST diff --git a/components/esp32/include/esp_coexist.h b/components/esp32/include/esp_coexist.h index c9b241d3d..7d31e8602 100644 --- a/components/esp32/include/esp_coexist.h +++ b/components/esp32/include/esp_coexist.h @@ -32,6 +32,22 @@ typedef enum { ESP_COEX_PREFER_NUM, /*!< Prefer value numbers */ } esp_coex_prefer_t; + /** + * @brief coex status type + */ +typedef enum { + ESP_COEX_ST_TYPE_WIFI = 0, + ESP_COEX_ST_TYPE_BLE, + ESP_COEX_ST_TYPE_BT, +} esp_coex_status_type_t; + +#define ESP_COEX_BLE_ST_MESH_CONFIG 0x08 +#define ESP_COEX_BLE_ST_MESH_TRAFFIC 0x10 +#define ESP_COEX_BLE_ST_MESH_STANDBY 0x20 + +#define ESP_COEX_BT_ST_A2DP_STREAMING 0x10 +#define ESP_COEX_BT_ST_A2DP_PAUSED 0x20 + /** * @brief Get software coexist version string * @@ -40,7 +56,8 @@ typedef enum { const char *esp_coex_version_get(void); /** - * @brief Set coexist preference of performance + * @deprecated Use esp_coex_status_bit_set() and esp_coex_status_bit_clear() instead. + * Set coexist preference of performance * For example, if prefer to bluetooth, then it will make A2DP(play audio via classic bt) * more smooth while wifi is runnning something. * If prefer to wifi, it will do similar things as prefer to bluetooth. @@ -51,6 +68,23 @@ const char *esp_coex_version_get(void); */ esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer); +/** + * @brief Set coex schm status + * @param type : WIFI/BLE/BT + * @param status : WIFI/BLE/BT STATUS + * @return : ESP_OK - success, other - failed + */ +esp_err_t esp_coex_status_bit_set(esp_coex_status_type_t type, uint32_t status); + +/** + * @brief Clear coex schm status + * @param type : WIFI/BLE/BT + * @param status : WIFI/BLE/BT STATUS + * @return : ESP_OK - success, other - failed + */ +esp_err_t esp_coex_status_bit_clear(esp_coex_status_type_t type, uint32_t status); + + #ifdef __cplusplus } #endif diff --git a/components/esp32/lib b/components/esp32/lib index 3aa21ee5b..af82da39e 160000 --- a/components/esp32/lib +++ b/components/esp32/lib @@ -1 +1 @@ -Subproject commit 3aa21ee5be737121584c874a3188dd482163f30b +Subproject commit af82da39eb0d265bf813f7580f81a73224c30c6a diff --git a/components/esp32/phy_init.c b/components/esp32/phy_init.c index 35ca1cd0a..5968fef50 100644 --- a/components/esp32/phy_init.c +++ b/components/esp32/phy_init.c @@ -241,7 +241,6 @@ esp_err_t esp_phy_rf_init(const esp_phy_init_data_t* init_data, esp_phy_calibrat uint32_t phy_bt_wifi_mask = BIT(PHY_BT_MODULE) | BIT(PHY_WIFI_MODULE); if ((s_module_phy_rf_init & phy_bt_wifi_mask) == phy_bt_wifi_mask) { //both wifi & bt enabled coex_init(); - coex_preference_set(CONFIG_SW_COEXIST_PREFERENCE_VALUE); coex_resume(); } } diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index 98948127e..602743446 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -310,7 +310,8 @@ menu "LWIP" config TCP_SND_BUF_DEFAULT int "Default send buffer size" default 5744 # 4 * default MSS - range 2440 65535 + range 2440 65535 if !LWIP_WND_SCALE + range 2440 1024000 if LWIP_WND_SCALE help Set default send buffer size for new TCP sockets. @@ -326,7 +327,8 @@ menu "LWIP" config TCP_WND_DEFAULT int "Default receive window size" default 5744 # 4 * default MSS - range 2440 65535 + range 2440 65535 if !LWIP_WND_SCALE + range 2440 1024000 if LWIP_WND_SCALE help Set default TCP receive window size for new TCP sockets.