mirror of
https://github.com/espressif/openthread.git
synced 2026-07-09 13:50:28 +00:00
5fc0e7774c
This commit updates public APIs for getting and setting CSL period to
use microseconds unit instead of the internal ten symbols unit. This
makes the APIs easier to use.
The CSL APIs have been renamed to follow the `otLinkGet/SetCsl{Item}()`
pattern, which is the common naming style of OpenThread. This
renaming will make the APIs more consistent and avoid potential
confusion with the now-removed APIs, which used a different unit for
CSL period.
This commit also updates the related CLI CSL commands:
- The `csl period` expects the given period to be in microseconds.
- The `csl` command (which outputs all CSL parameter) shows the CSL
period in microsecond unit (e.g., "Period: 160000us").
The NCP spinel `SPINEL_PROP_THREAD_CSL_PERIOD` is also updated to use
microsecond unit for CSL period.
The related test script are updated to use the new unit, in particular
the test harness `setCSLperiod()` in `harness-thci/OpenThread.py` is
updated (no need to convert from msec).
147 lines
4.6 KiB
Plaintext
Executable File
147 lines
4.6 KiB
Plaintext
Executable File
#!/usr/bin/expect -f
|
|
#
|
|
# Copyright (c) 2023, The OpenThread Authors.
|
|
# All rights reserved.
|
|
#
|
|
# Redistribution and use in source and binary forms, with or without
|
|
# modification, are permitted provided that the following conditions are met:
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
# notice, this list of conditions and the following disclaimer.
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
# documentation and/or other materials provided with the distribution.
|
|
# 3. Neither the name of the copyright holder nor the
|
|
# names of its contributors may be used to endorse or promote products
|
|
# derived from this software without specific prior written permission.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
#
|
|
|
|
source "tests/scripts/expect/_common.exp"
|
|
source "tests/scripts/expect/_multinode.exp"
|
|
|
|
for {set i 1} {$i <= 5} {incr i} {
|
|
spawn_node $i
|
|
}
|
|
|
|
switch_node 1
|
|
|
|
send "dataset init new\n"
|
|
expect_line "Done"
|
|
send "dataset networkkey 00112233445566778899aabbccddeeff\n"
|
|
expect_line "Done"
|
|
send "dataset channel 12\n"
|
|
expect_line "Done"
|
|
send "dataset networkname OpenThread-ch12\n"
|
|
expect_line "Done"
|
|
send "dataset commit active\n"
|
|
expect_line "Done"
|
|
send "dataset active -x\n"
|
|
expect -re {([0-9a-f]+)[\r\n]+Done}
|
|
set dataset $expect_out(1,string)
|
|
attach
|
|
|
|
set extaddr_1 [get_extaddr]
|
|
set extpan_1 [get_extpanid]
|
|
set pan_1 [get_panid]
|
|
|
|
switch_node 2
|
|
|
|
send "dataset init new\n"
|
|
expect_line "Done"
|
|
send "dataset channel 23\n"
|
|
expect_line "Done"
|
|
send "dataset networkname OpenThread-ch23\n"
|
|
expect_line "Done"
|
|
send "dataset commit active\n"
|
|
expect_line "Done"
|
|
attach
|
|
|
|
set extaddr_2 [get_extaddr]
|
|
set extpan_2 [get_extpanid]
|
|
set pan_2 [get_panid]
|
|
|
|
switch_node 3
|
|
|
|
send "dataset set active $dataset\n"
|
|
expect_line "Done"
|
|
send "mode r\n"
|
|
expect_line "Done"
|
|
attach "child"
|
|
|
|
switch_node 4
|
|
|
|
send "dataset set active $dataset\n"
|
|
expect_line "Done"
|
|
send "mode -\n"
|
|
expect_line "Done"
|
|
attach "child"
|
|
|
|
for {set i 3} {$i <= 4} {incr i} {
|
|
switch_node $i
|
|
|
|
send "discover\n"
|
|
expect "| Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |"
|
|
expect "+------------------+------------------+------+------------------+----+-----+-----+"
|
|
wait_for "" "\\| OpenThread-ch12 +\\| $extpan_1 \\| $pan_1 \\| $extaddr_1 \\| 12 \\| +-?\\d+ \\| +\\d \\|"
|
|
wait_for "" "\\| OpenThread-ch23 +\\| $extpan_2 \\| $pan_2 \\| $extaddr_2 \\| 23 \\| +-?\\d+ \\| +\\d \\|"
|
|
wait_for "" "Done"
|
|
}
|
|
|
|
if {$::env(THREAD_VERSION) != "1.1" && $::env(OT_NODE_TYPE) == "cli"} {
|
|
send "csl channel 12\n"
|
|
expect_line "Done"
|
|
send "csl period 500000\n"
|
|
expect_line "Done"
|
|
|
|
sleep 1
|
|
|
|
send "discover\n"
|
|
expect "| Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |"
|
|
expect "+------------------+------------------+------+------------------+----+-----+-----+"
|
|
wait_for "" "\\| OpenThread-ch12 +\\| $extpan_1 \\| $pan_1 \\| $extaddr_1 \\| 12 \\| +-?\\d+ \\| +\\d \\|"
|
|
wait_for "" "\\| OpenThread-ch23 +\\| $extpan_2 \\| $pan_2 \\| $extaddr_2 \\| 23 \\| +-?\\d+ \\| +\\d \\|"
|
|
wait_for "" "Done"
|
|
}
|
|
|
|
switch_node 1
|
|
send "discover reqcallback enable\n"
|
|
expect_line "Done"
|
|
|
|
switch_node 5
|
|
send "discover\n"
|
|
expect "Error 13: InvalidState"
|
|
send "ifconfig up\n"
|
|
expect_line "Done"
|
|
send "discover 12\n"
|
|
|
|
expect "| Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |"
|
|
expect "+------------------+------------------+------+------------------+----+-----+-----+"
|
|
wait_for "" "\\| OpenThread-ch12 +\\| $extpan_1 \\| $pan_1 \\| $extaddr_1 \\| 12 \\| +-?\\d+ \\| +\\d \\|"
|
|
wait_for "" "Done"
|
|
|
|
switch_node 1
|
|
expect -re {version=\d,joiner=0}
|
|
|
|
switch_node 5
|
|
send "ifconfig up\n"
|
|
expect_line "Done"
|
|
send "joiner start 123456\n"
|
|
set timeout 10
|
|
expect "NotFound"
|
|
|
|
switch_node 1
|
|
expect -re {version=\d,joiner=1}
|
|
|
|
dispose_all
|