Many sub templates to inherit from!
This commit is contained in:
@@ -13,7 +13,14 @@
|
||||
|
||||
#define TINY_GSM_MUX_COUNT 6
|
||||
|
||||
#include "TinyGsmCommon.h"
|
||||
#include "TinyGsmCalling.tpp"
|
||||
#include "TinyGsmGPRS.tpp"
|
||||
#include "TinyGsmModem.tpp"
|
||||
#include "TinyGsmSMS.tpp"
|
||||
#include "TinyGsmSSL.tpp"
|
||||
#include "TinyGsmTCP.tpp"
|
||||
#include "TinyGsmTemperature.tpp"
|
||||
#include "TinyGsmTime.tpp"
|
||||
|
||||
#define GSM_NL "\r\n"
|
||||
static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL;
|
||||
@@ -41,10 +48,24 @@ enum SocketStatus {
|
||||
};
|
||||
|
||||
class TinyGsmSequansMonarch
|
||||
: public TinyGsmModem<TinyGsmSequansMonarch, READ_AND_CHECK_SIZE,
|
||||
TINY_GSM_MUX_COUNT> {
|
||||
friend class TinyGsmModem<TinyGsmSequansMonarch, READ_AND_CHECK_SIZE,
|
||||
TINY_GSM_MUX_COUNT>;
|
||||
: public TinyGsmModem<TinyGsmSequansMonarch>,
|
||||
public TinyGsmGPRS<TinyGsmSequansMonarch>,
|
||||
public TinyGsmTCP<TinyGsmSequansMonarch, READ_AND_CHECK_SIZE,
|
||||
TINY_GSM_MUX_COUNT>,
|
||||
public TinyGsmSSL<TinyGsmSequansMonarch>,
|
||||
public TinyGsmCalling<TinyGsmSequansMonarch>,
|
||||
public TinyGsmSMS<TinyGsmSequansMonarch>,
|
||||
public TinyGsmTime<TinyGsmSequansMonarch>,
|
||||
public TinyGsmTemperature<TinyGsmSequansMonarch> {
|
||||
friend class TinyGsmModem<TinyGsmSequansMonarch>;
|
||||
friend class TinyGsmGPRS<TinyGsmSequansMonarch>;
|
||||
friend class TinyGsmTCP<TinyGsmSequansMonarch, READ_AND_CHECK_SIZE,
|
||||
TINY_GSM_MUX_COUNT>;
|
||||
friend class TinyGsmSSL<TinyGsmSequansMonarch>;
|
||||
friend class TinyGsmCalling<TinyGsmSequansMonarch>;
|
||||
friend class TinyGsmSMS<TinyGsmSequansMonarch>;
|
||||
friend class TinyGsmTime<TinyGsmSequansMonarch>;
|
||||
friend class TinyGsmTemperature<TinyGsmSequansMonarch>;
|
||||
|
||||
/*
|
||||
* Inner Client
|
||||
@@ -77,24 +98,16 @@ class TinyGsmSequansMonarch
|
||||
}
|
||||
|
||||
public:
|
||||
int connect(const char* host, uint16_t port, int timeout_s) {
|
||||
virtual int connect(const char* host, uint16_t port, int timeout_s) {
|
||||
if (sock_connected) stop();
|
||||
TINY_GSM_YIELD();
|
||||
rx.clear();
|
||||
sock_connected = at->modemConnect(host, port, mux, false, timeout_s);
|
||||
return sock_connected;
|
||||
}
|
||||
int connect(IPAddress ip, uint16_t port, int timeout_s) {
|
||||
return connect(TinyGsmStringFromIp(ip).c_str(), port, timeout_s);
|
||||
}
|
||||
int connect(const char* host, uint16_t port) override {
|
||||
return connect(host, port, 75);
|
||||
}
|
||||
int connect(IPAddress ip, uint16_t port) override {
|
||||
return connect(ip, port, 75);
|
||||
}
|
||||
TINY_GSM_CLIENT_CONNECT_OVERRIDES
|
||||
|
||||
void stop(uint32_t maxWaitMs) {
|
||||
virtual void stop(uint32_t maxWaitMs) {
|
||||
dumpModemBuffer(maxWaitMs);
|
||||
at->sendAT(GF("+SQNSH="), mux);
|
||||
sock_connected = false;
|
||||
@@ -127,7 +140,7 @@ class TinyGsmSequansMonarch
|
||||
bool strictSSL = false;
|
||||
|
||||
public:
|
||||
int connect(const char* host, uint16_t port, int timeout_s) {
|
||||
int connect(const char* host, uint16_t port, int timeout_s) override {
|
||||
stop();
|
||||
TINY_GSM_YIELD();
|
||||
rx.clear();
|
||||
@@ -153,6 +166,7 @@ class TinyGsmSequansMonarch
|
||||
sock_connected = at->modemConnect(host, port, mux, true, timeout_s);
|
||||
return sock_connected;
|
||||
}
|
||||
TINY_GSM_CLIENT_CONNECT_OVERRIDES
|
||||
|
||||
void setStrictSSL(bool strict) {
|
||||
strictSSL = strict;
|
||||
@@ -225,18 +239,6 @@ class TinyGsmSequansMonarch
|
||||
while (stream.available()) { waitResponse(15, NULL, NULL); }
|
||||
}
|
||||
|
||||
bool thisHasGPRS() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool thisHasWifi() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool thisHasSSL() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Power functions
|
||||
*/
|
||||
@@ -287,16 +289,9 @@ class TinyGsmSequansMonarch
|
||||
RegStatus s = getRegistrationStatus();
|
||||
return (s == REG_OK_HOME || s == REG_OK_ROAMING);
|
||||
}
|
||||
|
||||
/*
|
||||
* IP Address functions
|
||||
*/
|
||||
protected:
|
||||
String getLocalIPImpl() {
|
||||
sendAT(GF("+CGPADDR=3"));
|
||||
if (waitResponse(10000L, GF("+CGPADDR: 3,\"")) != 1) {
|
||||
return "";
|
||||
}
|
||||
if (waitResponse(10000L, GF("+CGPADDR: 3,\"")) != 1) { return ""; }
|
||||
String res = stream.readStringUntil('\"');
|
||||
waitResponse();
|
||||
return res;
|
||||
@@ -344,9 +339,7 @@ class TinyGsmSequansMonarch
|
||||
protected:
|
||||
String getSimCCIDImpl() {
|
||||
sendAT(GF("+SQNCCID"));
|
||||
if (waitResponse(GF(GSM_NL "+SQNCCID:")) != 1) {
|
||||
return "";
|
||||
}
|
||||
if (waitResponse(GF(GSM_NL "+SQNCCID:")) != 1) { return ""; }
|
||||
String res = stream.readStringUntil('\n');
|
||||
waitResponse();
|
||||
res.trim();
|
||||
@@ -367,18 +360,6 @@ class TinyGsmSequansMonarch
|
||||
protected:
|
||||
// Follows all messaging functions per template
|
||||
|
||||
/*
|
||||
* Location functions
|
||||
*/
|
||||
protected:
|
||||
String getGsmLocationImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
|
||||
/*
|
||||
* GPS location functions
|
||||
*/
|
||||
public:
|
||||
// No functions of this type supported
|
||||
|
||||
/*
|
||||
* Time functions
|
||||
*/
|
||||
@@ -386,14 +367,8 @@ class TinyGsmSequansMonarch
|
||||
// Can follow the standard CCLK function in the template
|
||||
|
||||
/*
|
||||
* Battery & temperature functions
|
||||
* Temperature functions
|
||||
*/
|
||||
protected:
|
||||
uint16_t getBattVoltageImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
int8_t getBattPercentImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
uint8_t getBattChargeStateImpl() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
bool getBattStatsImpl(uint8_t& chargeState, int8_t& percent,
|
||||
uint16_t& milliVolts) TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||
|
||||
float getTemperatureImpl() {
|
||||
sendAT(GF("+SMDTH"));
|
||||
|
||||
Reference in New Issue
Block a user