Multi-Hackers / SocketModem

Dependents:   M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more

Files at this revision

API Documentation at this revision

Comitter:
mfiore
Date:
Thu Dec 19 19:53:43 2013 +0000
Parent:
38:4739e039421a
Parent:
39:6e94520a3217
Child:
42:2e90ccaa2d69
Commit message:
merge changes

Changed in this revision

cellular/Cellular.cpp Show annotated file Show diff for this revision Revisions of this file
cellular/Cellular.h Show annotated file Show diff for this revision Revisions of this file
io/IPStack.h Show annotated file Show diff for this revision Revisions of this file
io/MTSBufferedIO.cpp Show annotated file Show diff for this revision Revisions of this file
io/MTSBufferedIO.h Show annotated file Show diff for this revision Revisions of this file
io/MTSSerial.h Show annotated file Show diff for this revision Revisions of this file
io/MTSSerialFlowControl.h Show annotated file Show diff for this revision Revisions of this file
--- a/Socket/Socket.cpp	Thu Dec 19 16:54:09 2013 +0000
+++ b/Socket/Socket.cpp	Thu Dec 19 19:53:43 2013 +0000
@@ -20,7 +20,7 @@
 #include <cstring>
 
 Socket::Socket() : _blocking(true), _timeout(1500) {
-    cellular = Cellular::getInstance();
+    cellular = mts::Cellular::getInstance();
 }
 
 void Socket::set_blocking(bool blocking, unsigned int timeout) {
--- a/Socket/Socket.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/Socket/Socket.h	Thu Dec 19 19:53:43 2013 +0000
@@ -44,7 +44,7 @@
 protected:
     bool _blocking;
     int _timeout;
-    Cellular * cellular;
+    mts::Cellular * cellular;
 };
 
 
--- a/Socket/TCPSocketConnection.cpp	Thu Dec 19 16:54:09 2013 +0000
+++ b/Socket/TCPSocketConnection.cpp	Thu Dec 19 19:53:43 2013 +0000
@@ -25,7 +25,7 @@
 
 int TCPSocketConnection::connect(const char* host, const int port)
 {
-    if (!cellular->open(host, port, IPStack::TCP)) {
+    if (!cellular->open(host, port, mts::IPStack::TCP)) {
         return -1;
     }
     return 0;
--- a/Socket/UDPSocket.cpp	Thu Dec 19 16:54:09 2013 +0000
+++ b/Socket/UDPSocket.cpp	Thu Dec 19 19:53:43 2013 +0000
@@ -43,7 +43,7 @@
 // -1 if unsuccessful, else number of bytes written
 int UDPSocket::sendTo(Endpoint &remote, char *packet, int length)
 {
-    if (!cellular->open(remote.get_address(), remote.get_port(), IPStack::UDP)) {
+    if (!cellular->open(remote.get_address(), remote.get_port(), mts::IPStack::UDP)) {
         return -1;
     }
 
@@ -65,7 +65,7 @@
 // -1 if unsuccessful, else number of bytes received
 int UDPSocket::receiveFrom(Endpoint &remote, char *buffer, int length)
 {
-    if (!cellular->open(remote.get_address(), remote.get_port(), IPStack::UDP)) {
+    if (!cellular->open(remote.get_address(), remote.get_port(), mts::IPStack::UDP)) {
         return -1;
     }
 
--- a/cellular/Cellular.cpp	Thu Dec 19 16:54:09 2013 +0000
+++ b/cellular/Cellular.cpp	Thu Dec 19 19:53:43 2013 +0000
@@ -5,6 +5,8 @@
 #include "MTSText.h"
 #include "MTSSerial.h"
 
+using namespace mts;
+
 Cellular* Cellular::instance = NULL;
 
 Cellular* Cellular::getInstance() {
@@ -102,7 +104,7 @@
     }
     
     Code code = sendBasicCommand("AT#CONNECTIONSTOP", 10000);
-    if(code == OK) {
+    if(code == CELL_OK) {
         printf("[DEBUG] Successfully closed PPP Connection\r\n");
     } else {
         printf("[ERROR] Closing PPP Connection [%d].  Continuing ...\r\n", (int)code);   
@@ -163,7 +165,7 @@
     if(mode == TCP) {
         if(socketCloseable) {
             Code code = sendBasicCommand("AT#DLEMODE=1,0", 1000);
-            if(code != OK) {
+            if(code != CELL_OK) {
                 printf("[WARNING] Unable to set socket closeable [%d]\r\n", (int) code);       
             }
         }
@@ -173,7 +175,7 @@
     } else {
         if(socketCloseable) {
             Code code = sendBasicCommand("AT#UDPDLEMODE=1", 1000);
-            if(code != OK) {
+            if(code != CELL_OK) {
                 printf("[WARNING] Unable to set socket closeable [%d]\r\n", (int) code);       
             }
         }
@@ -182,13 +184,13 @@
         addressCode = sendBasicCommand("AT#UDPSERV=1,\"" + address + "\"", 1000);
     }
     
-    if(portCode == OK) {
+    if(portCode == CELL_OK) {
         host_port = port;
     } else {
         printf("[ERROR] Host port could not be set\r\n");
     }
     
-    if(addressCode == OK) {
+    if(addressCode == CELL_OK) {
         host_address = address;
     } else {
         printf("[ERROR] Host address could not be set\r\n");
@@ -438,7 +440,7 @@
 void Cellular::reset() {
     disconnect();
     Code code = sendBasicCommand("AT#RESET=0", 10000);
-    if(code != OK) {
+    if(code != CELL_OK) {
         printf("[ERROR] Socket Modem did not accept RESET command\n\r");
     } else {
         printf("[WARNING] Socket Modem is resetting, allow 30 seconds for it to come back\n\r");
@@ -449,7 +451,7 @@
 {
     Code code = sendBasicCommand("AT", 1000);
     
-    if(code != OK) {
+    if(code != CELL_OK) {
         printf("[Error] Failed basic AT command");
         return code;
     }
@@ -457,7 +459,7 @@
     //AT#VSTATE != "CHECKING"
     
     //AT#GPRSMODE == 
-    return OK;
+    return CELL_OK;
 }
 
 Cellular::Code Cellular::echo(bool state)
@@ -465,10 +467,10 @@
     Code code;
     if (state) {
         code = sendBasicCommand("ATE0", 1000);
-        echoMode = (code == OK) ? false : echoMode;
+        echoMode = (code == CELL_OK) ? false : echoMode;
     } else {
         code = sendBasicCommand("ATE1", 1000);
-        echoMode = (code == OK) ? true : echoMode;
+        echoMode = (code == CELL_OK) ? true : echoMode;
     }
     return code;
 }
@@ -523,24 +525,24 @@
 {
     if(socketOpened) {
         printf("[ERROR] socket is open. Can not send AT commands\r\n");    
-        return ERROR;
+        return CELL_ERROR;
     }
 
     string response = sendCommand(command, timeoutMillis, esc);
     if (response.size() == 0) {
-        return NO_RESPONSE;
+        return CELL_NO_RESPONSE;
     } else if (response.find("OK") != string::npos) {
-        return OK;
+        return CELL_OK;
     } else if (response.find("ERROR") != string::npos) {
-        return ERROR;
+        return CELL_ERROR;
     } else {
-        return FAILURE;
+        return CELL_FAILURE;
     }
 }
 
 Cellular::Code Cellular::setApn(const std::string& apn) {
     Code code = sendBasicCommand("AT#APNSERV=\"" + apn + "\"", 1000);
-    if (code != OK) {
+    if (code != CELL_OK) {
         return code;
     }
     this->apn = apn;
@@ -548,7 +550,7 @@
 }
 
 Cellular::Code Cellular::setDns(const std::string& address) {
-    return FAILURE;   
+    return CELL_FAILURE;   
 }
 
 bool Cellular::ping(const std::string& address) {
@@ -556,19 +558,19 @@
     Code code;
     
     code = sendBasicCommand("AT#PINGREMOTE=\"" + address + "\"", 1000);
-    if (code != OK) {
+    if (code != CELL_OK) {
         return false;
     }
     
     sprintf(buffer, "AT#PINGNUM=%d", 1);
     code = sendBasicCommand(buffer , 1000);
-    if (code != OK) {
+    if (code != CELL_OK) {
         return false;
     }
     
     sprintf(buffer, "AT#PINGDELAY=%d", PINGDELAY);
     code = sendBasicCommand(buffer , 1000);
-    if (code != OK) {
+    if (code != CELL_OK) {
         return false;
     }
     
@@ -584,17 +586,17 @@
 
 Cellular::Code Cellular::setSocketCloseable(bool enabled) {
     if(socketCloseable == enabled) {
-        return OK;    
+        return CELL_OK;    
     }
     
     if(socketOpened) {
         printf("[ERROR] socket is already opened. Can not set closeable\r\n");    
-        return ERROR;
+        return CELL_ERROR;
     }
     
     socketCloseable = enabled;
     
-    return OK;
+    return CELL_OK;
 }
 
 Cellular::Code Cellular::sendSMS(const Sms& sms) {
@@ -604,7 +606,7 @@
 Cellular::Code Cellular::sendSMS(const std::string& phoneNumber, const std::string& message)
 {    
     Code code = sendBasicCommand("AT+CMGF=1", 1000);
-    if (code != OK) {
+    if (code != CELL_OK) {
         return code;
     }
     string cmd = "AT+CMGS=\"+";
@@ -612,15 +614,15 @@
     cmd.append("\"");
     string response1 = sendCommand(cmd, 1000);
     if (response1.find('>') == string::npos) {
-        return NO_RESPONSE;
+        return CELL_NO_RESPONSE;
     }
     wait(.2);
     string  response2 = sendCommand(message, 4000, CTRL_Z);
     printf("SMS Response: %s\r\n", response2.c_str());
     if (response2.find("+CMGS:") == string::npos) {
-        return FAILURE;
+        return CELL_FAILURE;
     }
-    return OK;
+    return CELL_OK;
 }
 
 std::vector<Cellular::Sms> Cellular::getReceivedSms() {
--- a/cellular/Cellular.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/cellular/Cellular.h	Thu Dec 19 19:53:43 2013 +0000
@@ -7,6 +7,8 @@
 #include <string>
 #include <vector>
 
+namespace mts {
+
 #define PINGDELAY 3 //Time to wait on each ping for a response before timimg out (seconds)
 #define PINGNUM 4 //Number of pings to try on ping command
 
@@ -127,12 +129,12 @@
 * @endcode
 */
 
-class Cellular : virtual IPStack
+class Cellular : virtual mts::IPStack
 {
 public:
     /// An enumeration for common responses to an AT command.
     enum Code {
-        OK, ERROR, NO_RESPONSE, FAILURE
+        CELL_OK, CELL_ERROR, CELL_NO_RESPONSE, CELL_FAILURE
     };
 
     /// An enumeration for escape characters at the end of AT commands.
@@ -338,4 +340,6 @@
     Cellular(MTSBufferedIO* io); //Private constructor, use the getInstance() method.
 };
 
+}
+
 #endif /* CELLULAR_H */
\ No newline at end of file
--- a/include_me.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/include_me.h	Thu Dec 19 19:53:43 2013 +0000
@@ -2,4 +2,5 @@
 #include "MTSSerial.h"
 #include "MTSSerialFlowControl.h"
 #include "TCPSocketConnection.h"
-#include "UDPSocket.h"
\ No newline at end of file
+#include "UDPSocket.h"
+#include "AxedaWrapper.h"
\ No newline at end of file
--- a/io/IPStack.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/io/IPStack.h	Thu Dec 19 19:53:43 2013 +0000
@@ -3,6 +3,8 @@
 
 #include <string>
 
+namespace mts {
+    
 /** This class is a pure virtual class that should be inherited from when implementing
 * a communications device with an onboard IP stack.  Examples of this would be a Wi-Fi
 * or Cellular radio with a built in IP stack. Typically the IP functionality in these
@@ -116,4 +118,6 @@
     virtual void reset() = 0;
 };
 
+}
+
 #endif /* IPSTACK_H */
\ No newline at end of file
--- a/io/MTSBufferedIO.cpp	Thu Dec 19 16:54:09 2013 +0000
+++ b/io/MTSBufferedIO.cpp	Thu Dec 19 19:53:43 2013 +0000
@@ -3,6 +3,8 @@
 
 #include "MTSBufferedIO.h"
 
+using namespace mts;
+
 MTSBufferedIO::MTSBufferedIO(int txBufferSize, int rxBufferSize)
 {
     txBuffer = new MTSCircularBuffer(txBufferSize);
--- a/io/MTSBufferedIO.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/io/MTSBufferedIO.h	Thu Dec 19 19:53:43 2013 +0000
@@ -4,12 +4,15 @@
 #include "mbed.h"
 #include "MTSCircularBuffer.h"
 
+namespace mts {
+
 /** This is an abstract class for lightweight buffered io to an underlying
 * data interface. Specifically the inheriting class will need to override
 * both the handle read and handle write functions which transfer data between
 * the classes internal read and write buffers and the physical communications
 * link or its HW buffers.
 */
+
 class MTSBufferedIO
 {
 public:
@@ -88,4 +91,6 @@
     MTSCircularBuffer* rxBuffer; // Internal read or receieve circular buffer
 };
 
+}
+
 #endif /* MTSBUFFEREDIO_H */
\ No newline at end of file
--- a/io/MTSSerial.cpp	Thu Dec 19 16:54:09 2013 +0000
+++ b/io/MTSSerial.cpp	Thu Dec 19 19:53:43 2013 +0000
@@ -3,6 +3,8 @@
 
 #include "MTSSerial.h"
 
+using namespace mts;
+
 MTSSerial::MTSSerial(PinName TXD, PinName RXD, int txBufferSize, int rxBufferSize, char* name) : MTSBufferedIO(txBufferSize, rxBufferSize), writeSize(30), if_name(name)
 {
     serial = new Serial(TXD, RXD);
--- a/io/MTSSerial.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/io/MTSSerial.h	Thu Dec 19 19:53:43 2013 +0000
@@ -4,6 +4,8 @@
 #include "mbed.h"
 #include "MTSBufferedIO.h"
 
+namespace mts {
+    
 /** This class derives from MTSBufferedIO and provides a buffered wrapper to the
 * standard Mbed Serial class. Since it depends only on the Mbed Serial class for
 * accessing serial data, this class is inherently portable accross Mbed platforms.
@@ -54,4 +56,6 @@
     char* if_name; // Name of the interface
 };
 
+}
+
 #endif /* MTSSERIAL_H */
\ No newline at end of file
--- a/io/MTSSerialFlowControl.cpp	Thu Dec 19 16:54:09 2013 +0000
+++ b/io/MTSSerialFlowControl.cpp	Thu Dec 19 19:53:43 2013 +0000
@@ -3,6 +3,8 @@
 
 #include "MTSSerialFlowControl.h"
 
+using namespace mts;
+
 MTSSerialFlowControl::MTSSerialFlowControl(PinName TXD, PinName RXD, PinName RTS, PinName CTS, int txBufSize, int rxBufSize, char* name) : MTSBufferedIO(txBufSize, rxBufSize), if_name(name)
 {
     serial = new Serial(TXD, RXD);
--- a/io/MTSSerialFlowControl.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/io/MTSSerialFlowControl.h	Thu Dec 19 19:53:43 2013 +0000
@@ -4,6 +4,8 @@
 #include "mbed.h"
 #include "MTSBufferedIO.h"
 
+namespace mts {
+
 class MTSSerialFlowControl : public MTSBufferedIO
 {
 public:
@@ -54,4 +56,6 @@
     virtual void handleWrite();
 };
 
+}
+
 #endif /* MTSSERIALFLOWCONTROL */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sample_application.h	Thu Dec 19 19:53:43 2013 +0000
@@ -0,0 +1,87 @@
+#include "mbed.h"
+#include "AxedaWrapper.h"
+
+using namespace mts;
+
+bool bring_ppp_link_up(Cellular* cell);
+
+int axeda_test() {
+    // serial connection to the radio
+    // should not need to be changed
+    MTSSerialFlowControl* serial = new MTSSerialFlowControl(PTD3, PTD2, PTA12, PTC8);
+    serial->baud(115200);
+    Cellular* cell = Cellular::getInstance(serial);
+    
+    if (! bring_ppp_link_up(cell)) {
+        printf("failed to set up cellular\n\r");
+        return -1;
+    } else {
+        printf("PPP layer is up and ready to go!\n\r");
+    }
+    
+    // unique serial number <initials>-<random number>
+    std::string serial_num = "MWF-7215";
+    AxedaWrapper* client = new AxedaWrapper(serial_num);
+    
+    std::string key = "test";
+    int value = 10;
+    bool retval;
+    
+    printf("sending key-value pair: %s->%d\n\r", key.c_str(), value);
+    retval = client->sendKvp(key, value);
+    printf("%s sending data\n\r", retval ? "succeeded" : "failed");
+    
+    return 0;
+}
+
+bool bring_ppp_link_up(Cellular* cell) {
+    // how many times we try setting APN, getting registration, etc before giving up
+    int max_tries = 5;
+    int i;
+    std::string apn = "wap.cingular";
+    
+    printf("waiting for radio to come up\n\r");
+    wait(30);
+    
+    i = 0;
+    while (i++ < max_tries) {
+        if (cell->getRegistration() == Cellular::REGISTERED) {
+            printf("registered with tower\n\r");
+            break;
+        } else if (i >= max_tries) {
+            printf("failed to register with tower\n\r");
+            return false;
+        }
+        wait(3);
+    }
+    
+    printf("signal strength: %d\n\r", cell->getSignalStrength());
+
+    i = 0;
+    printf("setting APN to %s\n\r", apn.c_str());
+    while (i++ < max_tries) {
+        if (cell->setApn(apn) == Cellular::CELL_OK) {
+            printf("successfully set APN\n\r");
+            break;
+        } else if (i >= max_tries) {
+            printf("failed to set APN\n\r");
+            return false;
+        }
+        wait(1);
+    }
+    
+    i = 0;
+    printf("bringing up PPP link\n\r");
+    while (i++ < max_tries) {
+        if (cell->connect()) {
+            printf("PPP link is up\n\r");
+            break;
+        } else if (i >= max_tries) {
+            printf("failed to bring PPP link up\n\r");
+            return false;
+        }
+        wait(1);
+    }
+    
+    return true;
+}
\ No newline at end of file
--- a/tests/blinky_ping_test.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/tests/blinky_ping_test.h	Thu Dec 19 19:53:43 2013 +0000
@@ -52,7 +52,7 @@
     i = 0;
     printf("setting APN to %s\n\r", apn.c_str());
     while (i++ < MAX_TRIES) {
-        if (cell->setApn(apn) == Cellular::OK) {
+        if (cell->setApn(apn) == Cellular::CELL_OK) {
             printf("successfully set APN\n\r");
             break;
         } else if (i >= MAX_TRIES) {
--- a/tests/flowControlLoopback.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/tests/flowControlLoopback.h	Thu Dec 19 19:53:43 2013 +0000
@@ -1,5 +1,7 @@
 #include "MTSSerialFlowControl.h"
 
+using namespace mts;
+
 void flowControlLoopback() {
     char buf[16];
     int size = 16;
--- a/tests/flowControlPassThrough.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/tests/flowControlPassThrough.h	Thu Dec 19 19:53:43 2013 +0000
@@ -1,5 +1,7 @@
 #include "MTSSerialFlowControl.h"
 
+using namespace mts;
+
 void flowControlPassThrough() {
     int tmp;
     char buf[16];
--- a/tests/loopback.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/tests/loopback.h	Thu Dec 19 19:53:43 2013 +0000
@@ -1,5 +1,7 @@
 #include "MTSSerial.h"
 
+using namespace mts;
+
 void loopback() {
     char buf[16];
     int size = 16;
--- a/tests/passThrough.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/tests/passThrough.h	Thu Dec 19 19:53:43 2013 +0000
@@ -1,5 +1,7 @@
 #include "MTSSerial.h"
 
+using namespace mts;
+
 void passThrough() {
     int tmp;
     char buf[128];
--- a/tests/test_SMS.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/tests/test_SMS.h	Thu Dec 19 19:53:43 2013 +0000
@@ -10,7 +10,7 @@
     printf("Sending message [%s] to [%s]\r\n", sMsg.c_str(), sPhoneNum.c_str());
     code = Cellular::getInstance()->sendSMS(sPhoneNum, sMsg);
     
-    if(code != Cellular::OK) {
+    if(code != Cellular::CELL_OK) {
         printf("Error during SMS send [%d]\r\n", (int)code);
     } else {
         printf("Success!\r\n");
--- a/tests/test_TCP_Socket.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/tests/test_TCP_Socket.h	Thu Dec 19 19:53:43 2013 +0000
@@ -1,6 +1,8 @@
 #ifndef _TEST_TCP_SOCKET_H_
 #define _TEST_TCP_SOCKET_H_
 
+using namespace mts;
+
 void testTcpSocket() {
     Cellular::Code code;
     const int TEST_PORT = 7000;
@@ -9,7 +11,7 @@
     printf("TCP SOCKET TESTING\r\n");
     printf("Setting APN\r\n");
     code = Cellular::getInstance()->setApn("b2b.tmobile.com");
-    if(code == Cellular::OK) {
+    if(code == Cellular::CELL_OK) {
         printf("Success!\r\n");
     } else {
         printf("Error during APN setup [%d]\r\n", (int)code);
@@ -17,7 +19,7 @@
     
     printf("Setting Socket Closeable\r\n");
     code = Cellular::getInstance()->setSocketCloseable();
-    if(code == Cellular::OK) {
+    if(code == Cellular::CELL_OK) {
         printf("Success!\r\n");
     } else {
         printf("Error setting socket closeable [%d]\r\n", (int)code);
--- a/tests/test_TCP_Socket_Connection.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/tests/test_TCP_Socket_Connection.h	Thu Dec 19 19:53:43 2013 +0000
@@ -3,6 +3,8 @@
 
 #include "TCPSocketConnection.h"
 
+using namespace mts;
+
 void testTcpSocketConnection()
 {
     Cellular::Code code;
@@ -13,7 +15,7 @@
     printf("Setting APN\r\n");
     //code = Cellular::getInstance()->setApn("b2b.tmobile.com");
     code = Cellular::getInstance()->setApn("wap.cingular");
-    if(code == Cellular::OK) {
+    if(code == Cellular::CELL_OK) {
         printf("Success!\r\n");
     } else {
         printf("Error during APN setup [%d]\r\n", (int)code);
@@ -21,7 +23,7 @@
 
     printf("Setting Socket Closeable\r\n");
     code = Cellular::getInstance()->setSocketCloseable();
-    if(code == Cellular::OK) {
+    if(code == Cellular::CELL_OK) {
         printf("Success!\r\n");
     } else {
         printf("Error setting socket closeable [%d]\r\n", (int)code);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/utils/AxedaWrapper.cpp	Thu Dec 19 19:53:43 2013 +0000
@@ -0,0 +1,123 @@
+#include "AxedaWrapper.h"
+#include <string>
+#include <vector>
+#include <stdlib.h>
+
+using namespace mts;
+
+static const char* PATH_BASE = "/ammp/data/1/";
+
+AxedaWrapper::AxedaWrapper(const std::string& serial, const std::string& model, const std::string& host, int port) : _timeout(30000) {
+    _http_client = new HTTPClient();
+    _data = new MbedJSONValue();
+    
+    char buf[256];
+    std::string path = PATH_BASE + model + "/" + serial;
+    sprintf(buf, "http://%s:%d%s", host.c_str(), port, path.c_str());
+    _url = std::string(buf);
+}
+
+AxedaWrapper::~AxedaWrapper() {
+    delete _http_client;
+    delete _data;
+}
+
+void AxedaWrapper::addKvp(const std::string& key, const std::string& value) {
+    (*_data)[key] = value;
+}
+
+void AxedaWrapper::addKvp(const char* key, const char* value) {
+    (*_data)[std::string(key)] = value;
+}
+
+void AxedaWrapper::addKvp(const std::string& key, int value) {
+    (*_data)[key] = value;
+}
+
+void AxedaWrapper::addKvp(const char* key, int value) {
+    (*_data)[std::string(key)] = value;
+}
+
+void AxedaWrapper::addKvp(const std::string& key, double value) {
+    (*_data)[key] = value;
+}
+
+void AxedaWrapper::addKvp(const char* key, double value) {
+    (*_data)[std::string(key)] = value;
+}
+
+void AxedaWrapper::addKvp(const std::string& key, bool value) {
+    (*_data)[key] = value;
+}
+
+void AxedaWrapper::addKvp(const char* key, bool value) {
+    (*_data)[std::string(key)] = value;
+}
+
+void AxedaWrapper::deleteAllKvp() {
+    delete _data;
+    _data = new MbedJSONValue();
+}
+
+int AxedaWrapper::kvpMapSize() {
+    return _data->size();
+}
+
+bool AxedaWrapper::sendKvp(const std::string& key, const std::string& value) {
+    MbedJSONValue data;
+    data[key] = value;
+    return sendBase(data);
+}
+
+bool AxedaWrapper::sendKvp(const char* key, const char* value) {
+    MbedJSONValue data;
+    data[key] = value;
+    return sendBase(data);
+}
+
+bool AxedaWrapper::sendKvp(const std::string& key, int value) {
+    MbedJSONValue data;
+    data[key] = value;
+    return sendBase(data);
+}
+
+bool AxedaWrapper::sendKvp(const char* key, int value) {
+    MbedJSONValue data;
+    data[key] = value;
+    return sendBase(data);
+}
+
+bool AxedaWrapper::sendKvp(const std::string& key, double value) {
+    MbedJSONValue data;
+    data[key] = value;
+    return sendBase(data);
+}
+
+bool AxedaWrapper::sendKvp(const char* key, double value) {
+    MbedJSONValue data;
+    data[key] = value;
+    return sendBase(data);
+}
+
+bool AxedaWrapper::sendAllKvp(bool clear) {
+    bool ret = sendBase(_data);
+    if (ret && clear) {
+        deleteAllKvp();
+    }
+    return ret;
+}
+
+bool AxedaWrapper::sendBase(MbedJSONValue data) {
+    int ret;
+    char buf[512] = {0};
+    HTTPMap map;
+    HTTPText text(buf, sizeof(buf));
+    std::string data_str = data.serialize();
+    
+    map.put("data", data_str.c_str());
+    ret = _http_client->post(_url.c_str(), map, &text, _timeout);
+    if (ret != HTTP_OK) {
+        return false;
+    }
+    return true;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/utils/AxedaWrapper.h	Thu Dec 19 19:53:43 2013 +0000
@@ -0,0 +1,94 @@
+#ifndef AXEDAWRAPPER_H
+#define AXEDAWRAPPER_H
+
+#include "include_me.h"
+#include "HTTPClient.h"
+#include "HTTPMap.h"
+#include "MbedJSONValue.h"
+
+#define MAX_KVP 32
+namespace mts {
+    
+class AxedaWrapper {
+public:
+    /** Constructor
+    * Creates an AxedaWrapper object
+    *
+    * @param serial A made up serial number for your device.  It needs to be unique!
+    *               A good format to use is <your initials>-<a random string of numbers>,
+    *               e.g. "JTA-862653"
+    */
+    AxedaWrapper(const std::string& serial, const std::string& model = "mbed", const std::string& host = "dev6-connect.axeda.com", int port = 52689);
+    
+    /** Destructor
+    * Deletes the AxedaWrapper object and returns all allocated memory
+    */
+    ~AxedaWrapper();
+    
+    /** addKvp
+    * Adds a key-value pair to the internal map.
+    *
+    * @param key The "name" of the value.
+    * @param value The value to be stored.
+    */
+    void addKvp(const std::string& key, const std::string& value);
+    void addKvp(const char* key, const char* value);
+    void addKvp(const std::string& key, int value);
+    void addKvp(const char* key, int value);
+    void addKvp(const std::string& key, double value);
+    void addKvp(const char* key, double value);
+    void addKvp(const std::string& key, bool value);
+    void addKvp(const char* key, bool value);
+    
+    /** deleteAllKvp
+    * Removes all key-value pairs from the internal map.
+    * If the internal map is empty, no action is taken.
+    */
+    void deleteAllKvp();
+    
+    /** kvpMapSize
+    * @returns the current size of the map
+    */
+    int kvpMapSize();
+    
+    /** sendKvp
+    * Sends a key-value pair to the Axeda platform
+    * Specifically for the versions which take a double:
+    *       - the double value is formatted into a 256 byte buffer
+    *       - if the length of the string version of the value is greater than 255 bytes,
+    *         it will be cut off at 255 bytes (to leave room for the '\0' character)
+    *
+    * @param key The "name" of the value.
+    * @param value The value to be sent.
+    * @return true if the value was sent successfully, false otherwise
+    */
+    bool sendKvp(const std::string& key, const std::string& value);
+    bool sendKvp(const char* key, const char* value);
+    bool sendKvp(const std::string& key, int value);
+    bool sendKvp(const char* key, int value);
+    bool sendKvp(const std::string& key, double value);
+    bool sendKvp(const char* key, double value);
+    bool sendKvp(const std::string& key, bool value);
+    bool sendKvp(const char* key, bool value);
+    
+    /** sendAllKvp
+    * Sends all the key-value pairs in the internal map to the Axeda platform
+    *
+    * @param clear If true, clear the internal map if the send is successful,
+    *              if false, don't clear the internal map
+    * @return true if successful, false otherwise
+    */
+    bool sendAllKvp(bool clear = true);
+    
+private:
+    bool sendBase(MbedJSONValue data);
+    
+    HTTPClient* _http_client;
+    std::string _url;
+    MbedJSONValue* _data;
+    int _timeout;
+};
+
+}
+
+#endif
\ No newline at end of file
--- a/utils/MTSCircularBuffer.cpp	Thu Dec 19 16:54:09 2013 +0000
+++ b/utils/MTSCircularBuffer.cpp	Thu Dec 19 19:53:43 2013 +0000
@@ -3,6 +3,8 @@
 
 #include "MTSCircularBuffer.h"
 
+using namespace mts;
+
 MTSCircularBuffer::MTSCircularBuffer(int bufferSize) : bufferSize(bufferSize), readIndex(0), writeIndex(0), _threshold(-1), _op(Vars::GREATER)
 {
     buffer = new char[bufferSize];
--- a/utils/MTSCircularBuffer.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/utils/MTSCircularBuffer.h	Thu Dec 19 19:53:43 2013 +0000
@@ -4,6 +4,8 @@
 #include "mbed.h"
 #include "Vars.h"
 
+namespace mts {
+
 /** This class provides a circular byte buffer meant for temporary storage
 * during IO transactions.  It contains many of the common methods you
 * would expect from a circular buffer like read, write, and various
@@ -127,4 +129,6 @@
     void checkThreshold(); // private function that checks thresholds and processes notifications
 };
 
+}
+
 #endif /* MTSCIRCULARBUFFER_H */
\ No newline at end of file
--- a/utils/MTSText.cpp	Thu Dec 19 16:54:09 2013 +0000
+++ b/utils/MTSText.cpp	Thu Dec 19 19:53:43 2013 +0000
@@ -1,6 +1,8 @@
 
 #include "MTSText.h"
 
+using namespace mts;
+
 std::string Text::getLine(const std::string& source, const size_t& start, size_t& cursor) {
     char delimiters[2];
     delimiters[0] = '\n';
--- a/utils/MTSText.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/utils/MTSText.h	Thu Dec 19 19:53:43 2013 +0000
@@ -5,6 +5,8 @@
 #include <vector>
 #include <stddef.h>
 
+namespace mts {
+
 class Text {
     
     public:
@@ -18,4 +20,5 @@
         Text& operator=(const Text& other);
 };
 
+}
 #endif
--- a/utils/Vars.h	Thu Dec 19 16:54:09 2013 +0000
+++ b/utils/Vars.h	Thu Dec 19 19:53:43 2013 +0000
@@ -3,6 +3,8 @@
 
 #include <string>
 
+namespace mts {
+
 #ifndef MAX
 #define MAX(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
 #endif
@@ -27,6 +29,8 @@
     enum RelationalOperator {GREATER, LESS, EQUAL, GREATER_EQUAL, LESS_EQUAL};
 };
 
+}
+
 //Test Commit!!!
 
 #endif /* VARS_H */ 
\ No newline at end of file