openthread
openthread copied to clipboard
[mle] update `otThreadBecomeLeader()` to allow leader take over
This commit updates the otThreadBecomeLeader()
API (and its related core MleRouter::BecomeLeader()
method) to allow an already attached device to take over as leader, creating a new partition. For this to work, the local leader weight (otThreadGetLocalLeaderWeight()
) must be greater than the weight of the current leader (which can be retrieved using otThreadGetLeaderWeight()
). If it is not, error code OT_ERROR_NOT_CAPABLE
is returned to indicate to the caller that they need to adjust the local weight.
This commit also updates the related CLI command and adds a new test, test-022-leader-take-over.py
, to validate the newly added mechanism.
Related to SPEC-1140.
Size Report of OpenThread
Merging #9186 into main(aba7aede1476339abe3032a250349d67a4ec1605).
name | branch | text | data | bss | total |
---|---|---|---|---|---|
ot-cli-ftd | main | 466816 | 856 | 66364 | 534036 |
#9186 | 466848 | 856 | 66364 | 534068 | |
+/- | +32 | 0 | 0 | +32 | |
ot-ncp-ftd | main | 435908 | 760 | 61592 | 498260 |
#9186 | 435940 | 760 | 61592 | 498292 | |
+/- | +32 | 0 | 0 | +32 | |
libopenthread-ftd.a | main | 236112 | 95 | 40302 | 276509 |
#9186 | 236142 | 95 | 40302 | 276539 | |
+/- | +30 | 0 | 0 | +30 | |
libopenthread-cli-ftd.a | main | 57580 | 0 | 8075 | 65655 |
#9186 | 57580 | 0 | 8075 | 65655 | |
+/- | 0 | 0 | 0 | 0 | |
libopenthread-ncp-ftd.a | main | 32127 | 0 | 5924 | 38051 |
#9186 | 32127 | 0 | 5924 | 38051 | |
+/- | 0 | 0 | 0 | 0 | |
ot-cli-mtd | main | 365472 | 760 | 51236 | 417468 |
#9186 | 365472 | 760 | 51236 | 417468 | |
+/- | 0 | 0 | 0 | 0 | |
ot-ncp-mtd | main | 348188 | 760 | 46480 | 395428 |
#9186 | 348188 | 760 | 46480 | 395428 | |
+/- | 0 | 0 | 0 | 0 | |
libopenthread-mtd.a | main | 158941 | 0 | 25190 | 184131 |
#9186 | 158941 | 0 | 25190 | 184131 | |
+/- | 0 | 0 | 0 | 0 | |
libopenthread-cli-mtd.a | main | 39795 | 0 | 8059 | 47854 |
#9186 | 39795 | 0 | 8059 | 47854 | |
+/- | 0 | 0 | 0 | 0 | |
libopenthread-ncp-mtd.a | main | 25007 | 0 | 5924 | 30931 |
#9186 | 25007 | 0 | 5924 | 30931 | |
+/- | 0 | 0 | 0 | 0 | |
ot-cli-ftd-br | main | 551576 | 864 | 131228 | 683668 |
#9186 | 551608 | 864 | 131228 | 683700 | |
+/- | +32 | 0 | 0 | +32 | |
libopenthread-ftd-br.a | main | 325027 | 100 | 105142 | 430269 |
#9186 | 325057 | 100 | 105142 | 430299 | |
+/- | +30 | 0 | 0 | +30 | |
libopenthread-cli-ftd-br.a | main | 71711 | 0 | 8099 | 79810 |
#9186 | 71711 | 0 | 8099 | 79810 | |
+/- | 0 | 0 | 0 | 0 | |
ot-rcp | main | 62312 | 564 | 20636 | 83512 |
#9186 | 62312 | 564 | 20636 | 83512 | |
+/- | 0 | 0 | 0 | 0 | |
libopenthread-rcp.a | main | 9734 | 0 | 5060 | 14794 |
#9186 | 9734 | 0 | 5060 | 14794 | |
+/- | 0 | 0 | 0 | 0 | |
libopenthread-radio.a | main | 18991 | 0 | 222 | 19213 |
#9186 | 18991 | 0 | 222 | 19213 | |
+/- | 0 | 0 | 0 | 0 |
Codecov Report
Merging #9186 (6fa1f69) into main (70adcab) will increase coverage by
0.00%
. The diff coverage is83.33%
.
Additional details and impacted files
@@ Coverage Diff @@
## main #9186 +/- ##
=======================================
Coverage 85.89% 85.89%
=======================================
Files 551 551
Lines 73268 73271 +3
=======================================
+ Hits 62932 62938 +6
+ Misses 10336 10333 -3
Files Changed | Coverage Δ | |
---|---|---|
src/core/thread/mle_router.hpp | 84.84% <ø> (ø) |
|
src/core/thread/mle_router.cpp | 84.01% <75.00%> (-0.03%) |
:arrow_down: |
src/core/api/thread_ftd_api.cpp | 76.96% <100.00%> (ø) |
|
src/core/thread/mle.cpp | 88.99% <100.00%> (-0.09%) |
:arrow_down: |
@abtink @EskoDijk any plans to merge this in?
@abtink @EskoDijk any plans to merge this in?
I am okay merging this. Just rebased it on main
.
@abtink @EskoDijk any plans to merge this in?
@nand-nor , merged!