This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 78682572afd2b4bd2e68a78074163435dd5c0c31
Author: raiden00pl <[email protected]>
AuthorDate: Fri Jun 12 13:34:20 2026 +0200

    arch/arm/nrf91: improve LTE_CMDID_GETQUAL handling
    
    1. Don't fail LTE GETQUAL on AT+CSQ error
       The LTE_CMDID_GETQUAL handler queried the modem with AT+CESQ (RSRP/RSRQ)
       and then AT+CSQ (RSSI), returning the result of the last command.
    
       Set 'valid' only when AT+CESQ parses, treat AT+CSQ as optional, zero
       the metrics up front, and return OK so the caller inspects 'valid'.
    
    2. get SNIR
    
    Signed-off-by: raiden00pl <[email protected]>
---
 arch/arm/src/nrf91/nrf91_modem_sock.c | 39 ++++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 14 deletions(-)

diff --git a/arch/arm/src/nrf91/nrf91_modem_sock.c 
b/arch/arm/src/nrf91/nrf91_modem_sock.c
index 2b190ee2d2a..5b89201fc11 100644
--- a/arch/arm/src/nrf91/nrf91_modem_sock.c
+++ b/arch/arm/src/nrf91/nrf91_modem_sock.c
@@ -801,10 +801,19 @@ static int nrf91_ioctl_ltecmd(int fd, int cmd, unsigned 
long arg)
       {
         lte_quality_t **quality =
           (lte_quality_t **)(ltecmd->outparam + 1);
+        bool valid = false;
+        int cresult;
         int tmp;
         int rsrp;
         int rsrq;
-        int rssi;
+        int snr;
+
+        (*quality)->rsrp = 0;
+        (*quality)->rsrq = 0;
+        (*quality)->rssi = 0;
+        (*quality)->sinr = 0;
+
+        /* RSRP/RSRQ via AT+CESQ - available whenever the modem is camped. */
 
         ret = nrf_modem_at_scanf("AT+CESQ",
                                  "+CESQ: %d,%d,%d,%d,%d,%d",
@@ -812,28 +821,30 @@ static int nrf91_ioctl_ltecmd(int fd, int cmd, unsigned 
long arg)
                                  &rsrq, &rsrp);
         if (ret > 0)
           {
-            (*quality)->rsrq  = (rsrq / 2) - 19;
-            (*quality)->rsrp  = rsrp - 140;
+            (*quality)->rsrq = (rsrq / 2) - 19;
+            (*quality)->rsrp = rsrp - 140;
+            valid = true;
           }
         else
           {
             nerr("AT+CESQ failed %d\n", ret);
           }
 
-        ret = nrf_modem_at_scanf("AT+CSQ",
-                                 "+CSQ: %d,%d",
-                                 &rssi, &tmp);
-        if (ret > 0)
-          {
-            (*quality)->rssi  = rssi;
-            (*quality)->sinr  = 0;
-          }
-        else
+        /* SNR via AT%CONEVAL - the only SNR source on this modem (AT+CSQ is
+         * not answered and carries no SNR). Reported SNR is the raw
+         * value - 24.
+         */
+
+        ret = nrf_modem_at_scanf("AT%CONEVAL",
+                                 "%%CONEVAL: %d,%d,%d,%d,%d,%d",
+                                 &cresult, &tmp, &tmp, &tmp, &tmp, &snr);
+        if (ret >= 6 && cresult == 0)
           {
-            nerr("AT+CSQ failed %d\n", ret);
+            (*quality)->sinr = snr - 24;
           }
 
-        (*quality)->valid = true;
+        (*quality)->valid = valid;
+        ret = OK;
         break;
       }
 

Reply via email to