Moved "OK" and "ERROR" to modem template

Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
Sara Damiano
2024-04-11 16:14:31 -04:00
parent 9659e83b59
commit 56305cb1a4
15 changed files with 29 additions and 121 deletions

View File

@@ -14,6 +14,7 @@
#define TINY_GSM_MUX_COUNT 8
#define TINY_GSM_NO_MODEM_BUFFER
#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem!
#include "TinyGsmBattery.tpp"
#include "TinyGsmCalling.tpp"
@@ -23,14 +24,6 @@
#include "TinyGsmTCP.tpp"
#include "TinyGsmTime.tpp"
#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;
#if defined TINY_GSM_DEBUG
static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:";
static const char GSM_CMS_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CMS ERROR:";
#endif
enum RegStatus {
REG_NO_RESULT = -1,
REG_UNREGISTERED = 0,
@@ -574,7 +567,6 @@ class TinyGsmA6 : public TinyGsmModem<TinyGsmA6>,
protected:
GsmClientA6* sockets[TINY_GSM_MUX_COUNT];
const char* gsmNL = GSM_NL;
};
#endif // SRC_TINYGSMCLIENTA6_H_

View File

@@ -14,6 +14,7 @@
#define TINY_GSM_MUX_COUNT 12
#define TINY_GSM_BUFFER_READ_AND_CHECK_SIZE
#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem!
#include "TinyGsmBattery.tpp"
#include "TinyGsmCalling.tpp"
@@ -26,14 +27,6 @@
#include "TinyGsmTime.tpp"
#include "TinyGsmNTP.tpp"
#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;
#if defined TINY_GSM_DEBUG
static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:";
static const char GSM_CMS_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CMS ERROR:";
#endif
enum RegStatus {
REG_NO_RESULT = -1,
REG_UNREGISTERED = 0,
@@ -721,7 +714,6 @@ class TinyGsmBG96 : public TinyGsmModem<TinyGsmBG96>,
protected:
GsmClientBG96* sockets[TINY_GSM_MUX_COUNT];
const char* gsmNL = GSM_NL;
};
#endif // SRC_TINYGSMCLIENTBG96_H_

View File

@@ -14,16 +14,14 @@
#define TINY_GSM_MUX_COUNT 5
#define TINY_GSM_NO_MODEM_BUFFER
#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem!
#include "TinyGsmModem.tpp"
#include "TinyGsmSSL.tpp"
#include "TinyGsmTCP.tpp"
#include "TinyGsmWifi.tpp"
#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;
static uint8_t TINY_GSM_TCP_KEEP_ALIVE = 120;
static uint8_t TINY_GSM_TCP_KEEP_ALIVE = 120;
// <stat> status of ESP8266 station interface
// 2 : ESP8266 station connected to an AP and has obtained IP
@@ -479,7 +477,6 @@ class TinyGsmESP8266 : public TinyGsmModem<TinyGsmESP8266>,
protected:
GsmClientESP8266* sockets[TINY_GSM_MUX_COUNT];
const char* gsmNL = GSM_NL;
};
#endif // SRC_TINYGSMCLIENTESP8266_H_

View File

@@ -14,6 +14,7 @@
#define TINY_GSM_MUX_COUNT 2
#define TINY_GSM_NO_MODEM_BUFFER
#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem!
#include "TinyGsmGPRS.tpp"
#include "TinyGsmModem.tpp"
@@ -21,14 +22,6 @@
#include "TinyGsmTCP.tpp"
#include "TinyGsmTime.tpp"
#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;
#if defined TINY_GSM_DEBUG
static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:";
static const char GSM_CMS_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CMS ERROR:";
#endif
enum RegStatus {
REG_NO_RESULT = -1,
REG_UNREGISTERED = 0,
@@ -467,7 +460,6 @@ class TinyGsmM590 : public TinyGsmModem<TinyGsmM590>,
protected:
GsmClientM590* sockets[TINY_GSM_MUX_COUNT];
const char* gsmNL = GSM_NL;
};
#endif // SRC_TINYGSMCLIENTM590_H_

View File

@@ -15,6 +15,7 @@
#define TINY_GSM_MUX_COUNT 6
#define TINY_GSM_BUFFER_READ_NO_CHECK
#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem!
#include "TinyGsmBattery.tpp"
#include "TinyGsmCalling.tpp"
@@ -25,14 +26,6 @@
#include "TinyGsmTemperature.tpp"
#include "TinyGsmTime.tpp"
#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;
#if defined TINY_GSM_DEBUG
static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:";
static const char GSM_CMS_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CMS ERROR:";
#endif
enum RegStatus {
REG_NO_RESULT = -1,
REG_UNREGISTERED = 0,
@@ -630,7 +623,6 @@ class TinyGsmM95 : public TinyGsmModem<TinyGsmM95>,
protected:
GsmClientM95* sockets[TINY_GSM_MUX_COUNT];
const char* gsmNL = GSM_NL;
};
#endif // SRC_TINYGSMCLIENTM95_H_

View File

@@ -17,6 +17,7 @@
#define TINY_GSM_MUX_COUNT 6
#define TINY_GSM_BUFFER_READ_NO_CHECK
#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem!
#include "TinyGsmBattery.tpp"
#include "TinyGsmCalling.tpp"
@@ -26,14 +27,6 @@
#include "TinyGsmTCP.tpp"
#include "TinyGsmTime.tpp"
#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;
#if defined TINY_GSM_DEBUG
static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:";
static const char GSM_CMS_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CMS ERROR:";
#endif
enum RegStatus {
REG_NO_RESULT = -1,
REG_UNREGISTERED = 0,
@@ -616,7 +609,6 @@ class TinyGsmMC60 : public TinyGsmModem<TinyGsmMC60>,
protected:
GsmClientMC60* sockets[TINY_GSM_MUX_COUNT];
const char* gsmNL = GSM_NL;
};
#endif // SRC_TINYGSMCLIENTMC60_H_

View File

@@ -14,6 +14,7 @@
#define TINY_GSM_MUX_COUNT 10
#define TINY_GSM_BUFFER_READ_AND_CHECK_SIZE
#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem!
#include "TinyGsmBattery.tpp"
#include "TinyGsmGPRS.tpp"
@@ -25,14 +26,6 @@
#include "TinyGsmTime.tpp"
#include "TinyGsmNTP.tpp"
#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;
#if defined TINY_GSM_DEBUG
static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:";
static const char GSM_CMS_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CMS ERROR:";
#endif
enum RegStatus {
REG_NO_RESULT = -1,
REG_UNREGISTERED = 0,
@@ -735,7 +728,6 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>,
protected:
GsmClientSim5360* sockets[TINY_GSM_MUX_COUNT];
const char* gsmNL = GSM_NL;
};
#endif // SRC_TINYGSMCLIENTSIM5360_H_

View File

@@ -11,6 +11,7 @@
// #define TINY_GSM_DEBUG Serial
// #define TINY_GSM_USE_HEX
#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem!
#include "TinyGsmBattery.tpp"
#include "TinyGsmGPRS.tpp"
@@ -21,14 +22,6 @@
#include "TinyGsmNTP.tpp"
#include "TinyGsmGSMLocation.tpp"
#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;
#if defined TINY_GSM_DEBUG
static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:";
static const char GSM_CMS_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CMS ERROR:";
#endif
enum RegStatus {
REG_NO_RESULT = -1,
REG_UNREGISTERED = 0,
@@ -451,9 +444,6 @@ class TinyGsmSim70xx : public TinyGsmModem<TinyGsmSim70xx<modemType>>,
public:
Stream& stream;
protected:
const char* gsmNL = GSM_NL;
};
#endif // SRC_TINYGSMCLIENTSIM70XX_H_

View File

@@ -14,6 +14,7 @@
#define TINY_GSM_MUX_COUNT 10
#define TINY_GSM_BUFFER_READ_AND_CHECK_SIZE
#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem!
#include "TinyGsmBattery.tpp"
#include "TinyGsmCalling.tpp"
@@ -28,14 +29,6 @@
#include "TinyGsmNTP.tpp"
#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;
#if defined TINY_GSM_DEBUG
static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:";
static const char GSM_CMS_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CMS ERROR:";
#endif
enum RegStatus {
REG_NO_RESULT = -1,
REG_UNREGISTERED = 0,
@@ -860,7 +853,6 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>,
protected:
GsmClientSim7600* sockets[TINY_GSM_MUX_COUNT];
const char* gsmNL = GSM_NL;
};
#endif // SRC_TINYGSMCLIENTSIM7600_H_

View File

@@ -15,6 +15,7 @@
#define TINY_GSM_MUX_COUNT 5
#define TINY_GSM_BUFFER_READ_AND_CHECK_SIZE
#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem!
#include "TinyGsmBattery.tpp"
#include "TinyGsmCalling.tpp"
@@ -27,14 +28,6 @@
#include "TinyGsmTime.tpp"
#include "TinyGsmNTP.tpp"
#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;
#if defined TINY_GSM_DEBUG
static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:";
static const char GSM_CMS_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CMS ERROR:";
#endif
enum RegStatus {
REG_NO_RESULT = -1,
REG_UNREGISTERED = 0,
@@ -765,7 +758,6 @@ class TinyGsmSim800 : public TinyGsmModem<TinyGsmSim800>,
protected:
GsmClientSim800* sockets[TINY_GSM_MUX_COUNT];
const char* gsmNL = GSM_NL;
};
#endif // SRC_TINYGSMCLIENTSIM800_H_

View File

@@ -14,6 +14,7 @@
#define TINY_GSM_MUX_COUNT 7
#define TINY_GSM_BUFFER_READ_AND_CHECK_SIZE
#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem!
#include "TinyGsmBattery.tpp"
#include "TinyGsmGPRS.tpp"
@@ -26,14 +27,6 @@
#include "TinyGsmTemperature.tpp"
#include "TinyGsmTime.tpp"
#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;
#if defined TINY_GSM_DEBUG
static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:";
static const char GSM_CMS_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CMS ERROR:";
#endif
enum RegStatus {
REG_NO_RESULT = -1,
REG_UNREGISTERED = 0,
@@ -892,7 +885,6 @@ class TinyGsmSaraR4 : public TinyGsmModem<TinyGsmSaraR4>,
protected:
GsmClientSaraR4* sockets[TINY_GSM_MUX_COUNT];
const char* gsmNL = GSM_NL;
bool has2GFallback;
bool supportsAsyncSockets;
};

View File

@@ -13,6 +13,7 @@
#define TINY_GSM_MUX_COUNT 6
#define TINY_GSM_BUFFER_READ_AND_CHECK_SIZE
#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem!
#include "TinyGsmCalling.tpp"
#include "TinyGsmGPRS.tpp"
@@ -23,14 +24,6 @@
#include "TinyGsmTemperature.tpp"
#include "TinyGsmTime.tpp"
#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;
#if defined TINY_GSM_DEBUG
static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:";
static const char GSM_CMS_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CMS ERROR:";
#endif
enum RegStatus {
REG_NO_RESULT = -1,
REG_UNREGISTERED = 0,
@@ -727,7 +720,7 @@ class TinyGsmSequansMonarch
protected:
GsmClientSequansMonarch* sockets[TINY_GSM_MUX_COUNT];
// GSM_NL (\r\n) is not accepted with SQNSSENDEXT in data mode so use \n
const char* gsmNL = "\n";
const char* gsmNL = "\n";
};
#endif // SRC_TINYGSMCLIENTSEQUANSMONARCH_H_

View File

@@ -14,6 +14,7 @@
#define TINY_GSM_MUX_COUNT 7
#define TINY_GSM_BUFFER_READ_AND_CHECK_SIZE
#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem!
#include "TinyGsmBattery.tpp"
#include "TinyGsmCalling.tpp"
@@ -26,14 +27,6 @@
#include "TinyGsmTCP.tpp"
#include "TinyGsmTime.tpp"
#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;
#if defined TINY_GSM_DEBUG
static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:";
static const char GSM_CMS_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CMS ERROR:";
#endif
enum RegStatus {
REG_NO_RESULT = -1,
REG_UNREGISTERED = 0,
@@ -848,7 +841,6 @@ class TinyGsmUBLOX : public TinyGsmModem<TinyGsmUBLOX>,
protected:
GsmClientUBLOX* sockets[TINY_GSM_MUX_COUNT];
const char* gsmNL = GSM_NL;
};
#endif // SRC_TINYGSMCLIENTUBLOX_H_

View File

@@ -20,6 +20,7 @@
// XBee's have a default guard time of 1 second (1000ms, 10 extra for safety
// here)
#define TINY_GSM_XBEE_GUARD_TIME 1010
#define GSM_NL "\r" // NOTE: define before including TinyGsmModem!
#include "TinyGsmBattery.tpp"
#include "TinyGsmGPRS.tpp"
@@ -30,10 +31,6 @@
#include "TinyGsmTemperature.tpp"
#include "TinyGsmWifi.tpp"
#define GSM_NL "\r"
static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL;
static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL;
// Use this to avoid too many entrances and exits from command mode.
// The cellular Bee's often freeze up and won't respond when attempting
// to enter command mode too many times.
@@ -1623,7 +1620,6 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
protected:
GsmClientXBee* sockets[TINY_GSM_MUX_COUNT];
const char* gsmNL = GSM_NL;
int16_t guardTime;
XBeeType beeType;
int8_t resetPin;

View File

@@ -11,6 +11,18 @@
#include "TinyGsmCommon.h"
#ifndef GSM_NL
#define GSM_NL "\r\n"
#endif
static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL;
static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL;
#if defined TINY_GSM_DEBUG
static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:";
static const char GSM_CMS_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CMS ERROR:";
#endif
template <class modemType>
class TinyGsmModem {
public:
@@ -25,7 +37,7 @@ class TinyGsmModem {
}
template <typename... Args>
inline void sendAT(Args... cmd) {
thisModem().streamWrite("AT", cmd..., thisModem().gsmNL);
thisModem().streamWrite("AT", cmd..., GSM_NL);
thisModem().stream.flush();
TINY_GSM_YIELD(); /* DBG("### AT:", cmd...); */
}