mirror of
https://github.com/KevinMidboe/TinyGSM.git
synced 2025-10-29 18:00:18 +00:00
Clean up
This commit is contained in:
BIN
extras/doc/Quectel_M95_GSM_Specification_V3.1.pdf
Normal file
BIN
extras/doc/Quectel_M95_GSM_Specification_V3.1.pdf
Normal file
Binary file not shown.
BIN
extras/doc/Quectel_M95_at_commands_manual_v1.3.pdf
Normal file
BIN
extras/doc/Quectel_M95_at_commands_manual_v1.3.pdf
Normal file
Binary file not shown.
@@ -48,20 +48,20 @@
|
|||||||
#define TINY_GSM_MODEM_HAS_GPRS
|
#define TINY_GSM_MODEM_HAS_GPRS
|
||||||
#include <TinyGsmClientA6.h>
|
#include <TinyGsmClientA6.h>
|
||||||
typedef TinyGsmA6 TinyGsm;
|
typedef TinyGsmA6 TinyGsm;
|
||||||
typedef TinyGsm::GsmClient TinyGsmClient;
|
typedef TinyGsmA6::GsmClient TinyGsmClient;
|
||||||
|
|
||||||
#elif defined(TINY_GSM_MODEM_M590)
|
#elif defined(TINY_GSM_MODEM_M590)
|
||||||
#define TINY_GSM_MODEM_HAS_GPRS
|
#define TINY_GSM_MODEM_HAS_GPRS
|
||||||
#include <TinyGsmClientM590.h>
|
#include <TinyGsmClientM590.h>
|
||||||
typedef TinyGsmM590 TinyGsm;
|
typedef TinyGsmM590 TinyGsm;
|
||||||
typedef TinyGsm::GsmClient TinyGsmClient;
|
typedef TinyGsmM590::GsmClient TinyGsmClient;
|
||||||
|
|
||||||
#elif defined(TINY_GSM_MODEM_ESP8266)
|
#elif defined(TINY_GSM_MODEM_ESP8266)
|
||||||
#define TINY_GSM_MODEM_HAS_WIFI
|
#define TINY_GSM_MODEM_HAS_WIFI
|
||||||
#include <TinyGsmClientESP8266.h>
|
#include <TinyGsmClientESP8266.h>
|
||||||
typedef TinyGsmESP8266 TinyGsm;
|
typedef TinyGsmESP8266 TinyGsm;
|
||||||
typedef TinyGsm::GsmClient TinyGsmClient;
|
typedef TinyGsmESP8266::GsmClient TinyGsmClient;
|
||||||
typedef TinyGsm::GsmClientSecure TinyGsmClientSecure;
|
typedef TinyGsmESP8266::GsmClientSecure TinyGsmClientSecure;
|
||||||
|
|
||||||
#elif defined(TINY_GSM_MODEM_XBEE)
|
#elif defined(TINY_GSM_MODEM_XBEE)
|
||||||
#define TINY_GSM_MODEM_HAS_GPRS
|
#define TINY_GSM_MODEM_HAS_GPRS
|
||||||
@@ -74,7 +74,8 @@
|
|||||||
#elif defined(TINY_GSM_MODEM_M95)
|
#elif defined(TINY_GSM_MODEM_M95)
|
||||||
#define TINY_GSM_MODEM_HAS_GPRS
|
#define TINY_GSM_MODEM_HAS_GPRS
|
||||||
#include <TinyGsmClientM95.h>
|
#include <TinyGsmClientM95.h>
|
||||||
typedef TinyGsm::GsmClient TinyGsmClient;
|
typedef TinyGsmM95 TinyGsm;
|
||||||
|
typedef TinyGsmM95::GsmClient TinyGsmClient;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "Please define GSM modem model"
|
#error "Please define GSM modem model"
|
||||||
|
|||||||
@@ -38,21 +38,15 @@ enum RegStatus {
|
|||||||
REG_UNKNOWN = 4,
|
REG_UNKNOWN = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
// Declaration of the TinyGsmA6 Class
|
// Declaration of the TinyGsmA6 Class
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TinyGsmA6
|
class TinyGsmA6
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
// The A6 Client Class
|
// The A6 Client Class
|
||||||
@@ -60,6 +54,8 @@ public:
|
|||||||
//============================================================================//
|
//============================================================================//
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
class GsmClient : public Client
|
class GsmClient : public Client
|
||||||
{
|
{
|
||||||
friend class TinyGsmA6;
|
friend class TinyGsmA6;
|
||||||
@@ -343,10 +339,10 @@ public:
|
|||||||
int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"));
|
int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"));
|
||||||
waitResponse();
|
waitResponse();
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 2:
|
case 2:
|
||||||
case 3: return SIM_LOCKED;
|
case 3: return SIM_LOCKED;
|
||||||
case 1: return SIM_READY;
|
case 1: return SIM_READY;
|
||||||
default: return SIM_ERROR;
|
default: return SIM_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SIM_ERROR;
|
return SIM_ERROR;
|
||||||
@@ -370,16 +366,16 @@ public:
|
|||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RegStatus getRegistrationStatus() {
|
RegStatus getRegistrationStatus() {
|
||||||
sendAT(GF("+CREG?"));
|
sendAT(GF("+CREG?"));
|
||||||
if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
|
if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
|
||||||
return REG_UNKNOWN;
|
return REG_UNKNOWN;
|
||||||
}
|
}
|
||||||
streamSkipUntil(','); // Skip format (0)
|
streamSkipUntil(','); // Skip format (0)
|
||||||
int status = stream.readStringUntil('\n').toInt();
|
int status = stream.readStringUntil('\n').toInt();
|
||||||
waitResponse();
|
waitResponse();
|
||||||
return (RegStatus)status;
|
return (RegStatus)status;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSignalQuality() {
|
int getSignalQuality() {
|
||||||
sendAT(GF("+CSQ"));
|
sendAT(GF("+CSQ"));
|
||||||
@@ -587,7 +583,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool modemGetConnected(uint8_t mux) {
|
bool modemGetConnected(uint8_t mux) {
|
||||||
sendAT(GF("+CIPSTATUS")); //TODO mux?
|
sendAT(GF("+CIPSTATUS")); // TODO mux?
|
||||||
int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), GF(",\"CLOSING\""), GF(",\"INITIAL\""));
|
int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), GF(",\"CLOSING\""), GF(",\"INITIAL\""));
|
||||||
waitResponse();
|
waitResponse();
|
||||||
return 1 == res;
|
return 1 == res;
|
||||||
|
|||||||
@@ -9,14 +9,14 @@
|
|||||||
#ifndef TinyGsmClientBG96_h
|
#ifndef TinyGsmClientBG96_h
|
||||||
#define TinyGsmClientBG96_h
|
#define TinyGsmClientBG96_h
|
||||||
|
|
||||||
//#define TINY_GSM_DEBUG Serial
|
// #define TINY_GSM_DEBUG Serial
|
||||||
//#define TINY_GSM_USE_HEX
|
// #define TINY_GSM_USE_HEX
|
||||||
|
|
||||||
#if !defined(TINY_GSM_RX_BUFFER)
|
#if !defined(TINY_GSM_RX_BUFFER)
|
||||||
#define TINY_GSM_RX_BUFFER 64
|
#define TINY_GSM_RX_BUFFER 64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TINY_GSM_MUX_COUNT 5
|
#define TINY_GSM_MUX_COUNT 12
|
||||||
|
|
||||||
#include <TinyGsmCommon.h>
|
#include <TinyGsmCommon.h>
|
||||||
|
|
||||||
@@ -39,10 +39,22 @@ enum RegStatus {
|
|||||||
REG_UNKNOWN = 4,
|
REG_UNKNOWN = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//============================================================================//
|
||||||
|
//============================================================================//
|
||||||
|
// Declaration of the TinyGsmBG96 Class
|
||||||
|
//============================================================================//
|
||||||
|
//============================================================================//
|
||||||
|
|
||||||
class TinyGsmBG96
|
class TinyGsmBG96
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//============================================================================//
|
||||||
|
//============================================================================//
|
||||||
|
// The BG96 Client Class
|
||||||
|
//============================================================================//
|
||||||
|
//============================================================================//
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
class GsmClient : public Client
|
class GsmClient : public Client
|
||||||
@@ -166,13 +178,20 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
TinyGsmBG96* at;
|
TinyGsmBG96* at;
|
||||||
uint8_t mux;
|
uint8_t mux;
|
||||||
uint16_t sock_available;
|
uint16_t sock_available;
|
||||||
bool sock_connected;
|
bool sock_connected;
|
||||||
bool got_data;
|
bool got_data;
|
||||||
RxFifo rx;
|
RxFifo rx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//============================================================================//
|
||||||
|
//============================================================================//
|
||||||
|
// The BG96 Secure Client
|
||||||
|
//============================================================================//
|
||||||
|
//============================================================================//
|
||||||
|
|
||||||
|
|
||||||
class GsmClientSecure : public GsmClient
|
class GsmClientSecure : public GsmClient
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -192,9 +211,19 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//============================================================================//
|
||||||
|
//============================================================================//
|
||||||
|
// The BG96 Modem Functions
|
||||||
|
//============================================================================//
|
||||||
|
//============================================================================//
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
#ifdef GSM_DEFAULT_STREAM
|
||||||
|
TinyGsmBG96(Stream& stream = GSM_DEFAULT_STREAM)
|
||||||
|
#else
|
||||||
TinyGsmBG96(Stream& stream)
|
TinyGsmBG96(Stream& stream)
|
||||||
|
#endif
|
||||||
: stream(stream)
|
: stream(stream)
|
||||||
{
|
{
|
||||||
memset(sockets, 0, sizeof(sockets));
|
memset(sockets, 0, sizeof(sockets));
|
||||||
@@ -344,26 +373,15 @@ public:
|
|||||||
int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), GF("NOT INSERTED"));
|
int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), GF("NOT INSERTED"));
|
||||||
waitResponse();
|
waitResponse();
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 2:
|
case 2:
|
||||||
case 3: return SIM_LOCKED;
|
case 3: return SIM_LOCKED;
|
||||||
case 1: return SIM_READY;
|
case 1: return SIM_READY;
|
||||||
default: return SIM_ERROR;
|
default: return SIM_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SIM_ERROR;
|
return SIM_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegStatus getRegistrationStatus() {
|
|
||||||
sendAT(GF("+CREG?"));
|
|
||||||
if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
|
|
||||||
return REG_UNKNOWN;
|
|
||||||
}
|
|
||||||
streamSkipUntil(','); // Skip format (0)
|
|
||||||
int status = stream.readStringUntil('\n').toInt();
|
|
||||||
waitResponse();
|
|
||||||
return (RegStatus)status;
|
|
||||||
}
|
|
||||||
|
|
||||||
String getOperator() {
|
String getOperator() {
|
||||||
sendAT(GF("+COPS?"));
|
sendAT(GF("+COPS?"));
|
||||||
if (waitResponse(GF(GSM_NL "+COPS:")) != 1) {
|
if (waitResponse(GF(GSM_NL "+COPS:")) != 1) {
|
||||||
@@ -379,6 +397,17 @@ public:
|
|||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
RegStatus getRegistrationStatus() {
|
||||||
|
sendAT(GF("+CREG?"));
|
||||||
|
if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
|
||||||
|
return REG_UNKNOWN;
|
||||||
|
}
|
||||||
|
streamSkipUntil(','); // Skip format (0)
|
||||||
|
int status = stream.readStringUntil('\n').toInt();
|
||||||
|
waitResponse();
|
||||||
|
return (RegStatus)status;
|
||||||
|
}
|
||||||
|
|
||||||
int getSignalQuality() {
|
int getSignalQuality() {
|
||||||
sendAT(GF("+CSQ"));
|
sendAT(GF("+CSQ"));
|
||||||
if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) {
|
if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) {
|
||||||
@@ -404,6 +433,27 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getLocalIP() {
|
||||||
|
sendAT(GF("+CGPADDR=1"));
|
||||||
|
if (waitResponse(10000L, GF(GSM_NL "+CGPADDR:")) != 1) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
streamSkipUntil(',');
|
||||||
|
String res = stream.readStringUntil('\n');
|
||||||
|
if (waitResponse() != 1) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPAddress localIP() {
|
||||||
|
return TinyGsmIpFromString(getLocalIP());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* WiFi functions
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GPRS functions
|
* GPRS functions
|
||||||
*/
|
*/
|
||||||
@@ -450,53 +500,6 @@ public:
|
|||||||
return localIP() != 0;
|
return localIP() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getLocalIP() {
|
|
||||||
sendAT(GF("+CGPADDR=1"));
|
|
||||||
if (waitResponse(10000L, GF(GSM_NL "+CGPADDR:")) != 1) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
streamSkipUntil(',');
|
|
||||||
String res = stream.readStringUntil('\n');
|
|
||||||
if (waitResponse() != 1) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPAddress localIP() {
|
|
||||||
return TinyGsmIpFromString(getLocalIP());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Phone Call functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool setGsmBusy(bool busy = true) TINY_GSM_ATTR_NOT_AVAILABLE;
|
|
||||||
|
|
||||||
bool callAnswer() {
|
|
||||||
sendAT(GF("A"));
|
|
||||||
return waitResponse() == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true on pick-up, false on error/busy
|
|
||||||
bool callNumber(const String& number) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
|
||||||
|
|
||||||
bool callHangup() {
|
|
||||||
sendAT(GF("H"));
|
|
||||||
return waitResponse() == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 0-9,*,#,A,B,C,D
|
|
||||||
bool dtmfSend(char cmd, int duration_ms = 100) { // TODO: check
|
|
||||||
duration_ms = constrain(duration_ms, 100, 1000);
|
|
||||||
|
|
||||||
sendAT(GF("+VTD="), duration_ms / 100); // VTD accepts in 1/10 of a second
|
|
||||||
waitResponse();
|
|
||||||
|
|
||||||
sendAT(GF("+VTS="), cmd);
|
|
||||||
return waitResponse(10000L) == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messaging functions
|
* Messaging functions
|
||||||
*/
|
*/
|
||||||
@@ -660,9 +663,13 @@ public:
|
|||||||
streamWrite(tail...);
|
streamWrite(tail...);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool streamSkipUntil(char c) { //TODO: timeout
|
bool streamSkipUntil(char c) {
|
||||||
while (true) {
|
const unsigned long timeout = 1000L;
|
||||||
while (!stream.available()) { TINY_GSM_YIELD(); }
|
unsigned long startMillis = millis();
|
||||||
|
while (millis() - startMillis < timeout) {
|
||||||
|
while (millis() - startMillis < timeout && !stream.available()) {
|
||||||
|
TINY_GSM_YIELD();
|
||||||
|
}
|
||||||
if (stream.read() == c)
|
if (stream.read() == c)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -674,7 +681,7 @@ public:
|
|||||||
streamWrite("AT", cmd..., GSM_NL);
|
streamWrite("AT", cmd..., GSM_NL);
|
||||||
stream.flush();
|
stream.flush();
|
||||||
TINY_GSM_YIELD();
|
TINY_GSM_YIELD();
|
||||||
//DBG("### AT:", cmd...);
|
DBG("### AT:", cmd...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Optimize this!
|
// TODO: Optimize this!
|
||||||
@@ -682,12 +689,12 @@ public:
|
|||||||
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
|
||||||
GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL)
|
GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL)
|
||||||
{
|
{
|
||||||
/*String r1s(r1); r1s.trim();
|
String r1s(r1); r1s.trim();
|
||||||
String r2s(r2); r2s.trim();
|
String r2s(r2); r2s.trim();
|
||||||
String r3s(r3); r3s.trim();
|
String r3s(r3); r3s.trim();
|
||||||
String r4s(r4); r4s.trim();
|
String r4s(r4); r4s.trim();
|
||||||
String r5s(r5); r5s.trim();
|
String r5s(r5); r5s.trim();
|
||||||
DBG("### ..:", r1s, ",", r2s, ",", r3s, ",", r4s, ",", r5s);*/
|
DBG("### ..:", r1s, ",", r2s, ",", r3s, ",", r4s, ",", r5s);
|
||||||
data.reserve(64);
|
data.reserve(64);
|
||||||
int index = 0;
|
int index = 0;
|
||||||
unsigned long startMillis = millis();
|
unsigned long startMillis = millis();
|
||||||
@@ -743,6 +750,7 @@ finish:
|
|||||||
}
|
}
|
||||||
data = "";
|
data = "";
|
||||||
}
|
}
|
||||||
|
DBG('<', index, '>');
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,10 +172,10 @@ public:
|
|||||||
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TinyGsmESP8266* at;
|
TinyGsmESP8266* at;
|
||||||
uint8_t mux;
|
uint8_t mux;
|
||||||
bool sock_connected;
|
bool sock_connected;
|
||||||
RxFifo rx;
|
RxFifo rx;
|
||||||
};
|
};
|
||||||
|
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
@@ -257,8 +257,8 @@ public:
|
|||||||
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
||||||
sendAT(GF(""));
|
sendAT(GF(""));
|
||||||
if (waitResponse(200) == 1) {
|
if (waitResponse(200) == 1) {
|
||||||
delay(100);
|
delay(100);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
@@ -313,7 +313,6 @@ public:
|
|||||||
|
|
||||||
bool sleepEnable(bool enable = true) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
bool sleepEnable(bool enable = true) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SIM card functions
|
* SIM card functions
|
||||||
*/
|
*/
|
||||||
@@ -323,13 +322,13 @@ public:
|
|||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RegStatus getRegistrationStatus() {
|
RegStatus getRegistrationStatus() {
|
||||||
sendAT(GF("+CIPSTATUS"));
|
sendAT(GF("+CIPSTATUS"));
|
||||||
if (waitResponse(3000, GF("STATUS:")) != 1) return REG_UNKNOWN;
|
if (waitResponse(3000, GF("STATUS:")) != 1) return REG_UNKNOWN;
|
||||||
int status = waitResponse(GFP(GSM_ERROR), GF("2"), GF("3"), GF("4"), GF("5"));
|
int status = waitResponse(GFP(GSM_ERROR), GF("2"), GF("3"), GF("4"), GF("5"));
|
||||||
waitResponse(); // Returns an OK after the status
|
waitResponse(); // Returns an OK after the status
|
||||||
return (RegStatus)status;
|
return (RegStatus)status;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSignalQuality() {
|
int getSignalQuality() {
|
||||||
sendAT(GF("+CWJAP_CUR?"));
|
sendAT(GF("+CWJAP_CUR?"));
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class TinyGsmM590
|
|||||||
//============================================================================//
|
//============================================================================//
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
class GsmClient : public Client
|
class GsmClient : public Client
|
||||||
@@ -172,10 +173,10 @@ public:
|
|||||||
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TinyGsmM590* at;
|
TinyGsmM590* at;
|
||||||
uint8_t mux;
|
uint8_t mux;
|
||||||
bool sock_connected;
|
bool sock_connected;
|
||||||
RxFifo rx;
|
RxFifo rx;
|
||||||
};
|
};
|
||||||
|
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
@@ -236,8 +237,8 @@ public:
|
|||||||
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
||||||
sendAT(GF(""));
|
sendAT(GF(""));
|
||||||
if (waitResponse(200) == 1) {
|
if (waitResponse(200) == 1) {
|
||||||
delay(100);
|
delay(100);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
@@ -349,10 +350,10 @@ public:
|
|||||||
int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"));
|
int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"));
|
||||||
waitResponse();
|
waitResponse();
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 2:
|
case 2:
|
||||||
case 3: return SIM_LOCKED;
|
case 3: return SIM_LOCKED;
|
||||||
case 1: return SIM_READY;
|
case 1: return SIM_READY;
|
||||||
default: return SIM_ERROR;
|
default: return SIM_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SIM_ERROR;
|
return SIM_ERROR;
|
||||||
@@ -373,16 +374,16 @@ public:
|
|||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RegStatus getRegistrationStatus() {
|
RegStatus getRegistrationStatus() {
|
||||||
sendAT(GF("+CREG?"));
|
sendAT(GF("+CREG?"));
|
||||||
if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
|
if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
|
||||||
return REG_UNKNOWN;
|
return REG_UNKNOWN;
|
||||||
}
|
}
|
||||||
streamSkipUntil(','); // Skip format (0)
|
streamSkipUntil(','); // Skip format (0)
|
||||||
int status = stream.readStringUntil('\n').toInt();
|
int status = stream.readStringUntil('\n').toInt();
|
||||||
waitResponse();
|
waitResponse();
|
||||||
return (RegStatus)status;
|
return (RegStatus)status;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSignalQuality() {
|
int getSignalQuality() {
|
||||||
sendAT(GF("+CSQ"));
|
sendAT(GF("+CSQ"));
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -273,8 +273,8 @@ public:
|
|||||||
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
||||||
sendAT(GF(""));
|
sendAT(GF(""));
|
||||||
if (waitResponse(200) == 1) {
|
if (waitResponse(200) == 1) {
|
||||||
delay(100);
|
delay(100);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
@@ -425,10 +425,10 @@ public:
|
|||||||
int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), GF("NOT INSERTED"));
|
int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), GF("NOT INSERTED"));
|
||||||
waitResponse();
|
waitResponse();
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 2:
|
case 2:
|
||||||
case 3: return SIM_LOCKED;
|
case 3: return SIM_LOCKED;
|
||||||
case 1: return SIM_READY;
|
case 1: return SIM_READY;
|
||||||
default: return SIM_ERROR;
|
default: return SIM_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SIM_ERROR;
|
return SIM_ERROR;
|
||||||
@@ -449,16 +449,16 @@ public:
|
|||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RegStatus getRegistrationStatus() {
|
RegStatus getRegistrationStatus() {
|
||||||
sendAT(GF("+CREG?"));
|
sendAT(GF("+CREG?"));
|
||||||
if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
|
if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
|
||||||
return REG_UNKNOWN;
|
return REG_UNKNOWN;
|
||||||
}
|
}
|
||||||
streamSkipUntil(','); // Skip format (0)
|
streamSkipUntil(','); // Skip format (0)
|
||||||
int status = stream.readStringUntil('\n').toInt();
|
int status = stream.readStringUntil('\n').toInt();
|
||||||
waitResponse();
|
waitResponse();
|
||||||
return (RegStatus)status;
|
return (RegStatus)status;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSignalQuality() {
|
int getSignalQuality() {
|
||||||
sendAT(GF("+CSQ"));
|
sendAT(GF("+CSQ"));
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ enum RegStatus {
|
|||||||
REG_UNKNOWN = 4,
|
REG_UNKNOWN = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
// Declaration of the TinyGsmU201 Class
|
// Declaration of the TinyGsmU201 Class
|
||||||
@@ -177,12 +176,12 @@ public:
|
|||||||
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TinyGsmU201* at;
|
TinyGsmU201* at;
|
||||||
uint8_t mux;
|
uint8_t mux;
|
||||||
uint16_t sock_available;
|
uint16_t sock_available;
|
||||||
bool sock_connected;
|
bool sock_connected;
|
||||||
bool got_data;
|
bool got_data;
|
||||||
RxFifo rx;
|
RxFifo rx;
|
||||||
};
|
};
|
||||||
|
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
@@ -212,7 +211,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
// The U201 Modem Functions
|
// The U201 Modem Functions
|
||||||
@@ -375,10 +373,10 @@ public:
|
|||||||
int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), GF("NOT INSERTED"));
|
int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), GF("NOT INSERTED"));
|
||||||
waitResponse();
|
waitResponse();
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 2:
|
case 2:
|
||||||
case 3: return SIM_LOCKED;
|
case 3: return SIM_LOCKED;
|
||||||
case 1: return SIM_READY;
|
case 1: return SIM_READY;
|
||||||
default: return SIM_ERROR;
|
default: return SIM_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SIM_ERROR;
|
return SIM_ERROR;
|
||||||
@@ -399,16 +397,16 @@ public:
|
|||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RegStatus getRegistrationStatus() {
|
RegStatus getRegistrationStatus() {
|
||||||
sendAT(GF("+CGREG?"));
|
sendAT(GF("+CGREG?"));
|
||||||
if (waitResponse(GF(GSM_NL "+CGREG:")) != 1) {
|
if (waitResponse(GF(GSM_NL "+CGREG:")) != 1) {
|
||||||
return REG_UNKNOWN;
|
return REG_UNKNOWN;
|
||||||
}
|
}
|
||||||
streamSkipUntil(','); // Skip format (0)
|
streamSkipUntil(','); // Skip format (0)
|
||||||
int status = stream.readStringUntil('\n').toInt();
|
int status = stream.readStringUntil('\n').toInt();
|
||||||
waitResponse();
|
waitResponse();
|
||||||
return (RegStatus)status;
|
return (RegStatus)status;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSignalQuality() {
|
int getSignalQuality() {
|
||||||
sendAT(GF("+CSQ"));
|
sendAT(GF("+CSQ"));
|
||||||
@@ -521,19 +519,6 @@ public:
|
|||||||
|
|
||||||
return localIP() != 0;
|
return localIP() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Phone Call functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool setGsmBusy(bool busy = true) TINY_GSM_ATTR_NOT_AVAILABLE;
|
|
||||||
|
|
||||||
bool callAnswer() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
|
||||||
|
|
||||||
bool callNumber(const String& number) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
|
||||||
|
|
||||||
bool callHangup() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messaging functions
|
* Messaging functions
|
||||||
*/
|
*/
|
||||||
@@ -721,7 +706,7 @@ public:
|
|||||||
TINY_GSM_YIELD();
|
TINY_GSM_YIELD();
|
||||||
while (stream.available() > 0) {
|
while (stream.available() > 0) {
|
||||||
int a = stream.read();
|
int a = stream.read();
|
||||||
if (a < 0) continue;
|
if (a <= 0) continue; // Skip 0x00 bytes, just in case
|
||||||
data += (char)a;
|
data += (char)a;
|
||||||
if (r1 && data.endsWith(r1)) {
|
if (r1 && data.endsWith(r1)) {
|
||||||
index = 1;
|
index = 1;
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ enum XBeeType {
|
|||||||
XBEE3_LTENB = 3, // Digi XBee3™ Cellular NB-IoT -- HS unknown to SRGD
|
XBEE3_LTENB = 3, // Digi XBee3™ Cellular NB-IoT -- HS unknown to SRGD
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
// Declaration of the TinyGsmXBee Class
|
// Declaration of the TinyGsmXBee Class
|
||||||
@@ -170,9 +169,9 @@ public:
|
|||||||
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TinyGsmXBee* at;
|
TinyGsmXBee* at;
|
||||||
uint8_t mux;
|
uint8_t mux;
|
||||||
bool sock_connected;
|
bool sock_connected;
|
||||||
};
|
};
|
||||||
|
|
||||||
//============================================================================//
|
//============================================================================//
|
||||||
@@ -665,8 +664,6 @@ fail:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
bool modemConnect(const char* host, uint16_t port, uint8_t mux = 0, bool ssl = false) {
|
bool modemConnect(const char* host, uint16_t port, uint8_t mux = 0, bool ssl = false) {
|
||||||
String strIP; strIP.reserve(16);
|
String strIP; strIP.reserve(16);
|
||||||
unsigned long startMillis = millis();
|
unsigned long startMillis = millis();
|
||||||
|
|||||||
Reference in New Issue
Block a user