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

@@ -39,11 +39,27 @@ enum RegStatus {
};
//============================================================================//
//============================================================================//
// Declaration of the TinyGsmA6 Class
//============================================================================//
//============================================================================//
class TinyGsmA6
{
public:
//============================================================================//
//============================================================================//
// The A6 Client Class
//============================================================================//
//============================================================================//
class GsmClient : public Client
{
friend class TinyGsmA6;
@@ -167,9 +183,28 @@ private:
RxFifo rx;
};
//============================================================================//
//============================================================================//
// The A6 Does not have a secure client!
//============================================================================//
//============================================================================//
//============================================================================//
//============================================================================//
// The A6 Modem Functions
//============================================================================//
//============================================================================//
public:
#ifdef GSM_DEFAULT_STREAM
TinyGsmA6(Stream& stream = GSM_DEFAULT_STREAM)
#else
TinyGsmA6(Stream& stream)
#endif
: stream(stream)
{
memset(sockets, 0, sizeof(sockets));
@@ -241,6 +276,8 @@ public:
return res;
}
bool hasSSL() { return false; }
/*
* Power functions
*/
@@ -313,17 +350,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=3,0")); // Set format
waitResponse();
@@ -342,6 +368,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) {
@@ -367,6 +404,26 @@ public:
return false;
}
String getLocalIP() {
sendAT(GF("+CIFSR"));
String res;
if (waitResponse(10000L, res) != 1) {
return "";
}
res.replace(GSM_NL "OK" GSM_NL, "");
res.replace(GSM_NL, "");
res.trim();
return res;
}
IPAddress localIP() {
return TinyGsmIpFromString(getLocalIP());
}
/*
* WiFi functions
*/
/*
* GPRS functions
*/
@@ -423,22 +480,6 @@ public:
return (res == 1);
}
String getLocalIP() {
sendAT(GF("+CIFSR"));
String res;
if (waitResponse(10000L, res) != 1) {
return "";
}
res.replace(GSM_NL "OK" GSM_NL, "");
res.replace(GSM_NL, "");
res.trim();
return res;
}
IPAddress localIP() {
return TinyGsmIpFromString(getLocalIP());
}
/*
* Messaging functions
*/