Skip to content

Commit 4000499

Browse files
committed
Merge branch 'ci/matter_tbr_v1_4' into 'release/v1.4'
pytest: Use the Matter Thread Border Router example as the TBR for ESP32-H2's pytest(v1.4) See merge request app-frameworks/esp-matter!1164
2 parents 2a497bb + 68bccfa commit 4000499

File tree

5 files changed

+47
-51
lines changed

5 files changed

+47
-51
lines changed

.gitlab-ci.yml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,6 @@ variables:
6060
time rsync -a ~/.espressif/dist/ ${MATTER_CACHE_DIR}/espressif_dist/ || true
6161
fi
6262
63-
.setup_ot_br: &setup_ot_br
64-
- cd ${CI_PROJECT_DIR}
65-
- apt-get update
66-
- apt-get install -y openssh-client
67-
- git clone ${ESP_THREAD_BR_REPO_URL}
68-
- cd ${BR_PATH}/examples/basic_thread_border_router
69-
- git checkout v1.1
70-
- idf.py set-target esp32s3
71-
- idf.py build
72-
7363
.setup_ot_rcp: &setup_ot_rcp
7464
- cd ${IDF_PATH}
7565
- ./install.sh
@@ -307,16 +297,17 @@ build_esp_matter_examples_pytest_H2_idf_v5_1:
307297
- "${IDF_PATH}/examples/openthread/ot_rcp/build/bootloader/*.bin"
308298
- "${IDF_PATH}/examples/openthread/ot_rcp/build/config/sdkconfig.json"
309299
- "${IDF_PATH}/examples/openthread/ot_rcp/build/flasher_args.json"
310-
- "${BR_PATH}/examples/basic_thread_border_router/build/*.bin"
311-
- "${BR_PATH}/examples/basic_thread_border_router/build/partition_table/*.bin"
312-
- "${BR_PATH}/examples/basic_thread_border_router/build/bootloader/*.bin"
313-
- "${BR_PATH}/examples/basic_thread_border_router/build/config/sdkconfig.json"
314-
- "${BR_PATH}/examples/basic_thread_border_router/build/flasher_args.json"
315300
when: always
316301
expire_in: 4 days
317302
script:
318303
- *setup_ot_rcp
319-
- *setup_ot_br
304+
- cd ${ESP_MATTER_PATH}/examples/thread_border_router
305+
- touch main/MatterProjConfig.h
306+
# Use different discriminators for TBR and light examples
307+
- echo "#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xE00" >> main/MatterProjConfig.h
308+
- echo "CONFIG_CHIP_PROJECT_CONFIG=\"main/MatterProjConfig.h\"" >> sdkconfig.defaults
309+
- cd ${ESP_MATTER_PATH}/examples/light
310+
- echo "CONFIG_ENABLE_MEMORY_PROFILING=y" >> sdkconfig.defaults
320311
- cd ${ESP_MATTER_PATH}
321312
- pip install -r tools/ci/requirements-build.txt
322313
- python tools/ci/build_apps.py ./examples --pytest_h2

examples/pytest_esp_matter_light.py

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
CURRENT_DIR_LIGHT = str(pathlib.Path(__file__).parent)+'/light'
1717
CHIP_TOOL_EXE = str(pathlib.Path(__file__).parent)+ '/../connectedhomeip/connectedhomeip/out/host/chip-tool'
18-
OT_BR_EXAMPLE_PATH = str(pathlib.Path(__file__).parent)+'/../esp-thread-br/examples/basic_thread_border_router'
18+
OT_BR_EXAMPLE_PATH = str(pathlib.Path(__file__).parent)+'/thread_border_router'
19+
OT_DATASET_HEXSTR = '0e08000000000001000035060004001fffe00708fdb824be22185de50c0402a0f7f8051020112014020519772011201402051977030d41706f6c6c6f6e54687265616404101fefc90ee1637d47ca75f87ec24f9403000300000f0208201120140205197701022201'
1920
pytest_build_dir = CURRENT_DIR_LIGHT
2021
pytest_matter_thread_dir = CURRENT_DIR_LIGHT+'|'+OT_BR_EXAMPLE_PATH
2122

@@ -227,7 +228,7 @@ def fixture_Init_interface() -> bool:
227228
@pytest.mark.esp_matter_dut
228229
@pytest.mark.parametrize(
229230
'count, app_path, target, erase_all', [
230-
( 2, pytest_matter_thread_dir, 'esp32h2|esp32s3', 'y|n'),
231+
( 2, pytest_matter_thread_dir, 'esp32h2|esp32s3', 'y|y'),
231232
],
232233
indirect=True,
233234
)
@@ -240,51 +241,56 @@ def test_matter_commissioning_h2(dut:Tuple[Dut, Dut]) -> None:
240241
fixture_Init_interface()
241242
# BLE start advertising
242243
light.expect(r'chip\[DL\]\: Configuring CHIPoBLE advertising', timeout=20)
243-
# flash ot_br
244-
ot_br.expect('OpenThread attached to netif', timeout=30)
244+
ot_br.expect(r'chip\[DL\]\: Configuring CHIPoBLE advertising', timeout=20)
245+
# Start commissioning OTBR
245246
time.sleep(2)
246-
ot_br.write('factoryreset')
247-
ot_br.expect('OpenThread attached to netif', timeout=30)
248-
time.sleep(2)
249-
ot_br.write('log level 3')
250-
ot_br.expect('Done', timeout=5)
251-
time.sleep(2)
252-
# wifi connect -s ChipTEH2 -p chiptest123
253-
ot_br.write('wifi connect -s ChipTEH2 -p chiptest123')
254-
ot_br.expect('wifi sta is connected successfully', timeout=5)
247+
command = CHIP_TOOL_EXE + ' pairing ble-wifi 1 ChipTEH2 chiptest123 20202021 3584'
248+
out_str = subprocess.getoutput(command)
249+
print(out_str)
250+
result = re.findall(r'Run command failure', str(out_str))
251+
if len(result) != 0:
252+
assert False
253+
# Set the active dataset and start Thread network
255254
time.sleep(2)
256-
# start an ot network
257-
ot_br.write('ifconfig up')
258-
ot_br.expect('netif up', timeout=5)
255+
command = CHIP_TOOL_EXE + ' generalcommissioning arm-fail-safe 180 1 1 0'
256+
out_str = subprocess.getoutput(command)
257+
print(out_str)
258+
result = re.findall(r'Run command failure', str(out_str))
259+
if len(result) != 0:
260+
assert False
259261
time.sleep(2)
260-
ot_br.write('thread start')
261-
ot_br.expect('Role detached -> leader', timeout=20)
262+
command = CHIP_TOOL_EXE + ' threadborderroutermanagement set-active-dataset-request hex:' + OT_DATASET_HEXSTR + ' 1 1'
263+
out_str = subprocess.getoutput(command)
264+
print(out_str)
265+
result = re.findall(r'Run command failure', str(out_str))
266+
if len(result) != 0:
267+
assert False
262268
time.sleep(2)
263-
# get dataset
264-
ot_br.write('dataset active -x')
265-
dataset=ot_br.expect(r'\n(\w{202}\r)', timeout=5)[1].decode()
266-
print(dataset)
267-
ot_br.expect('Got IPv6 event: Interface "example_netif_sta" address: fdde:ad00:beef:cafe', timeout=30)
268-
print("Got unique local ipv6 address")
269-
# Start commissioning
269+
command = CHIP_TOOL_EXE + ' generalcommissioning commissioning-complete 1 0'
270+
out_str = subprocess.getoutput(command)
271+
print(out_str)
272+
result = re.findall(r'Run command failure', str(out_str))
273+
if len(result) != 0:
274+
assert False
275+
# Start commissioning Light
270276
time.sleep(2)
271-
command = CHIP_TOOL_EXE + " pairing ble-thread 1 hex:{} ".format(dataset.strip())+"20202021 3840"
277+
command = CHIP_TOOL_EXE + ' pairing ble-thread 2 hex:' + OT_DATASET_HEXSTR +' 20202021 3840'
272278
out_str = subprocess.getoutput(command)
273279
print(out_str)
274280
result = re.findall(r'Run command failure', str(out_str))
275281
if len(result) != 0:
276282
assert False
277283
# Use toggle command to turn-off the light
278284
time.sleep(2)
279-
command = CHIP_TOOL_EXE + ' onoff toggle 1 1'
285+
command = CHIP_TOOL_EXE + ' onoff toggle 2 1'
280286
out_str = subprocess.getoutput(command)
281287
print(out_str)
282288
result = re.findall(r'Run command failure', str(out_str))
283289
if len(result) != 0:
284290
assert False
285291
# Use toggle command to turn-on the light
286292
time.sleep(2)
287-
command = CHIP_TOOL_EXE + ' onoff toggle 1 1'
293+
command = CHIP_TOOL_EXE + ' onoff toggle 2 1'
288294
out_str = subprocess.getoutput(command)
289295
print(out_str)
290296
result = re.findall(r'Run command failure', str(out_str))

examples/thread_border_router/main/app_main.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,11 @@ extern "C" void app_main()
7272
static chip::KvsPersistentStorageDelegate tbr_storage_delegate;
7373
chip::DeviceLayer::PersistedStorage::KeyValueStoreManager & kvsManager = chip::DeviceLayer::PersistedStorage::KeyValueStoreMgr();
7474
tbr_storage_delegate.Init(&kvsManager);
75-
GenericOpenThreadBorderRouterDelegate *delegate = chip::Platform::New<GenericOpenThreadBorderRouterDelegate>(&tbr_storage_delegate);
75+
static GenericOpenThreadBorderRouterDelegate delegate(&tbr_storage_delegate);
7676
char threadBRName[] = "Espressif-ThreadBR";
77-
delegate->SetThreadBorderRouterName(chip::CharSpan(threadBRName));
78-
if (!delegate) {
79-
ESP_LOGE(TAG, "Failed to create thread_border_router delegate");
80-
return;
81-
}
77+
delegate.SetThreadBorderRouterName(chip::CharSpan(threadBRName));
8278
thread_border_router::config_t tbr_config;
83-
tbr_config.thread_border_router_management.delegate = delegate;
79+
tbr_config.thread_border_router_management.delegate = &delegate;
8480
endpoint_t *tbr_endpoint = thread_border_router::create(node, &tbr_config, ENDPOINT_FLAG_NONE, NULL);
8581
if (!node || !tbr_endpoint) {
8682
ESP_LOGE(TAG, "Failed to create data model");

examples/thread_border_router/sdkconfig.defaults

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,5 @@ CONFIG_USE_MINIMAL_MDNS=n
5656
# Enable Matter shell
5757
CONFIG_ENABLE_CHIP_SHELL=y
5858
CONFIG_ESP_MATTER_CONSOLE_TASK_STACK=4096
59+
60+
CONFIG_AUTO_UPDATE_RCP=y

tools/ci/build_apps.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
PYTEST_H2_APPS = [
3030
{"target": "esp32h2", "name": "light"},
31+
{"target": "esp32s3", "name": "thread_border_router"},
3132
]
3233
MAINFEST_FILES = [
3334
str(PROJECT_ROOT / 'examples' / '.build-rules.yml'),

0 commit comments

Comments
 (0)