upsv

Branch:
power_down
Revision:
17:c6a4d5072589
Parent:
15:93b157a47b8d
Child:
19:15f31e074d67
--- a/UbloxCellularBase.cpp	Thu Jul 12 10:13:45 2018 +0500
+++ b/UbloxCellularBase.cpp	Thu Sep 13 16:35:07 2018 +0500
@@ -602,15 +602,20 @@
 
     MBED_ASSERT(_at != NULL);
 
-    // If we have been running, do a soft power-off first
-    if (_modem_initialised && (_at != NULL)) {
-        _at->send("AT+CPWROFF") && _at->recv("OK");
-    }
-
-    // Now do a hard power-off
+    // power-off modem
     modem_power_down();
     modem_deinit();
 
+    if (_modem_initialised && (_at != NULL)) {
+        int at_timeout = _at_timeout; // Save previous timeout
+    	_at->set_timeout(1000);
+    	// Check modem is powered off
+    	if(_at->send("AT") && _at->recv("OK")) {
+            _at->send("AT+CPWROFF") && _at->recv("OK");
+    	}
+    	_at->set_timeout(at_timeout);
+    }
+
     _dev_info.reg_status_csd = CSD_NOT_REGISTERED_NOT_SEARCHING;
     _dev_info.reg_status_psd = PSD_NOT_REGISTERED_NOT_SEARCHING;
     _dev_info.reg_status_eps = EPS_NOT_REGISTERED_NOT_SEARCHING;