From c01f22804e0e4ac35216208e4a38da02cc56290c Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Sun, 17 Oct 2021 21:58:54 +0200 Subject: modem-helpers: setup common RSSI to signal quality converter --- src/mm-modem-helpers.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/mm-modem-helpers.h') diff --git a/src/mm-modem-helpers.h b/src/mm-modem-helpers.h index 9345db8e..7391409f 100644 --- a/src/mm-modem-helpers.h +++ b/src/mm-modem-helpers.h @@ -569,6 +569,13 @@ gboolean mm_sim_parse_cpol_test_response (const gchar *response, * and in order to avoid -Wtype-limits warnings. */ #define MM_CLAMP_HIGH(x, high) (((x) > (high)) ? (high) : (x)) +/*****************************************************************************/ +/* Signal quality percentage from different sources */ + +/* Limit the value betweeen [-113,-51] and scale it to a percentage */ +#define MM_RSSI_TO_QUALITY(rssi) \ + (guint8)(100 - ((CLAMP (rssi, -113, -51) + 51) * 100 / (-113 + 51))) + /*****************************************************************************/ /* Helper function to decode eid read from esim */ -- cgit v1.2.3-70-g09d2