Index: rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/Adafruit_MQTT.cpp
===================================================================
--- rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/Adafruit_MQTT.cpp	(revision 178)
+++ rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/Adafruit_MQTT.cpp	(revision 180)
@@ -35,4 +35,5 @@
     else
       DEBUG_PRINTER.print(" ");
+#if 0      
     DEBUG_PRINTER.print(F(" [0x"));
     if (buffer[i] < 0x10)
@@ -41,4 +42,5 @@
     DEBUG_PRINTER.print("], ");
     if (i % 8 == 7) DEBUG_PRINTER.println();
+#endif            
   }
   DEBUG_PRINTER.println();
Index: rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/Client_ESP8266.h
===================================================================
--- rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/Client_ESP8266.h	(revision 178)
+++ rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/Client_ESP8266.h	(revision 180)
@@ -23,9 +23,10 @@
 #include "ESP8266.h"
 
-#define ESP8266CLIENT_BUFFER_LEN  512
-
 class ESP8266Client: public Client, public ESP8266 {
-
   public:
+    ESP8266Client(void) {
+        pbuffer = &rx_buffer[0];
+    }
+    
     /*
      * @retval 0 : faild
@@ -34,21 +35,14 @@
     int connect(IPAddress ip, uint16_t port) {
         String ip_str;
-        bufferlen= 0;
-        ip_str.concat(ip[0]);
-        ip_str.concat(".");
-        ip_str.concat(ip[1]);
-        ip_str.concat(".");
-        ip_str.concat(ip[2]);
-        ip_str.concat(".");
+        ip_str.concat(ip[0]); ip_str.concat(".");
+        ip_str.concat(ip[1]); ip_str.concat(".");
+        ip_str.concat(ip[2]); ip_str.concat(".");
         ip_str.concat(ip[3]);
-        _connected = (createTCP(ip_str, port))? 1 : 0;        
-        return (int)_connected;
+        return (createTCP(ip_str, port))? 1 : 0;
     };
     
     int connect(const char *host, uint16_t port) {
         String ip_str(host);
-        bufferlen= 0;
-        _connected = (createTCP(ip_str, port))? 1 : 0;        
-        return (int)_connected;        
+        return (createTCP(ip_str, port))? 1 : 0;
     };
     
@@ -56,59 +50,41 @@
         if(send(&data, 1)){
             return 1;
-        }
-        else {
-            return 0;
-        }
+        }        
+        return 0;
     };
+    
     size_t write(const uint8_t *buf, size_t size){
         if(send(buf, size)){
             return size;
         }
-        else {
-            return 0;
-        }
-    };
-    int available(){
-        if (bufferlen > 0) {
-            return 1;
-        }
-        if (dataAvailable()) {
-            bufferlen = recv(buffer, ESP8266CLIENT_BUFFER_LEN);
-            pbuffer = buffer;
-            //In case of that data is available but it is not valid data(not +IPD,...),
-            //connection is closed by server.(send "CLOSED")
-            if(bufferlen == 0){
-                _connected = 0;
-                releaseTCP();
-                return 0;
-            }
-            return 1;
-        }
         return 0;
     };
+    
+    int available(){
+        return isDataAvailable();
+    };
+    
     int read(){
-        if (bufferlen == 0) {
-            bufferlen = recv(buffer, ESP8266CLIENT_BUFFER_LEN);
-            pbuffer = buffer;
+        uint8_t data;
+        if(recv(&data, 1) == 1) {
+            return data;
         }
-        if (bufferlen > 0){
-            bufferlen--;
-            return *pbuffer++;
-        }
-        else {
-            return (int)-1;
-        }            
+        return (int)-1;
     };
-    int read(uint8_t *buf, size_t size){return recv(buf, size);};
-    int peek(){return 1;};
+    
+    int read(uint8_t *buf, size_t size){
+        return recv(buf, size);
+    };
+    
+    int peek(){
+        return pbuffer->peek();
+    };
+    
     void flush(){};
     void stop(){releaseTCP();};
-    uint8_t connected(){return _connected;};
-    operator bool(){return (bool)(_connected == 1);};
+    uint8_t connected(){return (isConnected())? 1 : 0;};
+    operator bool(){return isConnected();};
   private:
-    uint8_t _connected;
-    uint8_t buffer[ESP8266CLIENT_BUFFER_LEN];
-    uint8_t bufferlen;
-    uint8_t *pbuffer;
+    ESP8266_RingBuffer *pbuffer;
 };
 
Index: rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/Milkcocoa.cpp
===================================================================
--- rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/Milkcocoa.cpp	(revision 178)
+++ rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/Milkcocoa.cpp	(revision 180)
@@ -35,5 +35,5 @@
 DataElement::DataElement(char *json_string) {
   paJsonObj = aJson.parse(json_string);
-  params = aJson.getObjectItem(paJsonObj, "params");    
+  params = aJson.getObjectItem(paJsonObj, "params");
 }
 
@@ -56,21 +56,24 @@
 }
 
-char *DataElement::getString(const char *key) {
+bool DataElement::getString(const char *key, char **pdata) {
   aJsonObject* obj = aJson.getObjectItem(params, key);
-  return obj->valuestring;
-}
-
-int DataElement::getInt(const char *key) {
+  if((obj == NULL) || (obj->type != aJson_String)) {return false;}
+  *pdata = obj->valuestring;    
+  return true;
+}
+
+bool DataElement::getInt(const char *key, int *pdata) {
+  aJsonObject* obj = aJson.getObjectItem(params, key);    
+  if((obj == NULL) || (obj->type != aJson_Int)) {return false;}
+  *pdata = obj->valueint;
+  return true;
+}
+
+bool DataElement::getFloat(const char *key, float *pdata) {
   aJsonObject* obj = aJson.getObjectItem(params, key);
-  if(obj == NULL)
-    Serial.println("obj is NULL");
-  return obj->valueint;
-}
-
-float DataElement::getFloat(const char *key) {
-  aJsonObject* obj = aJson.getObjectItem(params, key);
-  return obj->valuefloat;
-}
-
+  if((obj == NULL) || (obj->type != aJson_Float)) {return false;}
+  *pdata = obj->valuefloat;
+  return true;
+}
 
 char *DataElement::toCharArray() {
@@ -106,49 +109,76 @@
 }
 
-void Milkcocoa::connect() {
-  int ret;
+/*
+ *  tmout
+ *   1-   : Connect try time.
+ *   0    : retry Forever
+ *  Return code
+ *   0     : Success
+ *   other : Error code (see Adafruit_MQTT::connectErrorString()) 
+ */
+int8_t Milkcocoa::connect(int32_t tmout) {
+  int8_t ret;
+  int32_t retry = 0;
 
   if (mqtt->connected()) {
-    return;
-  }
-
-  Serial.print("Connecting to MQTT... ");
+    return 0;
+  }
+
+  MILKCOCOA_DEBUG_PRINTLN("Connecting to MQTT... ");
 
   while ((ret = mqtt->connect()) != 0) { // connect will return 0 for connected
-       Serial.println(mqtt->connectErrorString(ret));
-       Serial.println(ret);
-       Serial.println("Retrying MQTT connection in 5 seconds...");
-       mqtt->disconnect();
-       delay(5000);  // wait 5 seconds
-  }
-  Serial.println("MQTT Connected!");
-}
-
-bool Milkcocoa::push(const char *path, DataElement *pdataelement) {
+      mqtt->disconnect();
+      // Timeout
+      if ((tmout !=  0) && (++retry == tmout)) {
+          return ret;
+      }
+      delay(MILKCOCOA_CONNECT_DELAY_MS);
+  }
+  MILKCOCOA_DEBUG_PRINTLN("MQTT Connected!");
+
+  return 0;  
+}
+
+int8_t Milkcocoa::push(const char *path, DataElement *pdataelement, uint16_t timeout) {
   char topic[100];
-  bool ret;
+  int8_t ret;
   char *send_array;
+
+  if((ret = connect(timeout)) != 0){return ret;}
+    
   sprintf(topic, "%s/%s/push", app_id, path);
   Adafruit_MQTT_Publish pushPublisher = Adafruit_MQTT_Publish(mqtt, topic);
   send_array = pdataelement->toCharArray();
-  ret = pushPublisher.publish(send_array);
+  ret = (pushPublisher.publish(send_array))? 0 : MILKCOCOA_PUSH_ERRORNO;
   free(send_array);
   return ret;
 }
 
-bool Milkcocoa::send(const char *path, DataElement *pdataelement) {
+int8_t Milkcocoa::send(const char *path, DataElement *pdataelement, uint16_t timeout) {
   char topic[100];
-  bool ret;
-  char *send_array;    
+  int8_t ret;
+  char *send_array;
+
+  if((ret = connect(timeout)) != 0){return ret;}
+    
   sprintf(topic, "%s/%s/send", app_id, path);
   Adafruit_MQTT_Publish pushPublisher = Adafruit_MQTT_Publish(mqtt, topic);
   send_array = pdataelement->toCharArray();
-  ret = pushPublisher.publish(send_array);
+  ret = (pushPublisher.publish(send_array))? 0 : MILKCOCOA_PUSH_ERRORNO;
   free(send_array);    
   return ret;
 }
 
-void Milkcocoa::loop() {
-  connect();
+/*
+ *  Return code
+ *   0     : Success
+ *   other : Error code
+ *           -1,1-6 : see Adafruit_MQTT::connectErrorString()
+ */
+int8_t Milkcocoa::loop(uint16_t timeout) {
+  int8_t ret;
+
+  if((ret = connect(timeout)) != 0){return ret;}
+   
   Adafruit_MQTT_Subscribe *subscription;
   while ((subscription = mqtt->readSubscription(1000))) {
@@ -161,4 +191,6 @@
     }
   }
+
+  return 0;  
 }
 
Index: rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/Milkcocoa.h
===================================================================
--- rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/Milkcocoa.h	(revision 178)
+++ rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/Milkcocoa.h	(revision 180)
@@ -32,4 +32,22 @@
 
 #define MILKCOCOA_SUBSCRIBERS 8
+#define MILKCOCOA_CONNECT_DELAY_MS 5000
+
+#define MILKCOCOA_PUSH_ERRORNO -2
+#define MILKCOCOA_SEND_ERRORNO -2
+
+//#define MILKCOCOA_DEBUG
+
+#define DEBUG_PRINTER Serial
+
+#ifdef MILKCOCOA_DEBUG
+  #define MILKCOCOA_DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); }
+  #define MILKCOCOA_DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); }
+  #define MILKCOCOA_DEBUG_PRINTBUFFER(buffer, len) { printBuffer(buffer, len); }
+#else
+  #define MILKCOCOA_DEBUG_PRINT(...) {}
+  #define MILKCOCOA_DEBUG_PRINTLN(...) {}
+  #define MILKCOCOA_DEBUG_PRINTBUFFER(buffer, len) {}
+#endif
 
 class DataElement {
@@ -42,7 +60,7 @@
     void setValue(const char *key, double v);
     char *toCharArray();
-    char *getString(const char *key);
-    int getInt(const char *key);
-    float getFloat(const char *key);
+    bool getString(const char *key, char **pdata);
+    bool getInt(const char *key, int *pdata);
+    bool getFloat(const char *key, float *pdata);
     
   private:
@@ -67,10 +85,11 @@
   Milkcocoa(Client *client, const char *host, uint16_t port, const char *_app_id, const char *client_id, const char *_session);
   static Milkcocoa* createWithApiKey(Client *client, const char *host, uint16_t port, const char *app_id, const char *client_id, const char *key, const char *secret);
-  void connect();
-  void loop();
-  bool push(const char *path, DataElement *pdataelement);
-  bool send(const char *path, DataElement *pdataelement);
+  int8_t connect(int32_t tmout = 0);
+  int8_t loop(uint16_t timeout = 0);
+  int8_t push(const char *path, DataElement *pdataelement, uint16_t timeout = 0);
+  int8_t send(const char *path, DataElement *pdataelement, uint16_t timeout = 0);
   bool on(const char *path, const char *event, GeneralFunction cb);
-
+  const __FlashStringHelper* connectErrorString(int8_t code) {return mqtt->connectErrorString(code);};
+  const __FlashStringHelper* pushErrorString(int8_t code) {if(code == MILKCOCOA_PUSH_ERRORNO) return F("Push error"); return mqtt->connectErrorString(code);};
 
 private:
Index: rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/include/Adafruit/Adafruit_MQTT_CC3000.h
===================================================================
--- rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/include/Adafruit/Adafruit_MQTT_CC3000.h	(revision 178)
+++ 	(revision )
@@ -1,157 +1,0 @@
-// The MIT License (MIT)
-//
-// Copyright (c) 2015 Adafruit Industries
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-#ifndef _ADAFRUIT_MQTT_CC3000_H_
-#define _ADAFRUIT_MQTT_CC3000_H_
-
-#include <Adafruit_SleepyDog.h>
-#include <Adafruit_CC3000.h>
-#include "Adafruit_MQTT.h"
-
-
-// delay in ms between calls of available()
-#define MQTT_CC3000_INTERAVAILDELAY 10
-
-
-// CC3000-specific version of the Adafruit_MQTT class.
-// Note that this is defined as a header-only class to prevent issues with using
-// the library on non-CC3000 platforms (since Arduino will include all .cpp files
-// in the compilation of the library).
-class Adafruit_MQTT_CC3000 : public Adafruit_MQTT {
- public:
-  Adafruit_MQTT_CC3000(Adafruit_CC3000 *cc3k, const char *server, uint16_t port,
-                       const char *cid, const char *user, const char *pass):
-    Adafruit_MQTT(server, port, cid, user, pass),
-    cc3000(cc3k)
-  {}
-
-  bool connectServer() {
-    uint32_t ip = 0;
-
-    Watchdog.reset();
-
-    // look up IP address
-    if (serverip == 0) {
-      // Try looking up the website's IP address using CC3K's built in getHostByName
-      strcpy_P((char *)buffer, servername);
-      Serial.print((char *)buffer); Serial.print(F(" -> "));
-      uint8_t dnsretries = 5;
-
-      Watchdog.reset();
-      while (ip == 0) {
-        if (! cc3000->getHostByName((char *)buffer, &ip)) {
-          Serial.println(F("Couldn't resolve!"));
-          dnsretries--;
-          Watchdog.reset();
-        }
-        //Serial.println("OK"); Serial.println(ip, HEX);
-        if (!dnsretries) return false;
-        delay(500);
-      }
-
-      serverip = ip;
-      cc3000->printIPdotsRev(serverip);
-      Serial.println();
-    }
-
-    Watchdog.reset();
-
-    // connect to server
-    DEBUG_PRINTLN(F("Connecting to TCP"));
-    mqttclient = cc3000->connectTCP(serverip, portnum);
-
-    return mqttclient.connected();
-  }
-
-  bool disconnect() {
-    if (connected()) {
-      return (mqttclient.close() == 0);
-    }
-    else {
-      return true;
-    }
-  }
-
-  bool connected() {
-    return mqttclient.connected();
-  }
-
-  uint16_t readPacket(uint8_t *buffer, uint8_t maxlen, int16_t timeout,
-                      bool checkForValidPubPacket = false) {
-    /* Read data until either the connection is closed, or the idle timeout is reached. */
-    uint16_t len = 0;
-    int16_t t = timeout;
-
-    while (mqttclient.connected() && (timeout >= 0)) {
-      //DEBUG_PRINT('.');
-      while (mqttclient.available()) {
-        //DEBUG_PRINT('!');
-        char c = mqttclient.read();
-        timeout = t;  // reset the timeout
-        buffer[len] = c;
-        //DEBUG_PRINTLN((uint8_t)c, HEX);
-        len++;
-        if (len == maxlen) {  // we read all we want, bail
-          DEBUG_PRINT(F("Read packet:\t"));
-          DEBUG_PRINTBUFFER(buffer, len);
-          return len;
-        }
-
-        // special case where we just one one publication packet at a time
-        if (checkForValidPubPacket) {
-          if ((buffer[0] == (MQTT_CTRL_PUBLISH << 4)) && (buffer[1] == len-2)) {
-            // oooh a valid publish packet!
-            DEBUG_PRINT(F("Read PUBLISH packet:\t"));
-            DEBUG_PRINTBUFFER(buffer, len);
-            return len;
-          }
-        }
-      }
-      Watchdog.reset();
-      timeout -= MQTT_CC3000_INTERAVAILDELAY;
-      delay(MQTT_CC3000_INTERAVAILDELAY);
-    }
-    return len;
-  }
-
-  bool sendPacket(uint8_t *buffer, uint8_t len) {
-    if (mqttclient.connected()) {
-      uint16_t ret = mqttclient.write(buffer, len);
-      DEBUG_PRINT(F("sendPacket returned: ")); DEBUG_PRINTLN(ret);
-      if (ret != len) {
-        DEBUG_PRINTLN("Failed to send complete packet.")
-        return false;
-      }
-    } else {
-      DEBUG_PRINTLN(F("Connection failed!"));
-      return false;
-    }
-    return true;
-  }
-
- private:
-  uint32_t serverip;
-  Adafruit_CC3000 *cc3000;
-  Adafruit_CC3000_Client mqttclient;
-};
-
-
-#endif
Index: rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/include/Adafruit/Adafruit_MQTT_FONA.h
===================================================================
--- rtos_arduino/trunk/arduino_lib/libraries/Milkcocoa_Arduino_SDK/include/Adafruit/Adafruit_MQTT_FONA.h	(revision 178)
+++ 	(revision )
@@ -1,144 +1,0 @@
-// The MIT License (MIT)
-//
-// Copyright (c) 2015 Adafruit Industries
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-#ifndef _ADAFRUIT_MQTT_FONA_H_
-#define _ADAFRUIT_MQTT_FONA_H_
-
-#include <Adafruit_FONA.h>
-#include "Adafruit_MQTT.h"
-
-#define MQTT_FONA_INTERAVAILDELAY 100
-#define MQTT_FONA_QUERYDELAY 500
-
-
-// FONA-specific version of the Adafruit_MQTT class.
-// Note that this is defined as a header-only class to prevent issues with using
-// the library on non-FONA platforms (since Arduino will include all .cpp files
-// in the compilation of the library).
-class Adafruit_MQTT_FONA : public Adafruit_MQTT {
- public:
-  Adafruit_MQTT_FONA(Adafruit_FONA *f, const char *server, uint16_t port,
-                       const char *cid, const char *user, const char *pass):
-    Adafruit_MQTT(server, port, cid, user, pass),
-    fona(f)
-  {}
-
-  bool connectServer() {
-    char server[40];
-    strncpy_P(server, servername, 40);
-    Watchdog.reset();
-
-    // connect to server
-    DEBUG_PRINTLN(F("Connecting to TCP"));
-    return fona->TCPconnect(server, portnum);
-  }
-
-  bool disconnect() {
-    return fona->TCPclose();
-  }
-
-  bool connected() {
-    // Return true if connected, false if not connected.
-    return fona->TCPconnected();
-  }
-
-  uint16_t readPacket(uint8_t *buffer, uint8_t maxlen, int16_t timeout,
-                      bool checkForValidPubPacket = false) {
-    uint8_t *buffp = buffer;
-    DEBUG_PRINTLN(F("Reading a packet.."));
-
-    if (!fona->TCPconnected()) return 0;
-
-
-    /* Read data until either the connection is closed, or the idle timeout is reached. */
-    uint16_t len = 0;
-    int16_t t = timeout;
-    uint16_t avail;
-
-    while (fona->TCPconnected() && (timeout >= 0)) {
-      DEBUG_PRINT('.');
-      while (avail = fona->TCPavailable()) {
-        DEBUG_PRINT('!');
-
-        if (len + avail > maxlen) {
-	  avail = maxlen - len;
-	  if (avail == 0) return len;
-        }
-
-        // try to read the data into the end of the pointer
-        if (! fona->TCPread(buffp, avail)) return len;
-
-        // read it! advance pointer
-        buffp += avail;
-        len += avail;
-        timeout = t;  // reset the timeout
-
-        //DEBUG_PRINTLN((uint8_t)c, HEX);
-
-        if (len == maxlen) {  // we read all we want, bail
-          DEBUG_PRINT(F("Read packet:\t"));
-          DEBUG_PRINTBUFFER(buffer, len);
-    return len;
-        }
-
-        // special case where we just one one publication packet at a time
-        if (checkForValidPubPacket) {
-          if ((buffer[0] == (MQTT_CTRL_PUBLISH << 4)) && (buffer[1] == len-2)) {
-            // oooh a valid publish packet!
-            DEBUG_PRINT(F("Read PUBLISH packet:\t"));
-            DEBUG_PRINTBUFFER(buffer, len);
-            return len;
-          }
-        }
-
-      }
-      Watchdog.reset();
-      timeout -= MQTT_FONA_INTERAVAILDELAY;
-      timeout -= MQTT_FONA_QUERYDELAY; // this is how long it takes to query the FONA for avail()
-      delay(MQTT_FONA_INTERAVAILDELAY);
-    }
-
-    return len;
-  }
-
-  bool sendPacket(uint8_t *buffer, uint8_t len) {
-    DEBUG_PRINTLN(F("Writing packet"));
-    if (fona->TCPconnected()) {
-      boolean ret = fona->TCPsend((char *)buffer, len);
-      //DEBUG_PRINT(F("sendPacket returned: ")); DEBUG_PRINTLN(ret);
-      if (!ret) {
-        DEBUG_PRINTLN("Failed to send packet.")
-        return false;
-      }
-    } else {
-      DEBUG_PRINTLN(F("Connection failed!"));
-      return false;
-    }
-    return true;
-  }
-
- private:
-  uint32_t serverip;
-  Adafruit_FONA *fona;
-};
-
-
-#endif
