add thread br support

This commit is contained in:
liyashuai
2025-11-04 15:04:51 +08:00
parent e4d42e761b
commit 440db30e16
17 changed files with 315 additions and 101 deletions
@@ -245,6 +245,38 @@ static esp_err_t plugin_init_callback_endpoint(endpoint_t *endpoint)
return ESP_OK;
}
static esp_err_t cluster_server_init(endpoint_t *endpoint)
{
if (!endpoint) {
ESP_LOGE(TAG, "endpoint cannot be NULL");
return ESP_ERR_INVALID_ARG;
}
ESP_LOGI(TAG, "Cluster server init for the new added endpoint");
/* Take lock if not already taken */
lock::status_t lock_status = lock::chip_stack_lock(portMAX_DELAY);
VerifyOrReturnError(lock_status != lock::FAILED, ESP_FAIL, ESP_LOGE(TAG, "Could not get task context"));
cluster_t *cluster = cluster::get_first(endpoint);
while (cluster) {
uint8_t flags = cluster::get_flags(cluster);
cluster::initialization_callback_t init_callback = cluster::get_init_callback(cluster);
if (init_callback) {
init_callback(endpoint::get_id(endpoint));
}
if ((flags & CLUSTER_FLAG_SERVER) && (flags & CLUSTER_FLAG_INIT_FUNCTION)) {
cluster::function_cluster_init_t init_function =
(cluster::function_cluster_init_t)cluster::get_function(cluster, CLUSTER_FLAG_INIT_FUNCTION);
if (init_function) {
init_function(endpoint::get_id(endpoint));
}
}
cluster = cluster::get_next(cluster);
}
if (lock_status == lock::SUCCESS) {
lock::chip_stack_unlock();
}
return ESP_OK;
}
static bridge_device_type_callback_t device_type_callback;
esp_err_t set_device_type(device_t *bridged_device, uint32_t device_type_id, void *priv_data)
@@ -258,6 +290,9 @@ esp_err_t set_device_type(device_t *bridged_device, uint32_t device_type_id, voi
err = device_type_callback(bridged_device->endpoint, device_type_id, priv_data);
if (err != ESP_OK)
return err;
cluster_server_init(bridged_device->endpoint);
return plugin_init_callback_endpoint(bridged_device->endpoint);
}
@@ -1,8 +1,8 @@
# Rainmaker Bridge
This example demonstrates a Matter-Rainmaker Bridge that bridges Rainmaker devices to Matter fabric.
This example demonstrates a Matter-Rainmaker Bridge that bridges Rainmaker devices to the Matter fabric.
The Matter Bridge device is running on ESP32-S3.
The Matter Bridge device runs on ESP32-S3.
See the [docs](https://docs.espressif.com/projects/esp-matter/en/latest/esp32/developing.html) for more information about building and flashing the firmware.
@@ -12,11 +12,11 @@ See the [docs](https://docs.espressif.com/projects/esp-matter/en/latest/esp32/de
### 1.1 Hardware connection
This example run on ESP32S3 devkit by default.
This example runs on ESP32-S3 devkit by default.
### 1.2 Build and flash the Bridge (ESP32-S3)
For Standalone DevKit boards:
For Standalone DevKit boards without Thread Border Router:
```
cd ${ESP_MATTER_PATH}/examples/bridge_apps/esp_rainmaker_bridge
@@ -24,11 +24,21 @@ idf.py set-target esp32s3
idf.py -p <port> build flash
```
For ***ESP Thread Border Router/Zigbee Gateway Board*** with Thread Border Router:
```
cd ${ESP_MATTER_PATH}/examples/bridge_apps/esp_rainmaker_bridge
idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.otbr" set-target esp32s3
idf.py -p <port> build flash
```
## 2. Commissioning Setup
### 2.1 Use Rainmaker App pairing Bridge
### 2.1 Set up Rainmaker Bridge using Rainmaker App
Use Rainmaker App scan the qrcode print in device log to pairing the bridge
#### 2.1.1 Pair the bridge using Rainmaker App
Use the Rainmaker App to scan the QR code printed in the device log to pair the bridge.
```
I (16104) NimBLE: GAP procedure initiated: advertise;
@@ -67,13 +77,25 @@ I (16364) app_network: Provisioning will auto stop after 30 minute(s).
```
### 2.2 Use Rainmaker App pairing rainmaker end device
#### 2.1.2 Update Rainmaker Controller Params
Follow this [guide](https://github.com/espressif/esp-rainmaker/blob/master/README.md) to setup Rainmaker device
After successful Bridge pairing, it is necessary to use the parameter update function to grant the Bridge the Rainmaker controller permission. This enables the Bridge to have the authority to control other Rainmaker devices.
### 2.3 Use chip-tool pairing bridge through onnetwork method
![main](./docs/1_setup.png)
Use below command to pairing bridge
#### 2.1.3 Update Thread Dataset
If you need to bridge a Rainmaker over Thread device, you must update the Thread Border Router dataset after the Bridge is successfully paired.
![main](./docs/1_setup.png) ![main](./docs/3_dataset.png)
### 2.2 Pair Rainmaker end devices using Rainmaker App
Follow this [guide](https://github.com/espressif/esp-rainmaker/blob/master/README.md) to set up a Rainmaker device.
### 2.3 Pair the bridge using chip-tool through onnetwork method
Use the command below to pair the bridge.
```
./chip-tool pairing onnetwork 0x1234 20202021
@@ -81,7 +103,7 @@ Use below command to pairing bridge
### 2.4 Control the bulb with chip-tool
Now you can control the Rainmaker device using the chip tool.
Now you can control the Rainmaker device using chip-tool.
```
./chip-tool onoff toggle 0x1234 0x2
@@ -91,6 +113,8 @@ Now you can control the Rainmaker device using the chip tool.
### 3.1 Memory usage
**Config: Enable SPIRAM(2MB), 8MB flash, enable Thread Border Router**
The following is the Memory and Flash Usage.
- `Bootup` == Device just finished booting up. Device is not
@@ -102,14 +126,15 @@ The following is the Memory and Flash Usage.
- device used: ESP32-S3-DevKitC-1
- tested on:
[d0faa92c](https://github.com/espressif/esp-matter/commit/d0faa92c9336205de21a4b325c956893736c4d64)
(2025-09-29)
(2025-12-11)
- IDF: v5.4.1 [4c2820d3](https://github.com/espressif/esp-idf/tree/v5.4.1)
| | Bootup | After Rainmaker Commissioning | After Matter Commissioning | After Adding a Bridged device |
|:- |:-: |:-: |:-: |:-: |
|**Free Internal Memory** |162KB |118KB |118KB |106KB |
|**Free Internal Memory** |165KB |168KB |170KB |170KB |
|**Free SPIRAM Memory** |1886KB |1823KB |1858KB |1853KB |
**Flash Usage**: Firmware binary size: 1.65MB
**Flash Usage**: Firmware binary size: 1.98MB
This should give you a good idea about the amount of free memory that is
available for you to run your application's code.
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

@@ -103,20 +103,6 @@ esp_err_t app_network_set_custom_mfg_data(uint16_t device_type, uint8_t device_s
*/
esp_err_t app_network_set_custom_pop(const char *pop);
#if CONFIG_APP_WIFI_PROV_COMPAT
#define APP_WIFI_EVENT APP_NETWORK_EVENT
typedef app_network_event_t app_wifi_event_t;
#define APP_WIFI_EVENT_QR_DISPLAY APP_NETWORK_EVENT_QR_DISPLAY
#define APP_WIFI_EVENT_PROV_TIMEOUT APP_NETWORK_EVENT_PROV_TIMEOUT
#define APP_WIFI_EVENT_PROV_RESTART APP_NETWORK_EVENT_PROV_RESTART
#define APP_WIFI_EVENT_PROV_CRED_MISMATCH APP_NETWORK_EVENT_PROV_CRED_MISMATCH
typedef app_network_pop_type_t app_wifi_pop_type_t;
#define app_wifi_init() app_network_init()
#define app_wifi_start(pop_type) app_network_start(pop_type)
#define app_wifi_set_custom_mfg_data(device_type, device_subtype) app_network_set_custom_mfg_data(device_type, device_subtype)
#define app_wifi_set_custom_pop(pop) app_network_set_custom_pop(pop)
#endif /* !CONFIG_APP_WIFI_PROV_COMPAT */
#ifdef __cplusplus
}
#endif
@@ -1,32 +0,0 @@
/*
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#pragma once
#include <sdkconfig.h>
#include <app_network.h>
#ifdef __cplusplus
extern "C" {
#endif
#if CONFIG_APP_WIFI_PROV_COMPAT
#define APP_WIFI_EVENT APP_NETWORK_EVENT
typedef app_network_event_t app_wifi_event_t;
#define APP_WIFI_EVENT_QR_DISPLAY APP_NETWORK_EVENT_QR_DISPLAY
#define APP_WIFI_EVENT_PROV_TIMEOUT APP_NETWORK_EVENT_PROV_TIMEOUT
#define APP_WIFI_EVENT_PROV_RESTART APP_NETWORK_EVENT_PROV_RESTART
#define APP_WIFI_EVENT_PROV_CRED_MISMATCH APP_NETWORK_EVENT_PROV_CRED_MISMATCH
typedef app_network_pop_type_t app_wifi_pop_type_t;
#define app_wifi_init() app_network_init()
#define app_wifi_start(pop_type) app_network_start(pop_type)
#define app_wifi_set_custom_mfg_data(device_type, device_subtype) app_network_set_custom_mfg_data(device_type, device_subtype)
#define app_wifi_set_custom_pop(pop) app_network_set_custom_pop(pop)
#endif /* !CONFIG_APP_WIFI_PROV_COMPAT */
#ifdef __cplusplus
}
#endif
@@ -1,13 +0,0 @@
# sdkconfig replacement configurations for deprecated options formatted as
# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION
CONFIG_APP_WIFI_PROV_SHOW_QR CONFIG_APP_NETWORK_PROV_SHOW_QR
CONFIG_APP_WIFI_PROV_MAX_POP_MISMATCH CONFIG_APP_NETWORK_PROV_MAX_POP_MISMATCH
CONFIG_APP_WIFI_PROV_TRANSPORT_SOFTAP CONFIG_APP_NETWORK_PROV_TRANSPORT_SOFTAP
CONFIG_APP_WIFI_PROV_TRANSPORT_BLE CONFIG_APP_NETWORK_PROV_TRANSPORT_BLE
CONFIG_APP_WIFI_PROV_TRANSPORT CONFIG_APP_NETWORK_PROV_TRANSPORT
CONFIG_APP_WIFI_RESET_PROV_ON_FAILURE CONFIG_APP_NETWORK_RESET_PROV_ON_FAILURE
CONFIG_APP_WIFI_SHOW_DEMO_INTRO_TEXT CONFIG_APP_NETWORK_SHOW_DEMO_INTRO_TEXT
CONFIG_APP_WIFI_PROV_TIMEOUT_PERIOD CONFIG_APP_NETWORK_PROV_TIMEOUT_PERIOD
CONFIG_APP_WIFI_PROV_NAME_PREFIX CONFIG_APP_NETWORK_PROV_NAME_PREFIX
@@ -1,5 +1,6 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS "." "${ESP_MATTER_PATH}/examples/common/utils")
PRIV_INCLUDE_DIRS "." "${ESP_MATTER_PATH}/examples/common/utils"
LDFRAGMENTS "linker.lf")
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
@@ -7,6 +7,13 @@ menu "Rainmaker Bridge"
help
Set the period to get rainmaker devices params in rainmaker bridge.
config RAINMAKER_TASK_STACK_SIZE
int
default 10240
range 1024 65536
help
Set the stack size for the rainmaker task.
endmenu
menu "Thread BR Example"
@@ -90,16 +90,19 @@ esp_err_t create_bridge_devices(esp_matter::endpoint_t *ep, uint32_t device_type
}
case ESP_MATTER_DIMMABLE_LIGHT_DEVICE_TYPE_ID: {
dimmable_light::config_t dimmable_light_conf;
dimmable_light_conf.level_control_lighting.start_up_current_level = nullptr;
err = dimmable_light::add(ep, &dimmable_light_conf);
break;
}
case ESP_MATTER_COLOR_TEMPERATURE_LIGHT_DEVICE_TYPE_ID: {
color_temperature_light::config_t color_temperature_light_conf;
color_temperature_light_conf.level_control_lighting.start_up_current_level = nullptr;
err = color_temperature_light::add(ep, &color_temperature_light_conf);
break;
}
case ESP_MATTER_EXTENDED_COLOR_LIGHT_DEVICE_TYPE_ID: {
extended_color_light::config_t extended_color_light_conf;
extended_color_light_conf.level_control_lighting.start_up_current_level = nullptr;
err = extended_color_light::add(ep, &extended_color_light_conf);
cluster_t *color_cluster = cluster::get(ep, chip::app::Clusters::ColorControl::Id);
cluster::color_control::feature::hue_saturation::config_t hs_config;
@@ -137,12 +140,6 @@ extern "C" void app_main()
aggregator_endpoint_id = endpoint::get_id(aggregator);
#if CONFIG_ENABLE_CHIP_SHELL
esp_matter::console::diagnostics_register_commands();
esp_matter::console::wifi_register_commands();
esp_matter::console::factoryreset_register_commands();
esp_matter::console::init();
#endif
rainmaker_init();
/* Matter start */
@@ -151,4 +148,11 @@ extern "C" void app_main()
err = app_bridge_initialize(node, create_bridge_devices);
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to resume the bridged endpoints: %d", err));
#if CONFIG_ENABLE_CHIP_SHELL
esp_matter::console::diagnostics_register_commands();
esp_matter::console::wifi_register_commands();
esp_matter::console::factoryreset_register_commands();
esp_matter::console::init();
#endif
}
@@ -0,0 +1,70 @@
/*
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#pragma once
#include <esp_err.h>
#if CONFIG_OPENTHREAD_BORDER_ROUTER
#include <esp_openthread_types.h>
#include <esp_rcp_update.h>
#endif
#include <sdkconfig.h>
#ifdef __cplusplus
extern "C" {
#endif
#if CONFIG_OPENTHREAD_BORDER_ROUTER
#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \
{ \
.radio_mode = RADIO_MODE_UART_RCP, \
.radio_uart_config = { \
.port = 1, \
.uart_config = \
{ \
.baud_rate = 460800, \
.data_bits = UART_DATA_8_BITS, \
.parity = UART_PARITY_DISABLE, \
.stop_bits = UART_STOP_BITS_1, \
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, \
.rx_flow_ctrl_thresh = 0, \
.source_clk = UART_SCLK_DEFAULT, \
}, \
.rx_pin = CONFIG_PIN_TO_RCP_TX, \
.tx_pin = CONFIG_PIN_TO_RCP_RX, \
}, \
}
#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \
{ \
.host_connection_mode = HOST_CONNECTION_MODE_CLI_USB, \
.host_usb_config = USB_SERIAL_JTAG_DRIVER_CONFIG_DEFAULT(), \
}
#define ESP_OPENTHREAD_DEFAULT_PORT_CONFIG() \
{ \
.storage_partition_name = "nvs", .netif_queue_size = 10, \
.task_queue_size = 10, \
}
#ifdef CONFIG_AUTO_UPDATE_RCP
#define ESP_OPENTHREAD_RCP_UPDATE_CONFIG() \
{ \
.rcp_type = RCP_TYPE_ESP32H2_UART, .uart_rx_pin = CONFIG_PIN_TO_RCP_TX, .uart_tx_pin = CONFIG_PIN_TO_RCP_RX, \
.uart_port = 1, .uart_baudrate = 115200, .reset_pin = CONFIG_PIN_TO_RCP_RESET, \
.boot_pin = CONFIG_PIN_TO_RCP_BOOT, .update_baudrate = 460800, \
.firmware_dir = "/" CONFIG_RCP_PARTITION_NAME "/ot_rcp", .target_chip = ESP32H2_CHIP, \
}
#endif
#endif
#ifdef __cplusplus
}
#endif
@@ -1,6 +1,6 @@
dependencies:
espressif/esp_rainmaker:
version: "^1.4.2"
version: "~1.7.9" # Will update to latest version after the esp_rcp_update update to latest version.
espressif/qrcode:
version: "*"
espressif/button:
@@ -0,0 +1,31 @@
[mapping:CHIP]
archive: libCHIP.a
entries:
if SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y:
* (extram_bss)
else:
* (default)
[mapping:esp_matter]
archive: libesp_matter.a
entries:
if SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y:
* (extram_bss)
else:
* (default)
[mapping:main]
archive: libmain.a
entries:
if SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y:
* (extram_bss)
else:
* (default)
[mapping:openthread_bss]
archive: libopenthread.a
entries:
if SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y && OPENTHREAD_ENABLED = y:
* (extram_bss)
else:
* (default)
@@ -22,11 +22,22 @@
#include <app_network.h>
#include <common_macros.h>
#include <rainmaker_bridge.h>
#include <mdns.h>
#if CONFIG_OPENTHREAD_BORDER_ROUTER
#include <app_thread_config.h>
#include <esp_rmaker_thread_br.h>
#include <platform/ESP32/OpenthreadLauncher.h>
#ifdef CONFIG_AUTO_UPDATE_RCP
#include <esp_rcp_update.h>
#include <esp_spiffs.h>
#endif
#endif
#define INVALID_MATTER_DEVICE_TYPE 0xFFFF
static const char *TAG = "rainmaker_bridge";
using namespace chip;
using namespace chip::app::Clusters;
using namespace esp_matter;
using namespace esp_matter::cluster;
@@ -106,7 +117,9 @@ static esp_err_t get_attribute_value_from_rainmaker_device(uint16_t endpoint_id,
if (node_name[0] != 0) {
if (json_obj_get_object(&jctx, node_name) == 0) {
if (json_obj_get_int(&jctx, "Brightness", &attribute_value) == 0) {
attribute_update(endpoint_id, LevelControl::Id, LevelControl::Attributes::CurrentLevel::Id, attribute_value);
if (attribute_value > 0) {
attribute_update(endpoint_id, LevelControl::Id, LevelControl::Attributes::CurrentLevel::Id, attribute_value);
}
}
if (json_obj_get_int(&jctx, "Hue", &attribute_value) == 0) {
@@ -147,10 +160,10 @@ static uint32_t matter_get_device_type_from_rainmaker_device(const char *input_b
int device_count;
char type[32];
char param_type[32];
uint32_t matter_device_type_id = 0xFFFF;
uint32_t matter_device_type_id = INVALID_MATTER_DEVICE_TYPE;
if (json_parse_start(&jctx, input_buf, buf_length) != 0) {
return 0xFFFF;
return INVALID_MATTER_DEVICE_TYPE;
}
if (json_obj_get_array(&jctx, "devices", &device_count) == 0) {
@@ -247,7 +260,7 @@ static esp_err_t rainmaker_bridge_get_param_from_device(const char* node_id, uin
case ESP_MATTER_DIMMABLE_LIGHT_DEVICE_TYPE_ID:
case ESP_MATTER_ON_OFF_LIGHT_DEVICE_TYPE_ID:
{
get_attribute_value_from_rainmaker_device(endpoint_id ,node_id, app_bridge_get_rainmaker_node_name_by_matter_endpointid(endpoint_id));
get_attribute_value_from_rainmaker_device(endpoint_id, node_id, app_bridge_get_rainmaker_node_name_by_matter_endpointid(endpoint_id));
}
break;
/* Todo: add other device types */
@@ -290,7 +303,7 @@ static esp_err_t rainmaker_bridge_add_new_device(const char *node_id)
return ESP_FAIL;
}
matter_device_type = matter_get_device_type_from_rainmaker_device(receive_buffer, strlen(receive_buffer), node_name);
if ((matter_device_type != 0xFFFF) && (node_name[0] != 0)) {
if ((matter_device_type != INVALID_MATTER_DEVICE_TYPE) && (node_name[0] != 0)) {
rainmaker_bridge_match_device(node_id, node_name, matter_device_type);
} else {
ESP_LOGW(TAG, "Node %s device type 0x%lx is invalid\n", node_id, matter_device_type);
@@ -308,6 +321,7 @@ static esp_err_t rainmaker_bridge_delete_device(uint16_t endpoint_id)
if (node_id == NULL) {
ESP_LOGI(TAG, "Can't find rainmaker device from ep: %d", endpoint_id);
return ESP_FAIL;
}
app_bridged_device_t *bridged_device = app_bridge_get_device_by_rainmaker_node_id(node_id);
@@ -327,7 +341,7 @@ static void matter_check_and_remove_not_exist_device()
esp_matter_bridge::get_bridged_endpoint_ids(matter_endpoint_id_array);
for (int i = 0; i < MAX_BRIDGED_DEVICE_COUNT; i++) {
if (matter_endpoint_id_array[i] != 0xFFFF) {
if (matter_endpoint_id_array[i] != chip::kInvalidEndpointId) {
const char *node_id = app_bridge_get_rainmaker_node_id_by_matter_endpointid(matter_endpoint_id_array[i]);
if (node_id != NULL) {
char *buffer = esp_rainmaker_api_get_node_params(node_id);
@@ -372,7 +386,6 @@ static esp_err_t rainmaker_sync_nodes(char *out_buf, size_t out_buf_len)
json_obj_leave_array(&jctx);
} else {
ESP_LOGE(TAG, "No node found in json ");
json_obj_leave_array(&jctx);
}
json_parse_end(&jctx);
@@ -464,6 +477,25 @@ static esp_err_t write_cb(const esp_rmaker_device_t *device, const esp_rmaker_pa
return ESP_OK;
}
#ifdef CONFIG_AUTO_UPDATE_RCP
static esp_err_t init_spiffs()
{
esp_err_t err = ESP_OK;
esp_vfs_spiffs_conf_t rcp_fw_conf = {.base_path = "/" CONFIG_RCP_PARTITION_NAME,
.partition_label = CONFIG_RCP_PARTITION_NAME,
.max_files = 10, .format_if_mount_failed = false};
err = esp_vfs_spiffs_register(&rcp_fw_conf);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to mount rcp firmware storage");
}
return err;
}
#endif // CONFIG_AUTO_UPDATE_RCP
/**
* @brief Initialize the Rainmaker bridge
*
*/
void rainmaker_init()
{
/* Network Init */
@@ -483,36 +515,30 @@ void rainmaker_init()
}
esp_rmaker_device_t *device = esp_rmaker_device_create("Rainmaker Controller", ESP_RMAKER_DEVICE_CONTROLLER, NULL);
esp_rmaker_device_add_param(device, esp_rmaker_name_param_create(ESP_RMAKER_DEF_NAME_PARAM, "RainmakerController"));
esp_rmaker_node_add_device(node, device);
esp_rmaker_node_add_device(node, rainmaker_controller_service_create("RainmakerCTL", write_cb, NULL, NULL));
esp_rmaker_device_t *thread_br_device = esp_rmaker_device_create("ThreadBR", ESP_RMAKER_DEVICE_THREAD_BR, NULL);
esp_rmaker_device_add_param(thread_br_device,
esp_rmaker_name_param_create(ESP_RMAKER_DEF_NAME_PARAM, "ESP-ThreadBR"));
esp_rmaker_node_add_device(node, thread_br_device);
#if CONFIG_OPENTHREAD_BORDER_ROUTER
esp_openthread_platform_config_t thread_cfg = {
.radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG(),
.host_config = ESP_OPENTHREAD_DEFAULT_HOST_CONFIG(),
.port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG()
};
#ifdef CONFIG_AUTO_UPDATE_RCP
ESP_ERROR_CHECK(init_spiffs());
esp_rcp_update_config_t rcp_update_cfg = ESP_OPENTHREAD_RCP_UPDATE_CONFIG();
esp_rmaker_thread_br_enable(&thread_cfg, &rcp_update_cfg);
#else
esp_rmaker_thread_br_enable(&thread_cfg, NULL);
#endif
#endif // CONFIG_AUTO_UPDATE_RCP
#endif // CONFIG_OPENTHREAD_BORDER_ROUTER
esp_rmaker_start();
app_network_start(POP_TYPE_RANDOM);
/* create task to get node and params from rainmaker side */
xTaskCreate(rainmaker_bridge_task, "rainmaker_main", 10240, xTaskGetCurrentTaskHandle(), 5, NULL);
xTaskCreate(rainmaker_bridge_task, "rainmaker_main", CONFIG_RAINMAKER_TASK_STACK_SIZE, xTaskGetCurrentTaskHandle(), 5, NULL);
}
@@ -7,4 +7,5 @@ ota_0, app, ota_0, 0x20000, 0x250000,
ota_1, app, ota_1, 0x270000, 0x250000,
fctry, data, nvs, 0x4C0000, 0x6000,
phy_init, data, phy, 0x4C6000, 0x1000,
otadata, data, ota, 0x4C7000, 0x2000
otadata, data, ota, 0x4C7000, 0x2000,
rcp_fw, data, spiffs, 0x4C9000, 0x9A000,
1 # Name, Type, SubType, Offset, Size, Flags
7 ota_1, app, ota_1, 0x270000, 0x250000,
8 fctry, data, nvs, 0x4C0000, 0x6000,
9 phy_init, data, phy, 0x4C6000, 0x1000,
10 otadata, data, ota, 0x4C7000, 0x2000 otadata, data, ota, 0x4C7000, 0x2000,
11 rcp_fw, data, spiffs, 0x4C9000, 0x9A000,
@@ -45,3 +45,15 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN=y
# Disable BLE for matter
CONFIG_ENABLE_CHIPOBLE=n
# Use SPIRAM and external alloc
CONFIG_SPIRAM=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_SPIRAM_MODE_QUAD=y
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=512
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=16384
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL=y
CONFIG_ESP_MATTER_MEM_ALLOC_MODE_EXTERNAL=y
CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
@@ -0,0 +1,61 @@
# Temporary Fix for Timer Overflows
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=3120
# For additional security on reset to factory
CONFIG_ESP_RMAKER_USER_ID_CHECK=y
# Increase the MQTT task stack size to use generate new Thread dataset command
CONFIG_MQTT_USE_CUSTOM_CONFIG=y
CONFIG_MQTT_TASK_STACK_SIZE=7168
# mbedTLS
CONFIG_MBEDTLS_CMAC_C=y
CONFIG_MBEDTLS_SSL_PROTO_DTLS=y
CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y
CONFIG_MBEDTLS_ECJPAKE_C=y
# OpenThread
CONFIG_OPENTHREAD_ENABLED=y
CONFIG_OPENTHREAD_BORDER_ROUTER=y
CONFIG_OPENTHREAD_RADIO_SPINEL_UART=y
CONFIG_OPENTHREAD_LOG_LEVEL_DYNAMIC=n
CONFIG_OPENTHREAD_LOG_LEVEL_NOTE=y
CONFIG_OPENTHREAD_SRP_CLIENT=n
CONFIG_OPENTHREAD_DNS_CLIENT=n
CONFIG_THREAD_NETWORK_COMMISSIONING_DRIVER=n
CONFIG_ENABLE_MATTER_OVER_THREAD=n
CONFIG_AUTO_UPDATE_RCP=y
# lwIP
CONFIG_LWIP_IPV6_FORWARD=y
CONFIG_LWIP_IPV6_NUM_ADDRESSES=12
CONFIG_LWIP_MULTICAST_PING=y
CONFIG_LWIP_NETIF_STATUS_CALLBACK=y
CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y
CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y
CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM=y
CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_CUSTOM=y
CONFIG_LWIP_IPV6_AUTOCONFIG=y
# mDNS
CONFIG_USE_MINIMAL_MDNS=n
CONFIG_MDNS_MULTIPLE_INSTANCE=y
# ESP System Settings
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=3584
# USB console for Thread border board
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
# Firmware size optimization
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y
CONFIG_COMPILER_SAVE_RESTORE_LIBCALLS=y
CONFIG_NEWLIB_NANO_FORMAT=y
CONFIG_ESP_ERR_TO_NAME_LOOKUP=n
# ESP Thread border router board
CONFIG_ESP_THREAD_BR_BOARD_DEV_KIT=y
CONFIG_ENABLE_ROUTE_HOOK=n