This commit is contained in:
SRGDamia1
2018-05-15 15:42:34 -04:00
parent e7d159d1e8
commit a3914083bc
11 changed files with 947 additions and 882 deletions

View File

@@ -38,21 +38,15 @@ enum RegStatus {
REG_UNKNOWN = 4,
};
//============================================================================//
//============================================================================//
// Declaration of the TinyGsmA6 Class
//============================================================================//
//============================================================================//
class TinyGsmA6
{
public:
//============================================================================//
//============================================================================//
// The A6 Client Class
@@ -60,6 +54,8 @@ public:
//============================================================================//
public:
class GsmClient : public Client
{
friend class TinyGsmA6;
@@ -343,10 +339,10 @@ public:
int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"));
waitResponse();
switch (status) {
case 2:
case 3: return SIM_LOCKED;
case 1: return SIM_READY;
default: return SIM_ERROR;
case 2:
case 3: return SIM_LOCKED;
case 1: return SIM_READY;
default: return SIM_ERROR;
}
}
return SIM_ERROR;
@@ -370,16 +366,16 @@ 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;
}
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"));
@@ -587,7 +583,7 @@ protected:
}
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\""));
waitResponse();
return 1 == res;