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 34:73f2c02f14f3, committed 2019-10-07
- Comitter:
- wajahat.abbas@u-blox.com
- Date:
- Mon Oct 07 15:26:06 2019 +0500
- Parent:
- 33:32fc7c6e2f06
- Child:
- 35:5acdbb0ba583
- Commit message:
- Apply MNO profile in init() if defined in mbed-lib.json
Changed in this revision
--- a/UbloxCellularBase.cpp Mon Sep 23 17:07:23 2019 +0500
+++ b/UbloxCellularBase.cpp Mon Oct 07 15:26:06 2019 +0500
@@ -603,10 +603,6 @@
bool UbloxCellularBase::power_up()
{
bool success = false;
- int at_timeout;
- LOCK();
-
- at_timeout = _at_timeout; // Has to be inside LOCK()s
MBED_ASSERT(_at != NULL);
@@ -621,28 +617,25 @@
if ( (retry_count % 5) == 0) {
modem_power_up();
}
- wait_ms(500);
- // Modem tends to spit out noise during power up - don't confuse the parser
- _at->flush();
- at_set_timeout(1000);
- if (_at->send("AT")) {
- // C027 needs a delay here
- wait_ms(100);
- if (_at->recv("OK")) {
- success = true;
- }
- }
- at_set_timeout(at_timeout);
+ success = is_modem_ready();
}
- if (success) {
- // 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
- wait_ms(100);
- ((UARTSerial *)_fh)->set_baud(_baud);
- }
-
+ return success;
+}
+
+bool UbloxCellularBase::setup_modem()
+{
+ bool success = false;
+ LOCK();
+
+ MBED_ASSERT(_at != NULL);
+
+ // 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
+ wait_ms(100);
+ ((UARTSerial *)_fh)->set_baud(_baud);
+
// Turn off modem echoing and turn on verbose responses
success = _at->send("ATE0;+CMEE=2") && _at->recv("OK") &&
// The following commands are best sent separately
@@ -659,6 +652,43 @@
return success;
}
+bool UbloxCellularBase::is_modem_ready()
+{
+ bool success = false;
+ int at_timeout;
+ LOCK();
+
+ at_timeout = _at_timeout; // Has to be inside LOCK()s
+
+ MBED_ASSERT(_at != NULL);
+
+ _at->flush();
+ at_set_timeout(1000);
+ if (_at->send("AT")) {
+ // C027 needs a delay here
+ wait_ms(100);
+ if (_at->recv("OK")) {
+ success = true;
+ }
+ }
+ at_set_timeout(at_timeout);
+
+ UNLOCK();
+ return success;
+}
+
+bool UbloxCellularBase::initialize_modem()
+{
+ bool success = false;
+
+ if (power_up()) {
+ success = setup_modem();
+ } else {
+ tr_error("Preliminary modem setup failed.");
+ }
+ return success;
+}
+
// Power down modem via AT interface.
void UbloxCellularBase::power_down()
{
@@ -803,7 +833,7 @@
MBED_ASSERT(_at != NULL);
if (!_modem_initialised) {
- if (power_up()) {
+ if (initialize_modem()) {
tr_info("Modem Ready.");
if (pin != NULL) {
_pin = pin;
@@ -817,6 +847,15 @@
#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((mno_profile)MBED_CONF_UBLOX_CELL_DEFAULT_MNO_PROFILE) {
+ reboot_modem();
+ while(is_modem_ready() == false) {
+ wait_ms(1000);
+ }
+ setup_modem();
+ }
+#endif
if (mno_profile == SW_DEFAULT) {
tr_critical("!!CANNOT USE PROFILE 0(SW_DEFAULT). PLEASE SET AN APPROPRIATE MNO PROFILE!!");
_default_profile_is_set = true;
--- a/UbloxCellularBase.h Mon Sep 23 17:07:23 2019 +0500
+++ b/UbloxCellularBase.h Mon Oct 07 15:26:06 2019 +0500
@@ -259,15 +259,10 @@
} FunctionalityMode;
#ifdef TARGET_UBLOX_C030_R41XM
-
- #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 STANDARD_EU
- #endif
-
- /** Reads the current MNO profile from modem and sets it to user specified profile.
- * User can also specify profile in mbed_lib.json file and call set_mno_profile without any arguments.
+ /** 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().
+ * 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
* Note 2: ref to UBX-17003787 B.5, setting MNO profile can change other parameters such as PSM, Band mask, URAT etc.
@@ -277,7 +272,7 @@
* @param profile MNO profile to use
* @return true if operation was successful, false if there was an error
*/
- bool set_mno_profile(MNOProfile profile = DEFAULT_MNO_PROFILE);
+ bool set_mno_profile(MNOProfile profile);
/** Get current MNO profile.
*
@@ -698,6 +693,24 @@
*/
bool power_up();
+ /** Setup the modem baudrate, echo and flow control
+ *
+ * @return true if successful, otherwise false.
+ */
+ bool setup_modem();
+
+ /** Check if modem is accepting AT commands
+ *
+ * @return true if successful, otherwise false.
+ */
+ bool is_modem_ready();
+
+ /** Powers up the modem and set it up for application use.
+ *
+ * @return true if successful, otherwise false.
+ */
+ bool initialize_modem();
+
/** Power down the modem.
*/
void power_down();
--- a/mbed_lib.json Mon Sep 23 17:07:23 2019 +0500
+++ b/mbed_lib.json Mon Oct 07 15:26:06 2019 +0500
@@ -3,7 +3,6 @@
"config": {
"baud-rate": 115200,
"at-parser-buffer-size": 256,
- "at-parser-timeout": 8000,
- "default-mno-profile": 100
+ "at-parser-timeout": 8000
}
}