[mle] add `kBetterParent` in `AttachMode` enum (#7524)
This commit adds a new enumerator `kBetterParent` in `AttachMode`
enumeration. This new value is used by periodic parent search
feature only when searching for a better parent to help make
it explicit that attach process is started for this purpose.
diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp
index ccf5bc1..f877371 100644
--- a/src/core/thread/mle.cpp
+++ b/src/core/thread/mle.cpp
@@ -1937,6 +1937,7 @@
switch (mAttachMode)
{
case kAnyPartition:
+ case kBetterParent:
if (!IsChild())
{
if (mAlternatePanId != Mac::kPanIdBroadcast)
@@ -3528,6 +3529,7 @@
switch (mAttachMode)
{
case kAnyPartition:
+ case kBetterParent:
VerifyOrExit(!isPartitionIdSame || isIdSequenceGreater);
break;
@@ -4257,7 +4259,7 @@
{
LogInfo("PeriodicParentSearch: Parent RSS less than %d, searching for new parents", kParentSearchRssThreadhold);
mParentSearchIsInBackoff = true;
- Attach(kAnyPartition);
+ Attach(kBetterParent);
}
exit:
@@ -4560,6 +4562,7 @@
"SamePartitionRetry", // (2) kSamePartitionRetry
"BetterPartition", // (3) kBetterPartition
"DowngradeToReed", // (4) kDowngradeToReed
+ "BetterParent", // (5) kBetterParent
};
static_assert(kAnyPartition == 0, "kAnyPartition value is incorrect");
@@ -4567,6 +4570,7 @@
static_assert(kSamePartitionRetry == 2, "kSamePartitionRetry value is incorrect");
static_assert(kBetterPartition == 3, "kBetterPartition value is incorrect");
static_assert(kDowngradeToReed == 4, "kDowngradeToReed value is incorrect");
+ static_assert(kBetterParent == 5, "kBetterParent value is incorrect");
return kAttachModeStrings[aMode];
}
diff --git a/src/core/thread/mle.hpp b/src/core/thread/mle.hpp
index ddd7225..92211da 100644
--- a/src/core/thread/mle.hpp
+++ b/src/core/thread/mle.hpp
@@ -794,6 +794,7 @@
kSamePartitionRetry, ///< Attach to the same Thread partition (attempt 2 when losing connectivity).
kBetterPartition, ///< Attach to a better (i.e. higher weight/partition id) Thread partition.
kDowngradeToReed, ///< Attach to the same Thread partition during downgrade process.
+ kBetterParent, ///< Attach to a better parent.
};
/**
diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp
index 2b6b9b9..bc7e19c 100644
--- a/src/core/thread/mle_router.cpp
+++ b/src/core/thread/mle_router.cpp
@@ -335,6 +335,7 @@
break;
case kAnyPartition:
+ case kBetterParent:
// If attach was started due to receiving MLE Announce Messages, all rx-on-when-idle devices would
// start attach immediately when receiving such Announce message as in Thread 1.1 specification,
// Section 4.8.1,