Cleanup after XBee merge
This commit is contained in:
		| @@ -9,7 +9,7 @@ | |||||||
| #ifndef TinyGsmClient_h | #ifndef TinyGsmClient_h | ||||||
| #define TinyGsmClient_h | #define TinyGsmClient_h | ||||||
|  |  | ||||||
| #if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_SIM900) | #if   defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_SIM900) | ||||||
|   #include <TinyGsmClientSIM800.h> |   #include <TinyGsmClientSIM800.h> | ||||||
|   typedef TinyGsmSim800 TinyGsm; |   typedef TinyGsmSim800 TinyGsm; | ||||||
|   typedef TinyGsmSim800::GsmClient TinyGsmClient; |   typedef TinyGsmSim800::GsmClient TinyGsmClient; | ||||||
|   | |||||||
| @@ -348,17 +348,6 @@ public: | |||||||
|     return false; |     return false; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /* |  | ||||||
|    * WiFi functions |  | ||||||
|    */ |  | ||||||
|   bool networkConnect(const char* ssid, const char* pwd) { |  | ||||||
|     return false; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   bool networkDisconnect() { |  | ||||||
|     return false; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   /* |   /* | ||||||
|    * GPRS functions |    * GPRS functions | ||||||
|    */ |    */ | ||||||
| @@ -645,7 +634,7 @@ public: | |||||||
|     streamWrite("AT", cmd..., GSM_NL); |     streamWrite("AT", cmd..., GSM_NL); | ||||||
|     stream.flush(); |     stream.flush(); | ||||||
|     TINY_GSM_YIELD(); |     TINY_GSM_YIELD(); | ||||||
|     // DBG("### AT:", cmd...); |     //DBG("### AT:", cmd...); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // TODO: Optimize this! |   // TODO: Optimize this! | ||||||
| @@ -710,7 +699,7 @@ public: | |||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } while (millis() - startMillis < timeout); |     } while (millis() - startMillis < timeout); | ||||||
|   finish: | finish: | ||||||
|     if (!index) { |     if (!index) { | ||||||
|       data.trim(); |       data.trim(); | ||||||
|       if (data.length()) { |       if (data.length()) { | ||||||
|   | |||||||
| @@ -212,9 +212,6 @@ public: | |||||||
|     return autoBaud(); |     return autoBaud(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /* |  | ||||||
|    * SIM card functions |  | ||||||
|    */ |  | ||||||
|  |  | ||||||
|   /* |   /* | ||||||
|    * Generic network functions |    * Generic network functions | ||||||
| @@ -311,17 +308,6 @@ public: | |||||||
|     return res; |     return res; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /* |  | ||||||
|    * GPRS functions |  | ||||||
|    */ |  | ||||||
|   bool gprsConnect(const char* apn, const char* user, const char* pwd) { |  | ||||||
|     return false; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   bool gprsDisconnect() { |  | ||||||
|     return false; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
| private: | private: | ||||||
|  |  | ||||||
|   int modemConnect(const char* host, uint16_t port, uint8_t mux) { |   int modemConnect(const char* host, uint16_t port, uint8_t mux) { | ||||||
| @@ -330,7 +316,7 @@ private: | |||||||
|                            GFP(GSM_OK), |                            GFP(GSM_OK), | ||||||
|                            GFP(GSM_ERROR), |                            GFP(GSM_ERROR), | ||||||
|                            GF(GSM_NL "ALREADY CONNECT" GSM_NL)); |                            GF(GSM_NL "ALREADY CONNECT" GSM_NL)); | ||||||
|     waitResponse(100, GF("1,CONNECT")); |     waitResponse(100, GF("1,CONNECT")); // TODO | ||||||
|     return (1 == rsp); |     return (1 == rsp); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -383,7 +369,7 @@ public: | |||||||
|     streamWrite("AT", cmd..., GSM_NL); |     streamWrite("AT", cmd..., GSM_NL); | ||||||
|     stream.flush(); |     stream.flush(); | ||||||
|     TINY_GSM_YIELD(); |     TINY_GSM_YIELD(); | ||||||
|     // DBG("### AT:", cmd...); |     //DBG("### AT:", cmd...); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // TODO: Optimize this! |   // TODO: Optimize this! | ||||||
| @@ -444,7 +430,7 @@ public: | |||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } while (millis() - startMillis < timeout); |     } while (millis() - startMillis < timeout); | ||||||
|   finish: | finish: | ||||||
|     if (!index) { |     if (!index) { | ||||||
|       data.trim(); |       data.trim(); | ||||||
|       if (data.length()) { |       if (data.length()) { | ||||||
|   | |||||||
| @@ -357,17 +357,6 @@ public: | |||||||
|     return false; |     return false; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /* |  | ||||||
|    * WiFi functions |  | ||||||
|    */ |  | ||||||
|   bool networkConnect(const char* ssid, const char* pwd) { |  | ||||||
|     return false; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   bool networkDisconnect() { |  | ||||||
|     return false; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   /* |   /* | ||||||
|    * GPRS functions |    * GPRS functions | ||||||
|    */ |    */ | ||||||
| @@ -632,7 +621,7 @@ public: | |||||||
|     streamWrite("AT", cmd..., GSM_NL); |     streamWrite("AT", cmd..., GSM_NL); | ||||||
|     stream.flush(); |     stream.flush(); | ||||||
|     TINY_GSM_YIELD(); |     TINY_GSM_YIELD(); | ||||||
|     // DBG("### AT:", cmd...); |     //DBG("### AT:", cmd...); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // TODO: Optimize this! |   // TODO: Optimize this! | ||||||
| @@ -698,7 +687,7 @@ public: | |||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } while (millis() - startMillis < timeout); |     } while (millis() - startMillis < timeout); | ||||||
|   finish: | finish: | ||||||
|     if (!index) { |     if (!index) { | ||||||
|       data.trim(); |       data.trim(); | ||||||
|       if (data.length()) { |       if (data.length()) { | ||||||
|   | |||||||
| @@ -9,8 +9,8 @@ | |||||||
| #ifndef TinyGsmClientSIM800_h | #ifndef TinyGsmClientSIM800_h | ||||||
| #define TinyGsmClientSIM800_h | #define TinyGsmClientSIM800_h | ||||||
|  |  | ||||||
| // #define TINY_GSM_DEBUG Serial | //#define TINY_GSM_DEBUG Serial | ||||||
| // #define TINY_GSM_USE_HEX | //#define TINY_GSM_USE_HEX | ||||||
|  |  | ||||||
| #if !defined(TINY_GSM_RX_BUFFER) | #if !defined(TINY_GSM_RX_BUFFER) | ||||||
|   #define TINY_GSM_RX_BUFFER 64 |   #define TINY_GSM_RX_BUFFER 64 | ||||||
| @@ -426,17 +426,6 @@ public: | |||||||
|     return false; |     return false; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /* |  | ||||||
|    * WiFi functions |  | ||||||
|    */ |  | ||||||
|   bool networkConnect(const char* ssid, const char* pwd) { |  | ||||||
|     return false; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   bool networkDisconnect() { |  | ||||||
|     return false; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   /* |   /* | ||||||
|    * GPRS functions |    * GPRS functions | ||||||
|    */ |    */ | ||||||
| @@ -449,11 +438,11 @@ public: | |||||||
|     sendAT(GF("+SAPBR=3,1,\"APN\",\""), apn, '"'); |     sendAT(GF("+SAPBR=3,1,\"APN\",\""), apn, '"'); | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|  |  | ||||||
|     if (user) { |     if (user && strlen(user) > 0) { | ||||||
|       sendAT(GF("+SAPBR=3,1,\"USER\",\""), user, '"'); |       sendAT(GF("+SAPBR=3,1,\"USER\",\""), user, '"'); | ||||||
|       waitResponse(); |       waitResponse(); | ||||||
|     } |     } | ||||||
|     if (pwd) { |     if (pwd && strlen(pwd) > 0) { | ||||||
|       sendAT(GF("+SAPBR=3,1,\"PWD\",\""), pwd, '"'); |       sendAT(GF("+SAPBR=3,1,\"PWD\",\""), pwd, '"'); | ||||||
|       waitResponse(); |       waitResponse(); | ||||||
|     } |     } | ||||||
| @@ -868,7 +857,7 @@ public: | |||||||
|     streamWrite("AT", cmd..., GSM_NL); |     streamWrite("AT", cmd..., GSM_NL); | ||||||
|     stream.flush(); |     stream.flush(); | ||||||
|     TINY_GSM_YIELD(); |     TINY_GSM_YIELD(); | ||||||
|     DBG("### AT:", cmd...); |     //DBG("### AT:", cmd...); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // TODO: Optimize this! |   // TODO: Optimize this! | ||||||
| @@ -910,7 +899,7 @@ public: | |||||||
|           String mode = stream.readStringUntil(','); |           String mode = stream.readStringUntil(','); | ||||||
|           if (mode.toInt() == 1) { |           if (mode.toInt() == 1) { | ||||||
|             int mux = stream.readStringUntil('\n').toInt(); |             int mux = stream.readStringUntil('\n').toInt(); | ||||||
|             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT) { |             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|               sockets[mux]->got_data = true; |               sockets[mux]->got_data = true; | ||||||
|             } |             } | ||||||
|             data = ""; |             data = ""; | ||||||
| @@ -921,7 +910,7 @@ public: | |||||||
|           int nl = data.lastIndexOf(GSM_NL, data.length()-8); |           int nl = data.lastIndexOf(GSM_NL, data.length()-8); | ||||||
|           int coma = data.indexOf(',', nl+2); |           int coma = data.indexOf(',', nl+2); | ||||||
|           int mux = data.substring(nl+2, coma).toInt(); |           int mux = data.substring(nl+2, coma).toInt(); | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT) { |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|             sockets[mux]->sock_connected = false; |             sockets[mux]->sock_connected = false; | ||||||
|           } |           } | ||||||
|           data = ""; |           data = ""; | ||||||
| @@ -929,7 +918,7 @@ public: | |||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } while (millis() - startMillis < timeout); |     } while (millis() - startMillis < timeout); | ||||||
|   finish: | finish: | ||||||
|     if (!index) { |     if (!index) { | ||||||
|       data.trim(); |       data.trim(); | ||||||
|       if (data.length()) { |       if (data.length()) { | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /** | /** | ||||||
|  * @file       TinyWiFiClientESP8266.h |  * @file       TinyGsmClientXBee.h | ||||||
|  * @author     Volodymyr Shymanskyy |  * @author     Volodymyr Shymanskyy | ||||||
|  * @license    LGPL-3.0 |  * @license    LGPL-3.0 | ||||||
|  * @copyright  Copyright (c) 2016 Volodymyr Shymanskyy |  * @copyright  Copyright (c) 2016 Volodymyr Shymanskyy | ||||||
| @@ -47,11 +47,6 @@ enum RegStatus { | |||||||
| class TinyGsm | class TinyGsm | ||||||
| { | { | ||||||
|  |  | ||||||
| public: |  | ||||||
|   TinyGsm(Stream& stream) |  | ||||||
|     : stream(stream) |  | ||||||
|   {} |  | ||||||
|  |  | ||||||
| public: | public: | ||||||
|  |  | ||||||
| class GsmClient : public Client | class GsmClient : public Client | ||||||
| @@ -114,6 +109,8 @@ public: | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   virtual size_t write(const uint8_t *buf, size_t size) { |   virtual size_t write(const uint8_t *buf, size_t size) { | ||||||
|  |     TINY_GSM_YIELD(); | ||||||
|  |     //at->maintain(); | ||||||
|     return at->modemSend(buf, size, mux); |     return at->modemSend(buf, size, mux); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -122,6 +119,7 @@ public: | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   virtual int available() { |   virtual int available() { | ||||||
|  |     TINY_GSM_YIELD(); | ||||||
|     return at->stream.available(); |     return at->stream.available(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -144,6 +142,13 @@ public: | |||||||
|     return sock_connected; |     return sock_connected; | ||||||
|   } |   } | ||||||
|   virtual operator bool() { return connected(); } |   virtual operator bool() { return connected(); } | ||||||
|  |  | ||||||
|  |   /* | ||||||
|  |    * Extended API | ||||||
|  |    */ | ||||||
|  |  | ||||||
|  |   String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED; | ||||||
|  |  | ||||||
| private: | private: | ||||||
|   TinyGsm*      at; |   TinyGsm*      at; | ||||||
|   uint8_t       mux; |   uint8_t       mux; | ||||||
| @@ -152,6 +157,12 @@ private: | |||||||
|  |  | ||||||
| public: | public: | ||||||
|  |  | ||||||
|  |   TinyGsm(Stream& stream) | ||||||
|  |     : stream(stream) | ||||||
|  |   { | ||||||
|  |     memset(sockets, 0, sizeof(sockets)); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   /* |   /* | ||||||
|    * Basic functions |    * Basic functions | ||||||
|    */ |    */ | ||||||
| @@ -360,9 +371,9 @@ public: | |||||||
|  |  | ||||||
|     return true; |     return true; | ||||||
|  |  | ||||||
|     fail: | fail: | ||||||
|       exitCommand(); |     exitCommand(); | ||||||
|       return false; |     return false; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   bool networkDisconnect() { |   bool networkDisconnect() { | ||||||
| @@ -440,6 +451,7 @@ public: | |||||||
|  |  | ||||||
|  |  | ||||||
| private: | private: | ||||||
|  |  | ||||||
|   int modemConnect(const char* host, uint16_t port, uint8_t mux = 0) { |   int modemConnect(const char* host, uint16_t port, uint8_t mux = 0) { | ||||||
|     sendAT(GF("LA"), host); |     sendAT(GF("LA"), host); | ||||||
|     String strIP; strIP.reserve(16); |     String strIP; strIP.reserve(16); | ||||||
| @@ -495,7 +507,10 @@ private: | |||||||
|     return 1 == res; |     return 1 == res; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /* Private Utilities */ | public: | ||||||
|  |  | ||||||
|  |   /* Utilities */ | ||||||
|  |  | ||||||
|   template<typename T> |   template<typename T> | ||||||
|   void streamWrite(T last) { |   void streamWrite(T last) { | ||||||
|     stream.print(last); |     stream.print(last); | ||||||
| @@ -520,8 +535,7 @@ private: | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   void streamClear(void) { |   void streamClear(void) { | ||||||
|     while (stream.available()) |     while (stream.available()) { streamRead(); } | ||||||
|     {streamRead();} |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   bool commandMode(void) { |   bool commandMode(void) { | ||||||
| @@ -548,7 +562,7 @@ private: | |||||||
|     streamWrite("AT", cmd..., GSM_NL); |     streamWrite("AT", cmd..., GSM_NL); | ||||||
|     stream.flush(); |     stream.flush(); | ||||||
|     TINY_GSM_YIELD(); |     TINY_GSM_YIELD(); | ||||||
|     DBG(">>> AT ", cmd..., "\r\n"); |     //DBG("### AT:", cmd...); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // TODO: Optimize this! |   // TODO: Optimize this! | ||||||
| @@ -589,16 +603,17 @@ private: | |||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } while (millis() - startMillis < timeout); |     } while (millis() - startMillis < timeout); | ||||||
|   finish: | finish: | ||||||
|     if (!index) { |     if (!index) { | ||||||
|       data.trim(); |       data.trim(); | ||||||
|       data.replace(GSM_NL GSM_NL, GSM_NL); |       data.replace(GSM_NL GSM_NL, GSM_NL); | ||||||
|       data.replace(GSM_NL, "\r\n" "    "); |       data.replace(GSM_NL, "\r\n" "    "); | ||||||
|       if (data.length()) { |       if (data.length()) { | ||||||
|         DBG("### Unhandled:", data, "\r\n"); |         DBG("### Unhandled:", data, "\r\n"); | ||||||
|     } else DBG("### NO RESPONSE!\r\n"); |       } else { | ||||||
|     } |         DBG("### NO RESPONSE!\r\n"); | ||||||
|     else { |       } | ||||||
|  |     } else { | ||||||
|       data.trim(); |       data.trim(); | ||||||
|       data.replace(GSM_NL GSM_NL, GSM_NL); |       data.replace(GSM_NL GSM_NL, GSM_NL); | ||||||
|       data.replace(GSM_NL, "\r\n    "); |       data.replace(GSM_NL, "\r\n    "); | ||||||
|   | |||||||
| @@ -46,7 +46,6 @@ namespace { | |||||||
|   template<typename T> |   template<typename T> | ||||||
|   static void DBG(T last) { |   static void DBG(T last) { | ||||||
|     TINY_GSM_DEBUG.println(last); |     TINY_GSM_DEBUG.println(last); | ||||||
|     // TINY_GSM_DEBUG.print(last); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template<typename T, typename... Args> |   template<typename T, typename... Args> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user