mirror of
https://github.com/espressif/openthread.git
synced 2026-08-31 06:19:54 +00:00
Remove LinkQualityInfo::kUnknownRss and use OT_RADIO_RSSI_INVALID instead (#1897)
This commit is contained in:
@@ -333,7 +333,7 @@ otError otThreadGetParentAverageRssi(otInstance *aInstance, int8_t *aParentRssi)
|
||||
parent = aInstance->mThreadNetif.GetMle().GetParent();
|
||||
*aParentRssi = parent->GetLinkInfo().GetAverageRss();
|
||||
|
||||
VerifyOrExit(*aParentRssi != LinkQualityInfo::kUnknownRss, error = OT_ERROR_FAILED);
|
||||
VerifyOrExit(*aParentRssi != OT_RADIO_RSSI_INVALID, error = OT_ERROR_FAILED);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -349,7 +349,7 @@ otError otThreadGetParentLastRssi(otInstance *aInstance, int8_t *aLastRssi)
|
||||
parent = aInstance->mThreadNetif.GetMle().GetParent();
|
||||
*aLastRssi = parent->GetLinkInfo().GetLastRss();
|
||||
|
||||
VerifyOrExit(*aLastRssi != LinkQualityInfo::kUnknownRss, error = OT_ERROR_FAILED);
|
||||
VerifyOrExit(*aLastRssi != OT_RADIO_RSSI_INVALID, error = OT_ERROR_FAILED);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
#include <stdio.h>
|
||||
#include "utils/wrap_string.h"
|
||||
|
||||
#include <openthread/types.h>
|
||||
|
||||
#include "common/code_utils.hpp"
|
||||
|
||||
namespace ot {
|
||||
@@ -82,7 +80,7 @@ void LinkQualityInfo::AddRss(int8_t aNoiseFloor, int8_t aRss)
|
||||
uint16_t newValue;
|
||||
uint16_t oldAverage;
|
||||
|
||||
VerifyOrExit(aRss != kUnknownRss);
|
||||
VerifyOrExit(aRss != OT_RADIO_RSSI_INVALID);
|
||||
|
||||
mLastRss = aRss;
|
||||
|
||||
@@ -133,7 +131,7 @@ exit:
|
||||
|
||||
int8_t LinkQualityInfo::GetAverageRss(void) const
|
||||
{
|
||||
int8_t average = kUnknownRss;
|
||||
int8_t average = OT_RADIO_RSSI_INVALID;
|
||||
|
||||
if (mCount != 0)
|
||||
{
|
||||
@@ -212,7 +210,7 @@ uint8_t LinkQualityInfo::ConvertRssToLinkMargin(int8_t aNoiseFloor, int8_t aRss)
|
||||
{
|
||||
int8_t linkMargin = aRss - aNoiseFloor;
|
||||
|
||||
if (linkMargin < 0 || aRss == kUnknownRss)
|
||||
if (linkMargin < 0 || aRss == OT_RADIO_RSSI_INVALID)
|
||||
{
|
||||
linkMargin = 0;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <openthread/platform/radio.h>
|
||||
#include <openthread/types.h>
|
||||
|
||||
namespace ot {
|
||||
@@ -58,11 +59,6 @@ namespace ot {
|
||||
class LinkQualityInfo
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
kUnknownRss = 127, ///< Indicates an unknown signal strength value or average.
|
||||
};
|
||||
|
||||
/**
|
||||
* This constructor initializes an instance of the LinkQualityInfo class.
|
||||
*
|
||||
@@ -87,7 +83,7 @@ public:
|
||||
/**
|
||||
* This method returns the current average signal strength value.
|
||||
*
|
||||
* @returns The current average value or @c kUnknownRss if no average is available.
|
||||
* @returns The current average value or @c OT_RADIO_RSSI_INVALID if no average is available.
|
||||
*
|
||||
*/
|
||||
int8_t GetAverageRss(void) const;
|
||||
|
||||
@@ -71,7 +71,7 @@ void VerifyEncodedRssValue(LinkQualityInfo &aLinkInfo)
|
||||
int8_t rss = aLinkInfo.GetAverageRss();
|
||||
uint16_t encodedRss = aLinkInfo.GetAverageRssAsEncodedWord();
|
||||
|
||||
if (rss != LinkQualityInfo::kUnknownRss)
|
||||
if (rss != OT_RADIO_RSSI_INVALID)
|
||||
{
|
||||
VerifyOrQuit(rss == -static_cast<int16_t>((encodedRss + (kEncodedAverageMultiple / 2)) >> kEncodedAverageBitShift),
|
||||
"TestLinkQualityInfo failed - Ecoded RSS does not match the value from GetAverageRss().");
|
||||
@@ -141,7 +141,7 @@ void TestRssAveraging(void)
|
||||
// Values after initialization.
|
||||
|
||||
printf("\nAfter Initialization: ");
|
||||
VerifyOrQuit(linkInfo.GetAverageRss() == LinkQualityInfo::kUnknownRss,
|
||||
VerifyOrQuit(linkInfo.GetAverageRss() == OT_RADIO_RSSI_INVALID,
|
||||
"TestLinkQualityInfo failed - Inital value from GetAverageRss() is incorrect.");
|
||||
VerifyOrQuit(linkInfo.GetLinkMargin(sNoiseFloor) == 0,
|
||||
"TestLinkQualityInfo failed - Inital value for link margin is incorrect.");
|
||||
@@ -163,7 +163,7 @@ void TestRssAveraging(void)
|
||||
|
||||
printf("Clear(): ");
|
||||
linkInfo.Clear();
|
||||
VerifyOrQuit(linkInfo.GetAverageRss() == LinkQualityInfo::kUnknownRss,
|
||||
VerifyOrQuit(linkInfo.GetAverageRss() == OT_RADIO_RSSI_INVALID,
|
||||
"TestLinkQualityInfo failed - GetAverageRss() after Clear() is incorrect.");
|
||||
VerifyOrQuit(linkInfo.GetLinkMargin(sNoiseFloor) == 0,
|
||||
"TestLinkQualityInfo failed - link margin value after Clear() is incorrect.");
|
||||
|
||||
Reference in New Issue
Block a user