mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-14 06:04:19 +00:00
feat(openthread): allow enabling trel before getting interface
This commit is contained in:
@@ -37,3 +37,6 @@ examples/openthread/ot_sleepy_device/light_sleep:
|
||||
examples/openthread/ot_trel:
|
||||
enable:
|
||||
- if: SOC_WIFI_SUPPORTED == 1
|
||||
disable_test:
|
||||
- if: IDF_TARGET not in ["esp32c6", "esp32s3"]
|
||||
reason: only test on esp32c6 and esp32s3
|
||||
|
@@ -34,7 +34,8 @@ Component config → ESP System Settings → Channel for console output → USB
|
||||
Build the project and flash it to the board, then run monitor tool to view serial output:
|
||||
|
||||
```
|
||||
idf.py -p PORT build flash monitor
|
||||
idf.py build
|
||||
idf.py -p PORT erase-flash flash monitor
|
||||
```
|
||||
|
||||
Now you'll get an OpenThread command line shell.
|
||||
|
@@ -1,4 +1,4 @@
|
||||
menu "OpenThread CLI Example"
|
||||
menu "OpenThread TREL Example"
|
||||
|
||||
config OPENTHREAD_AUTO_START
|
||||
bool 'Enable the automatic start mode.'
|
||||
|
@@ -38,10 +38,13 @@
|
||||
#include "openthread/instance.h"
|
||||
#include "openthread/logging.h"
|
||||
#include "openthread/tasklet.h"
|
||||
#include "esp_openthread_trel.h"
|
||||
#include "protocol_examples_common.h"
|
||||
#include "mdns.h"
|
||||
|
||||
#if !CONFIG_EXAMPLE_CONNECT_WIFI && !CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
#error No netif for TREL!
|
||||
#endif
|
||||
|
||||
#if CONFIG_OPENTHREAD_STATE_INDICATOR_ENABLE
|
||||
#include "ot_led_strip.h"
|
||||
#endif
|
||||
@@ -71,12 +74,7 @@ static void ot_task_worker(void *aContext)
|
||||
.port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG(),
|
||||
};
|
||||
|
||||
#if !CONFIG_EXAMPLE_CONNECT_WIFI && !CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
#error No netif for TREL!
|
||||
#endif
|
||||
ESP_ERROR_CHECK(example_connect());
|
||||
assert(esp_openthread_get_trel_netif() == NULL);
|
||||
esp_openthread_set_trel_netif(get_example_netif());
|
||||
|
||||
// Initialize the OpenThread stack
|
||||
ESP_ERROR_CHECK(esp_openthread_init(&config));
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
espressif/esp_ot_cli_extension:
|
||||
version: "~1.1.0"
|
||||
version: "~1.2.0"
|
||||
espressif/mdns: "^1.0.3"
|
||||
idf:
|
||||
version: ">=4.1.0"
|
||||
|
3
examples/openthread/ot_trel/sdkconfig.ci.trel
Normal file
3
examples/openthread/ot_trel/sdkconfig.ci.trel
Normal file
@@ -0,0 +1,3 @@
|
||||
CONFIG_EXAMPLE_CONNECT_WIFI=y
|
||||
CONFIG_EXAMPLE_WIFI_SSID="OTCITE"
|
||||
CONFIG_EXAMPLE_WIFI_PASSWORD="otcitest888"
|
@@ -34,6 +34,7 @@ CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=4096
|
||||
CONFIG_LWIP_IPV6_NUM_ADDRESSES=8
|
||||
CONFIG_LWIP_MULTICAST_PING=y
|
||||
CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_CUSTOM=y
|
||||
CONFIG_LWIP_IPV6_AUTOCONFIG=y
|
||||
# end of lwIP
|
||||
|
||||
#
|
||||
|
@@ -44,6 +44,24 @@ from pytest_embedded_idf.dut import IdfDut
|
||||
# Case 9: TCP communication via NAT64
|
||||
# Thread device (IPV6) send tcp message to the host device (IPV4) via NAT64.
|
||||
|
||||
# Case 10: Sleepy device test
|
||||
# Start a Thread sleepy device, wait it join the Thread network and check related flags.
|
||||
|
||||
# Case 11: Basic startup Test of BR
|
||||
# Test the basic startup and network formation of a Thread device.
|
||||
|
||||
# Case 12: Curl a website via DNS and NAT64
|
||||
# A border router joins a Wi-Fi network and forms a Thread network, a Thread devices attached to it and curl a website.
|
||||
|
||||
# Case 13: Meshcop discovery of Border Router
|
||||
# A border router joins a Wi-Fi network, forms a Thread network and publish a meshcop service. Linux Host device discover the mescop service.
|
||||
|
||||
# Case 14: Curl a website over HTTPS via DNS and NAT64
|
||||
# A border router joins a Wi-Fi network and forms a Thread network, a Thread devices attached to it and curl a https website.
|
||||
|
||||
# Case 15: Thread network formation and attaching with TREL
|
||||
# A TREL device forms a Thread network, other TREL devices attach to it, then test ping connection between them.
|
||||
|
||||
|
||||
@pytest.fixture(scope='module', name='Init_avahi')
|
||||
def fixture_Init_avahi() -> bool:
|
||||
@@ -690,3 +708,57 @@ def test_br_meshcop(Init_interface:bool, Init_avahi:bool, dut: Tuple[IdfDut, Idf
|
||||
finally:
|
||||
ocf.execute_command(br, 'factoryreset')
|
||||
time.sleep(3)
|
||||
|
||||
|
||||
# Case 14: Curl a website over HTTPS via DNS and NAT64
|
||||
# Skip this check on release 5.1
|
||||
|
||||
|
||||
# Case 15: Thread network formation and attaching with TREL
|
||||
@pytest.mark.supported_targets
|
||||
@pytest.mark.esp32c6
|
||||
@pytest.mark.openthread_br
|
||||
@pytest.mark.flaky(reruns=1, reruns_delay=1)
|
||||
@pytest.mark.parametrize(
|
||||
'config, count, app_path, target', [
|
||||
('trel|trel', 2,
|
||||
f'{os.path.join(os.path.dirname(__file__), "ot_trel")}'
|
||||
f'|{os.path.join(os.path.dirname(__file__), "ot_trel")}',
|
||||
'esp32c6|esp32s3'),
|
||||
],
|
||||
indirect=True,
|
||||
)
|
||||
def test_trel_connect(dut: Tuple[IdfDut, IdfDut]) -> None:
|
||||
trel_s3 = dut[1]
|
||||
trel_c6 = dut[0]
|
||||
trel_list = [trel_c6]
|
||||
router_extaddr_list = ['7766554433221101']
|
||||
|
||||
trel_s3.expect('IPv4 address:', timeout=10)
|
||||
trel_c6.expect('IPv4 address:', timeout=10)
|
||||
ocf.init_thread(trel_s3)
|
||||
for trel in trel_list:
|
||||
ocf.init_thread(trel)
|
||||
trel_leader_para = copy.copy(default_br_ot_para)
|
||||
trel_leader_para.bbr = False
|
||||
ocf.joinThreadNetwork(trel_s3, trel_leader_para)
|
||||
trel_para = copy.copy(default_cli_ot_para)
|
||||
trel_para.dataset = ocf.getDataset(trel_s3)
|
||||
try:
|
||||
order = 0
|
||||
for trel in trel_list:
|
||||
trel_para.exaddr = router_extaddr_list[order]
|
||||
order = order + 1
|
||||
ocf.joinThreadNetwork(trel, trel_para)
|
||||
for trel in trel_list:
|
||||
trel_mleid_addr = ocf.get_mleid_addr(trel)
|
||||
trel_s3_mleid_addr = ocf.get_mleid_addr(trel_s3)
|
||||
rx_nums = ocf.ot_ping(trel, trel_s3_mleid_addr, 5)[1]
|
||||
assert rx_nums == 5
|
||||
rx_nums = ocf.ot_ping(trel_s3, trel_mleid_addr, 5)[1]
|
||||
assert rx_nums == 5
|
||||
finally:
|
||||
ocf.execute_command(trel_s3, 'factoryreset')
|
||||
for trel in trel_list:
|
||||
ocf.execute_command(trel, 'factoryreset')
|
||||
time.sleep(3)
|
||||
|
Reference in New Issue
Block a user