updates

Dependencies:   ublox-at-cellular-interface ublox-cellular-base ublox-cellular-base-n2xx ublox-at-cellular-interface-n2xx

Revision:
28:e33af9f1ce3e
Parent:
13:d31b8735cca8
Child:
30:4e55e975dd0b
--- a/main.cpp	Wed Sep 13 16:02:48 2017 +0100
+++ b/main.cpp	Thu Sep 14 10:41:30 2017 +0100
@@ -17,15 +17,30 @@
 #include "mbed.h"
 #include "UbloxATCellularInterface.h"
 #include "UbloxPPPCellularInterface.h"
+#include "UbloxATCellularInterfaceN2xx.h"
 
-// If you wish to use LWIP and the PPP cellular interface on the mbed
-// MCU, select the line UbloxPPPCellularInterface instead of the line
-// UbloxATCellularInterface.  Using the AT cellular interface does not
-// require LWIP and hence uses less RAM (significant on C027).  It also
+// You must select the correct interface library for your board,
+// where supported combinations are indicated with a "Y" in the
+// table below.
+//
+//                            C030_U201   C030_N211      C027
+// UbloxPPPCellularInterface      Y            -           Y
+// UbloxATCellularInterface       Y            -           Y
+// UbloxATCellularInterfaceN2xx   -            Y           -
+// Note: the N211 module supports only UDP, not TCP
+
+// UbloxPPPCellularInterface uses LWIP and the PPP cellular interface
+// on the mbed MCU, while using UbloxATCellularInterface and
+// UbloxATCellularInterfaceN2xx uses an IP stack on the cellular
+// module and hence uses less RAM (significant on C027).  This also
 // allows other AT command operations (e.g. sending an SMS) to happen
-// during a data transfer.
+// during a data transfer (for which you should replace the
+// UbloxATCellularInterface library with the UbloxATCellularInterfaceExt
+// library).  However, it is slower than using the LWIP/PPP on the mbed
+// MCU interface since more string parsing is required.
 #define INTERFACE_CLASS  UbloxATCellularInterface
 //#define INTERFACE_CLASS  UbloxPPPCellularInterface
+//#define INTERFACE_CLASS  UbloxATCellularInterfaceN2xx
 
 // The credentials of the SIM in the board.  If PIN checking is enabled
 // for your SIM card you must set this to the required PIN.
@@ -128,7 +143,9 @@
 //    INTERFACE_CLASS *interface = new INTERFACE_CLASS(MDMTXD, MDMRXD,
 //                                                     MBED_CONF_UBLOX_CELL_BAUD_RATE,
 //                                                     true);
+#ifndef TARGET_UBLOX_C030_N211
     TCPSocket sockTcp;
+#endif
     UDPSocket sockUdp;
     SocketAddress udpServer;
     SocketAddress udpSenderAddress;
@@ -163,11 +180,12 @@
         if ((interface->gethostbyname("2.pool.ntp.org", &udpServer) == 0) &&
             (interface->gethostbyname("developer.mbed.org", &tcpServer) == 0)) {
             pulseEvent();
+
             udpServer.set_port(123);
-            tcpServer.set_port(80);
             printf("\"2.pool.ntp.org\" address: %s on port %d.\n", udpServer.get_ip_address(), udpServer.get_port());
             printf("\"developer.mbed.org\" address: %s on port %d.\n", tcpServer.get_ip_address(), tcpServer.get_port());
-            
+            tcpServer.set_port(80);
+
             printf("Performing socket operations in a loop (until the user button is pressed on C030 or forever on C027)...\n");
             while (!buttonPressed) {
                 // UDP Sockets
@@ -199,6 +217,7 @@
                     printf("Socket closed.\n");
                 }
                 
+#ifndef TARGET_UBLOX_C030_N211
                 // TCP Sockets
                 printf("=== TCP ===\n");
                 printf("Opening a TCP socket...\n");
@@ -232,6 +251,7 @@
                     pulseEvent();
                     printf("Socket closed.\n");
                 }
+#endif
                 wait_ms(5000);
 #ifndef TARGET_UBLOX_C027
                 printf("[Checking if user button has been pressed]\n");