diff --git a/src/core/thread/mle.hpp b/src/core/thread/mle.hpp index 16ead4937..bb75a38f8 100644 --- a/src/core/thread/mle.hpp +++ b/src/core/thread/mle.hpp @@ -2270,6 +2270,11 @@ private: otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aResult); + +#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO) + const char *RouterUpgradeReasonToString(uint8_t aReason); +#endif + #endif // OPENTHREAD_FTD //------------------------------------------------------------------------------------------------------------------ diff --git a/src/core/thread/mle_ftd.cpp b/src/core/thread/mle_ftd.cpp index c4675b958..7b08cf1be 100644 --- a/src/core/thread/mle_ftd.cpp +++ b/src/core/thread/mle_ftd.cpp @@ -206,7 +206,7 @@ Error Mle::BecomeRouter(RouterUpgradeReason aReason) VerifyOrExit(IsRouterEligible(), error = kErrorNotCapable); - LogInfo("Attempt to become router"); + LogInfo("Attempt to become router, reason:%s", RouterUpgradeReasonToString(aReason)); Get().SetRxOnWhenIdle(true); mRouterRoleTransition.StopTimeout(); @@ -3529,6 +3529,13 @@ void Mle::ProcessAddressSolicit(AddrSolicitInfo &aInfo) aInfo.mResponse = kAddrSolicitNoAddressAvailable; aInfo.mRouter = nullptr; + LogInfo("AddrSolicit Reason: %s", RouterUpgradeReasonToString(aInfo.mReason)); + + if (aInfo.mRequestedRloc16 != kInvalidRloc16) + { + LogInfo("AddrSolicit Requested ID: %u", RouterIdFromRloc16(aInfo.mRequestedRloc16)); + } + #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE VerifyOrExit(aInfo.mXtalAccuracy <= Get().GetXtalThreshold()); #endif @@ -3556,8 +3563,6 @@ void Mle::ProcessAddressSolicit(AddrSolicitInfo &aInfo) (Get().CountBorderRouters(NetworkData::kRouterRoleOnly) >= kRouterUpgradeBorderRouterRequestThreshold)) { - LogInfo("Rejecting BR %s router role req - have %u BR routers", aInfo.mExtAddress.ToString().AsCString(), - kRouterUpgradeBorderRouterRequestThreshold); ExitNow(); } break; @@ -3570,11 +3575,6 @@ void Mle::ProcessAddressSolicit(AddrSolicitInfo &aInfo) if (aInfo.mRequestedRloc16 != kInvalidRloc16) { aInfo.mRouter = mRouterTable.Allocate(RouterIdFromRloc16(aInfo.mRequestedRloc16)); - - if (aInfo.mRouter != nullptr) - { - LogInfo("Router id %u requested and provided!", RouterIdFromRloc16(aInfo.mRequestedRloc16)); - } } if (aInfo.mRouter == nullptr) @@ -3945,6 +3945,33 @@ exit: } #endif // OPENTHREAD_CONFIG_TIME_SYNC_ENABLE +#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO) + +const char *Mle::RouterUpgradeReasonToString(uint8_t aReason) +{ + const char *str = "Unknown"; + + switch (aReason) + { + case kReasonTooFewRouters: + str = "TooFewRouters"; + break; + case kReasonHaveChildIdRequest: + str = "HaveChildIdRequest"; + break; + case kReasonParentPartitionChange: + str = "ParentPartitionChange"; + break; + case kReasonBorderRouterRequest: + str = "BorderRouterRequest"; + break; + } + + return str; +} + +#endif // OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO) + //---------------------------------------------------------------------------------------------------------------------- // RouterRoleTransition