[link-metrics] update the scaling of link margin and RSSI metrics (#8078)

This commit updates the scaling of the link margin and RSSI metrics.
The metric values are scaled when appended in the message (in a
Report sub-TLV) or when they are read back from received message. The
stored value in `MetricsValues` are changed to be always the actual
metric value (not the scaled value). This ensures that the value are
stored in proper int type (e.g., RSSI is `int8` vs the scaled value
which is `[0,255]`). Methods are added to perform the scaling which
now rounds to closest integer ensuring the reverse scaling gives back
the original value. Unit test is added to validate the scaling
methods.
This commit is contained in:
Abtin Keshavarzian
2022-08-25 11:08:44 -07:00
committed by GitHub
parent cba1bebf1f
commit 989a56e96d
5 changed files with 159 additions and 23 deletions
+13
View File
@@ -118,6 +118,19 @@ void TestNumUtils(void)
VerifyOrQuit(ThreeWayCompare<bool>(true, false) > 0);
VerifyOrQuit(ThreeWayCompare<bool>(false, true) < 0);
VerifyOrQuit(DivideAndRoundToClosest<uint8_t>(2, 1) == 2);
VerifyOrQuit(DivideAndRoundToClosest<uint8_t>(1, 3) == 0);
VerifyOrQuit(DivideAndRoundToClosest<uint8_t>(1, 2) == 1);
VerifyOrQuit(DivideAndRoundToClosest<uint8_t>(2, 3) == 1);
VerifyOrQuit(DivideAndRoundToClosest<uint8_t>(3, 2) == 2);
VerifyOrQuit(DivideAndRoundToClosest<uint8_t>(4, 2) == 2);
VerifyOrQuit(DivideAndRoundToClosest<uint8_t>(0, 10) == 0);
VerifyOrQuit(DivideAndRoundToClosest<uint8_t>(4, 10) == 0);
VerifyOrQuit(DivideAndRoundToClosest<uint8_t>(5, 10) == 1);
VerifyOrQuit(DivideAndRoundToClosest<uint8_t>(9, 10) == 1);
VerifyOrQuit(DivideAndRoundToClosest<uint8_t>(10, 10) == 1);
printf("TestNumUtils() passed\n");
}