mirror of
https://github.com/espressif/openthread.git
synced 2026-10-01 21:37:39 +00:00
[dataset] move DelayTimerMinimal to PendingDatasetManager (#12162)
This change relocates the `mDelayTimerMinimal` member and its associated accessor methods, `GetDelayTimerMinimal()` and `SetDelayTimerMinimal()`, from the `MeshCoP::Leader` class to the `PendingDatasetManager` class. This functionality is specific to the handling of the pending operational dataset. Placing it within `PendingDatasetManager` improves code structure and cohesion by grouping related parameters together.
This commit is contained in:
@@ -48,12 +48,12 @@ otError otDatasetCreateNewNetwork(otInstance *aInstance, otOperationalDataset *a
|
|||||||
|
|
||||||
uint32_t otDatasetGetDelayTimerMinimal(otInstance *aInstance)
|
uint32_t otDatasetGetDelayTimerMinimal(otInstance *aInstance)
|
||||||
{
|
{
|
||||||
return AsCoreType(aInstance).Get<MeshCoP::Leader>().GetDelayTimerMinimal();
|
return AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().GetDelayTimerMinimal();
|
||||||
}
|
}
|
||||||
|
|
||||||
otError otDatasetSetDelayTimerMinimal(otInstance *aInstance, uint32_t aDelayTimerMinimal)
|
otError otDatasetSetDelayTimerMinimal(otInstance *aInstance, uint32_t aDelayTimerMinimal)
|
||||||
{
|
{
|
||||||
return AsCoreType(aInstance).Get<MeshCoP::Leader>().SetDelayTimerMinimal(aDelayTimerMinimal);
|
return AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().SetDelayTimerMinimal(aDelayTimerMinimal);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // OPENTHREAD_FTD
|
#endif // OPENTHREAD_FTD
|
||||||
|
|||||||
@@ -892,6 +892,9 @@ void ActiveDatasetManager::HandleTimer(Timer &aTimer) { aTimer.Get<ActiveDataset
|
|||||||
PendingDatasetManager::PendingDatasetManager(Instance &aInstance)
|
PendingDatasetManager::PendingDatasetManager(Instance &aInstance)
|
||||||
: DatasetManager(aInstance, Dataset::kPending, PendingDatasetManager::HandleTimer)
|
: DatasetManager(aInstance, Dataset::kPending, PendingDatasetManager::HandleTimer)
|
||||||
, mDelayTimer(aInstance)
|
, mDelayTimer(aInstance)
|
||||||
|
#if OPENTHREAD_FTD
|
||||||
|
, mDelayTimerMinimal(DelayTimerTlv::kMinDelay)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -442,7 +442,28 @@ public:
|
|||||||
* Starts the Leader functions for maintaining the Active Operational Dataset.
|
* Starts the Leader functions for maintaining the Active Operational Dataset.
|
||||||
*/
|
*/
|
||||||
void StartLeader(void);
|
void StartLeader(void);
|
||||||
#endif
|
|
||||||
|
/**
|
||||||
|
* Gets the minimal delay timer.
|
||||||
|
*
|
||||||
|
* @retval the minimal delay timer (in ms).
|
||||||
|
*/
|
||||||
|
uint32_t GetDelayTimerMinimal(void) const { return mDelayTimerMinimal; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the minimal delay timer value.
|
||||||
|
*
|
||||||
|
* This method is reserved for testing and demo purposes only. Changing this will render a production application
|
||||||
|
* non-compliant with the Thread Specification.
|
||||||
|
*
|
||||||
|
* @param[in] aDelayTimerMinimal The value of minimal delay timer (in ms).
|
||||||
|
*
|
||||||
|
* @retval kErrorNone Successfully set the minimal delay timer.
|
||||||
|
* @retval kErrorInvalidArgs If @p aDelayTimerMinimal is not valid. It is zero or it is larger than or equal to
|
||||||
|
* the default minimum value of `DelayTimerTlv::kMinDelay`.
|
||||||
|
*/
|
||||||
|
Error SetDelayTimerMinimal(uint32_t aDelayTimerMinimal);
|
||||||
|
#endif // OPENTHREAD_FTD
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if OPENTHREAD_FTD
|
#if OPENTHREAD_FTD
|
||||||
@@ -461,6 +482,9 @@ private:
|
|||||||
using DelayTimer = TimerMilliIn<PendingDatasetManager, &PendingDatasetManager::HandleDelayTimer>;
|
using DelayTimer = TimerMilliIn<PendingDatasetManager, &PendingDatasetManager::HandleDelayTimer>;
|
||||||
|
|
||||||
DelayTimer mDelayTimer;
|
DelayTimer mDelayTimer;
|
||||||
|
#if OPENTHREAD_FTD
|
||||||
|
uint32_t mDelayTimerMinimal;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
DeclareTmfHandler(PendingDatasetManager, kUriPendingGet);
|
DeclareTmfHandler(PendingDatasetManager, kUriPendingGet);
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ Error DatasetManager::ProcessSetOrReplaceRequest(MgmtCommand aCommand,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delayTimer = Max(delayTimer, Get<Leader>().GetDelayTimerMinimal());
|
delayTimer = Max(delayTimer, Get<PendingDatasetManager>().GetDelayTimerMinimal());
|
||||||
}
|
}
|
||||||
|
|
||||||
IgnoreError(aInfo.mDataset.Write<DelayTimerTlv>(delayTimer));
|
IgnoreError(aInfo.mDataset.Write<DelayTimerTlv>(delayTimer));
|
||||||
@@ -393,6 +393,17 @@ exit:
|
|||||||
|
|
||||||
void PendingDatasetManager::StartLeader(void) { StartDelayTimer(); }
|
void PendingDatasetManager::StartLeader(void) { StartDelayTimer(); }
|
||||||
|
|
||||||
|
Error PendingDatasetManager::SetDelayTimerMinimal(uint32_t aDelayTimerMinimal)
|
||||||
|
{
|
||||||
|
Error error = kErrorNone;
|
||||||
|
|
||||||
|
VerifyOrExit((aDelayTimerMinimal != 0 && aDelayTimerMinimal < DelayTimerTlv::kMinDelay), error = kErrorInvalidArgs);
|
||||||
|
mDelayTimerMinimal = aDelayTimerMinimal;
|
||||||
|
|
||||||
|
exit:
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void PendingDatasetManager::HandleTmf<kUriPendingSet>(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
void PendingDatasetManager::HandleTmf<kUriPendingSet>(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||||
{
|
{
|
||||||
@@ -411,7 +422,7 @@ void PendingDatasetManager::ApplyActiveDataset(Dataset &aDataset)
|
|||||||
|
|
||||||
SuccessOrExit(aDataset.Read<ActiveTimestampTlv>(activeTimestamp));
|
SuccessOrExit(aDataset.Read<ActiveTimestampTlv>(activeTimestamp));
|
||||||
SuccessOrExit(aDataset.Write<PendingTimestampTlv>(activeTimestamp));
|
SuccessOrExit(aDataset.Write<PendingTimestampTlv>(activeTimestamp));
|
||||||
SuccessOrExit(aDataset.Write<DelayTimerTlv>(Get<Leader>().GetDelayTimerMinimal()));
|
SuccessOrExit(aDataset.Write<DelayTimerTlv>(GetDelayTimerMinimal()));
|
||||||
|
|
||||||
IgnoreError(DatasetManager::Save(aDataset));
|
IgnoreError(DatasetManager::Save(aDataset));
|
||||||
StartDelayTimer(aDataset);
|
StartDelayTimer(aDataset);
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ RegisterLogModule("MeshCoPLeader");
|
|||||||
Leader::Leader(Instance &aInstance)
|
Leader::Leader(Instance &aInstance)
|
||||||
: InstanceLocator(aInstance)
|
: InstanceLocator(aInstance)
|
||||||
, mTimer(aInstance)
|
, mTimer(aInstance)
|
||||||
, mDelayTimerMinimal(DelayTimerTlv::kMinDelay)
|
|
||||||
, mSessionId(Random::NonCrypto::GetUint16())
|
, mSessionId(Random::NonCrypto::GetUint16())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -201,17 +200,6 @@ exit:
|
|||||||
LogWarnOnError(error, "send dataset changed");
|
LogWarnOnError(error, "send dataset changed");
|
||||||
}
|
}
|
||||||
|
|
||||||
Error Leader::SetDelayTimerMinimal(uint32_t aDelayTimerMinimal)
|
|
||||||
{
|
|
||||||
Error error = kErrorNone;
|
|
||||||
|
|
||||||
VerifyOrExit((aDelayTimerMinimal != 0 && aDelayTimerMinimal < DelayTimerTlv::kMinDelay), error = kErrorInvalidArgs);
|
|
||||||
mDelayTimerMinimal = aDelayTimerMinimal;
|
|
||||||
|
|
||||||
exit:
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Leader::HandleTimer(void)
|
void Leader::HandleTimer(void)
|
||||||
{
|
{
|
||||||
VerifyOrExit(Get<Mle::Mle>().IsLeader());
|
VerifyOrExit(Get<Mle::Mle>().IsLeader());
|
||||||
|
|||||||
@@ -75,23 +75,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SendDatasetChanged(const Ip6::Address &aAddress);
|
void SendDatasetChanged(const Ip6::Address &aAddress);
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets minimal delay timer.
|
|
||||||
*
|
|
||||||
* @param[in] aDelayTimerMinimal The value of minimal delay timer (in ms).
|
|
||||||
*
|
|
||||||
* @retval kErrorNone Successfully set the minimal delay timer.
|
|
||||||
* @retval kErrorInvalidArgs If @p aDelayTimerMinimal is not valid.
|
|
||||||
*/
|
|
||||||
Error SetDelayTimerMinimal(uint32_t aDelayTimerMinimal);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets minimal delay timer.
|
|
||||||
*
|
|
||||||
* @retval the minimal delay timer (in ms).
|
|
||||||
*/
|
|
||||||
uint32_t GetDelayTimerMinimal(void) const { return mDelayTimerMinimal; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets empty Commissioner Data TLV in the Thread Network Data.
|
* Sets empty Commissioner Data TLV in the Thread Network Data.
|
||||||
*/
|
*/
|
||||||
@@ -132,7 +115,6 @@ private:
|
|||||||
using LeaderTimer = TimerMilliIn<Leader, &Leader::HandleTimer>;
|
using LeaderTimer = TimerMilliIn<Leader, &Leader::HandleTimer>;
|
||||||
|
|
||||||
LeaderTimer mTimer;
|
LeaderTimer mTimer;
|
||||||
uint32_t mDelayTimerMinimal;
|
|
||||||
CommissionerIdTlv::StringType mCommissionerId;
|
CommissionerIdTlv::StringType mCommissionerId;
|
||||||
uint16_t mSessionId;
|
uint16_t mSessionId;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user