Assert updated with the returned status code instead of URL

Dependencies:   ublox-at-cellular-interface

Revision:
11:3631f62bb359
Parent:
10:3b24bc50cc06
Child:
15:6f0a1ecc8cec
--- a/UbloxATCellularInterfaceExt.cpp	Tue Jun 13 10:46:08 2017 +0100
+++ b/UbloxATCellularInterfaceExt.cpp	Fri Jun 16 00:55:19 2017 +0100
@@ -705,6 +705,8 @@
                     // Received unsolicited: starting its analysis
                     _httpProfiles[httpProfile].pending = false;
                     if (_httpProfiles[httpProfile].result == 1) {
+                        // Leave a short delay to make sure the file has been written
+                        wait_ms(100);
                         // HTTP command successfully executed
                         if (readFile(rspFile, buf, len) >= 0) {
                             success = true;
@@ -760,18 +762,18 @@
 }
 
 // Reset the FTP configuration back to defaults.
-bool UbloxATCellularInterfaceExt::ftpResetPar()
+// Note: not all modrmd support all parameters,
+// hence the void return code.
+void UbloxATCellularInterfaceExt::ftpResetPar()
 {
-    bool success = true;
     LOCK();
-
     debug_if(_debug_trace_on, "ftpResetPar()\n");
-    for (int x = 0; success && (x < NUM_FTP_OP_CODES); x++) {
-        success = _at->send("AT+UFTP=%d", x) && _at->recv("OK");
+    for (int x = 0; x < NUM_FTP_OP_CODES; x++) {
+        if (_at->send("AT+UFTP=%d", x)) {
+            _at->recv("OK");
+        }
     }
-
     UNLOCK();
-    return success;
 }
 
 // Set FTP parameters.
@@ -813,8 +815,8 @@
 UbloxATCellularInterfaceExt::Error * UbloxATCellularInterfaceExt::ftpCommand(FtpCmd ftpCmd,
                                                                              const char* file1,
                                                                              const char* file2,
-                                                                             int offset,
-                                                                             char* buf, int len)
+                                                                             char* buf, int len,
+                                                                             int offset)
 {
     bool atSuccess = false;
     bool success = false;
@@ -849,6 +851,15 @@
             atSuccess = _at->send("AT+UFTPC=%d,\"%s\",\"%s\",%d",
                                   ftpCmd, file1, file2, offset) &&
                         _at->recv("OK");
+            
+            // Not all modules support continuing a GET/PUT (e.g.
+            // Sara-G350 00S-00 doesn't), so if we receive an error,
+            // try again without it
+            if (!atSuccess) {
+                atSuccess = _at->send("AT+UFTPC=%d,\"%s\",\"%s\"",
+                                      ftpCmd, file1, file2) &&
+                            _at->recv("OK");
+            }
             break;
         case FTP_FILE_INFO:
         case FTP_LS:
@@ -991,13 +1002,15 @@
             _loc[i].validData = false;
         }
 
-        // Switch on the URC
-        if (_at->send("AT+ULOCIND=1") && _at->recv("OK")) {
-            // Switch on Cell Locate
-            success = _at->send("AT+ULOC=2,%d,%d,%d,%d,%d", sensor, type, timeout, accuracy, hypothesis) &&
-                      _at->recv("OK");
-            // Answers are picked up by the URC
+        // Switch on the URC but don't error on it as some
+        // modules (e.g. Sara-G350) don't support it
+        if (_at->send("AT+ULOCIND=1")) {
+            _at->recv("OK");
         }
+        // Switch on Cell Locate
+        success = _at->send("AT+ULOC=2,%d,%d,%d,%d,%d", sensor, type, timeout, accuracy, hypothesis) &&
+                  _at->recv("OK");
+        // Answers are picked up by reacting to +ULOC
 
         UNLOCK();
     }