From d6aa72736610865729625e295ff39128c7dd4b17 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Sun, 17 Oct 2021 22:27:49 +0200 Subject: broadband-modem-mbim: fix signal quality reporting with MBIMEx v2.0 When we enable MBIMEx v2.0, the "Signal State" responses and indications no longer report a valid RSSI value; and instead, they report per access technology RSRP/RSRQ values. >>>>>> Header: >>>>>> length = 116 >>>>>> type = indicate-status (0x80000007) >>>>>> transaction = 0 >>>>>> Fragment header: >>>>>> total = 1 >>>>>> current = 0 >>>>>> Contents: >>>>>> service = 'basic-connect' (a289cc33-bcbb-8b4f-b6b0-133ec2aae6df) >>>>>> cid = 'signal-state' (0x0000000b) >>>>>> Fields: >>>>>> Rssi = '99' >>>>>> ErrorRate = '99' >>>>>> SignalStrengthInterval = '5' >>>>>> RssiThreshold = '2' >>>>>> ErrorRateThreshold = '4294967295' >>>>>> RsrpSnr = '{ >>>>>> [0] = { >>>>>> Rsrp = '0' >>>>>> Snr = '0' >>>>>> RsrpThreshold = '4294967295' >>>>>> SnrThreshold = '4294967295' >>>>>> SystemType = '5g-nsa' >>>>>> }, >>>>>> [1] = { >>>>>> Rsrp = '49' >>>>>> Snr = '45' >>>>>> RsrpThreshold = '4294967295' >>>>>> SnrThreshold = '4294967295' >>>>>> SystemType = 'lte' >>>>>> }, >>>>>> }' --- src/mm-modem-helpers.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/mm-modem-helpers.h') diff --git a/src/mm-modem-helpers.h b/src/mm-modem-helpers.h index 7391409f..4107137c 100644 --- a/src/mm-modem-helpers.h +++ b/src/mm-modem-helpers.h @@ -576,6 +576,10 @@ gboolean mm_sim_parse_cpol_test_response (const gchar *response, #define MM_RSSI_TO_QUALITY(rssi) \ (guint8)(100 - ((CLAMP (rssi, -113, -51) + 51) * 100 / (-113 + 51))) +/* Limit the value betweeen [-110,-60] and scale it to a percentage */ +#define MM_RSRP_TO_QUALITY(rsrp) \ + (guint8)(100 - ((CLAMP (rsrp, -110, -60) + 60) * 100 / (-110 + 60))) + /*****************************************************************************/ /* Helper function to decode eid read from esim */ -- cgit v1.2.3-70-g09d2