mirror of
https://github.com/espressif/openthread.git
synced 2026-10-08 08:47:38 +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;
|
Coap::Message * message = NULL;
|
||||||
Ip6::MessageInfo messageInfo;
|
Ip6::MessageInfo messageInfo;
|
||||||
|
|
||||||
VerifyOrExit(mLastAttempt.GetValue() == 0 || ((TimerMilli::GetNow() - mLastAttempt) > kDataResubmitDelay),
|
if (mLastAttempt.GetValue() != 0)
|
||||||
error = OT_ERROR_ALREADY);
|
{
|
||||||
|
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);
|
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);
|
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||||
SuccessOrExit(error = Get<Coap::Coap>().SendMessage(*message, messageInfo));
|
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.
|
// `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.
|
// Here avoids possible impact in rate limitation of SRV_DATA.ntf in case of wrap.
|
||||||
if (mLastAttempt.GetValue() == 0)
|
if (mLastAttempt.GetValue() == 0)
|
||||||
{
|
{
|
||||||
mLastAttempt.SetValue(1);
|
mLastAttempt.SetValue(1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
otLogInfoNetData("Sent server data notification");
|
otLogInfoNetData("Sent server data notification");
|
||||||
|
|||||||
@@ -496,7 +496,9 @@ protected:
|
|||||||
private:
|
private:
|
||||||
enum
|
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
|
class NetworkDataIterator
|
||||||
|
|||||||
Reference in New Issue
Block a user