Add a bunch of APNs

Fork of C027_Support by Xinlei Cao

Revision:
47:9a89e5195721
Parent:
45:ebc2fd8dcf21
Child:
48:46ba168127d6
diff -r 8ce9169e0747 -r 9a89e5195721 MDM.cpp
--- a/MDM.cpp	Tue May 06 06:54:12 2014 +0000
+++ b/MDM.cpp	Fri May 09 17:43:55 2014 +0000
@@ -3,8 +3,8 @@
 #include <string.h>
 #include "MDM.h"
 
-#define TRACE           (1/*1=off,0=trace*/)?:printf
-//#define DEBUG         // enable this for AT command debugging
+#define TRACE           (0/*1=off,0=trace*/)?:printf
+#define DEBUG         // enable this for AT command debugging
 #define PROFILE         "0"   // this is the psd profile used
 #define MAX_SIZE        256  // max expected messages
 // some helper 
@@ -621,6 +621,7 @@
 
 int MDMParser::socketSocket(IpProtocol ipproto)
 {
+    TRACE("socketSocket(%d)\r\n", ipproto);
     const char* cmd;
     if(ipproto == IPPROTO_TCP) {
         cmd = "AT+USOCR=6\r\n";
@@ -644,6 +645,7 @@
 
 bool MDMParser::socketConnect(int socket, const char * host, int port)
 {
+    TRACE("socketConnect(%d,%s,%d)\r\n", socket, host,port);
     IP ip = gethostbyname(host);
     if (ip == NOIP)
         return false;
@@ -659,11 +661,16 @@
 
 bool MDMParser::socketIsConnected(int socket)
 {
-    return (ISSOCKET(socket) && (_sockets[socket].state == SOCK_CONNECTED));
+    TRACE("socketIsConnected(%d)\r\n", socket);
+    if (!ISSOCKET(socket))
+        return false;
+    TRACE(" ... %d\r\n", _sockets[socket].state);
+    return _sockets[socket].state == SOCK_CONNECTED;
 }
 
 bool MDMParser::socketSetBlocking(int socket, unsigned int timeout_ms)
 {
+    TRACE("socketSetBlocking(%d,%d)\r\n", socket, timeout_ms);
     if (!ISSOCKET(socket))
         return false;
     _sockets[socket].timeout_ms = timeout_ms;
@@ -672,6 +679,7 @@
 
 bool  MDMParser::socketClose(int socket)
 {
+    TRACE("socketClose(%d)\r\n", socket);
     if (!ISSOCKET(socket) || (_sockets[socket].state != SOCK_CONNECTED))
         return false;
     sendFormated("AT+USOCL=%d\r\n", socket);
@@ -683,6 +691,7 @@
 
 bool  MDMParser::socketFree(int socket)
 {
+    TRACE("socketFree(%d)\r\n", socket);
     socketClose(socket);
     if (!ISSOCKET(socket) || (_sockets[socket].state != SOCK_CREATED))
         return false;
@@ -692,6 +701,7 @@
 
 int MDMParser::socketSend(int socket, const char * buf, int len)
 {
+    TRACE("socketSend(%d,,%d)\r\n", socket,len);
     if(len > 0) {
         sendFormated("AT+USOWR=%d,%d\r\n",socket,len);
         if (PROMPT != waitFinalResp())
@@ -706,6 +716,7 @@
 
 int MDMParser::socketSendTo(int socket, IP ip, int port, const char * buf, int len)
 {
+    TRACE("socketSendTo(%d," IPSTR "%d,,%d)\r\n", socket, IPNUM(ip),port,len);
     if(len > 0) {
         sendFormated("AT+USOWR=%d,\"" IPSTR "\",%d,%d\r\n",socket,IPNUM(ip),port,len);
         if (PROMPT != waitFinalResp())
@@ -720,6 +731,7 @@
 
 int MDMParser::socketReadable(int socket)
 {
+    TRACE("socketReadable(%d)\r\n", socket);
     if (!ISSOCKET(socket) || (_sockets[socket].state != SOCK_CONNECTED))
         return SOCKET_ERROR;
     // allow to receive unsolicited commands 
@@ -744,6 +756,7 @@
 int MDMParser::socketRecv(int socket, char* buf, int len)
 {
     int cnt = 0;
+    TRACE("socketRecv(%d,,%d)\r\n", socket, len);
     if (!ISSOCKET(socket))
         return SOCKET_ERROR;
     memset(buf, '\0', len);
@@ -795,6 +808,7 @@
 int MDMParser::socketRecvFrom(int socket, char* buf, int len, IP* ip)
 {
     int cnt = 0;
+    TRACE("socketRecvFrom(%d,,%d" IPSTR ")\r\n", socket, len, IPNUM(*ip));
     if (!ISSOCKET(socket))
         return SOCKET_ERROR;
     memset(buf, '\0', len);