diff --git a/src/core/meshcop/timestamp.hpp b/src/core/meshcop/timestamp.hpp index b4a6bfd0a..1eace251d 100644 --- a/src/core/meshcop/timestamp.hpp +++ b/src/core/meshcop/timestamp.hpp @@ -140,6 +140,15 @@ public: */ void AdvanceRandomTicks(void); + /** + * This method indicates whether the timestamp indicates an MLE Orphan Announce message. + * + * @retval TRUE The timestamp indicates an Orphan Announce message. + * @retval FALSE If the timestamp does not indicate an Orphan Announce message. + * + */ + bool IsOrphanTimestamp(void) const { return GetSeconds() == 0 && GetTicks() == 0 && GetAuthoritative(); } + /** * This static method compares two timestamps. * diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 99b93ef05..bde0550ed 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -4113,7 +4113,15 @@ void Mle::HandleAnnounce(RxInfo &aRxInfo) localTimestamp = Get().GetTimestamp(); - if (MeshCoP::Timestamp::Compare(×tamp, localTimestamp) > 0) + if (timestamp.IsOrphanTimestamp() || MeshCoP::Timestamp::Compare(×tamp, localTimestamp) < 0) + { + SendAnnounce(channel); + +#if OPENTHREAD_CONFIG_MLE_SEND_UNICAST_ANNOUNCE_RESPONSE + SendAnnounce(channel, aRxInfo.mMessageInfo.GetPeerAddr()); +#endif + } + else if (MeshCoP::Timestamp::Compare(×tamp, localTimestamp) > 0) { // No action is required if device is detached, and current // channel and pan-id match the values from the received MLE @@ -4136,14 +4144,6 @@ void Mle::HandleAnnounce(RxInfo &aRxInfo) LogNote("Delay processing Announce - channel %d, panid 0x%02x", channel, panId); } - else if (MeshCoP::Timestamp::Compare(×tamp, localTimestamp) < 0) - { - SendAnnounce(channel); - -#if OPENTHREAD_CONFIG_MLE_SEND_UNICAST_ANNOUNCE_RESPONSE - SendAnnounce(channel, aRxInfo.mMessageInfo.GetPeerAddr()); -#endif - } else { // Timestamps are equal.