From cd7457684f31359893d84faf53aeb5917e90f98d Mon Sep 17 00:00:00 2001 From: WanqQixiang Date: Tue, 13 Jun 2023 12:07:49 +0800 Subject: [PATCH] Submodule: update submodule to 6382144be --- connectedhomeip/connectedhomeip | 2 +- examples/generic_switch/main/app_main.cpp | 12 ++++++++++++ examples/generic_switch/main/app_priv.h | 21 +++++++++++++++++++++ examples/light/main/app_main.cpp | 14 ++++++++++++++ examples/light/main/app_priv.h | 21 +++++++++++++++++++++ examples/light_switch/main/app_main.cpp | 13 +++++++++++++ examples/light_switch/main/app_priv.h | 21 +++++++++++++++++++++ examples/zap_light/main/app_main.cpp | 13 +++++++++++++ examples/zap_light/main/app_priv.h | 21 +++++++++++++++++++++ 9 files changed, 137 insertions(+), 1 deletion(-) diff --git a/connectedhomeip/connectedhomeip b/connectedhomeip/connectedhomeip index 04b2fdfc6..6382144be 160000 --- a/connectedhomeip/connectedhomeip +++ b/connectedhomeip/connectedhomeip @@ -1 +1 @@ -Subproject commit 04b2fdfc6f7259116a50170b0d38dab9507e20d3 +Subproject commit 6382144be831a7bb930ed11823c00d7c0f9ba0da diff --git a/examples/generic_switch/main/app_main.cpp b/examples/generic_switch/main/app_main.cpp index f64a1dc70..7979ae65e 100644 --- a/examples/generic_switch/main/app_main.cpp +++ b/examples/generic_switch/main/app_main.cpp @@ -16,6 +16,9 @@ #include #include +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#include +#endif static const char *TAG = "app_main"; @@ -177,6 +180,15 @@ extern "C" void app_main() * // Call to createButton function to configure your button. * create_button(&button, node); */ +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + /* Set OpenThread platform config */ + esp_openthread_platform_config_t config = { + .radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG(), + .host_config = ESP_OPENTHREAD_DEFAULT_HOST_CONFIG(), + .port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG(), + }; + set_openthread_platform_config(&config); +#endif /* Matter start */ err = esp_matter::start(app_event_cb); diff --git a/examples/generic_switch/main/app_priv.h b/examples/generic_switch/main/app_priv.h index db8707a2a..2c0d76bf4 100644 --- a/examples/generic_switch/main/app_priv.h +++ b/examples/generic_switch/main/app_priv.h @@ -12,6 +12,10 @@ #include #include +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#include "esp_openthread_types.h" +#endif + struct gpio_button { gpio_num_t GPIO_PIN_VALUE; @@ -53,3 +57,20 @@ app_driver_handle_t app_driver_button_init(gpio_button *button = NULL); */ esp_err_t app_driver_attribute_update(app_driver_handle_t driver_handle, uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \ + { \ + .radio_mode = RADIO_MODE_NATIVE, \ + } + +#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \ + { \ + .host_connection_mode = HOST_CONNECTION_MODE_NONE, \ + } + +#define ESP_OPENTHREAD_DEFAULT_PORT_CONFIG() \ + { \ + .storage_partition_name = "ot_storage", .netif_queue_size = 10, .task_queue_size = 10, \ + } +#endif diff --git a/examples/light/main/app_main.cpp b/examples/light/main/app_main.cpp index 5f51f1699..ce4428086 100644 --- a/examples/light/main/app_main.cpp +++ b/examples/light/main/app_main.cpp @@ -16,9 +16,13 @@ #include #include +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#include +#endif #include #include + static const char *TAG = "app_main"; uint16_t light_endpoint_id = 0; @@ -162,6 +166,16 @@ extern "C" void app_main() light_endpoint_id = endpoint::get_id(endpoint); ESP_LOGI(TAG, "Light created with endpoint_id %d", light_endpoint_id); +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + /* Set OpenThread platform config */ + esp_openthread_platform_config_t config = { + .radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG(), + .host_config = ESP_OPENTHREAD_DEFAULT_HOST_CONFIG(), + .port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG(), + }; + set_openthread_platform_config(&config); +#endif + /* Matter start */ err = esp_matter::start(app_event_cb); if (err != ESP_OK) { diff --git a/examples/light/main/app_priv.h b/examples/light/main/app_priv.h index 867f8c899..c2a3ff49e 100644 --- a/examples/light/main/app_priv.h +++ b/examples/light/main/app_priv.h @@ -11,6 +11,10 @@ #include #include +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#include "esp_openthread_types.h" +#endif + /** Standard max values (used for remapping attributes) */ #define STANDARD_BRIGHTNESS 100 #define STANDARD_HUE 360 @@ -75,3 +79,20 @@ esp_err_t app_driver_attribute_update(app_driver_handle_t driver_handle, uint16_ * @return error in case of failure. */ esp_err_t app_driver_light_set_defaults(uint16_t endpoint_id); + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \ + { \ + .radio_mode = RADIO_MODE_NATIVE, \ + } + +#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \ + { \ + .host_connection_mode = HOST_CONNECTION_MODE_NONE, \ + } + +#define ESP_OPENTHREAD_DEFAULT_PORT_CONFIG() \ + { \ + .storage_partition_name = "ot_storage", .netif_queue_size = 10, .task_queue_size = 10, \ + } +#endif diff --git a/examples/light_switch/main/app_main.cpp b/examples/light_switch/main/app_main.cpp index 52ecfc17e..00f0258ae 100644 --- a/examples/light_switch/main/app_main.cpp +++ b/examples/light_switch/main/app_main.cpp @@ -16,6 +16,9 @@ #include #include +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#include +#endif static const char *TAG = "app_main"; uint16_t switch_endpoint_id = 0; @@ -107,6 +110,16 @@ extern "C" void app_main() switch_endpoint_id = endpoint::get_id(endpoint); ESP_LOGI(TAG, "Switch created with endpoint_id %d", switch_endpoint_id); +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + /* Set OpenThread platform config */ + esp_openthread_platform_config_t config = { + .radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG(), + .host_config = ESP_OPENTHREAD_DEFAULT_HOST_CONFIG(), + .port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG(), + }; + set_openthread_platform_config(&config); +#endif + /* Matter start */ err = esp_matter::start(app_event_cb); if (err != ESP_OK) { diff --git a/examples/light_switch/main/app_priv.h b/examples/light_switch/main/app_priv.h index 0e3916336..df4da43a4 100644 --- a/examples/light_switch/main/app_priv.h +++ b/examples/light_switch/main/app_priv.h @@ -11,6 +11,10 @@ #include #include +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#include "esp_openthread_types.h" +#endif + typedef void *app_driver_handle_t; /** Initialize the switch driver @@ -21,3 +25,20 @@ typedef void *app_driver_handle_t; * @return NULL in case of failure. */ app_driver_handle_t app_driver_switch_init(); + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \ + { \ + .radio_mode = RADIO_MODE_NATIVE, \ + } + +#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \ + { \ + .host_connection_mode = HOST_CONNECTION_MODE_NONE, \ + } + +#define ESP_OPENTHREAD_DEFAULT_PORT_CONFIG() \ + { \ + .storage_partition_name = "ot_storage", .netif_queue_size = 10, .task_queue_size = 10, \ + } +#endif diff --git a/examples/zap_light/main/app_main.cpp b/examples/zap_light/main/app_main.cpp index b63ac8acd..8be743b2b 100644 --- a/examples/zap_light/main/app_main.cpp +++ b/examples/zap_light/main/app_main.cpp @@ -15,6 +15,9 @@ #include #include +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#include +#endif using namespace esp_matter; using namespace esp_matter::attribute; @@ -89,6 +92,16 @@ extern "C" void app_main() attribute::set_callback(app_attribute_update_cb); light_endpoint_id = 1; /* This is from zap-generated/endpoint_config.h */ +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + /* Set OpenThread platform config */ + esp_openthread_platform_config_t config = { + .radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG(), + .host_config = ESP_OPENTHREAD_DEFAULT_HOST_CONFIG(), + .port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG(), + }; + set_openthread_platform_config(&config); +#endif + /* Matter start */ err = esp_matter::start(app_event_cb); if (err != ESP_OK) { diff --git a/examples/zap_light/main/app_priv.h b/examples/zap_light/main/app_priv.h index 867b265c2..7728ba092 100644 --- a/examples/zap_light/main/app_priv.h +++ b/examples/zap_light/main/app_priv.h @@ -11,6 +11,10 @@ #include #include +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#include "esp_openthread_types.h" +#endif + /** Standard max values (used for remapping attributes) */ #define STANDARD_BRIGHTNESS 100 #define STANDARD_HUE 360 @@ -71,3 +75,20 @@ esp_err_t app_driver_attribute_update(app_driver_handle_t driver_handle, uint16_ * @return error in case of failure. */ esp_err_t app_driver_light_set_defaults(uint16_t endpoint_id); + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \ + { \ + .radio_mode = RADIO_MODE_NATIVE, \ + } + +#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \ + { \ + .host_connection_mode = HOST_CONNECTION_MODE_NONE, \ + } + +#define ESP_OPENTHREAD_DEFAULT_PORT_CONFIG() \ + { \ + .storage_partition_name = "ot_storage", .netif_queue_size = 10, .task_queue_size = 10, \ + } +#endif