[posix] add channel mask configurations to configuration file (#9391)

This commit allows developers to set the preferred channel mask and
the supported channel mask in the configuration file. The posix
platform selects channel masks from the configuration file based on
the region code when the region code is updated.
This commit is contained in:
Zhanglong Xia
2023-09-18 07:17:54 -07:00
committed by GitHub
parent a383e366ba
commit 2a502abb88
12 changed files with 423 additions and 104 deletions
+3
View File
@@ -86,6 +86,9 @@ proc spawn_node {id {type ""} {radio_url ""}} {
switch -regexp ${type} {
{rcp|rcp-cli} {
# Sleep 0.2 seconds to ensure that the ot-rcp in the previous test has exited to
# avoid the error: "bind(sTxFd): Address already in use"
sleep 0.2
spawn /usr/bin/env GCOV_PREFIX=$gcov_prefix $::env(OT_POSIX_APPS)/ot-cli $radio_url
send "factoryreset\n"
wait_for "state" "disabled"
@@ -0,0 +1,64 @@
#!/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"
spawn_node 1
send "channel supported\n"
expect "0x7fff800"
expect_line "Done"
send "channel preferred\n"
expect "0x7fff800"
expect_line "Done"
send "region US\n"
expect_line "Done"
send "channel supported\n"
expect "0x7fff000"
expect_line "Done"
send "channel preferred\n"
expect "0x7ff7000"
expect_line "Done"
send "region WW\n"
expect_line "Done"
send "channel supported\n"
expect "0x7fff800"
expect_line "Done"
send "channel preferred\n"
expect "0x7fff000"
expect_line "Done"
dispose_node 1
@@ -29,6 +29,10 @@
source "tests/scripts/expect/_common.exp"
# backup the configuration file
spawn mv src/posix/platform/openthread.conf.example src/posix/platform/openthread.conf.example.backup
expect eof
# allows 11-25 and forbidden 26
spawn_node 1 "rcp" "spinel+hdlc+uart://$env(OT_SIMULATION_APPS)/ncp/ot-rcp?max-power-table=11,12,13,14,15,16,17,18,19,20,21,22,23,24,-1,0x7f&forkpty-arg=1"
send "channel supported\n"
@@ -44,6 +48,11 @@ expect "11 dBm"
expect_line "Done"
send "\x04"
expect eof
# restore the configuration file
spawn mv src/posix/platform/openthread.conf.example.backup src/posix/platform/openthread.conf.example
expect eof
# allows all channels by default
spawn_node 1 "rcp" "spinel+hdlc+uart://$env(OT_SIMULATION_APPS)/ncp/ot-rcp?forkpty-arg=1"
send "channel supported\n"