mirror of
https://github.com/KevinMidboe/TinyGSM.git
synced 2025-10-29 18:00:18 +00:00
Added virtual master class
This commit is contained in:
@@ -39,7 +39,7 @@ enum RegStatus {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmA6
|
class TinyGsmA6 : public TinyGsmMasterModem
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -182,7 +182,7 @@ public:
|
|||||||
#else
|
#else
|
||||||
TinyGsmA6(Stream& stream)
|
TinyGsmA6(Stream& stream)
|
||||||
#endif
|
#endif
|
||||||
: stream(stream)
|
: TinyGsmMasterModem(stream), stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
}
|
}
|
||||||
@@ -445,6 +445,10 @@ public:
|
|||||||
return (res == 1);
|
return (res == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IP Address functions
|
||||||
|
*/
|
||||||
|
|
||||||
String getLocalIP() {
|
String getLocalIP() {
|
||||||
sendAT(GF("+CIFSR"));
|
sendAT(GF("+CIFSR"));
|
||||||
String res;
|
String res;
|
||||||
@@ -457,10 +461,6 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress localIP() {
|
|
||||||
return TinyGsmIpFromString(getLocalIP());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messaging functions
|
* Messaging functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ enum RegStatus {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmBG96
|
class TinyGsmBG96 : public TinyGsmMasterModem
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -206,7 +206,7 @@ public:
|
|||||||
#else
|
#else
|
||||||
TinyGsmBG96(Stream& stream)
|
TinyGsmBG96(Stream& stream)
|
||||||
#endif
|
#endif
|
||||||
: stream(stream)
|
: TinyGsmMasterModem(stream), stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
}
|
}
|
||||||
@@ -467,6 +467,10 @@ public:
|
|||||||
return localIP() != 0;
|
return localIP() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IP Address functions
|
||||||
|
*/
|
||||||
|
|
||||||
String getLocalIP() {
|
String getLocalIP() {
|
||||||
sendAT(GF("+CGPADDR=1"));
|
sendAT(GF("+CGPADDR=1"));
|
||||||
if (waitResponse(10000L, GF(GSM_NL "+CGPADDR:")) != 1) {
|
if (waitResponse(10000L, GF(GSM_NL "+CGPADDR:")) != 1) {
|
||||||
@@ -480,10 +484,6 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress localIP() {
|
|
||||||
return TinyGsmIpFromString(getLocalIP());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messaging functions
|
* Messaging functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ enum RegStatus {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmESP8266
|
class TinyGsmESP8266 : public TinyGsmMasterModem
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -198,7 +198,7 @@ public:
|
|||||||
#else
|
#else
|
||||||
TinyGsmESP8266(Stream& stream)
|
TinyGsmESP8266(Stream& stream)
|
||||||
#endif
|
#endif
|
||||||
: stream(stream)
|
: TinyGsmMasterModem(stream), stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
}
|
}
|
||||||
@@ -366,6 +366,10 @@ public:
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IP Address functions
|
||||||
|
*/
|
||||||
|
|
||||||
String getLocalIP() {
|
String getLocalIP() {
|
||||||
sendAT(GF("+CIPSTA_CUR??"));
|
sendAT(GF("+CIPSTA_CUR??"));
|
||||||
int res1 = waitResponse(GF("ERROR"), GF("+CWJAP_CUR:"));
|
int res1 = waitResponse(GF("ERROR"), GF("+CWJAP_CUR:"));
|
||||||
@@ -377,10 +381,6 @@ public:
|
|||||||
return res2;
|
return res2;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress localIP() {
|
|
||||||
return TinyGsmIpFromString(getLocalIP());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GPRS functions
|
* GPRS functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ enum RegStatus {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmM590
|
class TinyGsmM590 : public TinyGsmMasterModem
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -179,7 +179,7 @@ public:
|
|||||||
#else
|
#else
|
||||||
TinyGsmM590(Stream& stream)
|
TinyGsmM590(Stream& stream)
|
||||||
#endif
|
#endif
|
||||||
: stream(stream)
|
: TinyGsmMasterModem(stream), stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
}
|
}
|
||||||
@@ -451,6 +451,10 @@ public:
|
|||||||
return res == 1;
|
return res == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IP Address functions
|
||||||
|
*/
|
||||||
|
|
||||||
String getLocalIP() {
|
String getLocalIP() {
|
||||||
sendAT(GF("+XIIC?"));
|
sendAT(GF("+XIIC?"));
|
||||||
if (waitResponse(GF(GSM_NL "+XIIC:")) != 1) {
|
if (waitResponse(GF(GSM_NL "+XIIC:")) != 1) {
|
||||||
@@ -463,10 +467,6 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress localIP() {
|
|
||||||
return TinyGsmIpFromString(getLocalIP());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messaging functions
|
* Messaging functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ enum RegStatus {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmM95
|
class TinyGsmM95 : public TinyGsmMasterModem
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -186,7 +186,7 @@ public:
|
|||||||
#else
|
#else
|
||||||
TinyGsmM95(Stream& stream)
|
TinyGsmM95(Stream& stream)
|
||||||
#endif
|
#endif
|
||||||
: stream(stream)
|
: TinyGsmMasterModem(stream), stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
}
|
}
|
||||||
@@ -470,6 +470,10 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IP Address functions
|
||||||
|
*/
|
||||||
|
|
||||||
String getLocalIP() {
|
String getLocalIP() {
|
||||||
sendAT(GF("+QILOCIP"));
|
sendAT(GF("+QILOCIP"));
|
||||||
stream.readStringUntil('\n');
|
stream.readStringUntil('\n');
|
||||||
@@ -478,10 +482,6 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress localIP() {
|
|
||||||
return TinyGsmIpFromString(getLocalIP());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Phone Call functions
|
* Phone Call functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -43,24 +43,10 @@ enum RegStatus {
|
|||||||
REG_UNKNOWN = 4,
|
REG_UNKNOWN = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
//============================================================================//
|
|
||||||
//============================================================================//
|
|
||||||
// Declaration of the TinyGsmMC60 Class
|
|
||||||
//============================================================================//
|
|
||||||
//============================================================================//
|
|
||||||
|
|
||||||
|
class TinyGsmMC60 : public TinyGsmMasterModem
|
||||||
|
|
||||||
class TinyGsmMC60
|
|
||||||
{
|
{
|
||||||
|
|
||||||
//============================================================================//
|
|
||||||
//============================================================================//
|
|
||||||
// The MC60 Internal Client Class
|
|
||||||
//============================================================================//
|
|
||||||
//============================================================================//
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
class GsmClient : public Client
|
class GsmClient : public Client
|
||||||
@@ -199,12 +185,6 @@ private:
|
|||||||
RxFifo rx;
|
RxFifo rx;
|
||||||
};
|
};
|
||||||
|
|
||||||
//============================================================================//
|
|
||||||
//============================================================================//
|
|
||||||
// The MC60 Secure Client
|
|
||||||
//============================================================================//
|
|
||||||
//============================================================================//
|
|
||||||
|
|
||||||
|
|
||||||
class GsmClientSecure : public GsmClient
|
class GsmClientSecure : public GsmClient
|
||||||
{
|
{
|
||||||
@@ -225,11 +205,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//============================================================================//
|
|
||||||
//============================================================================//
|
|
||||||
// The MC60 Modem Functions
|
|
||||||
//============================================================================//
|
|
||||||
//============================================================================//
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -238,7 +213,7 @@ public:
|
|||||||
#else
|
#else
|
||||||
TinyGsmMC60(Stream& stream)
|
TinyGsmMC60(Stream& stream)
|
||||||
#endif
|
#endif
|
||||||
: stream(stream)
|
: TinyGsmMasterModem(stream), stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
}
|
}
|
||||||
@@ -614,6 +589,10 @@ public:
|
|||||||
return waitResponse(60000L) == 1;
|
return waitResponse(60000L) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IP Address functions
|
||||||
|
*/
|
||||||
|
|
||||||
String getLocalIP() {
|
String getLocalIP() {
|
||||||
sendAT(GF("+CIFSR;E0"));
|
sendAT(GF("+CIFSR;E0"));
|
||||||
String res;
|
String res;
|
||||||
@@ -624,10 +603,6 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress localIP() {
|
|
||||||
return TinyGsmIpFromString(getLocalIP());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messaging functions
|
* Messaging functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ enum RegStatus {
|
|||||||
//============================================================================//
|
//============================================================================//
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmSim800
|
class TinyGsmSim800 : public TinyGsmMasterModem
|
||||||
{
|
{
|
||||||
|
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
@@ -228,7 +228,7 @@ public:
|
|||||||
#else
|
#else
|
||||||
TinyGsmSim800(Stream& stream)
|
TinyGsmSim800(Stream& stream)
|
||||||
#endif
|
#endif
|
||||||
: stream(stream)
|
: TinyGsmMasterModem(stream), stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
}
|
}
|
||||||
@@ -602,6 +602,10 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IP Address functions
|
||||||
|
*/
|
||||||
|
|
||||||
String getLocalIP() {
|
String getLocalIP() {
|
||||||
sendAT(GF("+CIFSR;E0"));
|
sendAT(GF("+CIFSR;E0"));
|
||||||
String res;
|
String res;
|
||||||
@@ -614,10 +618,6 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress localIP() {
|
|
||||||
return TinyGsmIpFromString(getLocalIP());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messaging functions
|
* Messaging functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ enum RegStatus {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmUBLOX
|
class TinyGsmUBLOX : public TinyGsmMasterModem
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -205,7 +205,7 @@ public:
|
|||||||
#else
|
#else
|
||||||
TinyGsmUBLOX(Stream& stream)
|
TinyGsmUBLOX(Stream& stream)
|
||||||
#endif
|
#endif
|
||||||
: stream(stream)
|
: TinyGsmMasterModem(stream), stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
}
|
}
|
||||||
@@ -485,6 +485,10 @@ public:
|
|||||||
return localIP() != 0;
|
return localIP() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IP Address functions
|
||||||
|
*/
|
||||||
|
|
||||||
String getLocalIP() {
|
String getLocalIP() {
|
||||||
sendAT(GF("+UPSND=0,0"));
|
sendAT(GF("+UPSND=0,0"));
|
||||||
if (waitResponse(GF(GSM_NL "+UPSND:")) != 1) {
|
if (waitResponse(GF(GSM_NL "+UPSND:")) != 1) {
|
||||||
@@ -499,10 +503,6 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress localIP() {
|
|
||||||
return TinyGsmIpFromString(getLocalIP());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messaging functions
|
* Messaging functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ enum XBeeType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmXBee
|
class TinyGsmXBee : public TinyGsmMasterModem
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -211,7 +211,7 @@ public:
|
|||||||
#else
|
#else
|
||||||
TinyGsmXBee(Stream& stream)
|
TinyGsmXBee(Stream& stream)
|
||||||
#endif
|
#endif
|
||||||
: stream(stream)
|
: TinyGsmMasterModem(stream), stream(stream)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -559,6 +559,10 @@ fail:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IP Address functions
|
||||||
|
*/
|
||||||
|
|
||||||
String getLocalIP() {
|
String getLocalIP() {
|
||||||
if (!commandMode()) return ""; // Return immediately
|
if (!commandMode()) return ""; // Return immediately
|
||||||
sendAT(GF("MY"));
|
sendAT(GF("MY"));
|
||||||
@@ -570,10 +574,6 @@ fail:
|
|||||||
return IPaddr;
|
return IPaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress localIP() {
|
|
||||||
return TinyGsmIpFromString(getLocalIP());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GPRS functions
|
* GPRS functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -194,4 +194,99 @@ String TinyGsmDecodeHex16bit(String &instr) {
|
|||||||
return result;
|
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
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user