Skip to content

Commit

Permalink
Make sure the Neighbor Table averageRSSI and LastRSSI are valid. (#23914
Browse files Browse the repository at this point in the history
)

* 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
  • Loading branch information
jmartinez-silabs authored and pull[bot] committed Aug 30, 2023
1 parent 8880f5d commit 00350aa
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1152,8 +1152,24 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_WriteThreadNetw
app::DataModel::Nullable<int8_t> averageRssi;
app::DataModel::Nullable<int8_t> 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;
Expand Down

0 comments on commit 00350aa

Please sign in to comment.