Add TinyGsmCommon
This commit is contained in:
@@ -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 <Client.h>
|
||||
#include <TinyGsmFifo.h>
|
||||
|
||||
#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<GsmConstStr>(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 <TinyGsmClientSIM800.h>
|
||||
#elif defined(TINY_GSM_MODEM_M590)
|
||||
|
@@ -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 <TinyGsmCommon.h>
|
||||
|
||||
#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<typename T>
|
||||
static void DBG(T last) {
|
||||
GSM_DEBUG.println(last);
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
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)
|
||||
|
@@ -16,6 +16,8 @@
|
||||
#define TINY_GSM_RX_BUFFER 64
|
||||
#endif
|
||||
|
||||
#include <TinyGsmCommon.h>
|
||||
|
||||
#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<typename T>
|
||||
static void DBG(T last) {
|
||||
GSM_DEBUG.println(last);
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
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)
|
||||
|
59
TinyGsmCommon.h
Normal file
59
TinyGsmCommon.h
Normal file
@@ -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 <Client.h>
|
||||
#include <TinyGsmFifo.h>
|
||||
|
||||
#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<GsmConstStr>(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<typename T>
|
||||
static void DBG(T last) {
|
||||
GSM_DEBUG.println(last);
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
static void DBG(T head, Args... tail) {
|
||||
GSM_DEBUG.print(head);
|
||||
GSM_DEBUG.print(' ');
|
||||
DBG(tail...);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define DBG(...)
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -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 <TinyGsmCommon.h>
|
||||
|
||||
#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<typename T>
|
||||
static void DBG(T last) {
|
||||
GSM_DEBUG.println(last);
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
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)
|
||||
|
Reference in New Issue
Block a user