Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 31:a673792bccd5, committed 2019-08-29
- Comitter:
- wajahat.abbas@u-blox.com
- Date:
- Thu Aug 29 12:49:10 2019 +0500
- Parent:
- 30:38230504a646
- Commit message:
- Set default profile in init
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 |
--- a/UbloxCellularBase.cpp Tue Aug 27 18:38:29 2019 +0500
+++ b/UbloxCellularBase.cpp Thu Aug 29 12:49:10 2019 +0500
@@ -501,6 +501,8 @@
#endif
#ifdef TARGET_UBLOX_C030_R41XM
_edrx_configured = false;
+ _first_run = false;
+ _default_mno_params = true;
#endif
}
@@ -514,7 +516,7 @@
// Initialise the portions of this class that are parameterised.
void UbloxCellularBase::baseClassInit(PinName tx, PinName rx,
- int baud, bool debug_on)
+ int baud, bool debug_on, bool default_mno_params)
{
// Only initialise ourselves if it's not already been done
if (_at == NULL) {
@@ -536,6 +538,7 @@
// Set up the AT parser
#ifdef TARGET_UBLOX_C030_R41XM
+ _default_mno_params = default_mno_params;
_at = new UbloxATCmdParser(_fh, OUTPUT_ENTER_KEY, AT_PARSER_BUFFER_SIZE,
_at_timeout, _debug_trace_on);
#else
@@ -816,29 +819,43 @@
if (set_functionality_mode(FUNC_AIRPLANE)) {
#endif
if (initialise_sim_card()) {
+#ifdef TARGET_UBLOX_C030_R41XM
int mno_profile;
+ if (_first_run == false) { //this is the first call for init()
+ _first_run = true;
+
+ if (get_mno_profile(&mno_profile)) {
+ tr_info("Current MNO profile is: %d", mno_profile);
+ }
+
+ if (_default_mno_params && (mno_profile != SW_DEFAULT)) {
+ tr_error("Selecting default MNO profile");
+ set_mno_profile(SW_DEFAULT);
+ reboot_modem(); //reboot and re-init the modem so new parameters can take effect
+ power_up();
+ set_functionality_mode(FUNC_AIRPLANE);
+ initialise_sim_card();
+ }
#ifdef TARGET_UBLOX_C030_R412M
- if (_psm_status == false) { //psm is not enabled by application yet so disable it at start-up
- set_power_saving_mode(0, 0);
+ else {
+ int status = 0, periodic_time = 0, active_time = 0;
+ if (get_power_saving_mode(&status, &periodic_time, &active_time)) {
+ if (status) { //PSM is already enabled either by a previous run or MNO profile
+ tr_info("PSM is already enabled, periodic_time %d, active_time %d", periodic_time, active_time);
+ _psm_status = true;
+ if ( !(set_psm_urcs(1)) ) { //enable PSM URCs
+ tr_error("Modem does not support PSM URCs, disabling PSM");
+ set_power_saving_mode(0, 0);
+ }
+ }
+ }
+ }
+#endif
}
-#endif
-#ifdef TARGET_UBLOX_C030_R41XM
if (_at->is_idle_mode_enabled() == false) {
set_idle_mode(false); //disable idle mode at start up
}
- if(_edrx_configured == false) {
- // A special form of the command can be given as +CEDRXS=3.
- // In this form, eDRX will be disabled and data for all parameters in the command +CEDRXS will be removed or,
- // if available, set to the manufacturer specific default values.
- set_receive_period(3,UbloxCellularBase::EDRXGSM_A_Gb_mode);
- set_receive_period(3,UbloxCellularBase::EDRXEUTRAN_WB_S1_mode);
- set_receive_period(3,UbloxCellularBase::EDRXEUTRAN_NB_S1_mode);
- }
- get_receive_period();
-
- if (get_mno_profile(&mno_profile))
- tr_info("Current MNO profile is: %d", mno_profile);
#endif
if (set_device_identity(&_dev_info.dev) && // Set up device identity
device_init(_dev_info.dev)) {// Initialise this device
@@ -1557,7 +1574,7 @@
LOCK();
//+UCPSMS:1,,,"01000011","01000011"
- if (_at->send("AT+UCPSMS?") && _at->recv("+UCPSMS:%d,,,\"%8c\",\"%8c\"\n", status, pt_encoded, at_encoded)) {
+ if (_at->send("AT+UCPSMS?") && _at->recv("+UCPSMS:%d,,,\"%8c\",\"%8c\"\nOK\n", status, pt_encoded, at_encoded)) {
if (*status == true) {
//PSM is enabled, decode the timer values, periodic TAU first
value = (pt_encoded[7]- '0');
@@ -1669,7 +1686,7 @@
if (periodic_time == 0 && active_time == 0) {
// disable PSM
if (_at->send("AT+CPSMS=0") && _at->recv("OK")) {
- if (_at->send("AT+UPSMR=0") && _at->recv("OK")) {//disable the URC
+ if (set_psm_urcs(0)) {//disable the URC
//de-register the callback
detach_cb_psm_going_in();
detach_cb_psm_coming_out();
@@ -1775,7 +1792,7 @@
at[8] = '\0';
if (_at->send("AT+CPSMS=1,,,\"%s\",\"%s\"", pt, at) && _at->recv("OK")) {
- if (_at->send("AT+UPSMR=1") && _at->recv("OK")) {//enable the PSM URC
+ if (set_psm_urcs(1)) {//enable the PSM URC
tr_info("PSM enabled successfully!");
_psm_status = true;
return_val = true;
@@ -1819,6 +1836,22 @@
UNLOCK();
}
+
+bool UbloxCellularBase::set_psm_urcs(bool enable)
+{
+
+ bool success = false;
+ LOCK();
+
+ MBED_ASSERT(_at != NULL);
+
+ if (_at->send("AT+UPSMR=%d", enable ? 1 : 0) && _at->recv("OK")) {
+ success = true;
+ }
+
+ UNLOCK();
+ return success;
+}
#endif
// End of File
--- a/UbloxCellularBase.h Tue Aug 27 18:38:29 2019 +0500
+++ b/UbloxCellularBase.h Thu Aug 29 12:49:10 2019 +0500
@@ -272,6 +272,8 @@
* Note: MNO profile should only be set in detached state and a reboot is required for settings to take effect
* Note 2: ref to UBX-17003787 B.5, setting MNO profile can change other parameters such as PSM, Band mask, URAT etc.
* Application must always set a profile first and if required, change parameters afterwards.
+ * Note 3: ref to UBX-17003787 B.5, some profiles have locked parameters and modem will return ERROR if you try to change those.
+ * It is suggested to switch to a profile e.g. STANDARD_EU (100) and then change the parameters as required.
* @param profile MNO profile to use
* @return true if operation was successful, false if there was an error
*/
@@ -657,7 +659,7 @@
void baseClassInit(PinName tx = MDMTXD,
PinName rx = MDMRXD,
int baud = MBED_CONF_UBLOX_CELL_BAUD_RATE,
- bool debug_on = false);
+ bool debug_on = false, bool default_mno_params = true);
/** Set the AT parser timeout.
*/
@@ -765,6 +767,7 @@
void CEREG_URC();
void UMWI_URC();
#ifdef TARGET_UBLOX_C030_R412M
+ bool set_psm_urcs(bool enable);
void UUPSMR_URC();
bool _psm_status;
void *_cb_param_psm_going_in;
@@ -775,6 +778,8 @@
#endif
#ifdef TARGET_UBLOX_C030_R41XM
bool _edrx_configured;
+ bool _first_run;
+ bool _default_mno_params;
#endif
};