@@ -661,7 +661,7 @@ int QuectelNcpClient::getCellularGlobalIdentity(CellularGlobalIdentity* cgi) {
661
661
// Fill in LAC and Cell ID based on current RAT, prefer PSD and EPS
662
662
// fallback to CSD
663
663
CHECK_PARSER_OK (parser_.execCommand (" AT+CEREG?" ));
664
- if (isQuecCat1Device () || ncpId () == PLATFORM_NCP_QUECTEL_BG95_M5 ) {
664
+ if (isQuec2g3gEnabled () ) {
665
665
CHECK_PARSER_OK (parser_.execCommand (" AT+CGREG?" ));
666
666
CHECK_PARSER_OK (parser_.execCommand (" AT+CREG?" ));
667
667
}
@@ -1065,6 +1065,17 @@ bool QuectelNcpClient::isQuecBG95xDevice() {
1065
1065
ncp_id == PLATFORM_NCP_QUECTEL_BG95_MF) ;
1066
1066
}
1067
1067
1068
+ bool QuectelNcpClient::isQuec2g3gEnabled () {
1069
+ // PLATFORM_NCP_QUECTEL_BG96 specifically not included to
1070
+ // disable 2G support so that a 10W power supply is not required
1071
+ int ncp_id = ncpId ();
1072
+ return (ncp_id == PLATFORM_NCP_QUECTEL_EG91_E ||
1073
+ ncp_id == PLATFORM_NCP_QUECTEL_EG91_NA ||
1074
+ ncp_id == PLATFORM_NCP_QUECTEL_EG91_EX ||
1075
+ ncp_id == PLATFORM_NCP_QUECTEL_EG91_NAX ||
1076
+ ncp_id == PLATFORM_NCP_QUECTEL_BG95_M5);
1077
+ }
1078
+
1068
1079
int QuectelNcpClient::getRuntimeBaudrate () {
1069
1080
auto runtimeBaudrate = QUECTEL_NCP_RUNTIME_SERIAL_BAUDRATE;
1070
1081
if (ncpId () == PLATFORM_NCP_QUECTEL_BG95_M5) {
@@ -1386,13 +1397,14 @@ int QuectelNcpClient::registerNet() {
1386
1397
1387
1398
resetRegistrationState ();
1388
1399
1389
- if (isQuecCat1Device () || ncpId () == PLATFORM_NCP_QUECTEL_BG95_M5 ) {
1390
- // Register GPRS, LET, NB-IOT network
1400
+ if (isQuec2g3gEnabled () ) {
1401
+ // Register GSM, GPRS network registration and location URCs
1391
1402
r = CHECK_PARSER (parser_.execCommand (" AT+CREG=2" ));
1392
1403
CHECK_TRUE (r == AtResponse::OK, SYSTEM_ERROR_UNKNOWN);
1393
1404
r = CHECK_PARSER (parser_.execCommand (" AT+CGREG=2" ));
1394
1405
CHECK_TRUE (r == AtResponse::OK, SYSTEM_ERROR_UNKNOWN);
1395
1406
}
1407
+ // Register LTE, NB-IoT network registration and location URCs
1396
1408
r = CHECK_PARSER (parser_.execCommand (" AT+CEREG=2" ));
1397
1409
CHECK_TRUE (r == AtResponse::OK, SYSTEM_ERROR_UNKNOWN);
1398
1410
@@ -1427,47 +1439,41 @@ int QuectelNcpClient::registerNet() {
1427
1439
// CHECK_TRUE(r == AtResponse::OK, SYSTEM_ERROR_UNKNOWN);
1428
1440
}
1429
1441
1430
- if (isQuecCatM1Device ()) {
1431
- if (ncpId () == PLATFORM_NCP_QUECTEL_BG96 || ncpId () == PLATFORM_NCP_QUECTEL_BG95_M5) {
1432
- // NOTE: BG96 supports 2G fallback which we disable explicitly so that a 10W power supply is not required
1433
- // Configure RATs to be searched
1434
- // Set to scan LTE only if not already set, take effect immediately
1435
- auto respNwMode = parser_.sendCommand (" AT+QCFG=\" nwscanmode\" " );
1436
- int nwScanMode = -1 ;
1437
- r = CHECK_PARSER (respNwMode.scanf (" +QCFG: \" nwscanmode\" ,%d" , &nwScanMode));
1438
- CHECK_TRUE (r == 1 , SYSTEM_ERROR_UNKNOWN);
1439
- r = CHECK_PARSER (respNwMode.readResult ());
1440
- CHECK_TRUE (r == AtResponse::OK, SYSTEM_ERROR_UNKNOWN);
1441
- #if PLATFORM_ID == PLATFORM_MSOM
1442
- // M404/BG95M5 should be LTEM only, ie scan mode 3
1443
- // M524/EG91EX should be AUTO (both LTEM and 2G), ie scan mode 0
1444
- int desiredNwScanMode = (ncpId () == PLATFORM_NCP_QUECTEL_BG95_M5) ? 3 : 0 ;
1442
+ // nwscanmode: configure RATs to be searched
1443
+ // only valid on BG96, BG95-M5 and EG91xxx
1444
+ if (ncpId () == PLATFORM_NCP_QUECTEL_BG96 || ncpId () == PLATFORM_NCP_QUECTEL_BG95_M5 || isQuecCat1Device ()) {
1445
+ auto respNwMode = parser_.sendCommand (" AT+QCFG=\" nwscanmode\" " );
1446
+ int nwScanMode = -1 ;
1447
+ r = CHECK_PARSER (respNwMode.scanf (" +QCFG: \" nwscanmode\" ,%d" , &nwScanMode));
1448
+ CHECK_TRUE (r == 1 , SYSTEM_ERROR_UNKNOWN);
1449
+ r = CHECK_PARSER (respNwMode.readResult ());
1450
+ CHECK_TRUE (r == AtResponse::OK, SYSTEM_ERROR_UNKNOWN);
1445
1451
1446
- if (nwScanMode != desiredNwScanMode) {
1447
- CHECK_PARSER (parser_.execCommand (" AT+QCFG=\" nwscanmode\" ,%d,1" , desiredNwScanMode));
1448
- }
1452
+ int desiredNwScanMode = isQuec2g3gEnabled () ? 0 : 3 ; // 0: AUTO, 3: LTE-ONLY
1453
+ if (nwScanMode != desiredNwScanMode) {
1454
+ CHECK_PARSER (parser_.execCommand (" AT+QCFG=\" nwscanmode\" ,%d,1" , desiredNwScanMode));
1455
+ }
1456
+ }
1449
1457
1450
- if (ncpId () == PLATFORM_NCP_QUECTEL_BG95_M5) {
1451
- auto respNwScanSeq = parser_.sendCommand (" AT+QCFG=\" nwscanseq\" " );
1452
- int nwScanSeq = -1 ;
1453
- r = CHECK_PARSER (respNwScanSeq.scanf (" +QCFG: \" nwscanseq\" ,%d" , &nwScanSeq));
1454
- CHECK_TRUE (r == 1 , SYSTEM_ERROR_UNKNOWN);
1455
- r = CHECK_PARSER (respNwScanSeq.readResult ());
1456
- CHECK_TRUE (r == AtResponse::OK, SYSTEM_ERROR_UNKNOWN);
1457
- if (nwScanSeq != 20103 ) { // i.e. 020103
1458
- CHECK_PARSER (parser_.execCommand (" AT+QCFG=\" nwscanseq\" ,020103,1" )); // LTE 02, then GSM 01, then NBIOT 03
1459
- }
1460
- }
1461
- #else
1462
- if (nwScanMode != 3 ) {
1463
- CHECK_PARSER (parser_.execCommand (" AT+QCFG=\" nwscanmode\" ,3,1" ));
1458
+ // nwscanseq: only setting RAT scan order for M404
1459
+ #if PLATFORM_ID == PLATFORM_MSOM
1460
+ if (ncpId () == PLATFORM_NCP_QUECTEL_BG95_M5) {
1461
+ auto respNwScanSeq = parser_.sendCommand (" AT+QCFG=\" nwscanseq\" " );
1462
+ int nwScanSeq = -1 ;
1463
+ r = CHECK_PARSER (respNwScanSeq.scanf (" +QCFG: \" nwscanseq\" ,%d" , &nwScanSeq));
1464
+ CHECK_TRUE (r == 1 , SYSTEM_ERROR_UNKNOWN);
1465
+ r = CHECK_PARSER (respNwScanSeq.readResult ());
1466
+ CHECK_TRUE (r == AtResponse::OK, SYSTEM_ERROR_UNKNOWN);
1467
+ if (nwScanSeq != 20103 ) { // i.e. 020103
1468
+ CHECK_PARSER (parser_.execCommand (" AT+QCFG=\" nwscanseq\" ,020103,1" )); // LTE 02, then GSM 01, then NBIOT 03
1464
1469
}
1465
- #endif
1466
1470
}
1471
+ #endif // PLATFORM_ID == PLATFORM_MSOM
1467
1472
1473
+ // iotopmode: configure network category to be searched
1474
+ // Set to use LTE Cat-M1 ONLY (exclude NBIOT) if not already set, take effect immediately
1475
+ if (isQuecCatM1Device ()) {
1468
1476
if (isQuecCatNBxDevice ()) {
1469
- // Configure Network Category to be searched
1470
- // Set to use LTE Cat-M1 ONLY (exclude NBIOT) if not already set, take effect immediately
1471
1477
auto respOpMode = parser_.sendCommand (" AT+QCFG=\" iotopmode\" " ) ;
1472
1478
1473
1479
int iotOpMode = -1 ;
@@ -1481,11 +1487,12 @@ int QuectelNcpClient::registerNet() {
1481
1487
}
1482
1488
}
1483
1489
}
1490
+
1484
1491
// Check GSM, GPRS, and LTE network registration status
1485
1492
CHECK_PARSER_OK (parser_.execCommand (" AT+CEREG?" ));
1486
- if (isQuecCat1Device () || ncpId () == PLATFORM_NCP_QUECTEL_BG95_M5) {
1487
- CHECK_PARSER_OK (parser_.execCommand (" AT+CREG?" ));
1493
+ if (isQuec2g3gEnabled ()) {
1488
1494
CHECK_PARSER_OK (parser_.execCommand (" AT+CGREG?" ));
1495
+ CHECK_PARSER_OK (parser_.execCommand (" AT+CREG?" ));
1489
1496
}
1490
1497
1491
1498
regStartTime_ = millis ();
@@ -1813,7 +1820,7 @@ int QuectelNcpClient::interveneRegistration() {
1813
1820
auto timeout = (registrationInterventions_ + 1 ) * REGISTRATION_INTERVENTION_TIMEOUT;
1814
1821
1815
1822
// Intervention to speed up registration or recover in case of failure
1816
- if (! isQuecCatM1Device ()) {
1823
+ if (isQuecCat1Device ()) {
1817
1824
if (eps_.sticky () && eps_.duration () >= timeout) {
1818
1825
if (eps_.status () == CellularRegistrationStatus::NOT_REGISTERING && csd_.status () == eps_.status ()) {
1819
1826
LOG (TRACE, " Sticky not registering state for %lu s, PLMN reselection" , eps_.duration () / 1000 );
@@ -1834,7 +1841,8 @@ int QuectelNcpClient::interveneRegistration() {
1834
1841
return 0 ;
1835
1842
}
1836
1843
}
1837
-
1844
+ }
1845
+ if (isQuec2g3gEnabled ()) {
1838
1846
if (csd_.sticky () && csd_.duration () >= timeout ) {
1839
1847
if (csd_.status () == CellularRegistrationStatus::DENIED && psd_.status () == csd_.status ()) {
1840
1848
LOG (TRACE, " Sticky CSD and PSD denied state for %lu s, RF reset" , csd_.duration () / 1000 );
@@ -1847,7 +1855,6 @@ int QuectelNcpClient::interveneRegistration() {
1847
1855
return 0 ;
1848
1856
}
1849
1857
}
1850
-
1851
1858
if (csd_.registered () && psd_.sticky () && psd_.duration () >= timeout) {
1852
1859
if (psd_.status () == CellularRegistrationStatus::NOT_REGISTERING && eps_.status () == psd_.status ()) {
1853
1860
LOG (TRACE, " Sticky not registering PSD state for %lu s, force GPRS attach" , psd_.duration () / 1000 );
@@ -1864,15 +1871,21 @@ int QuectelNcpClient::interveneRegistration() {
1864
1871
}
1865
1872
}
1866
1873
}
1867
- } else {
1874
+ }
1875
+ if (isQuecCatM1Device ()) {
1868
1876
if (eps_.sticky () && eps_.duration () >= timeout) {
1869
1877
if (eps_.status () == CellularRegistrationStatus::NOT_REGISTERING) {
1870
1878
LOG (TRACE, " Sticky not registering EPS state for %lu s, PLMN reselection" , eps_.duration () / 1000 );
1871
1879
eps_.reset ();
1872
1880
registrationInterventions_++;
1873
1881
CHECK_PARSER (parser_.execCommand (QUECTEL_COPS_TIMEOUT, " AT+COPS=0,2" ));
1874
- CHECK_PARSER (parser_.execCommand (" AT+QCFG=\" nwscanmode\" ,3,1" ));
1875
- CHECK_PARSER (parser_.execCommand (" AT+QCFG=\" iotopmode\" ,0,1" ));
1882
+ if (ncpId () == PLATFORM_NCP_QUECTEL_BG96 || ncpId () == PLATFORM_NCP_QUECTEL_BG95_M5) {
1883
+ int desiredNwScanMode = isQuec2g3gEnabled () ? 0 : 3 ; // 0: AUTO, 3: LTE-ONLY
1884
+ CHECK_PARSER (parser_.execCommand (" AT+QCFG=\" nwscanmode\" ,%d,1" , desiredNwScanMode));
1885
+ }
1886
+ if (isQuecCatNBxDevice ()) {
1887
+ CHECK_PARSER (parser_.execCommand (" AT+QCFG=\" iotopmode\" ,0,1" ));
1888
+ }
1876
1889
} else if (eps_.status () == CellularRegistrationStatus::DENIED) {
1877
1890
LOG (TRACE, " Sticky EPS denied state for %lu s, RF reset" , eps_.duration () / 1000 );
1878
1891
eps_.reset ();
@@ -1882,6 +1895,7 @@ int QuectelNcpClient::interveneRegistration() {
1882
1895
}
1883
1896
}
1884
1897
}
1898
+
1885
1899
return 0 ;
1886
1900
}
1887
1901
@@ -1916,9 +1930,9 @@ int QuectelNcpClient::processEventsImpl() {
1916
1930
1917
1931
// Check GSM, GPRS, and LTE network registration status
1918
1932
CHECK_PARSER_OK (parser_.execCommand (" AT+CEREG?" ));
1919
- if (isQuecCat1Device () || ncpId () == PLATFORM_NCP_QUECTEL_BG95_M5) {
1920
- CHECK_PARSER_OK (parser_.execCommand (" AT+CREG?" ));
1933
+ if (isQuec2g3gEnabled ()) {
1921
1934
CHECK_PARSER_OK (parser_.execCommand (" AT+CGREG?" ));
1935
+ CHECK_PARSER_OK (parser_.execCommand (" AT+CREG?" ));
1922
1936
}
1923
1937
1924
1938
// Check the signal seen by the module while trying to register
0 commit comments