mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
feat(openthread): make esp_netif glue optional
Signed-off-by: Zhibin (Ryan) Wen <wenzhibin@espressif.com>
This commit is contained in:
@@ -249,7 +249,7 @@ menu "OpenThread"
|
|||||||
|
|
||||||
config OPENTHREAD_BORDER_ROUTER
|
config OPENTHREAD_BORDER_ROUTER
|
||||||
bool "Enable Border Router"
|
bool "Enable Border Router"
|
||||||
depends on OPENTHREAD_FTD
|
depends on OPENTHREAD_FTD && OPENTHREAD_PLATFORM_NETIF
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Select this option to enable border router features in OpenThread.
|
Select this option to enable border router features in OpenThread.
|
||||||
@@ -299,7 +299,7 @@ menu "OpenThread"
|
|||||||
|
|
||||||
config OPENTHREAD_DNS64_CLIENT
|
config OPENTHREAD_DNS64_CLIENT
|
||||||
bool "Enable DNS64 Client"
|
bool "Enable DNS64 Client"
|
||||||
depends on LWIP_IPV4
|
depends on LWIP_IPV4 && OPENTHREAD_PLATFORM_NETIF
|
||||||
select LWIP_HOOK_DNS_EXTERNAL_RESOLVE_SELECT_CUSTOM
|
select LWIP_HOOK_DNS_EXTERNAL_RESOLVE_SELECT_CUSTOM
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
@@ -508,6 +508,15 @@ menu "OpenThread"
|
|||||||
failure.
|
failure.
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
|
config OPENTHREAD_PLATFORM_NETIF
|
||||||
|
bool "Enable esp_netif/lwIP glue"
|
||||||
|
depends on OPENTHREAD_FTD || OPENTHREAD_MTD
|
||||||
|
default y
|
||||||
|
help
|
||||||
|
Enable the default ESP-IDF OpenThread integration which creates an
|
||||||
|
OpenThread esp_netif, attaches the esp_netif glue, and enables
|
||||||
|
lwIP-specific DNS/netif handling.
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
menu "Thread Log"
|
menu "Thread Log"
|
||||||
|
|||||||
@@ -454,6 +454,21 @@
|
|||||||
#endif
|
#endif
|
||||||
#define OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_MARGIN CONFIG_OPENTHREAD_PARENT_SEARCH_RSS_MARGIN
|
#define OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_MARGIN CONFIG_OPENTHREAD_PARENT_SEARCH_RSS_MARGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE
|
||||||
|
*
|
||||||
|
* Define to 1 to enable platform NETIF support.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifdef OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE
|
||||||
|
#error `OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE` is redefined.
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_OPENTHREAD_PLATFORM_NETIF
|
||||||
|
#ifndef OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE
|
||||||
|
#define OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/*----The following options set fixed default values but can be overridden by the user header file.----*/
|
/*----The following options set fixed default values but can be overridden by the user header file.----*/
|
||||||
|
|
||||||
#if CONFIG_OPENTHREAD_BORDER_ROUTER
|
#if CONFIG_OPENTHREAD_BORDER_ROUTER
|
||||||
@@ -703,16 +718,6 @@
|
|||||||
#define OPENTHREAD_CONFIG_COAP_API_ENABLE 1
|
#define OPENTHREAD_CONFIG_COAP_API_ENABLE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* @def OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE
|
|
||||||
*
|
|
||||||
* Define to 1 to enable platform NETIF support.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#ifndef OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE
|
|
||||||
#define OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
|
* @def OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -245,6 +245,21 @@
|
|||||||
#endif
|
#endif
|
||||||
#define OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT CONFIG_OPENTHREAD_MAC_MAX_CSMA_BACKOFFS_DIRECT
|
#define OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT CONFIG_OPENTHREAD_MAC_MAX_CSMA_BACKOFFS_DIRECT
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE
|
||||||
|
*
|
||||||
|
* Define to 1 to enable platform NETIF support.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifdef OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE
|
||||||
|
#error `OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE` is redefined.
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_OPENTHREAD_PLATFORM_NETIF
|
||||||
|
#ifndef OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE
|
||||||
|
#define OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/*----The following options set fixed default values but can be overridden by the user header file.----*/
|
/*----The following options set fixed default values but can be overridden by the user header file.----*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -257,16 +272,6 @@
|
|||||||
#define OPENTHREAD_CONFIG_COAP_API_ENABLE 1
|
#define OPENTHREAD_CONFIG_COAP_API_ENABLE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* @def OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE
|
|
||||||
*
|
|
||||||
* Define to 1 to enable platform NETIF support.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#ifndef OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE
|
|
||||||
#define OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
|
* @def OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ static void ot_task_worker(void *aContext)
|
|||||||
// Initialize the OpenThread stack
|
// Initialize the OpenThread stack
|
||||||
ESP_ERROR_CHECK(esp_openthread_init(&(config->platform_config)));
|
ESP_ERROR_CHECK(esp_openthread_init(&(config->platform_config)));
|
||||||
|
|
||||||
#if CONFIG_OPENTHREAD_FTD || CONFIG_OPENTHREAD_MTD
|
#if CONFIG_OPENTHREAD_PLATFORM_NETIF
|
||||||
esp_netif_t *openthread_netif = esp_netif_new(&(config->netif_config));
|
esp_netif_t *openthread_netif = esp_netif_new(&(config->netif_config));
|
||||||
assert(openthread_netif != NULL);
|
assert(openthread_netif != NULL);
|
||||||
ESP_ERROR_CHECK(esp_netif_attach(openthread_netif, esp_openthread_netif_glue_init(&(config->platform_config))));
|
ESP_ERROR_CHECK(esp_netif_attach(openthread_netif, esp_openthread_netif_glue_init(&(config->platform_config))));
|
||||||
@@ -285,7 +285,7 @@ static void ot_task_worker(void *aContext)
|
|||||||
esp_openthread_cli_console_command_unregister();
|
esp_openthread_cli_console_command_unregister();
|
||||||
#endif // CONFIG_OPENTHREAD_CLI
|
#endif // CONFIG_OPENTHREAD_CLI
|
||||||
|
|
||||||
#if CONFIG_OPENTHREAD_FTD || CONFIG_OPENTHREAD_MTD
|
#if CONFIG_OPENTHREAD_PLATFORM_NETIF
|
||||||
// Clean up
|
// Clean up
|
||||||
esp_openthread_netif_glue_deinit();
|
esp_openthread_netif_glue_deinit();
|
||||||
esp_netif_destroy(openthread_netif);
|
esp_netif_destroy(openthread_netif);
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ static esp_openthread_netif_glue_t s_openthread_netif_glue = {
|
|||||||
.event_fd = -1,
|
.event_fd = -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_EVENT_DEFINE_BASE(OPENTHREAD_EVENT);
|
|
||||||
|
|
||||||
static QueueHandle_t s_packet_queue;
|
static QueueHandle_t s_packet_queue;
|
||||||
static esp_netif_t *s_openthread_netif;
|
static esp_netif_t *s_openthread_netif;
|
||||||
static const char *netif_glue_workflow = "netif_glue";
|
static const char *netif_glue_workflow = "netif_glue";
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#define TAG "OT_STATE"
|
#define TAG "OT_STATE"
|
||||||
|
|
||||||
|
ESP_EVENT_DEFINE_BASE(OPENTHREAD_EVENT);
|
||||||
|
|
||||||
#if CONFIG_OPENTHREAD_BORDER_ROUTER
|
#if CONFIG_OPENTHREAD_BORDER_ROUTER
|
||||||
static void handle_ot_border_router_state_changed(otInstance* instance)
|
static void handle_ot_border_router_state_changed(otInstance* instance)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -107,6 +107,12 @@ if(NOT CONFIG_OPENTHREAD_DNS64_CLIENT)
|
|||||||
"src/esp_openthread_dns64.c")
|
"src/esp_openthread_dns64.c")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT CONFIG_OPENTHREAD_PLATFORM_NETIF)
|
||||||
|
list(APPEND exclude_srcs
|
||||||
|
"src/esp_openthread_lwip_netif.c"
|
||||||
|
"src/esp_openthread_netif_glue.c")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT CONFIG_FREERTOS_USE_TICKLESS_IDLE)
|
if(NOT CONFIG_FREERTOS_USE_TICKLESS_IDLE)
|
||||||
list(APPEND exclude_srcs
|
list(APPEND exclude_srcs
|
||||||
"src/port/esp_openthread_sleep.c")
|
"src/port/esp_openthread_sleep.c")
|
||||||
|
|||||||
Reference in New Issue
Block a user