A library for talking to Multi-Tech's Cellular SocketModem Devices.

Dependents:   M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more

Files at this revision

API Documentation at this revision

Comitter:
jengbrecht
Date:
Tue Dec 31 19:57:21 2013 +0000
Parent:
112:4c7d6c30716a
Child:
114:cd34b1d64360
Commit message:
Made minor robustness improvements to Wifi close method and added NONE default to the transport class

Changed in this revision

Socket/Transport.cpp Show annotated file Show diff for this revision Revisions of this file
Socket/Transport.h Show annotated file Show diff for this revision Revisions of this file
wifi/Wifi.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Socket/Transport.cpp	Tue Dec 31 17:32:57 2013 +0000
+++ b/Socket/Transport.cpp	Tue Dec 31 19:57:21 2013 +0000
@@ -2,7 +2,7 @@
 #include "Cellular.h"
 #include "Wifi.h"
 
-Transport::TransportType Transport::_type = Transport::CELLULAR;
+Transport::TransportType Transport::_type = Transport::NONE;
 
 void Transport::setTransport(TransportType type)
 {
@@ -17,6 +17,7 @@
         case WIFI:
             return (IPStack*) Wifi::getInstance();
         default:
-            return (IPStack*) Cellular::getInstance();
+            printf("[ERROR] Transport not set, use setTransport method.\n\r");
+            return NULL;
     }
 }
--- a/Socket/Transport.h	Tue Dec 31 17:32:57 2013 +0000
+++ b/Socket/Transport.h	Tue Dec 31 19:57:21 2013 +0000
@@ -19,13 +19,13 @@
 public:
     ///An enumeration that holds the supported Transport Types.
     enum TransportType {
-        CELLULAR, WIFI
+        CELLULAR, WIFI, NONE
     };
     
     /** This method allows you to set the transport to be used when creating other 
     * objects from the Socket folder like TCPSocketConnection and UDPSocket.  
     *
-    * @param type the type of underlying transport to be used.
+    * @param type the type of underlying transport to be used. The default is NONE.
     */
     static void setTransport(TransportType type);
     
--- a/wifi/Wifi.cpp	Tue Dec 31 17:32:57 2013 +0000
+++ b/wifi/Wifi.cpp	Tue Dec 31 19:57:21 2013 +0000
@@ -310,12 +310,17 @@
     }
 
     std::string response = sendCommand("close", 10000, "CLOS");
+    //printf("Close Response: %s\n\r", response.c_str());
     if(response.find("CLOS") == string::npos) {
         printf("[ERROR] Failed to successfully close socket\r\n");
         return false;
     }
 
     socketOpened = false;
+    
+    io->rxClear();
+    io->txClear();
+    
     return true;
 }
 
@@ -416,7 +421,7 @@
         printf("[ERROR] Failed to set IP due to mode issue\r\n");
         return FAILURE;
     }
-    
+
     //Set to DHCP mode
     if(address.compare("DHCP") == 0) {
         return sendBasicCommand("set ip dhcp 1", 1000);
@@ -539,6 +544,7 @@
         std::string response = sendCommand("$$", 2000, "CMD", '$');
         if (response.find("CMD") != string::npos) {
             cmdOn = true;
+            wait(.5);
             return true;
         }
         printf("[ERROR] Failed to enter command mode\n\r");