From 94fab38d4a3a176c054157227cf596b410b082a2 Mon Sep 17 00:00:00 2001 From: Adam Eliot Date: Wed, 5 Apr 2017 19:21:33 -0700 Subject: [PATCH] Parent last rssi (#1558) * Added thread api call to get the last rssi for the parent --- include/openthread/thread.h | 14 +++++++++++++- src/core/api/thread_api.cpp | 16 ++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/include/openthread/thread.h b/include/openthread/thread.h index a88eaa21f..e55d3e381 100644 --- a/include/openthread/thread.h +++ b/include/openthread/thread.h @@ -834,11 +834,23 @@ OTAPI ThreadError OTCALL otThreadGetParentInfo(otInstance *aInstance, otRouterIn * The function retrieves the average RSSI for the Thread Parent. * * @param[in] aInstance A pointer to an OpenThread instance. - * @param[out] aParentInfo A pointer to where the parent rssi should be placed. + * @param[out] aParentRssi A pointer to where the parent rssi should be placed. * */ OTAPI ThreadError OTCALL otThreadGetParentAverageRssi(otInstance *aInstance, int8_t *aParentRssi); +/** + * The function retrieves the RSSI of the last packet from the Thread Parent. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[out] aLastRssi A pointer to where the last rssi should be placed. + * + * @retval kThreadError_None Successfully retrieved the RSSI data. + * @retval kThreadError_Failed Unable to get RSSI data. + * @retval kThreadError_InvalidArgs @p aLastRssi is NULL. + */ +OTAPI ThreadError OTCALL otThreadGetParentLastRssi(otInstance *aInstance, int8_t *aLastRssi); + /** * This function pointer is called when Network Diagnostic Get response is received. * diff --git a/src/core/api/thread_api.cpp b/src/core/api/thread_api.cpp index 8532297fd..348c765f6 100644 --- a/src/core/api/thread_api.cpp +++ b/src/core/api/thread_api.cpp @@ -511,6 +511,22 @@ exit: return error; } +ThreadError otThreadGetParentLastRssi(otInstance *aInstance, int8_t *aLastRssi) +{ + ThreadError error = kThreadError_None; + Router *parent; + + VerifyOrExit(aLastRssi != NULL, error = kThreadError_InvalidArgs); + + parent = aInstance->mThreadNetif.GetMle().GetParent(); + *aLastRssi = parent->mLinkInfo.GetLastRss(); + + VerifyOrExit(*aLastRssi != LinkQualityInfo::kUnknownRss, error = kThreadError_Failed); + +exit: + return error; +} + const char *otGetVersionString(void) { /**