mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
96c85c24e7
`Mle::AnnounceHandler::HandleAnnounce` previously executed the `kAnnounceAttachAfterDelay` action on an attached node even when the announced channel and PAN ID already equaled the current MAC parameters. The `!channelAndPanIdMatch` guard was only consulted in the `IsDetached()` branch. For an attached node this scheduled `StartAnnounceAttach`, which calls `Stop()` then `Start()` with the same channel/PAN ID -- accomplishing nothing while disrupting attached children. This causes an endless role flap in a topology where two FTDs share channel, PAN ID, and network credentials but hold different Active Dataset Timestamps, and where their RF link is too weak to merge partitions (Advertisements rejected with LinkMarginLow at `mle_router.cpp`). Each side restarts on every Announce received from the higher-timestamp peer; the reactive `kSendAnnouceBack` path further amplifies this because the lower-timestamp side's own outgoing Announces draw Announce responses from the peer. Apply the channel/PAN ID match guard unconditionally in `kAnnounceAttachAfterDelay`. Mirror it on the FTD `kSendAnnouceBack` path (matching the existing `isFromOrphan` behavior) so peers sharing MAC parameters are not prompted to migrate to the channel/PAN ID they already use. Add `addon_test_announce_no_flap_on_unmergeable_partitions.py` which builds the topology above and asserts that both nodes retain their original partition IDs across a 20-minute simulated window. Without this change the lower-timestamp node is repeatedly demoted from leader during that window.