ublox-cellular-base_R4_PR
Revision 33:64b96bdac04e, committed 2019-09-23
- Comitter:
- wajahat.abbas@u-blox.com
- Date:
- Mon Sep 23 14:29:32 2019 +0500
- Parent:
- 32:d961d0c06cdf
- Commit message:
- Default mno profile to 100, PSM is disabled for R410M
Changed in this revision
diff -r d961d0c06cdf -r 64b96bdac04e UbloxCellularBase.cpp --- a/UbloxCellularBase.cpp Thu Sep 05 15:46:11 2019 +0500 +++ b/UbloxCellularBase.cpp Mon Sep 23 14:29:32 2019 +0500 @@ -841,6 +841,8 @@ } else if (_psm_status == ENABLED && !_func_psm_going_in){ 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 #endif if (_at->is_idle_mode_enabled() == false) { set_idle_mode(false); //disable idle mode at start up @@ -1303,7 +1305,7 @@ bool return_val = false; int current_profile; MNOProfile arr[MAX_NUM_PROFILES] = { SW_DEFAULT, SIM_ICCID, ATT, TMO, VODAFONE, DT, STANDARD_EU -#ifdef TARGET_UBLOX_C030_R410M +#ifdef TARGET_UBLOX_C030_R410M , VERIZON, TELSTRA, CT, SPRINT, TELUS #endif }; @@ -1591,8 +1593,22 @@ return status; } + +bool UbloxCellularBase::disable_psm() +{ + bool return_value = false; + + LOCK(); + if (_at->send("AT+CPSMS=0") && _at->recv("OK")) { + return_value = true; + } + UNLOCK(); + + return return_value; +} #endif //TARGET_UBLOX_C030_R41XM + #ifdef TARGET_UBLOX_C030_R412M bool UbloxCellularBase::get_power_saving_mode(int *status, int *periodic_time, int *active_time) { @@ -1715,133 +1731,129 @@ int at_timeout = _at_timeout; at_set_timeout(10000); //AT+CPSMS has response time of < 10s - //check if modem supports PSM URCs - if (_at->send("AT+UPSMR?") && _at->recv("OK")) { - if (periodic_time == 0 && active_time == 0) { - // disable PSM - if (_at->send("AT+CPSMS=0") && _at->recv("OK")) { - if (set_psm_urcs(false)) {//disable the URC - //de-register the callback - detach_cb_psm_going_in(); - detach_cb_psm_coming_out(); - _psm_status = DISABLED; - return_val = true; - } - } - } else { //PSM string encoding code borrowed from AT_CellularPower.cpp - /** - Table 10.5.163a/3GPP TS 24.008: GPRS Timer 3 information element + 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 + /** + Table 10.5.163a/3GPP TS 24.008: GPRS Timer 3 information element - Bits 5 to 1 represent the binary coded timer value. + Bits 5 to 1 represent the binary coded timer value. - Bits 6 to 8 defines the timer value unit for the GPRS timer as follows: - 8 7 6 - 0 0 0 value is incremented in multiples of 10 minutes - 0 0 1 value is incremented in multiples of 1 hour - 0 1 0 value is incremented in multiples of 10 hours - 0 1 1 value is incremented in multiples of 2 seconds - 1 0 0 value is incremented in multiples of 30 seconds - 1 0 1 value is incremented in multiples of 1 minute - 1 1 0 value is incremented in multiples of 320 hours (NOTE 1) - 1 1 1 value indicates that the timer is deactivated (NOTE 2). - */ - char pt[8+1];// timer value encoded as 3GPP IE - const int ie_value_max = 0x1f; - uint32_t periodic_timer = 0; - if (periodic_time <= 2*ie_value_max) { // multiples of 2 seconds - periodic_timer = periodic_time/2; - strcpy(pt, "01100000"); + Bits 6 to 8 defines the timer value unit for the GPRS timer as follows: + 8 7 6 + 0 0 0 value is incremented in multiples of 10 minutes + 0 0 1 value is incremented in multiples of 1 hour + 0 1 0 value is incremented in multiples of 10 hours + 0 1 1 value is incremented in multiples of 2 seconds + 1 0 0 value is incremented in multiples of 30 seconds + 1 0 1 value is incremented in multiples of 1 minute + 1 1 0 value is incremented in multiples of 320 hours (NOTE 1) + 1 1 1 value indicates that the timer is deactivated (NOTE 2). + */ + char pt[8+1];// timer value encoded as 3GPP IE + const int ie_value_max = 0x1f; + uint32_t periodic_timer = 0; + if (periodic_time <= 2*ie_value_max) { // multiples of 2 seconds + periodic_timer = periodic_time/2; + strcpy(pt, "01100000"); + } else { + if (periodic_time <= 30*ie_value_max) { // multiples of 30 seconds + periodic_timer = periodic_time/30; + strcpy(pt, "10000000"); } else { - if (periodic_time <= 30*ie_value_max) { // multiples of 30 seconds - periodic_timer = periodic_time/30; - strcpy(pt, "10000000"); + if (periodic_time <= 60*ie_value_max) { // multiples of 1 minute + periodic_timer = periodic_time/60; + strcpy(pt, "10100000"); } else { - if (periodic_time <= 60*ie_value_max) { // multiples of 1 minute - periodic_timer = periodic_time/60; - strcpy(pt, "10100000"); + if (periodic_time <= 10*60*ie_value_max) { // multiples of 10 minutes + periodic_timer = periodic_time/(10*60); + strcpy(pt, "00000000"); } else { - if (periodic_time <= 10*60*ie_value_max) { // multiples of 10 minutes - periodic_timer = periodic_time/(10*60); - strcpy(pt, "00000000"); + if (periodic_time <= 60*60*ie_value_max) { // multiples of 1 hour + periodic_timer = periodic_time/(60*60); + strcpy(pt, "00100000"); } else { - if (periodic_time <= 60*60*ie_value_max) { // multiples of 1 hour - periodic_timer = periodic_time/(60*60); - strcpy(pt, "00100000"); - } else { - if (periodic_time <= 10*60*60*ie_value_max) { // multiples of 10 hours - periodic_timer = periodic_time/(10*60*60); - strcpy(pt, "01000000"); - } else { // multiples of 320 hours - int t = periodic_time / (320*60*60); - if (t > ie_value_max) { - t = ie_value_max; - } - periodic_timer = t; - strcpy(pt, "11000000"); + if (periodic_time <= 10*60*60*ie_value_max) { // multiples of 10 hours + periodic_timer = periodic_time/(10*60*60); + strcpy(pt, "01000000"); + } else { // multiples of 320 hours + int t = periodic_time / (320*60*60); + if (t > ie_value_max) { + t = ie_value_max; } + periodic_timer = t; + strcpy(pt, "11000000"); } } } } } + } - uint_to_binary_str(periodic_timer, &pt[3], sizeof(pt)-3, 5); - pt[8] = '\0'; + uint_to_binary_str(periodic_timer, &pt[3], sizeof(pt)-3, 5); + pt[8] = '\0'; + + /** + Table 10.5.172/3GPP TS 24.008: GPRS Timer information element - /** - Table 10.5.172/3GPP TS 24.008: GPRS Timer information element + Bits 5 to 1 represent the binary coded timer value. + + Bits 6 to 8 defines the timer value unit for the GPRS timer as follows: - Bits 5 to 1 represent the binary coded timer value. - - Bits 6 to 8 defines the timer value unit for the GPRS timer as follows: + 8 7 6 + 0 0 0 value is incremented in multiples of 2 seconds + 0 0 1 value is incremented in multiples of 1 minute + 0 1 0 value is incremented in multiples of decihours + 1 1 1 value indicates that the timer is deactivated. - 8 7 6 - 0 0 0 value is incremented in multiples of 2 seconds - 0 0 1 value is incremented in multiples of 1 minute - 0 1 0 value is incremented in multiples of decihours - 1 1 1 value indicates that the timer is deactivated. + Other values shall be interpreted as multiples of 1 minute in this version of the protocol. + */ + char at[8+1]; + uint32_t active_timer; // timer value encoded as 3GPP IE + if (active_time <= 2*ie_value_max) { // multiples of 2 seconds + active_timer = active_time/2; + strcpy(at, "00000000"); + } else { + if (active_time <= 60*ie_value_max) { // multiples of 1 minute + active_timer = (1<<5) | (active_time/60); + strcpy(at, "00100000"); + } else { // multiples of decihours + int t = active_time / (6*60); + if (t > ie_value_max) { + t = ie_value_max; + } + active_timer = t; + strcpy(at, "01000000"); + } + } - Other values shall be interpreted as multiples of 1 minute in this version of the protocol. - */ - char at[8+1]; - uint32_t active_timer; // timer value encoded as 3GPP IE - if (active_time <= 2*ie_value_max) { // multiples of 2 seconds - active_timer = active_time/2; - strcpy(at, "00000000"); + uint_to_binary_str(active_timer, &at[3], sizeof(at)-3, 5); + at[8] = '\0'; + + if (_at->send("AT+CPSMS=1,,,\"%s\",\"%s\"", pt, at) && _at->recv("OK")) { + if (set_psm_urcs(true)) {//enable the PSM URC + tr_info("PSM enabled successfully!"); + _psm_status = ENABLED; + return_val = true; } else { - if (active_time <= 60*ie_value_max) { // multiples of 1 minute - active_timer = (1<<5) | (active_time/60); - strcpy(at, "00100000"); - } else { // multiples of decihours - int t = active_time / (6*60); - if (t > ie_value_max) { - t = ie_value_max; - } - active_timer = t; - strcpy(at, "01000000"); - } - } - - uint_to_binary_str(active_timer, &at[3], sizeof(at)-3, 5); - at[8] = '\0'; - - if (_at->send("AT+CPSMS=1,,,\"%s\",\"%s\"", pt, at) && _at->recv("OK")) { - if (set_psm_urcs(true)) {//enable the PSM URC - tr_info("PSM enabled successfully!"); - _psm_status = ENABLED; - return_val = true; - } else { - tr_error("PSM URCs not supported"); - return_val = false; - } - } else { - tr_error("+CPSMS command failed"); + tr_error("Error enabling PSM URCs, PSM not enabled"); + _at->send("AT+CPSMS=0"); + _at->recv("OK"); return_val = false; } + } else { + tr_error("+CPSMS command failed"); + return_val = false; } } else { tr_error("PSM URCs not supported by this version of modem"); } + at_set_timeout(at_timeout); UNLOCK(); return return_val;
diff -r d961d0c06cdf -r 64b96bdac04e UbloxCellularBase.h --- a/UbloxCellularBase.h Thu Sep 05 15:46:11 2019 +0500 +++ b/UbloxCellularBase.h Mon Sep 23 14:29:32 2019 +0500 @@ -263,7 +263,7 @@ #if MBED_CONF_UBLOX_CELL_DEFAULT_MNO_PROFILE #define DEFAULT_MNO_PROFILE (MNOProfile)MBED_CONF_UBLOX_CELL_DEFAULT_MNO_PROFILE #else - #define DEFAULT_MNO_PROFILE SW_DEFAULT + #define DEFAULT_MNO_PROFILE STANDARD_EU #endif /** Reads the current MNO profile from modem and sets it to user specified profile. @@ -494,6 +494,12 @@ * @return True if successful, otherwise false. */ bool get_band_bitmask(uint64_t *m1_bitmask, uint64_t *nb1_bitmask); + + /** disables the PSM + * + * @return True if successful, otherwise false. + */ + bool disable_psm(); #endif protected:
diff -r d961d0c06cdf -r 64b96bdac04e mbed_lib.json --- a/mbed_lib.json Thu Sep 05 15:46:11 2019 +0500 +++ b/mbed_lib.json Mon Sep 23 14:29:32 2019 +0500 @@ -4,6 +4,6 @@ "baud-rate": 115200, "at-parser-buffer-size": 256, "at-parser-timeout": 8000, - "default-mno-profile": 0 + "default-mno-profile": 100 } }