diff --git a/TinyGsmClient.h b/TinyGsmClient.h index ed3b88c..7c704d6 100644 --- a/TinyGsmClient.h +++ b/TinyGsmClient.h @@ -9,35 +9,6 @@ #ifndef TinyGsmClient_h #define TinyGsmClient_h -#if defined(SPARK) || defined(PARTICLE) - #include "Particle.h" -#elif defined(ARDUINO) - #if ARDUINO >= 100 - #include "Arduino.h" - #else - #include "WProgram.h" - #endif -#endif - -#include -#include - -#ifndef TINY_GSM_YIELD - #define TINY_GSM_YIELD() { delay(0); } -#endif - -#if defined(__AVR__) - #define TINY_GSM_PROGMEM PROGMEM - typedef const __FlashStringHelper* GsmConstStr; - #define GFP(x) (reinterpret_cast(x)) - #define GF(x) F(x) -#else - #define TINY_GSM_PROGMEM - typedef const char* GsmConstStr; - #define GFP(x) x - #define GF(x) x -#endif - #if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_SIM900) #include #elif defined(TINY_GSM_MODEM_M590) diff --git a/TinyGsmClientM590.h b/TinyGsmClientM590.h index e857d78..a06e2f6 100644 --- a/TinyGsmClientM590.h +++ b/TinyGsmClientM590.h @@ -10,12 +10,13 @@ #define TinyGsmClientM590_h //#define GSM_DEBUG Serial -//#define GSM_USE_HEX #if !defined(TINY_GSM_RX_BUFFER) #define TINY_GSM_RX_BUFFER 256 #endif +#include + #define GSM_NL "\r\n" static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; @@ -39,22 +40,6 @@ enum RegStatus { class TinyGsm { -#ifdef GSM_DEBUG - template - static void DBG(T last) { - GSM_DEBUG.println(last); - } - - template - static void DBG(T head, Args... tail) { - GSM_DEBUG.print(head); - GSM_DEBUG.print(' '); - DBG(tail...); - } -#else - #define DBG(...) -#endif - public: TinyGsm(Stream& stream) : stream(stream) diff --git a/TinyGsmClientSIM800.h b/TinyGsmClientSIM800.h index 848ed1a..658ff76 100644 --- a/TinyGsmClientSIM800.h +++ b/TinyGsmClientSIM800.h @@ -16,6 +16,8 @@ #define TINY_GSM_RX_BUFFER 64 #endif +#include + #define GSM_NL "\r\n" static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; @@ -39,22 +41,6 @@ enum RegStatus { class TinyGsm { -#ifdef GSM_DEBUG - template - static void DBG(T last) { - GSM_DEBUG.println(last); - } - - template - static void DBG(T head, Args... tail) { - GSM_DEBUG.print(head); - GSM_DEBUG.print(' '); - DBG(tail...); - } -#else - #define DBG(...) -#endif - public: TinyGsm(Stream& stream) : stream(stream) diff --git a/TinyGsmCommon.h b/TinyGsmCommon.h new file mode 100644 index 0000000..7455274 --- /dev/null +++ b/TinyGsmCommon.h @@ -0,0 +1,59 @@ +/** + * @file TinyGsmCommon.h + * @author Volodymyr Shymanskyy + * @license LGPL-3.0 + * @copyright Copyright (c) 2016 Volodymyr Shymanskyy + * @date Nov 2016 + */ + +#ifndef TinyGsmCommon_h +#define TinyGsmCommon_h + +#if defined(SPARK) || defined(PARTICLE) + #include "Particle.h" +#elif defined(ARDUINO) + #if ARDUINO >= 100 + #include "Arduino.h" + #else + #include "WProgram.h" + #endif +#endif + +#include +#include + +#ifndef TINY_GSM_YIELD + #define TINY_GSM_YIELD() { delay(0); } +#endif + +#if defined(__AVR__) + #define TINY_GSM_PROGMEM PROGMEM + typedef const __FlashStringHelper* GsmConstStr; + #define GFP(x) (reinterpret_cast(x)) + #define GF(x) F(x) +#else + #define TINY_GSM_PROGMEM + typedef const char* GsmConstStr; + #define GFP(x) x + #define GF(x) x +#endif + +#ifdef GSM_DEBUG +namespace { + template + static void DBG(T last) { + GSM_DEBUG.println(last); + } + + template + static void DBG(T head, Args... tail) { + GSM_DEBUG.print(head); + GSM_DEBUG.print(' '); + DBG(tail...); + } +} +#else + #define DBG(...) +#endif + +#endif diff --git a/TinyWiFiClientESP8266.h b/TinyWiFiClientESP8266.h index 7430cce..4ac9ea3 100644 --- a/TinyWiFiClientESP8266.h +++ b/TinyWiFiClientESP8266.h @@ -10,12 +10,13 @@ #define TinyWiFiClientESP8266_h //#define GSM_DEBUG Serial -//#define GSM_USE_HEX #if !defined(TINY_GSM_RX_BUFFER) #define TINY_GSM_RX_BUFFER 256 #endif +#include + #define GSM_NL "\r\n" static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; @@ -23,22 +24,6 @@ static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; class TinyGsm { -#ifdef GSM_DEBUG - template - static void DBG(T last) { - GSM_DEBUG.println(last); - } - - template - static void DBG(T head, Args... tail) { - GSM_DEBUG.print(head); - GSM_DEBUG.print(' '); - DBG(tail...); - } -#else - #define DBG(...) -#endif - public: TinyGsm(Stream& stream) : stream(stream)