This class provides SMS, USSD and modem file system support for u-blox modules on the C027 and C030 boards (excepting the C030 N2xx flavour) from mbed 5.5 onwards.

Dependents:   example-ublox-at-cellular-interface-ext example-ublox-cellular-driver-gen HelloMQTT ublox_new_driver_test ... more

Revision:
7:a9eea2dbdd68
Parent:
5:b935404dcf7c
Child:
8:e6f6bf43a5d1
--- a/UbloxCellularDriverGen.cpp	Thu Jun 15 07:19:40 2017 +0100
+++ b/UbloxCellularDriverGen.cpp	Fri Jun 16 00:49:52 2017 +0100
@@ -641,7 +641,6 @@
     int blockSize = FILE_BUFFER_SIZE;
     char respFilename[48 + 1];
     int sz, sz_read;
-    char * endQuote;
     bool success = true;
     int ch = 0;
     int timeLimit;
@@ -665,46 +664,38 @@
 
             if (blockSize > 0) {
                 if (_at->send("AT+URDBLOCK=\"%s\",%d,%d\r\n", filename, offset, blockSize) &&
-                    _at->recv("+URDBLOCK: %48[^,],%d,\"", respFilename, &sz)) {
-                    // On some modules the response filename is not in quotes,
-                    // on others it is, so strip them here
-                    if ((*respFilename == '"') && ((endQuote = strchr(respFilename + 1, '"')) != NULL)) {
-                        memcpy (respFilename, respFilename + 1, endQuote - respFilename - 1);
-                        *(endQuote - 1) = 0;
+                    _at->recv("+URDBLOCK:%48[^,],%d,\"", respFilename, &sz)) {
+                    // Note: not checking respFilename as some modules (e.g. Sara-G350 00S-00)
+                    // doesn't always include it.
+                    // Would use _at->read() here, but if it runs ahead of the
+                    // serial stream it returns -1 instead of the number of characters
+                    // read so far, which is not very helpful so instead use _at->getc() and
+                    // a time limit. The time limit is four times the amount of time it
+                    // should take to read the block at the working baud rate with a minimum
+                    // of 100 ms (for short files)
+                    timer.reset();
+                    timer.start();
+                    timeLimit = blockSize * 4 / ((MBED_CONF_UBLOX_CELL_BAUD_RATE / 8) / 1000);
+                    if (timeLimit < 100) {
+                        timeLimit = 100;
                     }
-                    if (strcmp(filename, respFilename) == 0) {
-                        // Would use _at->read() here, but if it runs ahead of the
-                        // serial stream it returns -1 instead of the number of characters
-                        // read so far, which is not very helpful so instead use _at->getc() and
-                        // a time limit. The time limit is three times the amount of time it
-                        // should take to read the block at the working baud rate with a minimum
-                        // of 10 ms (for short files)
-                        timer.reset();
-                        timer.start();
-                        timeLimit = blockSize * 3 / ((MBED_CONF_UBLOX_CELL_BAUD_RATE / 8) / 1000);
-                        if (timeLimit < 10) {
-                            timeLimit = 10;
+                    sz_read = 0;
+                    while ((sz_read < blockSize) && (timer.read_ms() < timeLimit)) {
+                        ch = _at->getc();
+                        if (ch >= 0) {
+                            *buf = ch;
+                            buf++;
+                            sz_read++;
                         }
-                        sz_read = 0;
-                        while ((sz_read < blockSize) && (timer.read_ms() < timeLimit)) {
-                            ch = _at->getc();
-                            if (ch >= 0) {
-                                *buf = ch;
-                                buf++;
-                                sz_read++;
-                            }
-                        }
-                        timer.stop();
+                    }
+                    timer.stop();
 
-                        if (sz_read == blockSize) {
-                            bytesToRead -= sz_read;
-                            offset += sz_read;
-                            _at->recv("OK");
-                        } else {
-                        debug_if(_debug_trace_on, "blockSize %d but only received %d bytes\n", blockSize, sz_read);
-                            success = false;
-                        }
+                    if (sz_read == blockSize) {
+                        bytesToRead -= sz_read;
+                        offset += sz_read;
+                        _at->recv("OK");
                     } else {
+                    debug_if(_debug_trace_on, "blockSize %d but only received %d bytes\n", blockSize, sz_read);
                         success = false;
                     }
                } else {