Example program for MTS Universal Socked Modem Shield. Test that you can connect to a network.

Dependencies:   SocketModem mbed

Revision:
0:a21f66715fc0
Child:
1:bc4801701acb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Jan 04 04:23:09 2014 +0000
@@ -0,0 +1,49 @@
+#include "mbed.h"
+#include "Cellular.h"
+#include "MTSSerialFlowControl.h"
+
+using namespace mts;
+
+main()
+{
+    //Wait for radio to boot up
+    for (int i = 30; i >= 0; i = i - 5) {
+        wait(5);
+        printf("Waiting %d seconds...\n\r", i);
+    }
+
+    //Setup serial interface to radio
+    MTSSerialFlowControl* serial = new MTSSerialFlowControl(PTD3, PTD2, PTA12, PTC8);
+    serial->baud(115200);
+
+    //Setup Cellular class
+    Cellular* cellular = Cellular::getInstance();
+    cellular->init(serial, PTA4, PTC9); //DCD and DTR pins for KL46Z
+
+    //Run status and configuration commands
+    printf("\n\r////Start Status and Configuration Commands////\n\r");
+    printf("Command Test: %s\n\r", getCodeNames(cellular->test()).c_str());
+    printf("Signal Strength: %d\n\r", cellular->getSignalStrength());
+    printf("Registration State: %s\n\r", Cellular::getRegistrationNames(cellular->getRegistration()).c_str());
+    printf("Send Basic Command (AT): %s\n\r", getCodeNames(cellular->sendBasicCommand("AT", 1000)).c_str());
+    printf("Send Command (AT+CSQ): %s\n\r", cellular->sendCommand("AT+CSQ", 1000).c_str());
+
+    //Start Test
+    printf("\n\r////Start Network Connectivity Test////\n\r");
+    printf("Set APN: %s\n\r", getCodeNames(cellular->setApn("wap.cingular")).c_str()); //Use APN from service provider!!!
+
+    //Setup a data connection
+    printf("Attempting to Connect, this may take some time...\n\r");
+    while (!cellular->connect()) {
+        printf("Failed to connect... Trying again.\n\r");
+        wait(1);
+    }
+    printf("Connected to the Network!\n\r");
+
+    //Try pinging default server "8.8.8.8"
+    printf("Ping Valid: %s\n\r", cellular->ping() ? "true" : "false");
+
+    printf("End Program\n\r");
+
+    while(1);
+}