From 118200317d8bde26c8d870f678b4f11916314ecd Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Wed, 7 Dec 2022 14:14:32 -0500 Subject: [PATCH] Make sure the Neighbor Table averageRSSI and LastRSSI are valid. (#23914) * Make sure the Neighbor Table averageRSSI and LastRSSI are valid value per matter spec * Thread api restrict the average RSSI already, don't do it again in the matter code --- ...nericThreadStackManagerImpl_OpenThread.cpp | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp index 10d9bf94a530e1..6e59b2e8d0df60 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp @@ -1152,8 +1152,24 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_WriteThreadNetw app::DataModel::Nullable averageRssi; app::DataModel::Nullable lastRssi; - averageRssi.SetNonNull(neighInfo.mAverageRssi); - lastRssi.SetNonNull(neighInfo.mLastRssi); + if (neighInfo.mAverageRssi == OT_RADIO_RSSI_INVALID) + { + averageRssi.SetNull(); + } + else + { + // Thread average calculation already restrict mAverageRssi to be between -128 and 0 + averageRssi.SetNonNull(neighInfo.mAverageRssi); + } + + if (neighInfo.mAverageRssi == OT_RADIO_RSSI_INVALID) + { + lastRssi.SetNull(); + } + else + { + lastRssi.SetNonNull(((neighInfo.mLastRssi > 0) ? 0 : neighInfo.mLastRssi)); + } neighborTable.averageRssi = averageRssi; neighborTable.lastRssi = lastRssi;