mirror of
https://github.com/espressif/openthread.git
synced 2026-09-23 09:27:40 +00:00
This commit adds a mechanism to delay the downgrade of routers or leader when the security policy TLV changes in the Active Operational Dataset such that the device is no longer eligible to act as a router. If the decision to become a child is made due to a security policy change, the device first delays a random period up to the "router selection jitter" before downgrading. If the device is the leader, an additional fixed delay of 10 seconds is added to the random period. If the security policy changes again while the device is waiting to downgrade such that it becomes router-eligible again, the downgrade is cancelled and the device remains in its current role. This commit adds a `test_router_downgrade_on_sec_policy_change` to validate the behavior of newly added mechanism. This commit also updates the CLI `dataset` sub-commands to allow getting and setting the "version threshold for routing" (VR) field in security policy.
OpenThread Control Interface
The OpenThread Control Interface (OTCI) is a library which provides uniform python interfaces to connect and control various kinds of devices running OpenThread.
Supported device types
- OpenThread CLI
- SOC device via Serial
- OpenThread NCP (limited support via pyspinel)
- SOC device via Serial
- OpenThread Border Router
- OTBR device via SSH
Example
import otci
# Connect to an OTBR device via SSH
node1 = otci.connect_otbr_ssh("192.168.1.101")
# Connect to an OpenThread CLI device via Serial
node2 = otci.connect_cli_serial("/dev/ttyACM0"))
# Start node1 to become Leader
node1.dataset_init_buffer()
node1.dataset_set_buffer(network_name='test', network_key='00112233445566778899aabbccddeeff', panid=0xface, channel=11)
node1.dataset_commit_buffer('active')
node1.ifconfig_up()
node1.thread_start()
node1.wait(5)
assert node1.get_state() == "leader"
# Start Commissioner on node1
node1.commissioner_start()
node1.wait(3)
node1.commissioner_add_joiner("TEST123",eui64='*')
# Start node2
node2.ifconfig_up()
node2.set_router_selection_jitter(1)
# Start Joiner on node2 to join the network
node2.joiner_start("TEST123")
node2.wait(10, expect_line="Join success")
# Wait for node 2 to become Router
node2.thread_start()
node2.wait(5)
assert node2.get_state() == "router"