Base class for the ublox-xxx-cellular-xxx classes. Cannot be used standalone, only inherited by classes that do properly useful stuff. Or, to put it another way, if you are using any of the ublox-xxx-cellular-xxx classes, you will need this class also.
Dependents: example-ublox-cellular-interface example-ublox-cellular-driver-gen HelloMQTT example-ublox-cellular-interface_r410M ... more
Diff: UbloxCellularBase.cpp
- Revision:
- 36:2f8ef6ac16dc
- Parent:
- 34:d239824bfb8f
- Child:
- 37:a2466fcd63c3
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