Fork for new features

Files at this revision

API Documentation at this revision

Comitter:
wajahat.abbas@u-blox.com
Date:
Mon Mar 25 14:50:56 2019 +0500
Parent:
21:98aea8f49cd8
Commit message:
set_plmn() implementation

Changed in this revision

UbloxCellularBase.cpp Show annotated file Show diff for this revision Revisions of this file
UbloxCellularBase.h Show annotated file Show diff for this revision Revisions of this file
diff -r 98aea8f49cd8 -r b69465e9f076 UbloxCellularBase.cpp
--- a/UbloxCellularBase.cpp	Fri Mar 22 15:47:18 2019 +0500
+++ b/UbloxCellularBase.cpp	Mon Mar 25 14:50:56 2019 +0500
@@ -443,6 +443,7 @@
     _modem_initialised = false;
     _sim_pin_check_enabled = false;
     _debug_trace_on = false;
+    memset(_plmn, 0, sizeof(_plmn));
 
     _dev_info.dev = DEV_TYPE_NONE;
     _dev_info.reg_status_csd = CSD_NOT_REGISTERED_NOT_SEARCHING;
@@ -801,16 +802,16 @@
             }
 
             if (atSuccess) {
-                // See if we are already in automatic mode
-                if (_at->send("AT+COPS?") && _at->recv("+COPS: %d", &status) &&
-                    _at->recv("OK")) {
-                    // If not, set it
-                    if (status != 0) {
-                        // Don't check return code here as there's not much
-                        // we can do if this fails.
-                        _at->send("AT+COPS=0") && _at->recv("OK");
-                    }
+                // See if a PLMN is set by user
+                if (_plmn[0] != 0) {
+                    tr_debug("Manual network registration to %s, please wait upto 3 minutes", _plmn);
+                    at_set_timeout(3*60*1000);
+                    _at->send("AT+COPS=1,2,\"%s\"", _plmn) && _at->recv("OK");
+                } else {
+                    tr_debug("Automatic network registration");
+                    _at->send("AT+COPS=0") && _at->recv("OK");
                 }
+                at_set_timeout(at_timeout);
 
                 // Query the registration status directly as well,
                 // just in case
diff -r 98aea8f49cd8 -r b69465e9f076 UbloxCellularBase.h
--- a/UbloxCellularBase.h	Fri Mar 22 15:47:18 2019 +0500
+++ b/UbloxCellularBase.h	Mon Mar 25 14:50:56 2019 +0500
@@ -21,6 +21,7 @@
 #include "ATCmdParser.h"
 #include "FileHandle.h"
 
+#define PLMN_SIZE 24
 /**********************************************************************
  * CLASSES
  **********************************************************************/
@@ -492,6 +493,9 @@
      */
     bool initialise_sim_card();
 
+    /** PLMN for manual registration
+     */
+    char _plmn[PLMN_SIZE + 1];
 private:
 
     void set_nwk_reg_status_csd(int status);