Example program for power saving mode of cellular modem. This program can be used with UBLOX_C030_R412M board.

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

Revision:
2:500c4fe5b9a4
Parent:
0:4858efb34078
Child:
3:6debe6b322c4
--- a/main.cpp	Fri May 03 15:53:33 2019 +0500
+++ b/main.cpp	Mon Jun 24 15:12:21 2019 +0500
@@ -13,33 +13,27 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 #include "mbed.h"
 #include "UbloxATCellularInterface.h"
-#include "OnboardCellularInterface.h"
 #include "UbloxATCellularInterfaceN2xx.h"
 
 // You must select the correct interface library for your board, by
 // uncommenting the correct line below. Supported combinations are
 // indicated with a "Y" in the table below.
 //
-//                            C030_U201   C030_N211      C027
-// UbloxATCellularInterface       Y            -           Y
-// OnboardCellularInterface       Y            -           Y
-// UbloxATCellularInterfaceN2xx   -            Y           -
+//                            C030_U201   C030_N211      C027     C030_R41XM
+// UbloxATCellularInterface       Y            -           Y          Y
+// UbloxATCellularInterfaceN2xx   -            Y           -          -
 // Note: the N211 module supports only UDP, not TCP
 
-// OnboardCellularInterface 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
+// 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 (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  OnboardCellularInterface
 //#define INTERFACE_CLASS  UbloxATCellularInterfaceN2xx
 
 // The credentials of the SIM in the board.  If PIN checking is enabled
@@ -56,11 +50,11 @@
 #define APN         NULL
 #define USERNAME    NULL
 #define PASSWORD    NULL
-
+#define TCP_SERVER "os.mbed.com"
 
 // Uncomment the following line to enable Icellular Current measurement.
 // Current drawn by modem is printed on serial every 2 seconds.
-//#define CURRENT_MEASUREMENT
+#define CURRENT_MEASUREMENT
 
 // LEDs
 DigitalOut ledRed(LED1, 1);
@@ -132,7 +126,6 @@
 static void cbButton()
 {
     buttonPressed = true;
-    //pulseEvent();
 }
 
 void init_modem(INTERFACE_CLASS *interface) {
@@ -183,10 +176,10 @@
 #endif
 
 /* This example program for the u-blox C030-R410M board instantiates
- * the UbloxATCellularInterface or OnboardCellularInterface and uses it
- * to make a simple sockets connection to a server, using 2.pool.ntp.org
- * for UDP and developer.mbed.org for TCP. It also showcases the 3GPP PSM
- * feature. For a more comprehensive example, where higher layer protocols
+ * the UbloxATCellularInterface and uses it to make a simple sockets
+ * connection to a server, using 2.pool.ntp.org for UDP and
+ * developer.mbed.org for TCP. It also showcases the 3GPP PSM feature.
+ * For a more comprehensive example, where higher layer protocols
  * make use of the same sockets interface, see example-ublox-mbed-client.
  * Progress may be monitored with a serial terminal running at 9600 baud.
  * The LED on the C030 board will turn green when this program is
@@ -274,14 +267,14 @@
     }
 #endif
 
-    printf("Getting the IP address of \"developer.mbed.org\" and \"2.pool.ntp.org\"...\n");
+    printf("\nGetting the IP address of \"" TCP_SERVER "\" and \"2.pool.ntp.org\"...\n");
     if ((interface->gethostbyname("2.pool.ntp.org", &udpServer) == 0) &&
-        (interface->gethostbyname("developer.mbed.org", &tcpServer) == 0)) {
+        (interface->gethostbyname(TCP_SERVER, &tcpServer) == 0)) {
         pulseEvent();
 
         udpServer.set_port(123);
         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());
+        printf("\"" TCP_SERVER "\" 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");