Keeping changes I like from other branches

This commit is contained in:
SRGDamia1
2018-02-23 14:12:29 -05:00
parent fddf65eabc
commit 55ac0cd9ae
7 changed files with 581 additions and 301 deletions

View File

@@ -9,7 +9,7 @@
#ifndef TinyGsmClientM590_h
#define TinyGsmClientM590_h
//#define TINY_GSM_DEBUG Serial
// #define TINY_GSM_DEBUG Serial
#if !defined(TINY_GSM_RX_BUFFER)
#define TINY_GSM_RX_BUFFER 256
@@ -39,9 +39,21 @@ enum RegStatus {
};
//============================================================================//
//============================================================================//
// Declaration of the TinyGsmM590 Class
//============================================================================//
//============================================================================//
class TinyGsmM590
{
//============================================================================//
//============================================================================//
// The M590 Client Class
//============================================================================//
//============================================================================//
public:
class GsmClient : public Client
@@ -158,15 +170,33 @@ public:
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
private:
TinyGsmM590* at;
TinyGsmM590* at;
uint8_t mux;
bool sock_connected;
RxFifo rx;
};
//============================================================================//
//============================================================================//
// The M590 Has no Secure client!
//============================================================================//
//============================================================================//
//============================================================================//
//============================================================================//
// The M590 Modem Functions
//============================================================================//
//============================================================================//
public:
#ifdef GSM_DEFAULT_STREAM
TinyGsmM590(Stream& stream = GSM_DEFAULT_STREAM)
#else
TinyGsmM590(Stream& stream)
#endif
: stream(stream)
{
memset(sockets, 0, sizeof(sockets));
@@ -243,6 +273,8 @@ public:
return res;
}
bool hasSSL() { return false; }
/*
* Power functions
*/
@@ -322,17 +354,6 @@ public:
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() {
sendAT(GF("+COPS?"));
if (waitResponse(GF(GSM_NL "+COPS:")) != 1) {
@@ -348,6 +369,17 @@ public:
* 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() {
sendAT(GF("+CSQ"));
if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) {
@@ -373,10 +405,30 @@ public:
return false;
}
String getLocalIP() {
sendAT(GF("+XIIC?"));
if (waitResponse(GF(GSM_NL "+XIIC:")) != 1) {
return "";
}
stream.readStringUntil(',');
String res = stream.readStringUntil('\n');
waitResponse();
res.trim();
return res;
}
IPAddress localIP() {
return TinyGsmIpFromString(getLocalIP());
}
/*
* WiFi functions
*/
/*
* GPRS functions
*/
bool gprsConnect(const char* apn, const char* user, const char* pwd) {
bool gprsConnect(const char* apn, const char* user = "", const char* pwd = "") {
gprsDisconnect();
sendAT(GF("+XISP=0"));
@@ -429,22 +481,6 @@ public:
return res == 1;
}
String getLocalIP() {
sendAT(GF("+XIIC?"));
if (waitResponse(GF(GSM_NL "+XIIC:")) != 1) {
return "";
}
stream.readStringUntil(',');
String res = stream.readStringUntil('\n');
waitResponse();
res.trim();
return res;
}
IPAddress localIP() {
return TinyGsmIpFromString(getLocalIP());
}
/*
* Messaging functions
*/
@@ -596,7 +632,7 @@ public:
streamWrite("AT", cmd..., GSM_NL);
stream.flush();
TINY_GSM_YIELD();
//DBG("### AT:", cmd...);
// DBG("### AT:", cmd...);
}
// TODO: Optimize this!