From de5833a550219988ab4becc6f75841ecde38096b Mon Sep 17 00:00:00 2001
From: Serhii Kostiuk <serhii.o.kostiuk@globallogic.com>
Date: Wed, 19 Aug 2020 19:43:22 +0300
Subject: [IN:4046] MTR-MNG2 Dashboard has blank Cellular Mode.

This commit contains the following changes:

- mark all GSM modes as 2G (EGPRS/EDGE is also 2G/GSM);
- mark NB-IoT and CAT M1 as 4G/LTE.

Those changes allow to correctly display 4G modes for MNG2 and 2G modes for all radios.
---
 src/MTS_IO_CellularRadio.cpp | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

(limited to 'src')

diff --git a/src/MTS_IO_CellularRadio.cpp b/src/MTS_IO_CellularRadio.cpp
index ce95929..fe252c0 100644
--- a/src/MTS_IO_CellularRadio.cpp
+++ b/src/MTS_IO_CellularRadio.cpp
@@ -848,16 +848,32 @@ ICellularRadio::CODE CellularRadio::getCellularMode(CELLULAR_MODES &networks) {
         printError("%s| AT+COPS Error parsing reply [AT+COPS?][%s]", getName().c_str(), cmdResult.c_str());
         return FAILURE;
     }
-    if (op == 0) {
-        networks = CELLULAR_MODE_2G;
-    } else if (op >= 2 && op <= 6) {
-        networks = CELLULAR_MODE_3G;
-    } else if (op == 7) {
-        networks = CELLULAR_MODE_4G;
-    } else {
-        printError("%s| AT+COPS unknown Radio Access Technology [AT+COPS?][%s]", getName().c_str(), cmdResult.c_str());
-        return FAILURE;
+
+    switch (op) {
+        case 0:  // GSM
+        case 1:  // GSM Compact
+        case 3:  // GSM w/EGPRS
+            networks = CELLULAR_MODE_2G;
+            break;
+
+        case 2:  // UTRAN
+        case 4:  // UTRAN w/HSDPA
+        case 5:  // UTRAN w/HSUPA
+        case 6:  // UTRAN w/HSDPA and HSUPA
+            networks = CELLULAR_MODE_3G;
+            break;
+
+        case 7:  // E-UTRAN, LTE
+        case 8:  // CAT M1, EC-GSM-IoT (A/Gb mode), LTE
+        case 9:  // NB IoT, E-UTRAN (NB-S1 mode), LTE
+            networks = CELLULAR_MODE_4G;
+            break;
+
+        default:
+            printError("%s| AT+COPS unknown Radio Access Technology [AT+COPS?][%s]", getName().c_str(), cmdResult.c_str());
+            return FAILURE;
     }
+
     return SUCCESS;
 }
 
-- 
cgit v1.2.3