Skip to content

Commit

Permalink
Merge branch 'feature/support_ext_conn' into 'master'
Browse files Browse the repository at this point in the history
Feature/support ext conn

Closes IDF-7865

See merge request espressif/esp-idf!29884
  • Loading branch information
jack0c committed Apr 1, 2024
2 parents d5c6e53 + f3c5047 commit 3f486c4
Show file tree
Hide file tree
Showing 33 changed files with 1,345 additions and 418 deletions.
4 changes: 3 additions & 1 deletion components/bt/host/bluedroid/bta/dm/bta_dm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
#include "osi/allocator.h"
#include <string.h>

#ifdef CONFIG_ESP_COEX_ENABLED
#include "esp_coexist.h"
#endif

/*****************************************************************************
** Constants and types
Expand Down Expand Up @@ -91,7 +93,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
bta_dm_pin_reply, /* BTA_DM_API_PIN_REPLY_EVT */
#endif ///SMP_INCLUDED == TRUE
#if (BTA_DM_PM_INCLUDED == TRUE)
/* power manger events */
/* power manager events */
bta_dm_pm_btm_status, /* BTA_DM_PM_BTM_STATUS_EVT */
bta_dm_pm_timer, /* BTA_DM_PM_TIMER_EVT */
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
Expand Down
59 changes: 32 additions & 27 deletions components/esp_coex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,47 @@ if(${idf_target} STREQUAL "linux")
return() # This component is not supported by the POSIX/Linux simulator
endif()

if(CONFIG_ESP_COEX_SW_COEXIST_ENABLE OR CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE)
if(CONFIG_APP_NO_BLOBS)
set(link_binary_libs 0)
set(ldfragments)
else()
set(link_binary_libs 1)
set(ldfragments "linker.lf")
if(CONFIG_ESP_COEX_ENABLED)
if(CONFIG_ESP_COEX_SW_COEXIST_ENABLE OR CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE)
if(CONFIG_APP_NO_BLOBS)
set(link_binary_libs 0)
set(ldfragments)
else()
set(link_binary_libs 1)
set(ldfragments "linker.lf")
endif()
set(srcs "src/coexist.c"
"src/lib_printf.c"
"${idf_target}/esp_coex_adapter.c")
endif()
set(srcs "src/coexist.c"
"${idf_target}/esp_coex_adapter.c")
endif()

if(CONFIG_ESP_WIFI_ENABLED)
list(APPEND srcs "${idf_target}/esp_coex_adapter.c")
if(CONFIG_ESP_WIFI_ENABLED)
list(APPEND srcs "${idf_target}/esp_coex_adapter.c")
endif()
endif()

idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "include"
PRIV_REQUIRES esp_timer driver esp_event
LDFRAGMENTS "${ldfragments}")

if(CONFIG_ESP_COEX_SW_COEXIST_ENABLE OR CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE)
idf_build_get_property(build_dir BUILD_DIR)

set(target_name "${idf_target}")
target_link_directories(${COMPONENT_LIB} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}")

if(link_binary_libs)
set(blob coexist)
add_prebuilt_library(${blob} "${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}/lib${blob}.a"
REQUIRES ${COMPONENT_NAME})
target_link_libraries(${COMPONENT_LIB} PUBLIC ${blob})
if(CONFIG_IDF_TARGET_ESP32)
target_link_libraries(${COMPONENT_LIB} PRIVATE btdm_app)
if(CONFIG_ESP_COEX_ENABLED)
if(CONFIG_ESP_COEX_SW_COEXIST_ENABLE OR CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE)
idf_build_get_property(build_dir BUILD_DIR)

set(target_name "${idf_target}")
target_link_directories(${COMPONENT_LIB} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}")

if(link_binary_libs)
set(blob coexist)
add_prebuilt_library(${blob} "${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}/lib${blob}.a"
REQUIRES ${COMPONENT_NAME})
target_link_libraries(${COMPONENT_LIB} PUBLIC ${blob})
if(CONFIG_IDF_TARGET_ESP32)
target_link_libraries(${COMPONENT_LIB} PRIVATE btdm_app)
endif()
endif()
endif()

target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
endif()
endif()
53 changes: 30 additions & 23 deletions components/esp_coex/Kconfig
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@

menu "Wireless Coexistence"
config ESP_COEX_SW_COEXIST_ENABLE
bool "Software controls WiFi/Bluetooth coexistence"
depends on (ESP_WIFI_ENABLED && BT_ENABLED) || \
(ESP_WIFI_ENABLED && IEEE802154_ENABLED) || \
(IEEE802154_ENABLED && BT_ENABLED)
default y
select ESP_WIFI_STA_DISCONNECTED_PM_ENABLE if (ESP_WIFI_ENABLED)
help
If enabled, WiFi & Bluetooth coexistence is controlled by software rather than hardware.
Recommended for heavy traffic scenarios. Both coexistence configuration options are
automatically managed, no user intervention is required.
If only Bluetooth is used, it is recommended to disable this option to reduce binary file
size.

config ESP_COEX_EXTERNAL_COEXIST_ENABLE
bool "External Coexistence"
default n
depends on (!(BT_ENABLED||NIMBLE_ENABLED)&&(!IDF_TARGET_ESP32))
help
If enabled, HW External coexistence arbitration is managed by GPIO pins.
It can support three types of wired combinations so far which are 1-wired/2-wired/3-wired.
User can select GPIO pins in application code with configure interfaces.
config ESP_COEX_ENABLED
bool
default y if (!SOC_WIRELESS_HOST_SUPPORTED)

This function depends on BT-off
because currently we do not support external coex and internal coex simultaneously.
if(ESP_COEX_ENABLED)
config ESP_COEX_SW_COEXIST_ENABLE
bool "Software controls WiFi/Bluetooth coexistence"
depends on (ESP_WIFI_ENABLED && BT_ENABLED) || \
(ESP_WIFI_ENABLED && IEEE802154_ENABLED) || \
(IEEE802154_ENABLED && BT_ENABLED)
default y
select ESP_WIFI_STA_DISCONNECTED_PM_ENABLE if (ESP_WIFI_ENABLED)
help
If enabled, WiFi & Bluetooth coexistence is controlled by software rather than hardware.
Recommended for heavy traffic scenarios. Both coexistence configuration options are
automatically managed, no user intervention is required.
If only Bluetooth is used, it is recommended to disable this option to reduce binary file
size.

config ESP_COEX_EXTERNAL_COEXIST_ENABLE
bool "External Coexistence"
default n
depends on (!(BT_ENABLED||NIMBLE_ENABLED)&&(!IDF_TARGET_ESP32))
help
If enabled, HW External coexistence arbitration is managed by GPIO pins.
It can support three types of wired combinations so far which are 1-wired/2-wired/3-wired.
User can select GPIO pins in application code with configure interfaces.

This function depends on BT-off
because currently we do not support external coex and internal coex simultaneously.

endif
endmenu # Wireless Coexistence
52 changes: 52 additions & 0 deletions components/esp_coex/src/lib_printf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @file lib_printf.c
*
* This file contains library-specific printf functions
* used by WiFi libraries in the `lib` directory.
* These function are used to catch any output which gets printed
* by libraries, and redirect it to ESP_LOG macros.
*
* Eventually WiFi libraries will use ESP_LOG functions internally
* and these definitions will be removed.
*/

#include <stdio.h>
#include <stdlib.h>
#include "esp_log.h"
#include "esp_attr.h"

#define VPRINTF_STACK_BUFFER_SIZE 80

static int lib_printf(const char* tag, const char* format, va_list arg)
{
char temp[VPRINTF_STACK_BUFFER_SIZE];
int len = vsnprintf(temp, sizeof(temp) - 1, format, arg);
temp[sizeof(temp) - 1] = 0;
int i;
for (i = len - 1; i >= 0; --i) {
if (temp[i] != '\n' && temp[i] != '\r' && temp[i] != ' ') {
break;
}
temp[i] = 0;
}
if (i > 0) {
ESP_LOGI(tag, "%s", temp);
}
va_end(arg);
return len;
}

int coexist_printf(const char* format, ...)
{
va_list arg;
va_start(arg, format);
int res = lib_printf("coexist", format, arg);
va_end(arg);
return res;
}
Loading

0 comments on commit 3f486c4

Please sign in to comment.