aboutsummaryrefslogtreecommitdiff
path: root/src/mm-modem-helpers.h
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2021-10-17 21:58:54 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-10-18 00:04:09 +0200
commitc01f22804e0e4ac35216208e4a38da02cc56290c (patch)
tree2030663bf60b731364a633f293061c10cf484871 /src/mm-modem-helpers.h
parente1bc4b0999aa268358d2ab2c3182e87119cd255f (diff)
modem-helpers: setup common RSSI to signal quality converter
Diffstat (limited to 'src/mm-modem-helpers.h')
-rw-r--r--src/mm-modem-helpers.h7
1 files changed, 7 insertions, 0 deletions
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
@@ -570,6 +570,13 @@ gboolean mm_sim_parse_cpol_test_response (const gchar *response,
#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 */
gchar *mm_decode_eid (const gchar *eid, gsize eid_len);