Skip to content

Commit f1f445e

Browse files
committed
Merge branch 'feat/add_a_m5Stack_br_example' into 'main'
feat: add a border router example based on m5stack See merge request espressif/esp-thread-br!164
2 parents ab7f19c + 6af15ad commit f1f445e

35 files changed

+3171
-28
lines changed

.gitlab-ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ pre_commit:
6060
- cp ${CI_TOOLS_PATH}/basic_thread_border_router.cmake CMakeLists.txt
6161
- idf.py build
6262

63+
.build_m5stack_thread_border_router: &build_m5stack_thread_border_router
64+
- cd $IDF_PATH/examples/openthread/ot_rcp
65+
- idf.py set-target esp32h2
66+
- git rev-parse HEAD
67+
- idf.py build
68+
- cd $ESP_THREAD_BR_PATH/examples/m5stack_thread_border_router
69+
- git fetch origin main
70+
- python3 $ESP_THREAD_BR_PATH/example_build_version_check.py m5stack_thread_border_router esp_ot_cli_extension
71+
- python3 $ESP_THREAD_BR_PATH/example_build_version_check.py m5stack_thread_border_router esp_rcp_update
72+
- rm -rf CMakeLists.txt
73+
- cp ${CI_TOOLS_PATH}/basic_thread_border_router.cmake CMakeLists.txt
74+
- idf.py build
75+
6376
.build_local_components: &build_local_components
6477
- cd $IDF_PATH/examples/openthread/ot_rcp
6578
- idf.py set-target esp32h2
@@ -120,6 +133,15 @@ build_examples:
120133
tags:
121134
- build
122135

136+
build_examples_m5stack:
137+
stage: build
138+
image: espressif/idf:v5.4.1
139+
script:
140+
- *submodule_update
141+
- *build_m5stack_thread_border_router
142+
tags:
143+
- build
144+
123145
build_examples_local_components:
124146
stage: build
125147
image: $ESP_ENV_IMAGE

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ repos:
66
rev: 'v14.0.6' # Use the sha / tag you want to point at
77
hooks:
88
- id: clang-format
9+
exclude: "examples/common/thread_border_router_m5stack/image/.*"
910

1011
- repo: local
1112
hooks:

components/esp_ot_cli_extension/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.3.3"
1+
version: "1.3.4"
22
description: Espressif OpenThread CLI Extension
33
url: https://github.com/espressif/esp-thread-br/tree/main/components/esp_ot_cli_extension
44
dependencies:

components/esp_ot_cli_extension/include/esp_ot_wifi_cmd.h

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ typedef enum {
2727
otError esp_ot_process_wifi_cmd(void *aContext, uint8_t aArgsLength, char *aArgs[]);
2828

2929
/**
30-
* @brief This function set or clear the border router initalization flag.
30+
* @brief This function sets or clears the border router initalization flag.
3131
*
3232
* @param[in] initialized border router is or not initalized.
3333
*/
3434
void esp_ot_wifi_border_router_init_flag_set(bool initialized);
3535

3636
/**
37-
* @brief This function connect the wifi.
37+
* @brief This function connects to Wi-Fi.
3838
*
39-
* @param[in] ssid ssid of wifi
40-
* @param[in] password password of wifi
39+
* @param[in] ssid ssid of Wi-Fi
40+
* @param[in] password password of Wi-Fi
4141
*
4242
* @return
4343
* - ESP_OK on success
@@ -46,7 +46,16 @@ void esp_ot_wifi_border_router_init_flag_set(bool initialized);
4646
esp_err_t esp_ot_wifi_connect(const char *ssid, const char *password);
4747

4848
/**
49-
* @brief This function initalize the nvs for wifi configurations.
49+
* @brief This function disconnects Wi-Fi.
50+
*
51+
* @return
52+
* - ESP_OK on success
53+
* - others on failure
54+
*/
55+
esp_err_t esp_ot_wifi_disconnect(void);
56+
57+
/**
58+
* @brief This function initializes the nvs for Wi-Fi configurations.
5059
*
5160
* @return
5261
* - ESP_OK on success
@@ -55,9 +64,9 @@ esp_err_t esp_ot_wifi_connect(const char *ssid, const char *password);
5564
esp_err_t esp_ot_wifi_config_init(void);
5665

5766
/**
58-
* @brief This function set the wifi ssid.
67+
* @brief This function sets the Wi-Fi ssid.
5968
*
60-
* @param[in] ssid pointer to ssid of wifi
69+
* @param[in] ssid pointer to ssid of Wi-Fi
6170
*
6271
* @return
6372
* - ESP_OK on success
@@ -66,9 +75,9 @@ esp_err_t esp_ot_wifi_config_init(void);
6675
esp_err_t esp_ot_wifi_config_set_ssid(const char *ssid);
6776

6877
/**
69-
* @brief This function get the wifi ssid.
78+
* @brief This function gets the Wi-Fi ssid.
7079
*
71-
* @param[in] password pointer to password of wifi
80+
* @param[in] password pointer to password of Wi-Fi
7281
*
7382
* @return
7483
* - ESP_OK on success
@@ -77,9 +86,9 @@ esp_err_t esp_ot_wifi_config_set_ssid(const char *ssid);
7786
esp_err_t esp_ot_wifi_config_get_ssid(char *ssid);
7887

7988
/**
80-
* @brief This function set the wifi password.
89+
* @brief This function sets the Wi-Fi password.
8190
*
82-
* @param[in] ssid pointer to ssid of wifi
91+
* @param[in] ssid pointer to ssid of Wi-Fi
8392
*
8493
* @return
8594
* - ESP_OK on success
@@ -88,9 +97,9 @@ esp_err_t esp_ot_wifi_config_get_ssid(char *ssid);
8897
esp_err_t esp_ot_wifi_config_set_password(const char *password);
8998

9099
/**
91-
* @brief This function get the wifi password.
100+
* @brief This function gets the Wi-Fi password.
92101
*
93-
* @param[in] password pointer to password of wifi
102+
* @param[in] password pointer to password of Wi-Fi
94103
*
95104
* @return
96105
* - ESP_OK on success
@@ -99,14 +108,24 @@ esp_err_t esp_ot_wifi_config_set_password(const char *password);
99108
esp_err_t esp_ot_wifi_config_get_password(char *password);
100109

101110
/**
102-
* @brief This function clear the wifi configurations stored in nvs.
111+
* @brief This function clears the Wi-Fi configurations stored in nvs.
103112
*
104113
* @return
105114
* - ESP_OK on success
106115
* - others on failure
107116
*/
108117
esp_err_t esp_ot_wifi_config_clear(void);
109118

119+
/**
120+
* @brief This function gets the Wi-Fi state.
121+
*
122+
* @return
123+
* OT_WIFI_DISCONNECTED if Wi-Fi is disconnected
124+
* OT_WIFI_CONNECTED if Wi-Fi is connected
125+
* OT_WIFI_RECONNECTING if Wi-Fi is reconnecting
126+
*/
127+
esp_ot_wifi_state_t esp_ot_wifi_state_get(void);
128+
110129
#ifdef __cplusplus
111130
}
112131
#endif

components/esp_ot_cli_extension/src/esp_ot_wifi_cmd.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,4 +420,9 @@ esp_err_t esp_ot_wifi_config_clear(void)
420420
ESP_RETURN_ON_FALSE((s_wifi_config_nvs_handle != 0), ESP_FAIL, OT_EXT_CLI_TAG, "wifi_config NVS handle is invalid");
421421
ESP_RETURN_ON_ERROR(nvs_erase_all(s_wifi_config_nvs_handle), OT_EXT_CLI_TAG, "Fail to clear wifi configurations");
422422
return ESP_OK;
423+
}
424+
425+
esp_ot_wifi_state_t esp_ot_wifi_state_get(void)
426+
{
427+
return s_wifi_state;
423428
}

examples/basic_thread_border_router/main/esp_ot_br.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void app_main(void)
8989
ESP_ERROR_CHECK(esp_event_loop_create_default());
9090

9191
#if !CONFIG_OPENTHREAD_BR_AUTO_START && CONFIG_EXAMPLE_CONNECT_ETHERNET
92-
// TODO: Add a menchanism for connecting ETH manually.
92+
// TODO: Add a mechanism for connecting ETH manually.
9393
#error Currently we do not support a manual way to connect ETH, if you want to use ETH, please enable OPENTHREAD_BR_AUTO_START.
9494
#endif
9595

examples/common/thread_border_router/Kconfig.projbuild

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,57 @@ menu "ESP Thread Border Router Example"
1515
bool "Border router dev kit"
1616
help
1717
Integrated border router dev kit
18+
19+
config ESP_BR_BOARD_M5STACK_CORES3
20+
bool "Border router M5Stack CoreS3"
21+
help
22+
M5Stack CoreS3
1823
endchoice
1924

2025
menu "Board Configuration"
2126
config PIN_TO_RCP_RESET
2227
int "Pin to RCP reset"
23-
default "7"
28+
default 7 if ESP_BR_BOARD_DEV_KIT
29+
default 7 if ESP_BR_BOARD_M5STACK_CORES3
2430

2531
config PIN_TO_RCP_BOOT
2632
int "Pin to RCP boot"
27-
default "8"
33+
default 8 if ESP_BR_BOARD_DEV_KIT
34+
default 18 if ESP_BR_BOARD_M5STACK_CORES3
2835

2936
config PIN_TO_RCP_TX
3037
int "Pin to RCP TX"
31-
default "17"
38+
default 17 if ESP_BR_BOARD_DEV_KIT
39+
default 10 if ESP_BR_BOARD_M5STACK_CORES3
3240

3341
config PIN_TO_RCP_RX
3442
int "Pin to RCP RX"
35-
default "18"
43+
default 18 if ESP_BR_BOARD_DEV_KIT
44+
default 17 if ESP_BR_BOARD_M5STACK_CORES3
3645

3746
config PIN_TO_RCP_CS
3847
depends on OPENTHREAD_RADIO_SPINEL_SPI
3948
int "Pin to RCP SPI CS"
40-
default "10"
49+
default 10 if ESP_BR_BOARD_DEV_KIT
50+
default 13 if ESP_BR_BOARD_M5STACK_CORES3
4151

4252
config PIN_TO_RCP_SCLK
4353
depends on OPENTHREAD_RADIO_SPINEL_SPI
4454
int "Pin to RCP SPI SCLK"
45-
default "12"
55+
default 12 if ESP_BR_BOARD_DEV_KIT
56+
default 36 if ESP_BR_BOARD_M5STACK_CORES3
4657

4758
config PIN_TO_RCP_MISO
4859
depends on OPENTHREAD_RADIO_SPINEL_SPI
4960
int "Pin to RCP SPI MISO"
50-
default "13"
61+
default 13 if ESP_BR_BOARD_DEV_KIT
62+
default 35 if ESP_BR_BOARD_M5STACK_CORES3
5163

5264
config PIN_TO_RCP_MOSI
5365
depends on OPENTHREAD_RADIO_SPINEL_SPI
5466
int "Pin to RCP SPI MOSI"
55-
default "11"
67+
default 11 if ESP_BR_BOARD_DEV_KIT
68+
default 37 if ESP_BR_BOARD_M5STACK_CORES3
5669
endmenu
5770

5871
choice ESP_BR_RCP_TARGET
@@ -100,22 +113,26 @@ menu "ESP Thread Border Router Example"
100113
config EXTERNAL_COEX_REQUEST_PIN
101114
int "The number of external coexist request pin"
102115
depends on ESP_COEX_EXTERNAL_COEXIST_ENABLE && (EXTERNAL_COEX_WIRE_TYPE >= 0)
103-
default 12
116+
default 12 if ESP_BR_BOARD_DEV_KIT
117+
default 36 if ESP_BR_BOARD_M5STACK_CORES3
104118

105119
config EXTERNAL_COEX_GRANT_PIN
106120
int "The number of external coexist grant pin"
107121
depends on ESP_COEX_EXTERNAL_COEXIST_ENABLE && (EXTERNAL_COEX_WIRE_TYPE >= 1)
108-
default 13
122+
default 13 if ESP_BR_BOARD_DEV_KIT
123+
default 35 if ESP_BR_BOARD_M5STACK_CORES3
109124

110125
config EXTERNAL_COEX_PRIORITY_PIN
111126
int "The number of external coexist priority pin"
112127
depends on ESP_COEX_EXTERNAL_COEXIST_ENABLE && (EXTERNAL_COEX_WIRE_TYPE >= 2)
113-
default 10
128+
default 10 if ESP_BR_BOARD_DEV_KIT
129+
default 13 if ESP_BR_BOARD_M5STACK_CORES3
114130

115131
config EXTERNAL_COEX_TX_LINE_PIN
116132
int "The number of external coexist tx_line pin"
117133
depends on ESP_COEX_EXTERNAL_COEXIST_ENABLE && (EXTERNAL_COEX_WIRE_TYPE = 3)
118-
default 11
134+
default 11 if ESP_BR_BOARD_DEV_KIT
135+
default 37 if ESP_BR_BOARD_M5STACK_CORES3
119136
endmenu # External coexist wire type and pin config
120137

121138
endmenu
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
set(requires esp_ot_cli_extension openthread protocol_examples_common vfs esp_wifi esp_eth esp_rcp_update m5stack_core_s3)
2+
3+
if(CONFIG_OPENTHREAD_CLI_OTA)
4+
list(APPEND requires esp_http_client esp_br_http_ota)
5+
endif()
6+
7+
set(extra_include_dirs
8+
$ENV{IDF_PATH}/components/openthread/private_include)
9+
10+
idf_component_register(SRC_DIRS "src" "image"
11+
INCLUDE_DIRS "include" "private_include" "${extra_include_dirs}"
12+
REQUIRES "${requires}"
13+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
menu "ESP Thread Border Router M5Stack Example"
2+
3+
config OPENTHREAD_EPHEMERALKEY_LIFE_TIME
4+
int "The life time (seconds) of openthread ephemeral key"
5+
default 100
6+
help
7+
Set the lifetime of the OpenThread ephemeral key in seconds.
8+
9+
config OPENTHREAD_EPHEMERALKEY_PORT
10+
int "The UDP port to use with the ephemeral key"
11+
default 49180
12+
help
13+
Set the UDP port to use with the ephemeral key.
14+
15+
endmenu

0 commit comments

Comments
 (0)