Skip to content

Commit

Permalink
Merge branch 'feature/enable_external_coex_for_br' into 'main'
Browse files Browse the repository at this point in the history
feat(esp_coex): Enable external coexist of border router example

See merge request espressif/esp-thread-br!85
  • Loading branch information
chshu committed Sep 27, 2023
2 parents 7426343 + 568221c commit dc6a6de
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 4 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ These features are currently provided by the SDK:
* **NAT64**: The devices can access the IPv4 Internet via the border router.
* **RCP Update**: The built border router image will contain an updatable RCP image and can automatically update the RCP on version mismatch or RCP failure.
* **Web GUI**: The border router will enable a web server and provide some practical functions including Thread network discovery, network formation and status query.

In the future releases, the following features will be added:

* RF Coexistence
* **RF Coexistence**: The border router supports optional external coexistence, a feature that enhances the transmission performance when there are channel conflicts between the Wi-Fi and Thread networks.

# Resources

Expand Down
9 changes: 9 additions & 0 deletions docs/en/dev-guide/build_and_run.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,15 @@ Disable ``OPENTHREAD_BR_AUTO_START`` option if you want to setup the network man
thread start
2.1.3.6. RF External coexistence
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Enable ``EXTERNAL_COEX_ENABLE`` option if you want to enable the RF External coexistence.

.. note::

To enable external coexistence of the Thread Border Router, enable the ``EXTERNAL_COEX_ENABLE`` option of ``$IDF_PATH/examples/openthread/ot_rcp`` before building the RCP Image.

2.1.4. Build and Run the Thread Border Router
---------------------------------------------

Expand Down
17 changes: 17 additions & 0 deletions examples/basic_thread_border_router/main/esp_ot_br.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
#include "border_router_launch.h"
#include "esp_br_web.h"

#if CONFIG_EXTERNAL_COEX_ENABLE
#include "esp_coexist.h"
#endif

#define TAG "esp_ot_br"

extern const uint8_t server_cert_pem_start[] asm("_binary_ca_cert_pem_start");
Expand All @@ -49,6 +53,15 @@ static esp_err_t init_spiffs(void)
return ESP_OK;
}

#if CONFIG_EXTERNAL_COEX_ENABLE
static void ot_br_external_coexist_init(void)
{
esp_external_coex_gpio_set_t gpio_pin = ESP_OPENTHREAD_DEFAULT_EXTERNAL_COEX_CONFIG();
esp_external_coex_set_work_mode(EXTERNAL_COEX_LEADER_ROLE);
ESP_ERROR_CHECK(esp_enable_extern_coex_gpio_pin(CONFIG_EXTERNAL_COEX_WIRE_TYPE, gpio_pin));
}
#endif /* CONFIG_EXTERNAL_COEX_ENABLE */

void app_main(void)
{
// Used eventfds:
Expand Down Expand Up @@ -89,6 +102,10 @@ void app_main(void)
#error No backbone netif!
#endif // CONFIG_EXAMPLE_CONNECT_WIFI

#if CONFIG_EXTERNAL_COEX_ENABLE
ot_br_external_coexist_init();
#endif // CONFIG_EXTERNAL_COEX_ENABLE

ESP_ERROR_CHECK(mdns_init());
ESP_ERROR_CHECK(mdns_hostname_set("esp-ot-br"));
esp_set_ota_server_cert((char *)server_cert_pem_start);
Expand Down
30 changes: 30 additions & 0 deletions examples/basic_thread_border_router/main/esp_ot_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

#include "esp_openthread_types.h"

#if CONFIG_EXTERNAL_COEX_ENABLE
#include "esp_coexist.h"
#endif

#define RCP_FIRMWARE_DIR "/spiffs/ot_rcp"

#if CONFIG_OPENTHREAD_RADIO_SPINEL_UART
Expand Down Expand Up @@ -97,3 +101,29 @@
{ \
.storage_partition_name = "nvs", .netif_queue_size = 10, .task_queue_size = 10, \
}

#if CONFIG_EXTERNAL_COEX_ENABLE
#if CONFIG_EXTERNAL_COEX_WIRE_TYPE == EXTERNAL_COEXIST_WIRE_1
#define ESP_OPENTHREAD_DEFAULT_EXTERNAL_COEX_CONFIG() \
{ \
.request = CONFIG_EXTERNAL_COEX_REQUEST_PIN, \
}
#elif CONFIG_EXTERNAL_COEX_WIRE_TYPE == EXTERNAL_COEXIST_WIRE_2
#define ESP_OPENTHREAD_DEFAULT_EXTERNAL_COEX_CONFIG() \
{ \
.request = CONFIG_EXTERNAL_COEX_REQUEST_PIN, .grant = CONFIG_EXTERNAL_COEX_GRANT_PIN, \
}
#elif CONFIG_EXTERNAL_COEX_WIRE_TYPE == EXTERNAL_COEXIST_WIRE_3
#define ESP_OPENTHREAD_DEFAULT_EXTERNAL_COEX_CONFIG() \
{ \
.request = CONFIG_EXTERNAL_COEX_REQUEST_PIN, .priority = CONFIG_EXTERNAL_COEX_PRIORITY_PIN, \
.grant = CONFIG_EXTERNAL_COEX_GRANT_PIN, \
}
#elif CONFIG_EXTERNAL_COEX_WIRE_TYPE == EXTERNAL_COEXIST_WIRE_4
#define ESP_OPENTHREAD_DEFAULT_EXTERNAL_COEX_CONFIG() \
{ \
.request = CONFIG_EXTERNAL_COEX_REQUEST_PIN, .priority = CONFIG_EXTERNAL_COEX_PRIORITY_PIN, \
.grant = CONFIG_EXTERNAL_COEX_GRANT_PIN, .tx_line = CONFIG_EXTERNAL_COEX_TX_LINE_PIN, \
}
#endif
#endif // CONFIG_EXTERNAL_COEX_ENABLE
30 changes: 30 additions & 0 deletions examples/common/thread_border_router/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,34 @@ menu "ESP Thread Border Router Example"
help
If enabled, a web server will be provided to configure and query Thread network via a Web GUI.

menu "External coexist wire type and pin config"
config EXTERNAL_COEX_WIRE_TYPE
int "The wire_type of external coexist"
depends on ESP_COEX_EXTERNAL_COEXIST_ENABLE
default 3
range 0 3
help
Select wire_type for external coexist, the wire_type define in external_coex_wire_t.

config EXTERNAL_COEX_REQUEST_PIN
int "The number of external coexist request pin"
depends on ESP_COEX_EXTERNAL_COEXIST_ENABLE && (EXTERNAL_COEX_WIRE_TYPE >= 0)
default 12

config EXTERNAL_COEX_GRANT_PIN
int "The number of external coexist grant pin"
depends on ESP_COEX_EXTERNAL_COEXIST_ENABLE && (EXTERNAL_COEX_WIRE_TYPE >= 1)
default 13

config EXTERNAL_COEX_PRIORITY_PIN
int "The number of external coexist priority pin"
depends on ESP_COEX_EXTERNAL_COEXIST_ENABLE && (EXTERNAL_COEX_WIRE_TYPE >= 2)
default 10

config EXTERNAL_COEX_TX_LINE_PIN
int "The number of external coexist tx_line pin"
depends on ESP_COEX_EXTERNAL_COEXIST_ENABLE && (EXTERNAL_COEX_WIRE_TYPE = 3)
default 11
endmenu # External coexist wire type and pin config

endmenu

0 comments on commit dc6a6de

Please sign in to comment.