Removed parent class
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "TinyGSM",
|
"name": "TinyGSM",
|
||||||
"version": "0.6.2",
|
"version": "0.7.0",
|
||||||
"description": "A small Arduino library for GPRS modules, that just works. Includes examples for Blynk, MQTT, File Download, and Web Client. Supports many GSM, LTE, and WiFi modules with AT command interfaces.",
|
"description": "A small Arduino library for GPRS modules, that just works. Includes examples for Blynk, MQTT, File Download, and Web Client. Supports many GSM, LTE, and WiFi modules with AT command interfaces.",
|
||||||
"keywords": "GSM, AT commands, AT, SIM800, SIM900, A6, A7, M590, ESP8266, SIM7000, SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868, SIM900A, SIM900D, SIM908, SIM968, M95, MC60, MC60E, BG96, ublox, Quectel, SIMCOM, AI Thinker, LTE, LTE-M",
|
"keywords": "GSM, AT commands, AT, SIM800, SIM900, A6, A7, M590, ESP8266, SIM7000, SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868, SIM900A, SIM900D, SIM908, SIM968, M95, MC60, MC60E, BG96, ublox, Quectel, SIMCOM, AI Thinker, LTE, LTE-M",
|
||||||
"authors":
|
"authors":
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
name=TinyGSM
|
name=TinyGSM
|
||||||
version=0.6.2
|
version=0.7.0
|
||||||
author=Volodymyr Shymanskyy
|
author=Volodymyr Shymanskyy
|
||||||
maintainer=Volodymyr Shymanskyy
|
maintainer=Volodymyr Shymanskyy
|
||||||
sentence=A small Arduino library for GPRS modules, that just works.
|
sentence=A small Arduino library for GPRS modules, that just works.
|
||||||
|
@@ -36,7 +36,7 @@ enum RegStatus {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmA6 : public TinyGsmModem
|
class TinyGsmA6
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -180,7 +180,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
TinyGsmA6(Stream& stream)
|
TinyGsmA6(Stream& stream)
|
||||||
: TinyGsmModem(stream), stream(stream)
|
: stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
}
|
}
|
||||||
@@ -207,6 +207,10 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool begin(const char* pin = NULL) {
|
||||||
|
return init(pin);
|
||||||
|
}
|
||||||
|
|
||||||
String getModemName() {
|
String getModemName() {
|
||||||
#if defined(TINY_GSM_MODEM_A6)
|
#if defined(TINY_GSM_MODEM_A6)
|
||||||
return "AI-Thinker A6";
|
return "AI-Thinker A6";
|
||||||
@@ -380,6 +384,16 @@ public:
|
|||||||
return (s == REG_OK_HOME || s == REG_OK_ROAMING);
|
return (s == REG_OK_HOME || s == REG_OK_ROAMING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool waitForNetwork(unsigned long timeout = 60000L) {
|
||||||
|
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
||||||
|
if (isNetworkConnected()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
delay(250);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GPRS functions
|
* GPRS functions
|
||||||
*/
|
*/
|
||||||
@@ -454,6 +468,10 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPAddress localIP() {
|
||||||
|
return TinyGsmIpFromString(getLocalIP());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Phone Call functions
|
* Phone Call functions
|
||||||
*/
|
*/
|
||||||
@@ -655,6 +673,17 @@ public:
|
|||||||
Utilities
|
Utilities
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void streamWrite(T last) {
|
||||||
|
stream.print(last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
void streamWrite(T head, Args... tail) {
|
||||||
|
stream.print(head);
|
||||||
|
streamWrite(tail...);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void sendAT(Args... cmd) {
|
void sendAT(Args... cmd) {
|
||||||
streamWrite("AT", cmd..., GSM_NL);
|
streamWrite("AT", cmd..., GSM_NL);
|
||||||
@@ -663,6 +692,19 @@ public:
|
|||||||
//DBG("### AT:", cmd...);
|
//DBG("### AT:", cmd...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool streamSkipUntil(const char c, const unsigned long timeout = 1000L) {
|
||||||
|
unsigned long startMillis = millis();
|
||||||
|
while (millis() - startMillis < timeout) {
|
||||||
|
while (millis() - startMillis < timeout && !stream.available()) {
|
||||||
|
TINY_GSM_YIELD();
|
||||||
|
}
|
||||||
|
if (stream.read() == c) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Optimize this!
|
// TODO: Optimize this!
|
||||||
uint8_t waitResponse(uint32_t timeout, String& data,
|
uint8_t waitResponse(uint32_t timeout, String& data,
|
||||||
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
||||||
|
@@ -37,7 +37,7 @@ enum RegStatus {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmBG96 : public TinyGsmModem
|
class TinyGsmBG96
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -216,7 +216,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
TinyGsmBG96(Stream& stream)
|
TinyGsmBG96(Stream& stream)
|
||||||
: TinyGsmModem(stream), stream(stream)
|
: stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
}
|
}
|
||||||
@@ -239,6 +239,10 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool begin(const char* pin = NULL) {
|
||||||
|
return init(pin);
|
||||||
|
}
|
||||||
|
|
||||||
String getModemName() {
|
String getModemName() {
|
||||||
return "Quectel BG96";
|
return "Quectel BG96";
|
||||||
}
|
}
|
||||||
@@ -424,6 +428,16 @@ public:
|
|||||||
return (s == REG_OK_HOME || s == REG_OK_ROAMING);
|
return (s == REG_OK_HOME || s == REG_OK_ROAMING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool waitForNetwork(unsigned long timeout = 60000L) {
|
||||||
|
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
||||||
|
if (isNetworkConnected()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
delay(250);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GPRS functions
|
* GPRS functions
|
||||||
*/
|
*/
|
||||||
@@ -486,6 +500,10 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPAddress localIP() {
|
||||||
|
return TinyGsmIpFromString(getLocalIP());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Phone Call functions
|
* Phone Call functions
|
||||||
*/
|
*/
|
||||||
@@ -705,6 +723,17 @@ public:
|
|||||||
Utilities
|
Utilities
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void streamWrite(T last) {
|
||||||
|
stream.print(last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
void streamWrite(T head, Args... tail) {
|
||||||
|
stream.print(head);
|
||||||
|
streamWrite(tail...);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void sendAT(Args... cmd) {
|
void sendAT(Args... cmd) {
|
||||||
streamWrite("AT", cmd..., GSM_NL);
|
streamWrite("AT", cmd..., GSM_NL);
|
||||||
@@ -713,6 +742,19 @@ public:
|
|||||||
//DBG("### AT:", cmd...);
|
//DBG("### AT:", cmd...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool streamSkipUntil(const char c, const unsigned long timeout = 1000L) {
|
||||||
|
unsigned long startMillis = millis();
|
||||||
|
while (millis() - startMillis < timeout) {
|
||||||
|
while (millis() - startMillis < timeout && !stream.available()) {
|
||||||
|
TINY_GSM_YIELD();
|
||||||
|
}
|
||||||
|
if (stream.read() == c) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Optimize this!
|
// TODO: Optimize this!
|
||||||
uint8_t waitResponse(uint32_t timeout, String& data,
|
uint8_t waitResponse(uint32_t timeout, String& data,
|
||||||
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
||||||
|
@@ -36,7 +36,7 @@ enum RegStatus {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmESP8266 : public TinyGsmModem
|
class TinyGsmESP8266
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -201,7 +201,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
TinyGsmESP8266(Stream& stream)
|
TinyGsmESP8266(Stream& stream)
|
||||||
: TinyGsmModem(stream), stream(stream)
|
: stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
}
|
}
|
||||||
@@ -231,6 +231,10 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool begin(const char* pin = NULL) {
|
||||||
|
return init(pin);
|
||||||
|
}
|
||||||
|
|
||||||
String getModemName() {
|
String getModemName() {
|
||||||
return "ESP8266";
|
return "ESP8266";
|
||||||
}
|
}
|
||||||
@@ -395,6 +399,10 @@ public:
|
|||||||
return res2;
|
return res2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPAddress localIP() {
|
||||||
|
return TinyGsmIpFromString(getLocalIP());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Client related functions
|
* Client related functions
|
||||||
*/
|
*/
|
||||||
@@ -440,6 +448,17 @@ public:
|
|||||||
Utilities
|
Utilities
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void streamWrite(T last) {
|
||||||
|
stream.print(last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
void streamWrite(T head, Args... tail) {
|
||||||
|
stream.print(head);
|
||||||
|
streamWrite(tail...);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void sendAT(Args... cmd) {
|
void sendAT(Args... cmd) {
|
||||||
streamWrite("AT", cmd..., GSM_NL);
|
streamWrite("AT", cmd..., GSM_NL);
|
||||||
@@ -448,6 +467,19 @@ public:
|
|||||||
//DBG("### AT:", cmd...);
|
//DBG("### AT:", cmd...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool streamSkipUntil(const char c, const unsigned long timeout = 1000L) {
|
||||||
|
unsigned long startMillis = millis();
|
||||||
|
while (millis() - startMillis < timeout) {
|
||||||
|
while (millis() - startMillis < timeout && !stream.available()) {
|
||||||
|
TINY_GSM_YIELD();
|
||||||
|
}
|
||||||
|
if (stream.read() == c) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Optimize this!
|
// TODO: Optimize this!
|
||||||
uint8_t waitResponse(uint32_t timeout, String& data,
|
uint8_t waitResponse(uint32_t timeout, String& data,
|
||||||
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
||||||
|
@@ -36,7 +36,7 @@ enum RegStatus {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmM590 : public TinyGsmModem
|
class TinyGsmM590
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -177,7 +177,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
TinyGsmM590(Stream& stream)
|
TinyGsmM590(Stream& stream)
|
||||||
: TinyGsmModem(stream), stream(stream)
|
: stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
}
|
}
|
||||||
@@ -204,6 +204,10 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool begin(const char* pin = NULL) {
|
||||||
|
return init(pin);
|
||||||
|
}
|
||||||
|
|
||||||
String getModemName() {
|
String getModemName() {
|
||||||
return "Neoway M590";
|
return "Neoway M590";
|
||||||
}
|
}
|
||||||
@@ -384,6 +388,16 @@ public:
|
|||||||
return (s == REG_OK_HOME || s == REG_OK_ROAMING);
|
return (s == REG_OK_HOME || s == REG_OK_ROAMING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool waitForNetwork(unsigned long timeout = 60000L) {
|
||||||
|
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
||||||
|
if (isNetworkConnected()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
delay(250);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GPRS functions
|
* GPRS functions
|
||||||
*/
|
*/
|
||||||
@@ -456,6 +470,10 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPAddress localIP() {
|
||||||
|
return TinyGsmIpFromString(getLocalIP());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Phone Call functions
|
* Phone Call functions
|
||||||
*/
|
*/
|
||||||
@@ -596,6 +614,17 @@ public:
|
|||||||
Utilities
|
Utilities
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void streamWrite(T last) {
|
||||||
|
stream.print(last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
void streamWrite(T head, Args... tail) {
|
||||||
|
stream.print(head);
|
||||||
|
streamWrite(tail...);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void sendAT(Args... cmd) {
|
void sendAT(Args... cmd) {
|
||||||
streamWrite("AT", cmd..., GSM_NL);
|
streamWrite("AT", cmd..., GSM_NL);
|
||||||
@@ -604,6 +633,19 @@ public:
|
|||||||
//DBG("### AT:", cmd...);
|
//DBG("### AT:", cmd...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool streamSkipUntil(const char c, const unsigned long timeout = 1000L) {
|
||||||
|
unsigned long startMillis = millis();
|
||||||
|
while (millis() - startMillis < timeout) {
|
||||||
|
while (millis() - startMillis < timeout && !stream.available()) {
|
||||||
|
TINY_GSM_YIELD();
|
||||||
|
}
|
||||||
|
if (stream.read() == c) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Optimize this!
|
// TODO: Optimize this!
|
||||||
uint8_t waitResponse(uint32_t timeout, String& data,
|
uint8_t waitResponse(uint32_t timeout, String& data,
|
||||||
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
||||||
|
@@ -37,7 +37,7 @@ enum RegStatus {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmM95 : public TinyGsmModem
|
class TinyGsmM95
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -216,7 +216,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
TinyGsmM95(Stream& stream)
|
TinyGsmM95(Stream& stream)
|
||||||
: TinyGsmModem(stream), stream(stream)
|
: stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
}
|
}
|
||||||
@@ -243,6 +243,10 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool begin(const char* pin = NULL) {
|
||||||
|
return init(pin);
|
||||||
|
}
|
||||||
|
|
||||||
String getModemName() {
|
String getModemName() {
|
||||||
return "Quectel M95";
|
return "Quectel M95";
|
||||||
}
|
}
|
||||||
@@ -441,6 +445,16 @@ public:
|
|||||||
waitResponse();
|
waitResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool waitForNetwork(unsigned long timeout = 60000L) {
|
||||||
|
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
||||||
|
if (isNetworkConnected()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
delay(250);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GPRS functions
|
* GPRS functions
|
||||||
*/
|
*/
|
||||||
@@ -522,6 +536,10 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPAddress localIP() {
|
||||||
|
return TinyGsmIpFromString(getLocalIP());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messaging functions
|
* Messaging functions
|
||||||
*/
|
*/
|
||||||
@@ -760,6 +778,17 @@ public:
|
|||||||
Utilities
|
Utilities
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void streamWrite(T last) {
|
||||||
|
stream.print(last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
void streamWrite(T head, Args... tail) {
|
||||||
|
stream.print(head);
|
||||||
|
streamWrite(tail...);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void sendAT(Args... cmd) {
|
void sendAT(Args... cmd) {
|
||||||
streamWrite("AT", cmd..., GSM_NL);
|
streamWrite("AT", cmd..., GSM_NL);
|
||||||
@@ -768,6 +797,19 @@ public:
|
|||||||
//DBG("### AT:", cmd...);
|
//DBG("### AT:", cmd...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool streamSkipUntil(const char c, const unsigned long timeout = 1000L) {
|
||||||
|
unsigned long startMillis = millis();
|
||||||
|
while (millis() - startMillis < timeout) {
|
||||||
|
while (millis() - startMillis < timeout && !stream.available()) {
|
||||||
|
TINY_GSM_YIELD();
|
||||||
|
}
|
||||||
|
if (stream.read() == c) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Optimize this!
|
// TODO: Optimize this!
|
||||||
uint8_t waitResponse(uint32_t timeout, String& data,
|
uint8_t waitResponse(uint32_t timeout, String& data,
|
||||||
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
||||||
|
@@ -41,7 +41,7 @@ enum RegStatus {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmMC60 : public TinyGsmModem
|
class TinyGsmMC60
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -220,7 +220,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
TinyGsmMC60(Stream& stream)
|
TinyGsmMC60(Stream& stream)
|
||||||
: TinyGsmModem(stream), stream(stream)
|
: stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
}
|
}
|
||||||
@@ -245,6 +245,10 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool begin(const char* pin = NULL) {
|
||||||
|
return init(pin);
|
||||||
|
}
|
||||||
|
|
||||||
String getModemName() {
|
String getModemName() {
|
||||||
#if defined(TINY_GSM_MODEM_MC60)
|
#if defined(TINY_GSM_MODEM_MC60)
|
||||||
return "Quectel MC60";
|
return "Quectel MC60";
|
||||||
@@ -456,6 +460,16 @@ public:
|
|||||||
return (s == REG_OK_HOME || s == REG_OK_ROAMING);
|
return (s == REG_OK_HOME || s == REG_OK_ROAMING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool waitForNetwork(unsigned long timeout = 60000L) {
|
||||||
|
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
||||||
|
if (isNetworkConnected()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
delay(250);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GPRS functions
|
* GPRS functions
|
||||||
*/
|
*/
|
||||||
@@ -550,6 +564,10 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPAddress localIP() {
|
||||||
|
return TinyGsmIpFromString(getLocalIP());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messaging functions
|
* Messaging functions
|
||||||
*/
|
*/
|
||||||
@@ -789,6 +807,17 @@ public:
|
|||||||
Utilities
|
Utilities
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void streamWrite(T last) {
|
||||||
|
stream.print(last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
void streamWrite(T head, Args... tail) {
|
||||||
|
stream.print(head);
|
||||||
|
streamWrite(tail...);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void sendAT(Args... cmd) {
|
void sendAT(Args... cmd) {
|
||||||
streamWrite("AT", cmd..., GSM_NL);
|
streamWrite("AT", cmd..., GSM_NL);
|
||||||
@@ -797,6 +826,19 @@ public:
|
|||||||
//DBG("### AT:", cmd...);
|
//DBG("### AT:", cmd...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool streamSkipUntil(const char c, const unsigned long timeout = 1000L) {
|
||||||
|
unsigned long startMillis = millis();
|
||||||
|
while (millis() - startMillis < timeout) {
|
||||||
|
while (millis() - startMillis < timeout && !stream.available()) {
|
||||||
|
TINY_GSM_YIELD();
|
||||||
|
}
|
||||||
|
if (stream.read() == c) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Optimize this!
|
// TODO: Optimize this!
|
||||||
uint8_t waitResponse(uint32_t timeout, String& data,
|
uint8_t waitResponse(uint32_t timeout, String& data,
|
||||||
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
||||||
|
@@ -45,7 +45,7 @@ enum TinyGSMDateTimeFormat {
|
|||||||
DATE_DATE = 2
|
DATE_DATE = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
class TinyGsmSim7000 : public TinyGsmModem
|
class TinyGsmSim7000
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -245,7 +245,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
TinyGsmSim7000(Stream& stream)
|
TinyGsmSim7000(Stream& stream)
|
||||||
: TinyGsmModem(stream), stream(stream)
|
: stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
}
|
}
|
||||||
@@ -268,6 +268,10 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool begin(const char* pin = NULL) {
|
||||||
|
return init(pin);
|
||||||
|
}
|
||||||
|
|
||||||
String getModemName() {
|
String getModemName() {
|
||||||
return "SIMCom SIM7000";
|
return "SIMCom SIM7000";
|
||||||
}
|
}
|
||||||
@@ -480,6 +484,16 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool waitForNetwork(unsigned long timeout = 60000L) {
|
||||||
|
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
||||||
|
if (isNetworkConnected()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
delay(250);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
String setNetworkMode(uint8_t mode) {
|
String setNetworkMode(uint8_t mode) {
|
||||||
sendAT(GF("+CNMP="), mode);
|
sendAT(GF("+CNMP="), mode);
|
||||||
if (waitResponse(GF(GSM_NL "+CNMP:")) != 1) {
|
if (waitResponse(GF(GSM_NL "+CNMP:")) != 1) {
|
||||||
@@ -641,6 +655,10 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPAddress localIP() {
|
||||||
|
return TinyGsmIpFromString(getLocalIP());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Phone Call functions
|
* Phone Call functions
|
||||||
@@ -1019,6 +1037,17 @@ public:
|
|||||||
Utilities
|
Utilities
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void streamWrite(T last) {
|
||||||
|
stream.print(last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
void streamWrite(T head, Args... tail) {
|
||||||
|
stream.print(head);
|
||||||
|
streamWrite(tail...);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void sendAT(Args... cmd) {
|
void sendAT(Args... cmd) {
|
||||||
streamWrite("AT", cmd..., GSM_NL);
|
streamWrite("AT", cmd..., GSM_NL);
|
||||||
@@ -1027,6 +1056,19 @@ public:
|
|||||||
//DBG("### AT:", cmd...);
|
//DBG("### AT:", cmd...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool streamSkipUntil(const char c, const unsigned long timeout = 1000L) {
|
||||||
|
unsigned long startMillis = millis();
|
||||||
|
while (millis() - startMillis < timeout) {
|
||||||
|
while (millis() - startMillis < timeout && !stream.available()) {
|
||||||
|
TINY_GSM_YIELD();
|
||||||
|
}
|
||||||
|
if (stream.read() == c) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Optimize this!
|
// TODO: Optimize this!
|
||||||
uint8_t waitResponse(uint32_t timeout, String& data,
|
uint8_t waitResponse(uint32_t timeout, String& data,
|
||||||
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
||||||
|
@@ -42,7 +42,7 @@ enum TinyGSMDateTimeFormat {
|
|||||||
DATE_DATE = 2
|
DATE_DATE = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
class TinyGsmSim800 : public TinyGsmModem
|
class TinyGsmSim800
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -240,7 +240,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
TinyGsmSim800(Stream& stream)
|
TinyGsmSim800(Stream& stream)
|
||||||
: TinyGsmModem(stream), stream(stream)
|
: stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
}
|
}
|
||||||
@@ -265,6 +265,10 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool begin(const char* pin = NULL) {
|
||||||
|
return init(pin);
|
||||||
|
}
|
||||||
|
|
||||||
String getModemName() {
|
String getModemName() {
|
||||||
#if defined(TINY_GSM_MODEM_SIM800)
|
#if defined(TINY_GSM_MODEM_SIM800)
|
||||||
return "SIMCom SIM800";
|
return "SIMCom SIM800";
|
||||||
@@ -495,6 +499,16 @@ public:
|
|||||||
return (s == REG_OK_HOME || s == REG_OK_ROAMING);
|
return (s == REG_OK_HOME || s == REG_OK_ROAMING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool waitForNetwork(unsigned long timeout = 60000L) {
|
||||||
|
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
||||||
|
if (isNetworkConnected()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
delay(250);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GPRS functions
|
* GPRS functions
|
||||||
*/
|
*/
|
||||||
@@ -632,6 +646,10 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPAddress localIP() {
|
||||||
|
return TinyGsmIpFromString(getLocalIP());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Phone Call functions
|
* Phone Call functions
|
||||||
@@ -941,6 +959,17 @@ public:
|
|||||||
Utilities
|
Utilities
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void streamWrite(T last) {
|
||||||
|
stream.print(last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
void streamWrite(T head, Args... tail) {
|
||||||
|
stream.print(head);
|
||||||
|
streamWrite(tail...);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void sendAT(Args... cmd) {
|
void sendAT(Args... cmd) {
|
||||||
streamWrite("AT", cmd..., GSM_NL);
|
streamWrite("AT", cmd..., GSM_NL);
|
||||||
@@ -949,6 +978,19 @@ public:
|
|||||||
//DBG("### AT:", cmd...);
|
//DBG("### AT:", cmd...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool streamSkipUntil(const char c, const unsigned long timeout = 1000L) {
|
||||||
|
unsigned long startMillis = millis();
|
||||||
|
while (millis() - startMillis < timeout) {
|
||||||
|
while (millis() - startMillis < timeout && !stream.available()) {
|
||||||
|
TINY_GSM_YIELD();
|
||||||
|
}
|
||||||
|
if (stream.read() == c) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Optimize this!
|
// TODO: Optimize this!
|
||||||
uint8_t waitResponse(uint32_t timeout, String& data,
|
uint8_t waitResponse(uint32_t timeout, String& data,
|
||||||
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <TinyGsmCommon.h>
|
#include <TinyGsmCommon.h>
|
||||||
|
|
||||||
#define GSM_NL "\r\n"
|
#define GSM_NL "\r"
|
||||||
static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL;
|
static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL;
|
||||||
static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL;
|
static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL;
|
||||||
|
|
||||||
@@ -251,11 +251,8 @@ public:
|
|||||||
/*
|
/*
|
||||||
* Basic functions
|
* Basic functions
|
||||||
*/
|
*/
|
||||||
bool begin() {
|
|
||||||
return init();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool init() {
|
bool init(const char* pin = NULL) {
|
||||||
DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION);
|
DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION);
|
||||||
if (!testAT()) {
|
if (!testAT()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -268,6 +265,10 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool begin(const char* pin = NULL) {
|
||||||
|
return init(pin);
|
||||||
|
}
|
||||||
|
|
||||||
void setBaud(unsigned long baud) {
|
void setBaud(unsigned long baud) {
|
||||||
sendAT(GF("+IPR="), baud);
|
sendAT(GF("+IPR="), baud);
|
||||||
}
|
}
|
||||||
@@ -710,11 +711,6 @@ public:
|
|||||||
|
|
||||||
/* Utilities */
|
/* Utilities */
|
||||||
|
|
||||||
bool commandMode(int retries = 2) {
|
|
||||||
streamWrite(GF("+++")); // enter command mode
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void streamWrite(T last) {
|
void streamWrite(T last) {
|
||||||
stream.print(last);
|
stream.print(last);
|
||||||
@@ -726,21 +722,25 @@ public:
|
|||||||
streamWrite(tail...);
|
streamWrite(tail...);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool streamSkipUntil(char c) { //TODO: timeout
|
|
||||||
while (true) {
|
|
||||||
while (!stream.available()) { TINY_GSM_YIELD(); }
|
|
||||||
if (stream.read() == c)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void sendAT(Args... cmd) {
|
void sendAT(Args... cmd) {
|
||||||
streamWrite("AT", cmd..., '\r');
|
streamWrite("AT", cmd..., GSM_NL);
|
||||||
stream.flush();
|
stream.flush();
|
||||||
TINY_GSM_YIELD();
|
TINY_GSM_YIELD();
|
||||||
DBG("### AT:", cmd...);
|
//DBG("### AT:", cmd...);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool streamSkipUntil(const char c, const unsigned long timeout = 1000L) {
|
||||||
|
unsigned long startMillis = millis();
|
||||||
|
while (millis() - startMillis < timeout) {
|
||||||
|
while (millis() - startMillis < timeout && !stream.available()) {
|
||||||
|
TINY_GSM_YIELD();
|
||||||
|
}
|
||||||
|
if (stream.read() == c) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Optimize this!
|
// TODO: Optimize this!
|
||||||
|
@@ -37,7 +37,7 @@ enum RegStatus {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmUBLOX : public TinyGsmModem
|
class TinyGsmUBLOX
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -249,7 +249,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
TinyGsmUBLOX(Stream& stream)
|
TinyGsmUBLOX(Stream& stream)
|
||||||
: TinyGsmModem(stream), stream(stream)
|
: stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
isCatM = false; // For SARA R4 and N4 series
|
isCatM = false; // For SARA R4 and N4 series
|
||||||
@@ -296,6 +296,10 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool begin(const char* pin = NULL) {
|
||||||
|
return init(pin);
|
||||||
|
}
|
||||||
|
|
||||||
String getModemName() {
|
String getModemName() {
|
||||||
sendAT(GF("+CGMI"));
|
sendAT(GF("+CGMI"));
|
||||||
String res1;
|
String res1;
|
||||||
@@ -521,6 +525,16 @@ public:
|
|||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool waitForNetwork(unsigned long timeout = 60000L) {
|
||||||
|
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
||||||
|
if (isNetworkConnected()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
delay(250);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool setURAT( uint8_t urat ) {
|
bool setURAT( uint8_t urat ) {
|
||||||
// AT+URAT=<SelectedAcT>[,<PreferredAct>[,<2ndPreferredAct>]]
|
// AT+URAT=<SelectedAcT>[,<PreferredAct>[,<2ndPreferredAct>]]
|
||||||
|
|
||||||
@@ -677,6 +691,10 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPAddress localIP() {
|
||||||
|
return TinyGsmIpFromString(getLocalIP());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Phone Call functions
|
* Phone Call functions
|
||||||
*/
|
*/
|
||||||
@@ -893,6 +911,17 @@ public:
|
|||||||
Utilities
|
Utilities
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void streamWrite(T last) {
|
||||||
|
stream.print(last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
void streamWrite(T head, Args... tail) {
|
||||||
|
stream.print(head);
|
||||||
|
streamWrite(tail...);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void sendAT(Args... cmd) {
|
void sendAT(Args... cmd) {
|
||||||
streamWrite("AT", cmd..., GSM_NL);
|
streamWrite("AT", cmd..., GSM_NL);
|
||||||
@@ -901,6 +930,19 @@ public:
|
|||||||
//DBG("### AT:", cmd...);
|
//DBG("### AT:", cmd...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool streamSkipUntil(const char c, const unsigned long timeout = 1000L) {
|
||||||
|
unsigned long startMillis = millis();
|
||||||
|
while (millis() - startMillis < timeout) {
|
||||||
|
while (millis() - startMillis < timeout && !stream.available()) {
|
||||||
|
TINY_GSM_YIELD();
|
||||||
|
}
|
||||||
|
if (stream.read() == c) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Optimize this!
|
// TODO: Optimize this!
|
||||||
uint8_t waitResponse(uint32_t timeout, String& data,
|
uint8_t waitResponse(uint32_t timeout, String& data,
|
||||||
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
||||||
|
@@ -49,7 +49,7 @@ enum XBeeType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmXBee : public TinyGsmModem
|
class TinyGsmXBee
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -255,7 +255,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
TinyGsmXBee(Stream& stream)
|
TinyGsmXBee(Stream& stream)
|
||||||
: TinyGsmModem(stream), stream(stream)
|
: stream(stream)
|
||||||
{
|
{
|
||||||
beeType = XBEE_UNKNOWN; // Start not knowing what kind of bee it is
|
beeType = XBEE_UNKNOWN; // Start not knowing what kind of bee it is
|
||||||
guardTime = TINY_GSM_XBEE_GUARD_TIME; // Start with the default guard time of 1 second
|
guardTime = TINY_GSM_XBEE_GUARD_TIME; // Start with the default guard time of 1 second
|
||||||
@@ -267,7 +267,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
TinyGsmXBee(Stream& stream, int8_t resetPin)
|
TinyGsmXBee(Stream& stream, int8_t resetPin)
|
||||||
: TinyGsmModem(stream), stream(stream)
|
: stream(stream)
|
||||||
{
|
{
|
||||||
beeType = XBEE_UNKNOWN; // Start not knowing what kind of bee it is
|
beeType = XBEE_UNKNOWN; // Start not knowing what kind of bee it is
|
||||||
guardTime = TINY_GSM_XBEE_GUARD_TIME; // Start with the default guard time of 1 second
|
guardTime = TINY_GSM_XBEE_GUARD_TIME; // Start with the default guard time of 1 second
|
||||||
@@ -307,6 +307,10 @@ public:
|
|||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool begin(const char* pin = NULL) {
|
||||||
|
return init(pin);
|
||||||
|
}
|
||||||
|
|
||||||
String getModemName() {
|
String getModemName() {
|
||||||
return getBeeName();
|
return getBeeName();
|
||||||
}
|
}
|
||||||
@@ -719,6 +723,10 @@ public:
|
|||||||
return IPaddr;
|
return IPaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPAddress localIP() {
|
||||||
|
return TinyGsmIpFromString(getLocalIP());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GPRS functions
|
* GPRS functions
|
||||||
*/
|
*/
|
||||||
@@ -925,6 +933,17 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void streamWrite(T last) {
|
||||||
|
stream.print(last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
void streamWrite(T head, Args... tail) {
|
||||||
|
stream.print(head);
|
||||||
|
streamWrite(tail...);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void sendAT(Args... cmd) {
|
void sendAT(Args... cmd) {
|
||||||
streamWrite("AT", cmd..., GSM_NL);
|
streamWrite("AT", cmd..., GSM_NL);
|
||||||
@@ -933,6 +952,19 @@ public:
|
|||||||
//DBG("### AT:", cmd...);
|
//DBG("### AT:", cmd...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool streamSkipUntil(const char c, const unsigned long timeout = 1000L) {
|
||||||
|
unsigned long startMillis = millis();
|
||||||
|
while (millis() - startMillis < timeout) {
|
||||||
|
while (millis() - startMillis < timeout && !stream.available()) {
|
||||||
|
TINY_GSM_YIELD();
|
||||||
|
}
|
||||||
|
if (stream.read() == c) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Optimize this!
|
// TODO: Optimize this!
|
||||||
// NOTE: This function is used while INSIDE command mode, so we're only
|
// NOTE: This function is used while INSIDE command mode, so we're only
|
||||||
// waiting for requested responses. The XBee has no unsoliliced responses
|
// waiting for requested responses. The XBee has no unsoliliced responses
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
#define TinyGsmCommon_h
|
#define TinyGsmCommon_h
|
||||||
|
|
||||||
// The current library version number
|
// The current library version number
|
||||||
#define TINYGSM_VERSION "0.6.2"
|
#define TINYGSM_VERSION "0.7.0"
|
||||||
|
|
||||||
#if defined(SPARK) || defined(PARTICLE)
|
#if defined(SPARK) || defined(PARTICLE)
|
||||||
#include "Particle.h"
|
#include "Particle.h"
|
||||||
@@ -202,135 +202,4 @@ String TinyGsmDecodeHex16bit(String &instr) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmModem
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
TinyGsmModem(Stream& stream)
|
|
||||||
: stream(stream)
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Basic functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Prepare the modem for further functionality
|
|
||||||
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() = 0;
|
|
||||||
// Sets the serial communication baud rate
|
|
||||||
virtual void setBaud(unsigned long baud) = 0;
|
|
||||||
// Checks that the modem is responding to standard AT commands
|
|
||||||
virtual bool testAT(unsigned long timeout = 10000L) = 0;
|
|
||||||
// Holds open communication with the modem waiting for data to come in
|
|
||||||
virtual void maintain() = 0;
|
|
||||||
// Resets all modem chip settings to factor defaults
|
|
||||||
virtual bool factoryDefault() = 0;
|
|
||||||
// Returns the response to a get info request. The format varies by modem.
|
|
||||||
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() = 0;
|
|
||||||
virtual bool poweroff() = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SIM card functions - only apply to cellular modems
|
|
||||||
*/
|
|
||||||
|
|
||||||
virtual bool simUnlock(const char *pin) { return false; }
|
|
||||||
virtual String getSimCCID() { return ""; }
|
|
||||||
virtual String getIMEI() { return ""; }
|
|
||||||
virtual String getOperator() { return ""; }
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Generic network functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
virtual int16_t 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() = 0;
|
|
||||||
virtual bool waitForNetwork(unsigned long timeout = 60000L) {
|
|
||||||
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
|
||||||
if (isNetworkConnected()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
delay(250);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* WiFi functions - only apply to WiFi modems
|
|
||||||
*/
|
|
||||||
|
|
||||||
virtual bool networkConnect(const char* ssid, const char* pwd) { return false; }
|
|
||||||
virtual bool networkDisconnect() { return false; }
|
|
||||||
|
|
||||||
/*
|
|
||||||
* GPRS functions - only apply to cellular modems
|
|
||||||
*/
|
|
||||||
|
|
||||||
virtual bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
virtual bool gprsDisconnect() { return false; }
|
|
||||||
virtual bool isGprsConnected() { return false; }
|
|
||||||
|
|
||||||
/*
|
|
||||||
* IP Address functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
virtual String getLocalIP() = 0;
|
|
||||||
virtual IPAddress localIP() {
|
|
||||||
return TinyGsmIpFromString(getLocalIP());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Utilities
|
|
||||||
*/
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void streamWrite(T last) {
|
|
||||||
stream.print(last);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename... Args>
|
|
||||||
void streamWrite(T head, Args... tail) {
|
|
||||||
stream.print(head);
|
|
||||||
streamWrite(tail...);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool streamSkipUntil(const char c, const unsigned long timeout = 1000L) {
|
|
||||||
unsigned long startMillis = millis();
|
|
||||||
while (millis() - startMillis < timeout) {
|
|
||||||
while (millis() - startMillis < timeout && !stream.available()) {
|
|
||||||
TINY_GSM_YIELD();
|
|
||||||
}
|
|
||||||
if (stream.read() == c)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
Stream& stream;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user