From c5c3cd2af58c3a53ccafbfcbb1e3523d433448e5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 12 Sep 2018 15:44:59 -0400 Subject: [PATCH] Back to virtual super class --- src/TinyGsmClientA6.h | 3 +- src/TinyGsmClientESP8266.h | 3 +- src/TinyGsmClientUBLOX.h | 3 +- src/TinyGsmCommon.h | 116 ++++++++----------------------------- 4 files changed, 28 insertions(+), 97 deletions(-) diff --git a/src/TinyGsmClientA6.h b/src/TinyGsmClientA6.h index b1574ec..5f720e2 100644 --- a/src/TinyGsmClientA6.h +++ b/src/TinyGsmClientA6.h @@ -285,8 +285,7 @@ public: bool radioOff() TINY_GSM_ATTR_NOT_IMPLEMENTED; - bool sleepEnable(bool enable = true) { return false; } - // TINY_GSM_ATTR_NOT_IMPLEMENTED; + bool sleepEnable(bool enable = true) TINY_GSM_ATTR_NOT_IMPLEMENTED; /* * SIM card functions diff --git a/src/TinyGsmClientESP8266.h b/src/TinyGsmClientESP8266.h index 240fab4..a87432e 100644 --- a/src/TinyGsmClientESP8266.h +++ b/src/TinyGsmClientESP8266.h @@ -298,8 +298,7 @@ public: bool radioOff() TINY_GSM_ATTR_NOT_IMPLEMENTED; - bool sleepEnable(bool enable = true) { return false; } - // TINY_GSM_ATTR_NOT_IMPLEMENTED; + bool sleepEnable(bool enable = true) TINY_GSM_ATTR_NOT_IMPLEMENTED; /* * SIM card functions diff --git a/src/TinyGsmClientUBLOX.h b/src/TinyGsmClientUBLOX.h index 9a61b60..42c736a 100644 --- a/src/TinyGsmClientUBLOX.h +++ b/src/TinyGsmClientUBLOX.h @@ -316,8 +316,7 @@ public: return true; } - bool sleepEnable(bool enable = true) { return false; } - // TINY_GSM_ATTR_NOT_IMPLEMENTED; + bool sleepEnable(bool enable = true) TINY_GSM_ATTR_NOT_IMPLEMENTED; /* * SIM card functions diff --git a/src/TinyGsmCommon.h b/src/TinyGsmCommon.h index fb53f32..d46ede1 100644 --- a/src/TinyGsmCommon.h +++ b/src/TinyGsmCommon.h @@ -212,104 +212,51 @@ public: */ // Prepare the modem for further functionality - virtual bool init(const char* pin = NULL) { - DBG_PLAIN("init function not implemented"); - return false; - } + virtual bool init(const char* pin = NULL) = 0; // Begin is redundant with init virtual bool begin(const char* pin = NULL) { return init(pin); } // Returns a string with the chip name - virtual String getModemName() { - DBG_PLAIN("getModemName function not implemented"); - return ""; - } + virtual String getModemName() = 0; // Sets the serial communication baud rate - virtual void setBaud(unsigned long baud) { - DBG_PLAIN("setBaud function not implemented"); - } + virtual void setBaud(unsigned long baud) = 0; // Checks that the modem is responding to standard AT commands - virtual bool testAT(unsigned long timeout = 10000L) { - DBG_PLAIN("testAT function not implemented"); - return false; - } + virtual bool testAT(unsigned long timeout = 10000L) = 0; // Holds open communication with the modem waiting for data to come in - virtual void maintain() { - DBG_PLAIN("maintain function not implemented"); - } + virtual void maintain() = 0; // Resets all modem chip settings to factor defaults - virtual bool factoryDefault() { - DBG_PLAIN("factoryDefault function not implemented"); - return false; - } + virtual bool factoryDefault() = 0; // Returns the response to a get info request. The format varies by modem. - virtual String getModemInfo() { - DBG_PLAIN("getModemInfo function not implemented"); - return ""; - } - // Answers whether secure communication is available on this modem - virtual bool hasSSL() { - DBG_PLAIN("hasSSL function not implemented"); - return false; - } - virtual bool hasWifi() { - DBG_PLAIN("hasWifi function not implemented"); - return false; - } - virtual bool hasGPRS() { - DBG_PLAIN("hasGPRS function not implemented"); - return false; - } + virtual String getModemInfo() = 0; + // Answers whether types of communication are available on this modem + virtual bool hasSSL() = 0; + virtual bool hasWifi() = 0; + virtual bool hasGPRS() = 0; /* * Power functions */ - virtual bool restart() { - DBG_PLAIN("restart function not implemented"); - return false; - } - virtual bool sleepEnable(bool enable = true) { - DBG_PLAIN("sleepEnable function not implemented"); - return false; - } + virtual bool restart() = 0; /* - * SIM card functions + * SIM card functions - only apply to cellular modems */ - virtual bool simUnlock(const char *pin) { - DBG_PLAIN("simUnlock function not implemented"); - return false; - } - virtual String getSimCCID() { - DBG_PLAIN("getSimCCID function not implemented"); - return ""; - } - virtual String getIMEI() { - DBG_PLAIN("getIMEI function not implemented"); - return ""; - } - virtual String getOperator() { - DBG_PLAIN("getOperator function not implemented"); - return ""; - } + virtual bool simUnlock(const char *pin) { return false; } + virtual String getSimCCID() { return ""; } + virtual String getIMEI() { return ""; } + virtual String getOperator() { return ""; } /* * Generic network functions */ - virtual int getSignalQuality() { - DBG_PLAIN("getSignalQuality function not implemented"); - return 0; - } + virtual int getSignalQuality() = 0; // NOTE: this returns whether the modem is registered on the cellular or WiFi // network NOT whether GPRS or other internet connections are available - virtual bool isNetworkConnected() { - DBG_PLAIN("isNetworkConnected function not implemented"); - return false; - } + virtual bool isNetworkConnected() = 0; virtual bool waitForNetwork(unsigned long timeout = 60000L) { for (unsigned long start = millis(); millis() - start < timeout; ) { if (isNetworkConnected()) { @@ -321,39 +268,26 @@ public: } /* - * WiFi functions + * WiFi functions - only apply to WiFi modems */ - virtual bool networkConnect(const char* ssid, const char* pwd) { - DBG_PLAIN("networkConnect function not implemented"); - return false; - } - virtual bool networkDisconnect() { - DBG_PLAIN("networkDisconnect function not implemented"); - return false; - } + virtual bool networkConnect(const char* ssid, const char* pwd) { return false; } + virtual bool networkDisconnect() { return false; } /* - * GPRS functions + * GPRS functions - only apply to cellular modems */ virtual bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) { - DBG_PLAIN("gprsConnect function not implemented"); - return false; - } - virtual bool gprsDisconnect() { - DBG_PLAIN("gprsDisconnect function not implemented"); return false; } + virtual bool gprsDisconnect() { return false; } /* * IP Address functions */ - virtual String getLocalIP() { - DBG_PLAIN("getLocalIP function not implemented"); - return ""; - } + virtual String getLocalIP() = 0; virtual IPAddress localIP() { return TinyGsmIpFromString(getLocalIP()); }