mirror of
https://github.com/espressif/openthread.git
synced 2026-08-12 21:57:47 +00:00
[network-data] introduce 5s delay between SRV_DATA.ntf when deregister for child (#4485)
This commit is contained in:
@@ -977,8 +977,16 @@ otError NetworkData::SendServerDataNotification(uint16_t aRloc16)
|
||||
Coap::Message * message = NULL;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
VerifyOrExit(mLastAttempt.GetValue() == 0 || ((TimerMilli::GetNow() - mLastAttempt) > kDataResubmitDelay),
|
||||
error = OT_ERROR_ALREADY);
|
||||
if (mLastAttempt.GetValue() != 0)
|
||||
{
|
||||
uint32_t diff = TimerMilli::GetNow() - mLastAttempt;
|
||||
|
||||
if (((mType == kTypeLocal) && (diff > kDataResubmitDelay)) ||
|
||||
((mType == kTypeLeader) && (diff > kProxyResubmitDelay)))
|
||||
{
|
||||
ExitNow(error = OT_ERROR_ALREADY);
|
||||
}
|
||||
}
|
||||
|
||||
VerifyOrExit((message = Get<Coap::Coap>().NewMessage()) != NULL, error = OT_ERROR_NO_BUFS);
|
||||
|
||||
@@ -1007,16 +1015,13 @@ otError NetworkData::SendServerDataNotification(uint16_t aRloc16)
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = Get<Coap::Coap>().SendMessage(*message, messageInfo));
|
||||
|
||||
if (mType == kTypeLocal)
|
||||
{
|
||||
mLastAttempt = TimerMilli::GetNow();
|
||||
mLastAttempt = TimerMilli::GetNow();
|
||||
|
||||
// `0` is a special value to indicate no delay limitation on sending SRV_DATA.ntf.
|
||||
// Here avoids possible impact in rate limitation of SRV_DATA.ntf in case of wrap.
|
||||
if (mLastAttempt.GetValue() == 0)
|
||||
{
|
||||
mLastAttempt.SetValue(1);
|
||||
}
|
||||
// `0` is a special value to indicate no delay limitation on sending SRV_DATA.ntf.
|
||||
// Here avoids possible impact in rate limitation of SRV_DATA.ntf in case of wrap.
|
||||
if (mLastAttempt.GetValue() == 0)
|
||||
{
|
||||
mLastAttempt.SetValue(1);
|
||||
}
|
||||
|
||||
otLogInfoNetData("Sent server data notification");
|
||||
|
||||
@@ -496,7 +496,9 @@ protected:
|
||||
private:
|
||||
enum
|
||||
{
|
||||
kDataResubmitDelay = 300000, ///< DATA_RESUBMIT_DELAY (milliseconds)
|
||||
kDataResubmitDelay = 300000, ///< DATA_RESUBMIT_DELAY (milliseconds) if the device itself is the server.
|
||||
kProxyResubmitDelay = 5000, ///< Resubmit delay (milliseconds) if deregister as the child server proxy.
|
||||
|
||||
};
|
||||
|
||||
class NetworkDataIterator
|
||||
|
||||
Reference in New Issue
Block a user