Simple example program to demonstrate and test cellular connection using the MTSAS library (over PPP protocol)

Dependencies:   mbed mtsas

Revision:
3:f22ad66e049e
Parent:
2:99606ba5d1bf
Child:
4:8b02a6b67f4d
--- a/main.cpp	Fri Jul 25 16:52:15 2014 +0000
+++ b/main.cpp	Mon Jul 28 14:57:44 2014 +0000
@@ -3,7 +3,7 @@
 
 int main(){
     //Modify to match your apn if you are using an HSPA radio with a SIM card
-    const char APN[] = "";
+    const char APN[] = "internet";
     
     /** STMicro Nucelo F401RE
     * The supported jumper configurations of the MTSAS do not line up with
@@ -17,16 +17,14 @@
     
     /** Freescale KL46Z
     * To configure the pins for the Freescale KL46Z board, use configuration B
-    * for the SocketModem. The TX pin should be jumped to pin D2 (JP8), and the
-    * RX pin should be jumped to pin D9 (JP9). 
+    * for the SocketModem.
     * Uncomment te following line to use the Freescale KL46Z board
     */
     //MTSSerialFlowControl* io = new MTSSerialFlowControl(D2, D9, D3, D6);
     
     /** Freescale KL64F
     * To configure the pins for the Freescale KL46Z board, use configuration A
-    * for the SocketModem. The TX pin should be jumped to pin D1 (JP8), and the
-    * RX pin should be jumped to pin D0 (JP9). 
+    * for the SocketModem.
     * Uncomment te following line to use the Freescale KL46F board
     */
     //MTSSerialFlowControl* io = new MTSSerialFlowControl(D1, D0, D3, D6);
@@ -37,10 +35,10 @@
     Cellular* radio = CellularFactory::create(io);
     for (int i = 0; i < 10; i++) {
         if (i >= 10) {
-            logError("Failed to set APN\n");
+            logError("Failed to set APN");
         }
         if (radio->setApn(APN) == MTS_SUCCESS) {
-            logInfo("Successfully set APN\n");
+            logInfo("Successfully set APN [%s]", APN);
             break;
         } else {
             wait(1);
@@ -50,10 +48,10 @@
     //Establish PPP link
     for (int i = 0; i < 10; i++) {
         if (i >= 10) {
-            logError("Failed to connect to cell network\n");
+            logError("Failed to connect to cell network");
         }
         if (radio->connect() == true) {
-            logInfo("Successfully established PPP link\n");
+            logInfo("Successfully established PPP link");
             break;
         } else {
             wait(1);
@@ -63,10 +61,10 @@
     //Ping google.com
     for (int i = 0; i < 10; i++) {
         if (i >= 10) {
-            logError("Failed to ping google.com\n");
+            logError("Failed to ping google.com");
         }
-        if (radio->ping() == true) {
-            logInfo("Successfully pinged google.com\n");
+        if (radio->ping("www.google.com") == true) {
+            logInfo("Successfully pinged google.com");
             break;
         } else {
             wait(1);
@@ -76,6 +74,6 @@
     //Disconnect ppp link
     radio->disconnect();
     
-    logInfo("End of example code\n");
+    logInfo("End of example code");
     return 0;
 }
\ No newline at end of file