ublox-cellular-base_psm
Revision 38:5ac7bc28d83d, committed 2020-02-04
- Comitter:
- mudassar0121
- Date:
- Tue Feb 04 16:34:01 2020 +0500
- Parent:
- 37:a2466fcd63c3
- Commit message:
- changes for SARA-R5
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 a2466fcd63c3 -r 5ac7bc28d83d UbloxCellularBase.cpp --- a/UbloxCellularBase.cpp Mon Jan 06 14:25:07 2020 +0500 +++ b/UbloxCellularBase.cpp Tue Feb 04 16:34:01 2020 +0500 @@ -610,7 +610,7 @@ tr_info("Powering up modem..."); modem_init(); /* Give modem a little time to settle down */ - ThisThread::sleep_for(250); + wait_ms(250); for (int retry_count = 0; !success && (retry_count < 20); retry_count++) { //In case of SARA-R4, modem takes a while to turn on, constantly toggling the power pin every ~2 secs causes the modem to never power up. @@ -633,7 +633,7 @@ // Set the final baud rate if (_at->send("AT+IPR=%d", _baud) && _at->recv("OK")) { // Need to wait for things to be sorted out on the modem side - ThisThread::sleep_for(100); + wait_ms(100); ((UARTSerial *)_fh)->set_baud(_baud); // Turn off modem echoing and turn on verbose responses @@ -666,7 +666,7 @@ at_set_timeout(1000); if (_at->send("AT")) { // C027 needs a delay here - ThisThread::sleep_for(100); + wait_ms(100); if (_at->recv("OK")) { success = true; } @@ -737,7 +737,7 @@ *dev = DEV_LISA_U2; else if (strstr(buf, "SARA-U2")) *dev = DEV_SARA_U2; - else if (strstr(buf, "SARA-R4")) + else if (strstr(buf, "SARA-R4") || strstr(buf, "SARA-R5")) *dev = DEV_SARA_R4; else if (strstr(buf, "LEON-G2")) *dev = DEV_LEON_G2; @@ -809,7 +809,7 @@ } /* wait for a second before retry */ - ThisThread::sleep_for(1000); + wait_ms(1000); } if (done) { @@ -847,21 +847,20 @@ #ifdef TARGET_UBLOX_C030_R41XM int mno_profile; if (get_mno_profile(&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)) { +#ifdef MBED_CONF_UBLOX_CELL_DEFAULT_MNO_PROFILE + if (set_mno_profile((MNOProfile)MBED_CONF_UBLOX_CELL_DEFAULT_MNO_PROFILE)) { reboot_modem(); while(is_modem_ready() == false) { - ThisThread::sleep_for(1000); + wait_ms(1000); } setup_modem(); - mno_profile = MBED_CONF_APP_DEFAULT_MNO_PROFILE; } #endif - if (mno_profile == SW_DEFAULT) { + /*if (mno_profile == SW_DEFAULT) { tr_critical("!!CANNOT USE PROFILE 0(SW_DEFAULT). PLEASE SET AN APPROPRIATE MNO PROFILE!!"); _default_profile_is_set = true; return false; - } + }*/ } #ifdef TARGET_UBLOX_C030_R412M int status = 0, periodic_time = 0, active_time = 0; @@ -872,7 +871,7 @@ _psm_status = ENABLED; if ( !(set_psm_urcs(true)) ) { //enable PSM URCs tr_error("Modem does not support PSM URCs, disabling PSM"); - disable_power_saving_mode(); + set_power_saving_mode(0, 0); } else if (!_func_psm_going_in){ tr_critical("!!PSM IS ENABLED, CALLBACK NOT ATTACHED. PLEASE REGISTER ONE!!"); } @@ -882,12 +881,10 @@ tr_critical("!!PSM IS ENABLED, CALLBACK NOT ATTACHED. PLEASE REGISTER ONE!!"); } #elif TARGET_UBLOX_C030_R410M - disable_power_saving_mode(); //PSM is currently not supported by driver for R410M due to lack of URCs + disable_psm(); //PSM is currently not supported by driver for R410M due to lack of URCs #endif - 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); + if (_at->is_idle_mode_enabled() == false) { + set_idle_mode(false); //disable idle mode at start up } #endif if (set_device_identity(&_dev_info.dev) && // Set up device identity @@ -898,7 +895,7 @@ // take a while to be retrieved, especially if a SIM PIN // was set) for (x = 0; (x < 3) && !get_imsi(); x++) { - ThisThread::sleep_for(1000); + wait_ms(1000); } if (x < 3) { // If we got the IMSI, can get the others @@ -1294,7 +1291,7 @@ //application should call init() or connect() in order to initialize the modem bool UbloxCellularBase::reboot_modem() { - return (set_functionality_mode(FUNC_RESET)); + return (set_functionality_mode(FUNC_RESET_WITH_SIM)); } bool UbloxCellularBase::set_functionality_mode(FunctionalityMode mode) @@ -1636,17 +1633,12 @@ return status; } -bool UbloxCellularBase::disable_power_saving_mode() +bool UbloxCellularBase::disable_psm() { 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(); @@ -1720,7 +1712,7 @@ break; default: - value = -1; + value = 0; break; } *periodic_time = value; @@ -1753,7 +1745,7 @@ break; default: - value = -1; + value = 0; break; } *active_time = value; @@ -1769,8 +1761,7 @@ bool UbloxCellularBase::set_power_saving_mode(int periodic_time, int active_time) { - if (_at->is_idle_mode_enabled() == true) { - tr_error("Please disable idle mode(+UPSV) first"); + if (_at->is_idle_mode_enabled() == true && periodic_time != 0 && active_time != 0 ) { return false; } bool return_val = false; @@ -1779,7 +1770,14 @@ int at_timeout = _at_timeout; at_set_timeout(10000); //AT+CPSMS has response time of < 10s - if (_at->send("AT+UPSMR?") && _at->recv("OK")) { //PSM string encoding code borrowed from AT_CellularPower.cpp + 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 (1){//_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 @@ -1927,8 +1925,8 @@ bool UbloxCellularBase::set_psm_urcs(bool enable) { - bool success = false; - LOCK(); + bool success = true; + /*LOCK(); MBED_ASSERT(_at != NULL); @@ -1936,7 +1934,7 @@ success = true; } - UNLOCK(); + UNLOCK();*/ return success; } #endif
diff -r a2466fcd63c3 -r 5ac7bc28d83d UbloxCellularBase.h --- a/UbloxCellularBase.h Mon Jan 06 14:25:07 2020 +0500 +++ b/UbloxCellularBase.h Tue Feb 04 16:34:01 2020 +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_app.json ("default-mno-profile": 100) and in that case profile will be applied in init(). + * User can also specify profile in mbed_lib.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_power_saving_mode(); + bool disable_psm(); #endif protected: @@ -794,8 +794,14 @@ 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; @@ -804,12 +810,6 @@ #endif #ifdef TARGET_UBLOX_C030_R41XM bool _default_profile_is_set; - typedef enum { - DISABLED = 0, - ENABLED = 1, - UNKNOWN = 2 - } PSMStatus; - PSMStatus _psm_status; #endif };