mirror of
https://github.com/espressif/openthread.git
synced 2026-09-18 07:00:08 +00:00
[mle] remove kReattachStart from ReattachState enum (#11609)
This commit simplifies the code by removing the `kReattachStart` state from the `ReattachState` enumeration. This enum is used after MLE `Start()` to track whether to attempt to attach using a persisted Active or Pending Dataset. Previously, `kReattachStart` was a transitory state set in `Start()` and then changed in the `Attach()` method to either `kReattachActive` or `kReattachStop`, based on whether the device had a saved Active Dataset. This change simplifies the code by determining the state directly in `Mle::Start()`, which allows for the removal of the now unnecessary `kReattachStart` case.
This commit is contained in:
+4
-17
@@ -231,7 +231,8 @@ Error Mle::Start(StartMode aMode)
|
|||||||
|
|
||||||
if (aMode == kNormalAttach)
|
if (aMode == kNormalAttach)
|
||||||
{
|
{
|
||||||
mReattachState = kReattachStart;
|
mReattachState =
|
||||||
|
(Get<MeshCoP::ActiveDatasetManager>().Restore() == kErrorNone) ? kReattachActive : kReattachStop;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((aMode == kAnnounceAttach) || (GetRloc16() == kInvalidRloc16))
|
if ((aMode == kAnnounceAttach) || (GetRloc16() == kInvalidRloc16))
|
||||||
@@ -631,18 +632,6 @@ void Mle::Attach(AttachMode aMode)
|
|||||||
mAttachCounter = 0;
|
mAttachCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mReattachState == kReattachStart)
|
|
||||||
{
|
|
||||||
if (Get<MeshCoP::ActiveDatasetManager>().Restore() == kErrorNone)
|
|
||||||
{
|
|
||||||
mReattachState = kReattachActive;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mReattachState = kReattachStop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mParentCandidate.Clear();
|
mParentCandidate.Clear();
|
||||||
SetAttachState(kAttachStateStart);
|
SetAttachState(kAttachStateStart);
|
||||||
mAttachMode = aMode;
|
mAttachMode = aMode;
|
||||||
@@ -4224,16 +4213,14 @@ const char *Mle::ReattachStateToString(ReattachState aState)
|
|||||||
{
|
{
|
||||||
static const char *const kReattachStateStrings[] = {
|
static const char *const kReattachStateStrings[] = {
|
||||||
"", // (0) kReattachStop
|
"", // (0) kReattachStop
|
||||||
"reattaching", // (1) kReattachStart
|
"reattaching with Active Dataset", // (1) kReattachActive
|
||||||
"reattaching with Active Dataset", // (2) kReattachActive
|
"reattaching with Pending Dataset", // (2) kReattachPending
|
||||||
"reattaching with Pending Dataset", // (3) kReattachPending
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EnumCheck
|
struct EnumCheck
|
||||||
{
|
{
|
||||||
InitEnumValidatorCounter();
|
InitEnumValidatorCounter();
|
||||||
ValidateNextEnum(kReattachStop);
|
ValidateNextEnum(kReattachStop);
|
||||||
ValidateNextEnum(kReattachStart);
|
|
||||||
ValidateNextEnum(kReattachActive);
|
ValidateNextEnum(kReattachActive);
|
||||||
ValidateNextEnum(kReattachPending);
|
ValidateNextEnum(kReattachPending);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1328,7 +1328,6 @@ private:
|
|||||||
enum ReattachState : uint8_t
|
enum ReattachState : uint8_t
|
||||||
{
|
{
|
||||||
kReattachStop, // Reattach process is disabled or finished
|
kReattachStop, // Reattach process is disabled or finished
|
||||||
kReattachStart, // Start reattach process
|
|
||||||
kReattachActive, // Reattach using stored Active Dataset
|
kReattachActive, // Reattach using stored Active Dataset
|
||||||
kReattachPending, // Reattach using stored Pending Dataset
|
kReattachPending, // Reattach using stored Pending Dataset
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user