From bec8f16d139bfb2b04dafd5920576bc9b21a0977 Mon Sep 17 00:00:00 2001 From: SRGDamia1 Date: Tue, 20 Feb 2018 11:33:19 -0500 Subject: [PATCH] Rename classes for A6, ESP, M590 and XBee --- src/TinyGsmClient.h | 7 ++++++- src/TinyGsmClientA6.h | 12 ++++++------ src/TinyGsmClientESP8266.h | 14 +++++++------- src/TinyGsmClientM590.h | 24 ++++++++++++------------ src/TinyGsmClientXBee.h | 20 ++++++++++++-------- 5 files changed, 43 insertions(+), 34 deletions(-) diff --git a/src/TinyGsmClient.h b/src/TinyGsmClient.h index 32f3c23..de6de0f 100644 --- a/src/TinyGsmClient.h +++ b/src/TinyGsmClient.h @@ -34,11 +34,13 @@ #elif defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_A7) #define TINY_GSM_MODEM_HAS_GPRS #include + typedef TinyGsmA6 TinyGsm; typedef TinyGsm::GsmClient TinyGsmClient; #elif defined(TINY_GSM_MODEM_M590) #define TINY_GSM_MODEM_HAS_GPRS #include + typedef TinyGsmM590 TinyGsm; typedef TinyGsm::GsmClient TinyGsmClient; #elif defined(TINY_GSM_MODEM_U201) @@ -51,6 +53,7 @@ #elif defined(TINY_GSM_MODEM_ESP8266) #define TINY_GSM_MODEM_HAS_WIFI #include + typedef TinyGsmESP8266 TinyGsm; typedef TinyGsm::GsmClient TinyGsmClient; typedef TinyGsm::GsmClientSecure TinyGsmClientSecure; @@ -58,7 +61,9 @@ #define TINY_GSM_MODEM_HAS_GPRS #define TINY_GSM_MODEM_HAS_WIFI #include - typedef TinyGsm::GsmClient TinyGsmClient; + typedef TinyGsmXBee TinyGsm; + typedef TinyGsmXBee::GsmClient TinyGsmClient; + typedef TinyGsmXBee::GsmClientSecure TinyGsmClientSecure; #else #error "Please define GSM modem model" diff --git a/src/TinyGsmClientA6.h b/src/TinyGsmClientA6.h index d1104db..da2b027 100644 --- a/src/TinyGsmClientA6.h +++ b/src/TinyGsmClientA6.h @@ -39,24 +39,24 @@ enum RegStatus { }; -class TinyGsm +class TinyGsmA6 { public: class GsmClient : public Client { - friend class TinyGsm; + friend class TinyGsmA6; typedef TinyGsmFifo RxFifo; public: GsmClient() {} - GsmClient(TinyGsm& modem) { + GsmClient(TinyGsmA6& modem) { init(&modem); } - bool init(TinyGsm* modem) { + bool init(TinyGsmA6* modem) { this->at = modem; this->mux = -1; sock_connected = false; @@ -161,7 +161,7 @@ public: String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED; private: - TinyGsm* at; + TinyGsmA6* at; uint8_t mux; bool sock_connected; RxFifo rx; @@ -169,7 +169,7 @@ private: public: - TinyGsm(Stream& stream) + TinyGsmA6(Stream& stream) : stream(stream) { memset(sockets, 0, sizeof(sockets)); diff --git a/src/TinyGsmClientESP8266.h b/src/TinyGsmClientESP8266.h index 93b5d6d..cac65fe 100644 --- a/src/TinyGsmClientESP8266.h +++ b/src/TinyGsmClientESP8266.h @@ -24,24 +24,24 @@ static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; static unsigned TINY_GSM_TCP_KEEP_ALIVE = 120; -class TinyGsm +class TinyGsmESP8266 { public: class GsmClient : public Client { - friend class TinyGsm; + friend class TinyGsmESP8266; typedef TinyGsmFifo RxFifo; public: GsmClient() {} - GsmClient(TinyGsm& modem, uint8_t mux = 1) { + GsmClient(TinyGsmESP8266& modem, uint8_t mux = 1) { init(&modem, mux); } - bool init(TinyGsm* modem, uint8_t mux = 1) { + bool init(TinyGsmESP8266* modem, uint8_t mux = 1) { this->at = modem; this->mux = mux; sock_connected = false; @@ -143,7 +143,7 @@ public: String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED; private: - TinyGsm* at; + TinyGsmESP8266* at; uint8_t mux; bool sock_connected; RxFifo rx; @@ -154,7 +154,7 @@ class GsmClientSecure : public GsmClient public: GsmClientSecure() {} - GsmClientSecure(TinyGsm& modem, uint8_t mux = 1) + GsmClientSecure(TinyGsmESP8266& modem, uint8_t mux = 1) : GsmClient(modem, mux) {} @@ -169,7 +169,7 @@ public: public: - TinyGsm(Stream& stream) + TinyGsmESP8266(Stream& stream) : stream(stream) { memset(sockets, 0, sizeof(sockets)); diff --git a/src/TinyGsmClientM590.h b/src/TinyGsmClientM590.h index e3d3cd3..e0d9431 100644 --- a/src/TinyGsmClientM590.h +++ b/src/TinyGsmClientM590.h @@ -39,24 +39,24 @@ enum RegStatus { }; -class TinyGsm +class TinyGsmM590 { public: class GsmClient : public Client { - friend class TinyGsm; + friend class TinyGsmM590; typedef TinyGsmFifo RxFifo; public: GsmClient() {} - GsmClient(TinyGsm& modem, uint8_t mux = 1) { + GsmClient(TinyGsmM590& modem, uint8_t mux = 1) { init(&modem, mux); } - bool init(TinyGsm* modem, uint8_t mux = 1) { + bool init(TinyGsmM590* modem, uint8_t mux = 1) { this->at = modem; this->mux = mux; sock_connected = false; @@ -158,7 +158,7 @@ public: String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED; private: - TinyGsm* at; + TinyGsmM590* at; uint8_t mux; bool sock_connected; RxFifo rx; @@ -166,7 +166,7 @@ private: public: - TinyGsm(Stream& stream) + TinyGsmM590(Stream& stream) : stream(stream) { memset(sockets, 0, sizeof(sockets)); @@ -403,12 +403,12 @@ public: } return false; -set_dns: - sendAT(GF("+DNSSERVER=1,8.8.8.8")); - waitResponse(); - - sendAT(GF("+DNSSERVER=2,8.8.4.4")); - waitResponse(); +// set_dns: // TODO +// sendAT(GF("+DNSSERVER=1,8.8.8.8")); +// waitResponse(); +// +// sendAT(GF("+DNSSERVER=2,8.8.4.4")); +// waitResponse(); return true; } diff --git a/src/TinyGsmClientXBee.h b/src/TinyGsmClientXBee.h index 70fbbd8..85282a0 100644 --- a/src/TinyGsmClientXBee.h +++ b/src/TinyGsmClientXBee.h @@ -44,23 +44,23 @@ enum RegStatus { }; -class TinyGsm +class TinyGsmXBee { public: class GsmClient : public Client { - friend class TinyGsm; + friend class TinyGsmXBee; public: GsmClient() {} - GsmClient(TinyGsm& modem, uint8_t mux = 0) { + GsmClient(TinyGsmXBee& modem, uint8_t mux = 0) { init(&modem, mux); } - bool init(TinyGsm* modem, uint8_t mux = 0) { + bool init(TinyGsmXBee* modem, uint8_t mux = 0) { this->at = modem; this->mux = mux; sock_connected = false; @@ -131,7 +131,7 @@ public: virtual int read(uint8_t *buf, size_t size) { TINY_GSM_YIELD(); - return at->stream.readBytes((uint8_t*)buf, size); + return at->stream.readBytes((char*)buf, size); } virtual int read() { @@ -157,7 +157,7 @@ public: String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED; private: - TinyGsm* at; + TinyGsmXBee* at; uint8_t mux; bool sock_connected; }; @@ -167,7 +167,7 @@ class GsmClientSecure : public GsmClient public: GsmClientSecure() {} - GsmClientSecure(TinyGsm& modem, uint8_t mux = 1) + GsmClientSecure(TinyGsmXBee& modem, uint8_t mux = 1) : GsmClient(modem, mux) {} @@ -199,7 +199,11 @@ public: public: - TinyGsm(Stream& stream) +#ifdef GSM_DEFAULT_STREAM + TinyGsmXBee(Stream& stream = GSM_DEFAULT_STREAM) +#else + TinyGsmXBee(Stream& stream) +#endif : stream(stream) { memset(sockets, 0, sizeof(sockets));