mirror of
https://github.com/espressif/openthread.git
synced 2026-07-29 07:07:47 +00:00
[link-quality] explicitly clear link quality for new child/router (#2941)
The child/router entries are generally cleared using `memset()` to avoid explicitly setting all fields to zero. As a result, it is necessary to explicitly clear the link quality state to properly initialize the last RSSI reading. The user-specific constructors are also removed.
This commit is contained in:
@@ -195,12 +195,11 @@ Mac::Mac(Instance &aInstance)
|
||||
, mTxFrame(static_cast<Frame *>(otPlatRadioGetTransmitBuffer(&aInstance)))
|
||||
, mOobFrame(NULL)
|
||||
, mKeyIdMode2FrameCounter(0)
|
||||
, mCcaSuccessRateTracker()
|
||||
, mCcaSampleCount(0)
|
||||
, mEnabled(true)
|
||||
{
|
||||
GenerateExtAddress(&mExtAddress);
|
||||
|
||||
mCcaSuccessRateTracker.Reset();
|
||||
memset(&mCounters, 0, sizeof(otMacCounters));
|
||||
|
||||
otPlatRadioEnable(&GetInstance());
|
||||
|
||||
@@ -140,18 +140,16 @@ exit:
|
||||
return string;
|
||||
}
|
||||
|
||||
LinkQualityInfo::LinkQualityInfo(void)
|
||||
: mLastRss(OT_RADIO_RSSI_INVALID)
|
||||
{
|
||||
mRssAverager.Reset();
|
||||
SetLinkQuality(0);
|
||||
}
|
||||
|
||||
void LinkQualityInfo::Clear(void)
|
||||
{
|
||||
mRssAverager.Reset();
|
||||
SetLinkQuality(0);
|
||||
mLastRss = OT_RADIO_RSSI_INVALID;
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_TX_ERROR_RATE_TRACKING
|
||||
mFrameErrorRate.Reset();
|
||||
mMessageErrorRate.Reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
void LinkQualityInfo::AddRss(int8_t aNoiseFloor, int8_t aRss)
|
||||
|
||||
@@ -67,17 +67,6 @@ public:
|
||||
kMaxRateValue = 0xffff, ///< Indicates value corresponding to maximum (failure/success) rate of 100%.
|
||||
};
|
||||
|
||||
/**
|
||||
* This constructor initializes a `SuccessRateTracker` instance.
|
||||
*
|
||||
* After initialization the tracker starts with success rate 100% (failure rate 0%).
|
||||
*
|
||||
*/
|
||||
SuccessRateTracker(void)
|
||||
: mFailureRate(0)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This method resets the tracker to its initialized state, setting success rate to 100%.
|
||||
*
|
||||
@@ -241,12 +230,6 @@ public:
|
||||
*/
|
||||
typedef String<kInfoStringSize> InfoString;
|
||||
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
*
|
||||
*/
|
||||
LinkQualityInfo(void);
|
||||
|
||||
/**
|
||||
* This method clears the all the data in the object.
|
||||
*
|
||||
|
||||
@@ -3504,6 +3504,7 @@ void MleRouter::RestoreChildren(void)
|
||||
memset(child, 0, sizeof(*child));
|
||||
|
||||
child->SetExtAddress(*static_cast<const Mac::ExtAddress *>(&childInfo.mExtAddress));
|
||||
child->GetLinkInfo().Clear();
|
||||
child->SetRloc16(childInfo.mRloc16);
|
||||
child->SetTimeout(childInfo.mTimeout);
|
||||
child->SetDeviceMode(childInfo.mMode);
|
||||
|
||||
@@ -93,6 +93,7 @@ void TestLinkQualityData(RssTestData aRssData)
|
||||
size_t i;
|
||||
|
||||
printf("- - - - - - - - - - - - - - - - - -\n");
|
||||
linkInfo.Clear();
|
||||
min = kMinRssValue;
|
||||
max = kMaxRssValue;
|
||||
|
||||
@@ -387,6 +388,8 @@ void TestSuccessRateTracker(void)
|
||||
|
||||
printf("\nTesting SuccessRateTracker\n");
|
||||
|
||||
rateTracker.Reset();
|
||||
|
||||
VerifyOrQuit(rateTracker.GetSuccessRate() == kMaxRate, "SuccessRateTracker: Initial value incorrect");
|
||||
VerifyOrQuit(rateTracker.GetFailureRate() == 0, "SuccessRateTracker: Initial value incorrect");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user