Implementation of the CellularInterface for u-blox C027 and C030 (non-N2xx flavour) modems that uses the IP stack on-board the cellular modem, hence not requiring LWIP (and so less RAM) and allowing any AT command exchanges to be carried out at the same time as data transfers (since the modem remains in AT mode all the time). This library may be used from mbed 5.5 onwards. If you need to use SMS, USSD or access the modem file system at the same time as using the CellularInterface then use ublox-at-cellular-interface-ext instead.

Dependents:   example-ublox-cellular-interface example-ublox-cellular-interface_r410M example-ublox-mbed-client example-ublox-cellular-interface ... more

Revision:
10:ba18f4418ee8
Parent:
7:3b2ca10cc23a
Child:
11:cc41a8636f7e
Child:
12:ff6fac481487
--- a/UbloxATCellularInterface.cpp	Wed Sep 27 15:33:07 2017 +0500
+++ b/UbloxATCellularInterface.cpp	Mon Oct 30 14:48:14 2017 +0000
@@ -688,8 +688,12 @@
                                   // losing characters in UARTSerial
             if (_at->send("AT+USORD=%d,%d", socket->modem_handle, read_blk) &&
                 _at->recv("+USORD: %*d,%d,\"", &usord_sz)) {
-                socket->pending -= usord_sz; // Must use what +USORD returns here as it
-                                             // may be less than we asked for
+                // Must use what +USORD returns here as it may be less or more than we asked for
+                if (usord_sz > socket->pending) {
+                    socket->pending = 0;
+                } else {
+                    socket->pending -= usord_sz; 
+                }
                 // Note: insert no debug between _at->recv() and _at->read(), no time...
                 if (usord_sz > size) {
                     usord_sz = size;
@@ -803,8 +807,12 @@
             if (_at->send("AT+USORF=%d,%d", socket->modem_handle, read_blk) &&
                 _at->recv("+USORF: %*d,\"%" u_stringify(NSAPI_IP_SIZE) "[^\"]\",%d,%d,\"",
                           ipAddress, &port, &usorf_sz)) {
-                socket->pending -= usorf_sz; // Must use what +USORF returns here as it
-                                             // may be less than we asked for
+                // Must use what +USORF returns here as it may be less or more than we asked for
+                if (usorf_sz > socket->pending) {
+                    socket->pending = 0;
+                } else {
+                    socket->pending -= usorf_sz; 
+                }
                 // Note: insert no debug between _at->recv() and _at->read(), no time...
                 if (usorf_sz > size) {
                     usorf_sz = size;