From 2437a75a6b78a7f3ab536121d3bcb21745a477d0 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Sun, 16 Feb 2020 22:09:58 -0800 Subject: [PATCH] [link-quality] have LinkQualityInfo inherit from IntsanceLocatorInit (#4569) --- src/core/thread/link_quality.cpp | 1 + src/core/thread/link_quality.hpp | 11 ++++++++++- src/core/thread/topology.cpp | 1 + tests/unit/test_child.cpp | 3 +-- tests/unit/test_link_quality.cpp | 6 ++++++ 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/core/thread/link_quality.cpp b/src/core/thread/link_quality.cpp index 90f246fa4..9f1c00bb0 100644 --- a/src/core/thread/link_quality.cpp +++ b/src/core/thread/link_quality.cpp @@ -37,6 +37,7 @@ #include "common/code_utils.hpp" #include "common/instance.hpp" +#include "common/locator-getters.hpp" namespace ot { diff --git a/src/core/thread/link_quality.hpp b/src/core/thread/link_quality.hpp index 7cb939508..b9a59412d 100644 --- a/src/core/thread/link_quality.hpp +++ b/src/core/thread/link_quality.hpp @@ -38,6 +38,7 @@ #include +#include "common/locator.hpp" #include "common/string.hpp" namespace ot { @@ -215,7 +216,7 @@ private: * strength (RSS), last RSS, link margin, and link quality. * */ -class LinkQualityInfo +class LinkQualityInfo : public InstanceLocatorInit { public: enum @@ -229,6 +230,14 @@ public: */ typedef String InfoString; + /** + * This method initializes the `LinkQualityInfo` object. + * + * @param[in] aInstance A reference to the OpenThread instance. + * + */ + void Init(Instance &aInstance) { InstanceLocatorInit::Init(aInstance); } + /** * This method clears the all the data in the object. * diff --git a/src/core/thread/topology.cpp b/src/core/thread/topology.cpp index 515645a20..3218d01d2 100644 --- a/src/core/thread/topology.cpp +++ b/src/core/thread/topology.cpp @@ -44,6 +44,7 @@ namespace ot { void Neighbor::Init(Instance &aInstance) { InstanceLocatorInit::Init(aInstance); + mLinkInfo.Init(aInstance); SetState(kStateInvalid); } diff --git a/tests/unit/test_child.cpp b/tests/unit/test_child.cpp index ebaf1b0c0..de5a15483 100644 --- a/tests/unit/test_child.cpp +++ b/tests/unit/test_child.cpp @@ -90,8 +90,7 @@ void VerifyChildIp6Addresses(const Child &aChild, uint8_t aAddressListLength, co if (sInstance->Get().IsMeshLocalAddress(aAddressList[index])) { - SuccessOrQuit(aChild.GetMeshLocalIp6Address(address), - "Child::GetMeshLocalIp6Address() failed\n"); + SuccessOrQuit(aChild.GetMeshLocalIp6Address(address), "Child::GetMeshLocalIp6Address() failed\n"); VerifyOrQuit(address == aAddressList[index], "GetMeshLocalIp6Address() did not return expected address"); hasMeshLocal = true; } diff --git a/tests/unit/test_link_quality.cpp b/tests/unit/test_link_quality.cpp index f352f2c15..caa664825 100644 --- a/tests/unit/test_link_quality.cpp +++ b/tests/unit/test_link_quality.cpp @@ -34,6 +34,8 @@ namespace ot { +static ot::Instance *sInstance; + enum { kMaxRssValue = 0, @@ -89,6 +91,10 @@ void TestLinkQualityData(RssTestData aRssData) int8_t rss, ave, min, max; size_t i; + sInstance = testInitInstance(); + VerifyOrQuit(sInstance != NULL, "Null instance"); + linkInfo.Init(*sInstance); + printf("- - - - - - - - - - - - - - - - - -\n"); linkInfo.Clear(); min = kMinRssValue;