ublox-cellular-base_mno_pr

Files at this revision

API Documentation at this revision

Comitter:
wajahat.abbas@u-blox.com
Date:
Fri Nov 08 12:32:37 2019 +0500
Parent:
38:24f29bf0d810
Commit message:
PSM timers value zero is valid

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 24f29bf0d810 -r 2f8ef6ac16dc UbloxCellularBase.cpp
--- a/UbloxCellularBase.cpp	Tue Nov 05 05:52:00 2019 +0000
+++ b/UbloxCellularBase.cpp	Fri Nov 08 12:32:37 2019 +0500
@@ -847,13 +847,14 @@
 #ifdef TARGET_UBLOX_C030_R41XM
                     int mno_profile;
                     if (get_mno_profile(&mno_profile)) {
-#ifdef MBED_CONF_UBLOX_CELL_DEFAULT_MNO_PROFILE
-                        if (set_mno_profile((MNOProfile)MBED_CONF_UBLOX_CELL_DEFAULT_MNO_PROFILE)) {
+#ifdef MBED_CONF_APP_DEFAULT_MNO_PROFILE
+                        if (mno_profile != MBED_CONF_APP_DEFAULT_MNO_PROFILE && set_mno_profile((MNOProfile)MBED_CONF_APP_DEFAULT_MNO_PROFILE)) {
                             reboot_modem();
                             while(is_modem_ready() == false) {
                                 wait_ms(1000);
                             }
                             setup_modem();
+                            mno_profile = MBED_CONF_APP_DEFAULT_MNO_PROFILE;
                         }
 #endif
                         if (mno_profile == SW_DEFAULT) {
@@ -871,7 +872,7 @@
                                 _psm_status = ENABLED;
                                 if ( !(set_psm_urcs(true)) ) { //enable PSM URCs
                                     tr_error("Modem does not support PSM URCs, disabling PSM");
-                                    set_power_saving_mode(0, 0);
+                                    disable_power_saving_mode();
                                 } else if (!_func_psm_going_in){
                                     tr_critical("!!PSM IS ENABLED, CALLBACK NOT ATTACHED. PLEASE REGISTER ONE!!");
                                 }
@@ -881,10 +882,12 @@
                         tr_critical("!!PSM IS ENABLED, CALLBACK NOT ATTACHED. PLEASE REGISTER ONE!!");
                     }
 #elif TARGET_UBLOX_C030_R410M
-                    disable_psm(); //PSM is currently not supported by driver for R410M due to lack of URCs
+                    disable_power_saving_mode(); //PSM is currently not supported by driver for R410M due to lack of URCs
 #endif
-                    if (_at->is_idle_mode_enabled() == false) {
-                        set_idle_mode(false); //disable idle mode at start up
+                    if (_at->is_idle_mode_enabled() == false || _psm_status == ENABLED) {
+                        //application has not yet enabled idle mode so disable it
+                        //PSM got enabled by MNO, disable idle mode.
+                        set_idle_mode(false);
                     }
 #endif
                     if (set_device_identity(&_dev_info.dev) && // Set up device identity
@@ -1633,12 +1636,17 @@
     return status;
 }
 
-bool UbloxCellularBase::disable_psm()
+bool UbloxCellularBase::disable_power_saving_mode()
 {
     bool return_value = false;
 
     LOCK();
     if (_at->send("AT+CPSMS=0") && _at->recv("OK")) {
+#ifdef TARGET_UBLOX_C030_R412M
+        _at->send("AT+UPSMR=0");
+        _at->recv("OK");
+#endif
+        _psm_status = DISABLED;
         return_value = true;
     }
     UNLOCK();
@@ -1712,7 +1720,7 @@
                 break;
 
                 default:
-                    value = 0;
+                    value = -1;
                 break;
             }
             *periodic_time = value;
@@ -1745,7 +1753,7 @@
                 break;
 
                 default:
-                    value = 0;
+                    value = -1;
                 break;
             }
             *active_time = value;
@@ -1761,7 +1769,8 @@
 bool UbloxCellularBase::set_power_saving_mode(int periodic_time, int active_time)
 {
 
-    if (_at->is_idle_mode_enabled() == true && periodic_time != 0 && active_time != 0 ) {
+    if (_at->is_idle_mode_enabled() == true) {
+        tr_error("Please disable idle mode(+UPSV) first");
         return false;
     }
     bool return_val = false;
@@ -1770,14 +1779,7 @@
     int at_timeout = _at_timeout;
     at_set_timeout(10000); //AT+CPSMS has response time of < 10s
 
-    if (periodic_time == 0 && active_time == 0) {
-        // disable PSM
-        if (_at->send("AT+CPSMS=0") && _at->recv("OK")) {
-            set_psm_urcs(false); //disable the URC
-            _psm_status = DISABLED;
-            return_val = true;
-        }
-    } else if (_at->send("AT+UPSMR?") && _at->recv("OK")) { //PSM string encoding code borrowed from AT_CellularPower.cpp
+    if (_at->send("AT+UPSMR?") && _at->recv("OK")) { //PSM string encoding code borrowed from AT_CellularPower.cpp
         /**
             Table 10.5.163a/3GPP TS 24.008: GPRS Timer 3 information element
 
diff -r 24f29bf0d810 -r 2f8ef6ac16dc UbloxCellularBase.h
--- a/UbloxCellularBase.h	Tue Nov 05 05:52:00 2019 +0000
+++ b/UbloxCellularBase.h	Fri Nov 08 12:32:37 2019 +0500
@@ -261,7 +261,7 @@
 #ifdef TARGET_UBLOX_C030_R41XM
     /** Set MNO profile. Profile will be applied on next boot.
      *
-     * User can also specify profile in mbed_lib.json ("default-mno-profile": 100) and in that case profile will be applied in init().
+     * User can also specify profile in mbed_app.json ("default-mno-profile": 100) and in that case profile will be applied in init().
      * Modem will also be rebooted so that profile parameters can be applied.
      *
      * Note: MNO profile should only be set in detached state and a reboot is required for settings to take effect
@@ -494,7 +494,7 @@
      *
      *  @return           True if successful, otherwise false.
      */
-    bool disable_psm();
+    bool disable_power_saving_mode();
 #endif
 
 protected:
@@ -794,14 +794,8 @@
     void CEREG_URC();
     void UMWI_URC();
 #ifdef TARGET_UBLOX_C030_R412M
-    typedef enum {
-       DISABLED = 0,
-       ENABLED = 1,
-       UNKNOWN = 2
-    } PSMStatus;
     bool set_psm_urcs(bool enable);
     void UUPSMR_URC();
-    PSMStatus _psm_status;
     void *_cb_param_psm_going_in;
     Callback<void(void*)>    _func_psm_going_in;  /**< Callback. */
     void *_cb_param_psm_coming_out;
@@ -810,6 +804,12 @@
 #endif
 #ifdef TARGET_UBLOX_C030_R41XM
     bool _default_profile_is_set;
+    typedef enum {
+       DISABLED = 0,
+       ENABLED = 1,
+       UNKNOWN = 2
+    } PSMStatus;
+    PSMStatus _psm_status;
 #endif
 };