Clean up
This commit is contained in:
		@@ -48,20 +48,20 @@
 | 
			
		||||
  #define TINY_GSM_MODEM_HAS_GPRS
 | 
			
		||||
  #include <TinyGsmClientA6.h>
 | 
			
		||||
  typedef TinyGsmA6 TinyGsm;
 | 
			
		||||
  typedef TinyGsm::GsmClient TinyGsmClient;
 | 
			
		||||
  typedef TinyGsmA6::GsmClient TinyGsmClient;
 | 
			
		||||
 | 
			
		||||
#elif defined(TINY_GSM_MODEM_M590)
 | 
			
		||||
  #define TINY_GSM_MODEM_HAS_GPRS
 | 
			
		||||
  #include <TinyGsmClientM590.h>
 | 
			
		||||
  typedef TinyGsmM590 TinyGsm;
 | 
			
		||||
  typedef TinyGsm::GsmClient TinyGsmClient;
 | 
			
		||||
  typedef TinyGsmM590::GsmClient TinyGsmClient;
 | 
			
		||||
 | 
			
		||||
#elif defined(TINY_GSM_MODEM_ESP8266)
 | 
			
		||||
  #define TINY_GSM_MODEM_HAS_WIFI
 | 
			
		||||
  #include <TinyGsmClientESP8266.h>
 | 
			
		||||
  typedef TinyGsmESP8266 TinyGsm;
 | 
			
		||||
  typedef TinyGsm::GsmClient TinyGsmClient;
 | 
			
		||||
  typedef TinyGsm::GsmClientSecure TinyGsmClientSecure;
 | 
			
		||||
  typedef TinyGsmESP8266::GsmClient TinyGsmClient;
 | 
			
		||||
  typedef TinyGsmESP8266::GsmClientSecure TinyGsmClientSecure;
 | 
			
		||||
 | 
			
		||||
#elif defined(TINY_GSM_MODEM_XBEE)
 | 
			
		||||
  #define TINY_GSM_MODEM_HAS_GPRS
 | 
			
		||||
@@ -74,7 +74,8 @@
 | 
			
		||||
#elif defined(TINY_GSM_MODEM_M95)
 | 
			
		||||
  #define TINY_GSM_MODEM_HAS_GPRS
 | 
			
		||||
  #include <TinyGsmClientM95.h>
 | 
			
		||||
  typedef TinyGsm::GsmClient TinyGsmClient;
 | 
			
		||||
  typedef TinyGsmM95 TinyGsm;
 | 
			
		||||
  typedef TinyGsmM95::GsmClient TinyGsmClient;
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
  #error "Please define GSM modem model"
 | 
			
		||||
 
 | 
			
		||||
@@ -38,21 +38,15 @@ enum RegStatus {
 | 
			
		||||
  REG_UNKNOWN      = 4,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//                       Declaration of the TinyGsmA6 Class
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TinyGsmA6
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//                          The A6 Client Class
 | 
			
		||||
@@ -60,6 +54,8 @@ public:
 | 
			
		||||
//============================================================================//
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
class GsmClient : public Client
 | 
			
		||||
{
 | 
			
		||||
  friend class TinyGsmA6;
 | 
			
		||||
@@ -343,10 +339,10 @@ public:
 | 
			
		||||
      int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"));
 | 
			
		||||
      waitResponse();
 | 
			
		||||
      switch (status) {
 | 
			
		||||
      case 2:
 | 
			
		||||
      case 3:  return SIM_LOCKED;
 | 
			
		||||
      case 1:  return SIM_READY;
 | 
			
		||||
      default: return SIM_ERROR;
 | 
			
		||||
        case 2:
 | 
			
		||||
        case 3:  return SIM_LOCKED;
 | 
			
		||||
        case 1:  return SIM_READY;
 | 
			
		||||
        default: return SIM_ERROR;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return SIM_ERROR;
 | 
			
		||||
@@ -370,16 +366,16 @@ public:
 | 
			
		||||
   * Generic network functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
   RegStatus getRegistrationStatus() {
 | 
			
		||||
     sendAT(GF("+CREG?"));
 | 
			
		||||
     if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
 | 
			
		||||
       return REG_UNKNOWN;
 | 
			
		||||
     }
 | 
			
		||||
     streamSkipUntil(','); // Skip format (0)
 | 
			
		||||
     int status = stream.readStringUntil('\n').toInt();
 | 
			
		||||
     waitResponse();
 | 
			
		||||
     return (RegStatus)status;
 | 
			
		||||
   }
 | 
			
		||||
  RegStatus getRegistrationStatus() {
 | 
			
		||||
    sendAT(GF("+CREG?"));
 | 
			
		||||
    if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
 | 
			
		||||
      return REG_UNKNOWN;
 | 
			
		||||
    }
 | 
			
		||||
    streamSkipUntil(','); // Skip format (0)
 | 
			
		||||
    int status = stream.readStringUntil('\n').toInt();
 | 
			
		||||
    waitResponse();
 | 
			
		||||
    return (RegStatus)status;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  int getSignalQuality() {
 | 
			
		||||
    sendAT(GF("+CSQ"));
 | 
			
		||||
@@ -587,7 +583,7 @@ protected:
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  bool modemGetConnected(uint8_t mux) {
 | 
			
		||||
    sendAT(GF("+CIPSTATUS")); //TODO mux?
 | 
			
		||||
    sendAT(GF("+CIPSTATUS")); // TODO mux?
 | 
			
		||||
    int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), GF(",\"CLOSING\""), GF(",\"INITIAL\""));
 | 
			
		||||
    waitResponse();
 | 
			
		||||
    return 1 == res;
 | 
			
		||||
 
 | 
			
		||||
@@ -9,14 +9,14 @@
 | 
			
		||||
#ifndef TinyGsmClientBG96_h
 | 
			
		||||
#define TinyGsmClientBG96_h
 | 
			
		||||
 | 
			
		||||
//#define TINY_GSM_DEBUG Serial
 | 
			
		||||
//#define TINY_GSM_USE_HEX
 | 
			
		||||
// #define TINY_GSM_DEBUG Serial
 | 
			
		||||
// #define TINY_GSM_USE_HEX
 | 
			
		||||
 | 
			
		||||
#if !defined(TINY_GSM_RX_BUFFER)
 | 
			
		||||
  #define TINY_GSM_RX_BUFFER 64
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define TINY_GSM_MUX_COUNT 5
 | 
			
		||||
#define TINY_GSM_MUX_COUNT 12
 | 
			
		||||
 | 
			
		||||
#include <TinyGsmCommon.h>
 | 
			
		||||
 | 
			
		||||
@@ -39,10 +39,22 @@ enum RegStatus {
 | 
			
		||||
  REG_UNKNOWN      = 4,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//                    Declaration of the TinyGsmBG96 Class
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
 | 
			
		||||
class TinyGsmBG96
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//                          The BG96 Client Class
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
class GsmClient : public Client
 | 
			
		||||
@@ -166,13 +178,20 @@ public:
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
  TinyGsmBG96*  at;
 | 
			
		||||
  uint8_t       mux;
 | 
			
		||||
  uint16_t      sock_available;
 | 
			
		||||
  bool          sock_connected;
 | 
			
		||||
  bool          got_data;
 | 
			
		||||
  RxFifo        rx;
 | 
			
		||||
  uint8_t         mux;
 | 
			
		||||
  uint16_t        sock_available;
 | 
			
		||||
  bool            sock_connected;
 | 
			
		||||
  bool            got_data;
 | 
			
		||||
  RxFifo          rx;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//                          The BG96 Secure Client
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class GsmClientSecure : public GsmClient
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
@@ -192,9 +211,19 @@ public:
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//                          The BG96 Modem Functions
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
#ifdef GSM_DEFAULT_STREAM
 | 
			
		||||
  TinyGsmBG96(Stream& stream = GSM_DEFAULT_STREAM)
 | 
			
		||||
#else
 | 
			
		||||
  TinyGsmBG96(Stream& stream)
 | 
			
		||||
#endif
 | 
			
		||||
    : stream(stream)
 | 
			
		||||
  {
 | 
			
		||||
    memset(sockets, 0, sizeof(sockets));
 | 
			
		||||
@@ -344,26 +373,15 @@ public:
 | 
			
		||||
      int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), GF("NOT INSERTED"));
 | 
			
		||||
      waitResponse();
 | 
			
		||||
      switch (status) {
 | 
			
		||||
      case 2:
 | 
			
		||||
      case 3:  return SIM_LOCKED;
 | 
			
		||||
      case 1:  return SIM_READY;
 | 
			
		||||
      default: return SIM_ERROR;
 | 
			
		||||
        case 2:
 | 
			
		||||
        case 3:  return SIM_LOCKED;
 | 
			
		||||
        case 1:  return SIM_READY;
 | 
			
		||||
        default: return SIM_ERROR;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return SIM_ERROR;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  RegStatus getRegistrationStatus() {
 | 
			
		||||
    sendAT(GF("+CREG?"));
 | 
			
		||||
    if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
 | 
			
		||||
      return REG_UNKNOWN;
 | 
			
		||||
    }
 | 
			
		||||
    streamSkipUntil(','); // Skip format (0)
 | 
			
		||||
    int status = stream.readStringUntil('\n').toInt();
 | 
			
		||||
    waitResponse();
 | 
			
		||||
    return (RegStatus)status;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  String getOperator() {
 | 
			
		||||
    sendAT(GF("+COPS?"));
 | 
			
		||||
    if (waitResponse(GF(GSM_NL "+COPS:")) != 1) {
 | 
			
		||||
@@ -379,6 +397,17 @@ public:
 | 
			
		||||
   * Generic network functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  RegStatus getRegistrationStatus() {
 | 
			
		||||
    sendAT(GF("+CREG?"));
 | 
			
		||||
    if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
 | 
			
		||||
      return REG_UNKNOWN;
 | 
			
		||||
    }
 | 
			
		||||
    streamSkipUntil(','); // Skip format (0)
 | 
			
		||||
    int status = stream.readStringUntil('\n').toInt();
 | 
			
		||||
    waitResponse();
 | 
			
		||||
    return (RegStatus)status;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  int getSignalQuality() {
 | 
			
		||||
    sendAT(GF("+CSQ"));
 | 
			
		||||
    if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) {
 | 
			
		||||
@@ -404,6 +433,27 @@ public:
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  String getLocalIP() {
 | 
			
		||||
    sendAT(GF("+CGPADDR=1"));
 | 
			
		||||
    if (waitResponse(10000L, GF(GSM_NL "+CGPADDR:")) != 1) {
 | 
			
		||||
      return "";
 | 
			
		||||
    }
 | 
			
		||||
    streamSkipUntil(',');
 | 
			
		||||
    String res = stream.readStringUntil('\n');
 | 
			
		||||
    if (waitResponse() != 1) {
 | 
			
		||||
      return "";
 | 
			
		||||
    }
 | 
			
		||||
    return res;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  IPAddress localIP() {
 | 
			
		||||
    return TinyGsmIpFromString(getLocalIP());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * WiFi functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * GPRS functions
 | 
			
		||||
   */
 | 
			
		||||
@@ -450,53 +500,6 @@ public:
 | 
			
		||||
    return localIP() != 0;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  String getLocalIP() {
 | 
			
		||||
    sendAT(GF("+CGPADDR=1"));
 | 
			
		||||
    if (waitResponse(10000L, GF(GSM_NL "+CGPADDR:")) != 1) {
 | 
			
		||||
      return "";
 | 
			
		||||
    }
 | 
			
		||||
    streamSkipUntil(',');
 | 
			
		||||
    String res = stream.readStringUntil('\n');
 | 
			
		||||
    if (waitResponse() != 1) {
 | 
			
		||||
      return "";
 | 
			
		||||
    }
 | 
			
		||||
    return res;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  IPAddress localIP() {
 | 
			
		||||
    return TinyGsmIpFromString(getLocalIP());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * Phone Call functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  bool setGsmBusy(bool busy = true) TINY_GSM_ATTR_NOT_AVAILABLE;
 | 
			
		||||
 | 
			
		||||
  bool callAnswer() {
 | 
			
		||||
    sendAT(GF("A"));
 | 
			
		||||
    return waitResponse() == 1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Returns true on pick-up, false on error/busy
 | 
			
		||||
  bool callNumber(const String& number) TINY_GSM_ATTR_NOT_IMPLEMENTED;
 | 
			
		||||
 | 
			
		||||
  bool callHangup() {
 | 
			
		||||
    sendAT(GF("H"));
 | 
			
		||||
    return waitResponse() == 1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // 0-9,*,#,A,B,C,D
 | 
			
		||||
  bool dtmfSend(char cmd, int duration_ms = 100) { // TODO: check
 | 
			
		||||
    duration_ms = constrain(duration_ms, 100, 1000);
 | 
			
		||||
 | 
			
		||||
    sendAT(GF("+VTD="), duration_ms / 100); // VTD accepts in 1/10 of a second
 | 
			
		||||
    waitResponse();
 | 
			
		||||
 | 
			
		||||
    sendAT(GF("+VTS="), cmd);
 | 
			
		||||
    return waitResponse(10000L) == 1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * Messaging functions
 | 
			
		||||
   */
 | 
			
		||||
@@ -660,9 +663,13 @@ public:
 | 
			
		||||
    streamWrite(tail...);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  bool streamSkipUntil(char c) { //TODO: timeout
 | 
			
		||||
    while (true) {
 | 
			
		||||
      while (!stream.available()) { TINY_GSM_YIELD(); }
 | 
			
		||||
  bool streamSkipUntil(char c) {
 | 
			
		||||
    const unsigned long timeout = 1000L;
 | 
			
		||||
    unsigned long startMillis = millis();
 | 
			
		||||
    while (millis() - startMillis < timeout) {
 | 
			
		||||
      while (millis() - startMillis < timeout && !stream.available()) {
 | 
			
		||||
        TINY_GSM_YIELD();
 | 
			
		||||
      }
 | 
			
		||||
      if (stream.read() == c)
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
@@ -674,7 +681,7 @@ public:
 | 
			
		||||
    streamWrite("AT", cmd..., GSM_NL);
 | 
			
		||||
    stream.flush();
 | 
			
		||||
    TINY_GSM_YIELD();
 | 
			
		||||
    //DBG("### AT:", cmd...);
 | 
			
		||||
    DBG("### AT:", cmd...);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // TODO: Optimize this!
 | 
			
		||||
@@ -682,12 +689,12 @@ public:
 | 
			
		||||
                       GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
 | 
			
		||||
                       GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL)
 | 
			
		||||
  {
 | 
			
		||||
    /*String r1s(r1); r1s.trim();
 | 
			
		||||
    String r1s(r1); r1s.trim();
 | 
			
		||||
    String r2s(r2); r2s.trim();
 | 
			
		||||
    String r3s(r3); r3s.trim();
 | 
			
		||||
    String r4s(r4); r4s.trim();
 | 
			
		||||
    String r5s(r5); r5s.trim();
 | 
			
		||||
    DBG("### ..:", r1s, ",", r2s, ",", r3s, ",", r4s, ",", r5s);*/
 | 
			
		||||
    DBG("### ..:", r1s, ",", r2s, ",", r3s, ",", r4s, ",", r5s);
 | 
			
		||||
    data.reserve(64);
 | 
			
		||||
    int index = 0;
 | 
			
		||||
    unsigned long startMillis = millis();
 | 
			
		||||
@@ -743,6 +750,7 @@ finish:
 | 
			
		||||
      }
 | 
			
		||||
      data = "";
 | 
			
		||||
    }
 | 
			
		||||
    DBG('<', index, '>');
 | 
			
		||||
    return index;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -172,10 +172,10 @@ public:
 | 
			
		||||
  String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
  TinyGsmESP8266*  at;
 | 
			
		||||
  uint8_t          mux;
 | 
			
		||||
  bool             sock_connected;
 | 
			
		||||
  RxFifo           rx;
 | 
			
		||||
  TinyGsmESP8266* at;
 | 
			
		||||
  uint8_t         mux;
 | 
			
		||||
  bool            sock_connected;
 | 
			
		||||
  RxFifo          rx;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
@@ -257,8 +257,8 @@ public:
 | 
			
		||||
    for (unsigned long start = millis(); millis() - start < timeout; ) {
 | 
			
		||||
      sendAT(GF(""));
 | 
			
		||||
      if (waitResponse(200) == 1) {
 | 
			
		||||
          delay(100);
 | 
			
		||||
          return true;
 | 
			
		||||
        delay(100);
 | 
			
		||||
        return true;
 | 
			
		||||
      }
 | 
			
		||||
      delay(100);
 | 
			
		||||
    }
 | 
			
		||||
@@ -313,7 +313,6 @@ public:
 | 
			
		||||
 | 
			
		||||
  bool sleepEnable(bool enable = true) TINY_GSM_ATTR_NOT_IMPLEMENTED;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * SIM card functions
 | 
			
		||||
   */
 | 
			
		||||
@@ -323,13 +322,13 @@ public:
 | 
			
		||||
   * Generic network functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
   RegStatus getRegistrationStatus() {
 | 
			
		||||
     sendAT(GF("+CIPSTATUS"));
 | 
			
		||||
  RegStatus getRegistrationStatus() {
 | 
			
		||||
    sendAT(GF("+CIPSTATUS"));
 | 
			
		||||
    if (waitResponse(3000, GF("STATUS:")) != 1) return REG_UNKNOWN;
 | 
			
		||||
    int status = waitResponse(GFP(GSM_ERROR), GF("2"), GF("3"), GF("4"), GF("5"));
 | 
			
		||||
     waitResponse();  // Returns an OK after the status
 | 
			
		||||
    waitResponse();  // Returns an OK after the status
 | 
			
		||||
    return (RegStatus)status;
 | 
			
		||||
   }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  int getSignalQuality() {
 | 
			
		||||
    sendAT(GF("+CWJAP_CUR?"));
 | 
			
		||||
 
 | 
			
		||||
@@ -54,6 +54,7 @@ class TinyGsmM590
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
class GsmClient : public Client
 | 
			
		||||
@@ -172,10 +173,10 @@ public:
 | 
			
		||||
  String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
  TinyGsmM590*  at;
 | 
			
		||||
  uint8_t       mux;
 | 
			
		||||
  bool          sock_connected;
 | 
			
		||||
  RxFifo        rx;
 | 
			
		||||
  TinyGsmM590*    at;
 | 
			
		||||
  uint8_t         mux;
 | 
			
		||||
  bool            sock_connected;
 | 
			
		||||
  RxFifo          rx;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
@@ -236,8 +237,8 @@ public:
 | 
			
		||||
    for (unsigned long start = millis(); millis() - start < timeout; ) {
 | 
			
		||||
      sendAT(GF(""));
 | 
			
		||||
      if (waitResponse(200) == 1) {
 | 
			
		||||
          delay(100);
 | 
			
		||||
          return true;
 | 
			
		||||
        delay(100);
 | 
			
		||||
        return true;
 | 
			
		||||
      }
 | 
			
		||||
      delay(100);
 | 
			
		||||
    }
 | 
			
		||||
@@ -349,10 +350,10 @@ public:
 | 
			
		||||
      int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"));
 | 
			
		||||
      waitResponse();
 | 
			
		||||
      switch (status) {
 | 
			
		||||
      case 2:
 | 
			
		||||
      case 3:  return SIM_LOCKED;
 | 
			
		||||
      case 1:  return SIM_READY;
 | 
			
		||||
      default: return SIM_ERROR;
 | 
			
		||||
        case 2:
 | 
			
		||||
        case 3:  return SIM_LOCKED;
 | 
			
		||||
        case 1:  return SIM_READY;
 | 
			
		||||
        default: return SIM_ERROR;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return SIM_ERROR;
 | 
			
		||||
@@ -373,16 +374,16 @@ public:
 | 
			
		||||
   * Generic network functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
   RegStatus getRegistrationStatus() {
 | 
			
		||||
     sendAT(GF("+CREG?"));
 | 
			
		||||
     if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
 | 
			
		||||
       return REG_UNKNOWN;
 | 
			
		||||
     }
 | 
			
		||||
     streamSkipUntil(','); // Skip format (0)
 | 
			
		||||
     int status = stream.readStringUntil('\n').toInt();
 | 
			
		||||
     waitResponse();
 | 
			
		||||
     return (RegStatus)status;
 | 
			
		||||
   }
 | 
			
		||||
  RegStatus getRegistrationStatus() {
 | 
			
		||||
    sendAT(GF("+CREG?"));
 | 
			
		||||
    if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
 | 
			
		||||
      return REG_UNKNOWN;
 | 
			
		||||
    }
 | 
			
		||||
    streamSkipUntil(','); // Skip format (0)
 | 
			
		||||
    int status = stream.readStringUntil('\n').toInt();
 | 
			
		||||
    waitResponse();
 | 
			
		||||
    return (RegStatus)status;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  int getSignalQuality() {
 | 
			
		||||
    sendAT(GF("+CSQ"));
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -273,8 +273,8 @@ public:
 | 
			
		||||
    for (unsigned long start = millis(); millis() - start < timeout; ) {
 | 
			
		||||
      sendAT(GF(""));
 | 
			
		||||
      if (waitResponse(200) == 1) {
 | 
			
		||||
          delay(100);
 | 
			
		||||
          return true;
 | 
			
		||||
        delay(100);
 | 
			
		||||
        return true;
 | 
			
		||||
      }
 | 
			
		||||
      delay(100);
 | 
			
		||||
    }
 | 
			
		||||
@@ -425,10 +425,10 @@ public:
 | 
			
		||||
      int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), GF("NOT INSERTED"));
 | 
			
		||||
      waitResponse();
 | 
			
		||||
      switch (status) {
 | 
			
		||||
      case 2:
 | 
			
		||||
      case 3:  return SIM_LOCKED;
 | 
			
		||||
      case 1:  return SIM_READY;
 | 
			
		||||
      default: return SIM_ERROR;
 | 
			
		||||
        case 2:
 | 
			
		||||
        case 3:  return SIM_LOCKED;
 | 
			
		||||
        case 1:  return SIM_READY;
 | 
			
		||||
        default: return SIM_ERROR;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return SIM_ERROR;
 | 
			
		||||
@@ -449,16 +449,16 @@ public:
 | 
			
		||||
   * Generic network functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
   RegStatus getRegistrationStatus() {
 | 
			
		||||
     sendAT(GF("+CREG?"));
 | 
			
		||||
     if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
 | 
			
		||||
       return REG_UNKNOWN;
 | 
			
		||||
     }
 | 
			
		||||
     streamSkipUntil(','); // Skip format (0)
 | 
			
		||||
     int status = stream.readStringUntil('\n').toInt();
 | 
			
		||||
     waitResponse();
 | 
			
		||||
     return (RegStatus)status;
 | 
			
		||||
   }
 | 
			
		||||
  RegStatus getRegistrationStatus() {
 | 
			
		||||
    sendAT(GF("+CREG?"));
 | 
			
		||||
    if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
 | 
			
		||||
      return REG_UNKNOWN;
 | 
			
		||||
    }
 | 
			
		||||
    streamSkipUntil(','); // Skip format (0)
 | 
			
		||||
    int status = stream.readStringUntil('\n').toInt();
 | 
			
		||||
    waitResponse();
 | 
			
		||||
    return (RegStatus)status;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  int getSignalQuality() {
 | 
			
		||||
    sendAT(GF("+CSQ"));
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,6 @@ enum RegStatus {
 | 
			
		||||
  REG_UNKNOWN      = 4,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//                   Declaration of the TinyGsmU201 Class
 | 
			
		||||
@@ -177,12 +176,12 @@ public:
 | 
			
		||||
  String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
  TinyGsmU201*  at;
 | 
			
		||||
  uint8_t       mux;
 | 
			
		||||
  uint16_t      sock_available;
 | 
			
		||||
  bool          sock_connected;
 | 
			
		||||
  bool          got_data;
 | 
			
		||||
  RxFifo        rx;
 | 
			
		||||
  TinyGsmU201*    at;
 | 
			
		||||
  uint8_t         mux;
 | 
			
		||||
  uint16_t        sock_available;
 | 
			
		||||
  bool            sock_connected;
 | 
			
		||||
  bool            got_data;
 | 
			
		||||
  RxFifo          rx;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
@@ -212,7 +211,6 @@ public:
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//                          The U201 Modem Functions
 | 
			
		||||
@@ -375,10 +373,10 @@ public:
 | 
			
		||||
      int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), GF("NOT INSERTED"));
 | 
			
		||||
      waitResponse();
 | 
			
		||||
      switch (status) {
 | 
			
		||||
      case 2:
 | 
			
		||||
      case 3:  return SIM_LOCKED;
 | 
			
		||||
      case 1:  return SIM_READY;
 | 
			
		||||
      default: return SIM_ERROR;
 | 
			
		||||
        case 2:
 | 
			
		||||
        case 3:  return SIM_LOCKED;
 | 
			
		||||
        case 1:  return SIM_READY;
 | 
			
		||||
        default: return SIM_ERROR;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return SIM_ERROR;
 | 
			
		||||
@@ -399,16 +397,16 @@ public:
 | 
			
		||||
   * Generic network functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
   RegStatus getRegistrationStatus() {
 | 
			
		||||
     sendAT(GF("+CGREG?"));
 | 
			
		||||
     if (waitResponse(GF(GSM_NL "+CGREG:")) != 1) {
 | 
			
		||||
       return REG_UNKNOWN;
 | 
			
		||||
     }
 | 
			
		||||
     streamSkipUntil(','); // Skip format (0)
 | 
			
		||||
     int status = stream.readStringUntil('\n').toInt();
 | 
			
		||||
     waitResponse();
 | 
			
		||||
     return (RegStatus)status;
 | 
			
		||||
   }
 | 
			
		||||
  RegStatus getRegistrationStatus() {
 | 
			
		||||
    sendAT(GF("+CGREG?"));
 | 
			
		||||
    if (waitResponse(GF(GSM_NL "+CGREG:")) != 1) {
 | 
			
		||||
      return REG_UNKNOWN;
 | 
			
		||||
    }
 | 
			
		||||
    streamSkipUntil(','); // Skip format (0)
 | 
			
		||||
    int status = stream.readStringUntil('\n').toInt();
 | 
			
		||||
    waitResponse();
 | 
			
		||||
    return (RegStatus)status;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  int getSignalQuality() {
 | 
			
		||||
    sendAT(GF("+CSQ"));
 | 
			
		||||
@@ -521,19 +519,6 @@ public:
 | 
			
		||||
 | 
			
		||||
    return localIP() != 0;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * Phone Call functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  bool setGsmBusy(bool busy = true) TINY_GSM_ATTR_NOT_AVAILABLE;
 | 
			
		||||
 | 
			
		||||
  bool callAnswer() TINY_GSM_ATTR_NOT_IMPLEMENTED;
 | 
			
		||||
 | 
			
		||||
  bool callNumber(const String& number) TINY_GSM_ATTR_NOT_IMPLEMENTED;
 | 
			
		||||
 | 
			
		||||
  bool callHangup() TINY_GSM_ATTR_NOT_IMPLEMENTED;
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * Messaging functions
 | 
			
		||||
   */
 | 
			
		||||
@@ -721,7 +706,7 @@ public:
 | 
			
		||||
      TINY_GSM_YIELD();
 | 
			
		||||
      while (stream.available() > 0) {
 | 
			
		||||
        int a = stream.read();
 | 
			
		||||
        if (a < 0) continue;
 | 
			
		||||
        if (a <= 0) continue; // Skip 0x00 bytes, just in case
 | 
			
		||||
        data += (char)a;
 | 
			
		||||
        if (r1 && data.endsWith(r1)) {
 | 
			
		||||
          index = 1;
 | 
			
		||||
 
 | 
			
		||||
@@ -44,7 +44,6 @@ enum XBeeType {
 | 
			
		||||
  XBEE3_LTENB    = 3,  // Digi XBee3™ Cellular NB-IoT  -- HS unknown to SRGD
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//                   Declaration of the TinyGsmXBee Class
 | 
			
		||||
@@ -170,9 +169,9 @@ public:
 | 
			
		||||
  String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
  TinyGsmXBee*  at;
 | 
			
		||||
  uint8_t       mux;
 | 
			
		||||
  bool          sock_connected;
 | 
			
		||||
  TinyGsmXBee*    at;
 | 
			
		||||
  uint8_t         mux;
 | 
			
		||||
  bool            sock_connected;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
@@ -665,8 +664,6 @@ fail:
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
 | 
			
		||||
  bool modemConnect(const char* host, uint16_t port, uint8_t mux = 0, bool ssl = false) {
 | 
			
		||||
    String strIP; strIP.reserve(16);
 | 
			
		||||
    unsigned long startMillis = millis();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user