Added virtual master class
This commit is contained in:
		@@ -39,7 +39,7 @@ enum RegStatus {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TinyGsmA6
 | 
			
		||||
class TinyGsmA6 : public TinyGsmMasterModem
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
@@ -182,7 +182,7 @@ public:
 | 
			
		||||
#else
 | 
			
		||||
  TinyGsmA6(Stream& stream)
 | 
			
		||||
#endif
 | 
			
		||||
    : stream(stream)
 | 
			
		||||
    : TinyGsmMasterModem(stream), stream(stream)
 | 
			
		||||
  {
 | 
			
		||||
    memset(sockets, 0, sizeof(sockets));
 | 
			
		||||
  }
 | 
			
		||||
@@ -445,6 +445,10 @@ public:
 | 
			
		||||
    return (res == 1);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * IP Address functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  String getLocalIP() {
 | 
			
		||||
    sendAT(GF("+CIFSR"));
 | 
			
		||||
    String res;
 | 
			
		||||
@@ -457,10 +461,6 @@ public:
 | 
			
		||||
    return res;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  IPAddress localIP() {
 | 
			
		||||
    return TinyGsmIpFromString(getLocalIP());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * Messaging functions
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,7 @@ enum RegStatus {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TinyGsmBG96
 | 
			
		||||
class TinyGsmBG96 : public TinyGsmMasterModem
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
@@ -206,7 +206,7 @@ public:
 | 
			
		||||
#else
 | 
			
		||||
  TinyGsmBG96(Stream& stream)
 | 
			
		||||
#endif
 | 
			
		||||
    : stream(stream)
 | 
			
		||||
    : TinyGsmMasterModem(stream), stream(stream)
 | 
			
		||||
  {
 | 
			
		||||
    memset(sockets, 0, sizeof(sockets));
 | 
			
		||||
  }
 | 
			
		||||
@@ -467,6 +467,10 @@ public:
 | 
			
		||||
    return localIP() != 0;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * IP Address functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  String getLocalIP() {
 | 
			
		||||
    sendAT(GF("+CGPADDR=1"));
 | 
			
		||||
    if (waitResponse(10000L, GF(GSM_NL "+CGPADDR:")) != 1) {
 | 
			
		||||
@@ -480,10 +484,6 @@ public:
 | 
			
		||||
    return res;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  IPAddress localIP() {
 | 
			
		||||
    return TinyGsmIpFromString(getLocalIP());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * Messaging functions
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ enum RegStatus {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TinyGsmESP8266
 | 
			
		||||
class TinyGsmESP8266 : public TinyGsmMasterModem
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
@@ -198,7 +198,7 @@ public:
 | 
			
		||||
#else
 | 
			
		||||
  TinyGsmESP8266(Stream& stream)
 | 
			
		||||
#endif
 | 
			
		||||
    : stream(stream)
 | 
			
		||||
    : TinyGsmMasterModem(stream), stream(stream)
 | 
			
		||||
  {
 | 
			
		||||
    memset(sockets, 0, sizeof(sockets));
 | 
			
		||||
  }
 | 
			
		||||
@@ -366,6 +366,10 @@ public:
 | 
			
		||||
    return retVal;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * IP Address functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  String getLocalIP() {
 | 
			
		||||
    sendAT(GF("+CIPSTA_CUR??"));
 | 
			
		||||
    int res1 = waitResponse(GF("ERROR"), GF("+CWJAP_CUR:"));
 | 
			
		||||
@@ -377,10 +381,6 @@ public:
 | 
			
		||||
    return res2;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  IPAddress localIP() {
 | 
			
		||||
    return TinyGsmIpFromString(getLocalIP());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * GPRS functions
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ enum RegStatus {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TinyGsmM590
 | 
			
		||||
class TinyGsmM590 : public TinyGsmMasterModem
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
@@ -179,7 +179,7 @@ public:
 | 
			
		||||
#else
 | 
			
		||||
  TinyGsmM590(Stream& stream)
 | 
			
		||||
#endif
 | 
			
		||||
    : stream(stream)
 | 
			
		||||
    : TinyGsmMasterModem(stream), stream(stream)
 | 
			
		||||
  {
 | 
			
		||||
    memset(sockets, 0, sizeof(sockets));
 | 
			
		||||
  }
 | 
			
		||||
@@ -451,6 +451,10 @@ public:
 | 
			
		||||
    return res == 1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * IP Address functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  String getLocalIP() {
 | 
			
		||||
    sendAT(GF("+XIIC?"));
 | 
			
		||||
    if (waitResponse(GF(GSM_NL "+XIIC:")) != 1) {
 | 
			
		||||
@@ -463,10 +467,6 @@ public:
 | 
			
		||||
    return res;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  IPAddress localIP() {
 | 
			
		||||
    return TinyGsmIpFromString(getLocalIP());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * Messaging functions
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,7 @@ enum RegStatus {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TinyGsmM95
 | 
			
		||||
class TinyGsmM95 : public TinyGsmMasterModem
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
@@ -186,7 +186,7 @@ public:
 | 
			
		||||
#else
 | 
			
		||||
  TinyGsmM95(Stream& stream)
 | 
			
		||||
#endif
 | 
			
		||||
    : stream(stream)
 | 
			
		||||
    : TinyGsmMasterModem(stream), stream(stream)
 | 
			
		||||
  {
 | 
			
		||||
    memset(sockets, 0, sizeof(sockets));
 | 
			
		||||
  }
 | 
			
		||||
@@ -470,6 +470,10 @@ public:
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * IP Address functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  String getLocalIP() {
 | 
			
		||||
    sendAT(GF("+QILOCIP"));
 | 
			
		||||
    stream.readStringUntil('\n');
 | 
			
		||||
@@ -478,10 +482,6 @@ public:
 | 
			
		||||
    return res;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  IPAddress localIP() {
 | 
			
		||||
    return TinyGsmIpFromString(getLocalIP());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * Phone Call functions
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
@@ -43,24 +43,10 @@ enum RegStatus {
 | 
			
		||||
  REG_UNKNOWN      = 4,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//                    Declaration of the TinyGsmMC60 Class
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TinyGsmMC60
 | 
			
		||||
class TinyGsmMC60 : public TinyGsmMasterModem
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//                          The MC60 Internal Client Class
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
class GsmClient : public Client
 | 
			
		||||
@@ -199,12 +185,6 @@ private:
 | 
			
		||||
  RxFifo        rx;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//                          The MC60 Secure Client
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class GsmClientSecure : public GsmClient
 | 
			
		||||
{
 | 
			
		||||
@@ -225,11 +205,6 @@ public:
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//                          The MC60 Modem Functions
 | 
			
		||||
//============================================================================//
 | 
			
		||||
//============================================================================//
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
@@ -238,7 +213,7 @@ public:
 | 
			
		||||
#else
 | 
			
		||||
  TinyGsmMC60(Stream& stream)
 | 
			
		||||
#endif
 | 
			
		||||
    : stream(stream)
 | 
			
		||||
    : TinyGsmMasterModem(stream), stream(stream)
 | 
			
		||||
  {
 | 
			
		||||
    memset(sockets, 0, sizeof(sockets));
 | 
			
		||||
  }
 | 
			
		||||
@@ -614,6 +589,10 @@ public:
 | 
			
		||||
    return waitResponse(60000L) == 1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * IP Address functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  String getLocalIP() {
 | 
			
		||||
    sendAT(GF("+CIFSR;E0"));
 | 
			
		||||
    String res;
 | 
			
		||||
@@ -624,10 +603,6 @@ public:
 | 
			
		||||
    return res;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  IPAddress localIP() {
 | 
			
		||||
    return TinyGsmIpFromString(getLocalIP());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * Messaging functions
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
@@ -46,7 +46,7 @@ enum RegStatus {
 | 
			
		||||
//============================================================================//
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TinyGsmSim800
 | 
			
		||||
class TinyGsmSim800 : public TinyGsmMasterModem
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
//============================================================================//
 | 
			
		||||
@@ -228,7 +228,7 @@ public:
 | 
			
		||||
#else
 | 
			
		||||
  TinyGsmSim800(Stream& stream)
 | 
			
		||||
#endif
 | 
			
		||||
    : stream(stream)
 | 
			
		||||
    : TinyGsmMasterModem(stream), stream(stream)
 | 
			
		||||
  {
 | 
			
		||||
    memset(sockets, 0, sizeof(sockets));
 | 
			
		||||
  }
 | 
			
		||||
@@ -602,6 +602,10 @@ public:
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * IP Address functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  String getLocalIP() {
 | 
			
		||||
    sendAT(GF("+CIFSR;E0"));
 | 
			
		||||
    String res;
 | 
			
		||||
@@ -614,10 +618,6 @@ public:
 | 
			
		||||
    return res;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  IPAddress localIP() {
 | 
			
		||||
    return TinyGsmIpFromString(getLocalIP());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * Messaging functions
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,7 @@ enum RegStatus {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TinyGsmUBLOX
 | 
			
		||||
class TinyGsmUBLOX : public TinyGsmMasterModem
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
@@ -205,7 +205,7 @@ public:
 | 
			
		||||
#else
 | 
			
		||||
  TinyGsmUBLOX(Stream& stream)
 | 
			
		||||
#endif
 | 
			
		||||
    : stream(stream)
 | 
			
		||||
    : TinyGsmMasterModem(stream), stream(stream)
 | 
			
		||||
  {
 | 
			
		||||
    memset(sockets, 0, sizeof(sockets));
 | 
			
		||||
  }
 | 
			
		||||
@@ -485,6 +485,10 @@ public:
 | 
			
		||||
    return localIP() != 0;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * IP Address functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  String getLocalIP() {
 | 
			
		||||
    sendAT(GF("+UPSND=0,0"));
 | 
			
		||||
    if (waitResponse(GF(GSM_NL "+UPSND:")) != 1) {
 | 
			
		||||
@@ -499,10 +503,6 @@ public:
 | 
			
		||||
    return res;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  IPAddress localIP() {
 | 
			
		||||
    return TinyGsmIpFromString(getLocalIP());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * Messaging functions
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
@@ -45,7 +45,7 @@ enum XBeeType {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TinyGsmXBee
 | 
			
		||||
class TinyGsmXBee : public TinyGsmMasterModem
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
@@ -211,7 +211,7 @@ public:
 | 
			
		||||
#else
 | 
			
		||||
  TinyGsmXBee(Stream& stream)
 | 
			
		||||
#endif
 | 
			
		||||
    : stream(stream)
 | 
			
		||||
    : TinyGsmMasterModem(stream), stream(stream)
 | 
			
		||||
  {}
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
@@ -559,6 +559,10 @@ fail:
 | 
			
		||||
    return res;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * IP Address functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  String getLocalIP() {
 | 
			
		||||
    if (!commandMode()) return "";  // Return immediately
 | 
			
		||||
    sendAT(GF("MY"));
 | 
			
		||||
@@ -570,10 +574,6 @@ fail:
 | 
			
		||||
    return IPaddr;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  IPAddress localIP() {
 | 
			
		||||
    return TinyGsmIpFromString(getLocalIP());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * GPRS functions
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
@@ -194,4 +194,99 @@ String TinyGsmDecodeHex16bit(String &instr) {
 | 
			
		||||
  return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TinyGsmMasterModem
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
class GsmClient : public Client
 | 
			
		||||
{
 | 
			
		||||
  friend class TinyGsmXBee;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
#ifdef GSM_DEFAULT_STREAM
 | 
			
		||||
  TinyGsmMasterModem(Stream& stream = GSM_DEFAULT_STREAM)
 | 
			
		||||
#else
 | 
			
		||||
  TinyGsmMasterModem(Stream& stream)
 | 
			
		||||
#endif
 | 
			
		||||
    : stream(stream)
 | 
			
		||||
  {}
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * Basic functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  virtual bool begin() = 0;
 | 
			
		||||
  virtual bool init() = 0;
 | 
			
		||||
  virtual void setBaud(unsigned long baud) = 0;
 | 
			
		||||
  virtual bool testAT(unsigned long timeout = 10000L) = 0;
 | 
			
		||||
  virtual void maintain() = 0;
 | 
			
		||||
  virtual bool factoryDefault() = 0;
 | 
			
		||||
  virtual String getModemInfo() = 0;
 | 
			
		||||
  virtual bool hasSSL() = 0;
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * Power functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  virtual bool restart() = 0;
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * SIM card functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  virtual bool simUnlock(const char *pin) = 0;
 | 
			
		||||
  virtual String getSimCCID() = 0;
 | 
			
		||||
  virtual String getIMEI() = 0;
 | 
			
		||||
  virtual String getOperator() = 0;
 | 
			
		||||
 | 
			
		||||
 /*
 | 
			
		||||
  * Generic network functions
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
  virtual int getSignalQuality() = 0;
 | 
			
		||||
  virtual bool isNetworkConnected() = 0;
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * WiFi functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  virtual bool networkConnect(const char* ssid, const char* pwd) = 0;
 | 
			
		||||
  virtual bool networkDisconnect() = 0;
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * GPRS functions
 | 
			
		||||
   */
 | 
			
		||||
  virtual bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) = 0;
 | 
			
		||||
  virtual bool gprsDisconnect() = 0;
 | 
			
		||||
  virtual bool isGprsConnected() = 0;
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * IP Address functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  virtual String getLocalIP() = 0;
 | 
			
		||||
  virtual IPAddress localIP() {
 | 
			
		||||
    return TinyGsmIpFromString(getLocalIP());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * Messaging functions
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  virtual bool sendSMS(const String& number, const String& text) = 0;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  Stream&       stream;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user