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.
Dependents: example-ublox-cellular-interface example-ublox-cellular-interface_r410M example-ublox-mbed-client example-ublox-cellular-interface ... more
Diff: UbloxATCellularInterface.cpp
- Revision:
- 34:ca02f8448085
- Parent:
- 33:5d5ce25405d4
- Child:
- 36:9d48ec522cb4
--- a/UbloxATCellularInterface.cpp Tue Aug 06 12:14:22 2019 +0500
+++ b/UbloxATCellularInterface.cpp Thu Aug 08 16:47:36 2019 +0500
@@ -431,6 +431,26 @@
UNLOCK();
return status;
}
+
+bool UbloxATCellularInterface::is_context_active()
+{
+ bool status = false;
+ int at_timeout;
+ int active = 0;
+ LOCK();
+
+ at_timeout = _at_timeout; // Has to be inside LOCK()s
+ at_set_timeout(150000);
+ if (_at->send("AT+CGACT?") && _at->recv("+CGACT: %*d,%d\n", &active)) {
+ if (active == 1) {
+ status = true;
+ }
+ }
+ at_set_timeout(at_timeout);
+
+ UNLOCK();
+ return status;
+}
#endif
// Connect the on board IP stack of the modem.
@@ -1214,11 +1234,14 @@
if (nwk_registration()) {
registered = true;
#ifdef TARGET_UBLOX_C030_R41XM
- if(is_registered_psd() || is_registered_eps()) {
+ if (is_context_active()) {
nsapi_error = NSAPI_ERROR_OK;
- }
- else if (activate_context()) {
- nsapi_error = NSAPI_ERROR_OK;
+ tr_info("Context is already active\r\n");
+ } else {
+ tr_info("Context is not active, activating it.\r\n");
+ if (activate_context()) {
+ nsapi_error = NSAPI_ERROR_OK;
+ }
}
#endif
}