[mac] update the cached supported channel mask when the region code changes (#9418)

The current code of the `mac.cpp` caches the supported channel mask to
a local variable. But the supported channel mask may be changed after
the country code is changed. This will cause the supported channel
mask used in `mac.cpp` to be inconsistent with the actual supported
channel mask.

This commit adds an API `otLinkSetRegion()` to set the region code and
then update the cached supported channel mask to avoid the channel
mask inconsistencies. The current Thread channel may be not included
in the new supported channel mask. When the Thread stack detects this
case, it detaches the current Thread network gracefully.
This commit is contained in:
Zhanglong Xia
2023-10-24 14:36:57 -07:00
committed by GitHub
parent d26f4e59a2
commit 4275c5826f
9 changed files with 183 additions and 7 deletions
@@ -61,4 +61,38 @@ send "channel preferred\n"
expect "0x1fff800"
expect_line "Done"
send "region US\n"
expect_line "Done"
send "channel supported\n"
expect "0x7fff800"
expect_line "Done"
send "dataset init new\n"
expect_line "Done"
send "dataset channel 26\n"
expect_line "Done"
send "dataset commit active\n"
expect_line "Done"
attach "leader"
send "channel\n"
expect "26"
expect_line "Done"
send "region WW\n"
expect_line "Done"
wait_for "state" "disabled"
expect_line "Done"
send "channel supported\n"
expect "0x3fff800"
expect_line "Done"
send "channel\n"
expect "26"
expect_line "Done"
dispose_node 1