sim7000 syntax fix

Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
Sara Damiano
2021-04-29 15:43:21 -04:00
parent 9128baeb27
commit 93fc96d9ec

View File

@@ -126,7 +126,7 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>,
: GsmClientSim7000(modem, mux) {}
public:
bool setCertificate(const String & certificateName) {
bool setCertificate(const String& certificateName) {
return at->setCertificate(certificateName, mux);
}
@@ -140,7 +140,7 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>,
TINY_GSM_CLIENT_CONNECT_OVERRIDES
};
public:
public:
boolean isValidNumber(String str) {
if (!(str.charAt(0) == '+' || str.charAt(0) == '-' ||
isDigit(str.charAt(0))))
@@ -189,10 +189,7 @@ public:
* Constructor
*/
public:
explicit TinyGsmSim7000(Stream& stream):
stream(stream),
certificates()
{
explicit TinyGsmSim7000(Stream& stream) : stream(stream), certificates() {
memset(sockets, 0, sizeof(sockets));
}
@@ -314,7 +311,7 @@ public:
}
protected:
bool setCertificate(const String & certificateName, const uint8_t mux = 0) {
bool setCertificate(const String& certificateName, const uint8_t mux = 0) {
if (mux >= TINY_GSM_MUX_COUNT) return false;
certificates[mux] = certificateName;
return true;
@@ -336,7 +333,7 @@ public:
return res;
}
bool getNetworkMode(int16_t & mode) {
bool getNetworkMode(int16_t& mode) {
sendAT(GF("+CNMP?"));
if (waitResponse(GF(GSM_NL "+CNMP:")) != 1) { return false; }
mode = streamGetIntBefore('\n');
@@ -359,7 +356,7 @@ public:
return res;
}
bool getPreferredMode(int16_t & mode) {
bool getPreferredMode(int16_t& mode) {
sendAT(GF("+CMNB?"));
if (waitResponse(GF(GSM_NL "+CMNB:")) != 1) { return false; }
mode = streamGetIntBefore('\n');
@@ -373,7 +370,7 @@ public:
return "OK";
}
bool getNetworkSystemMode(bool & n, int16_t & stat) {
bool getNetworkSystemMode(bool& n, int16_t& stat) {
// n: whether to automatically report the system mode info
// stat: the current service. 0 if it not connected
sendAT(GF("+CNSMOD?"));
@@ -625,9 +622,9 @@ public:
sendAT(GF("+CSSLCFG=\"ctxindex\",0"));
if (waitResponse() != 1) return false;
if (certificates[mux] != "")
{
sendAT(GF("+CASSLCFG="), mux, ",CACERT,\"", certificates[mux].c_str(),"\"");
if (certificates[mux] != "") {
sendAT(GF("+CASSLCFG="), mux, ",CACERT,\"", certificates[mux].c_str(),
"\"");
if (waitResponse() != 1) return false;
}
}
@@ -654,20 +651,14 @@ public:
int16_t modemSend(const void* buff, size_t len, uint8_t mux) {
sendAT(GF("+CASEND="), mux, ',', (uint16_t)len);
if (waitResponse(GF(">")) != 1) {
return 0;
}
if (waitResponse(GF(">")) != 1) { return 0; }
stream.write(reinterpret_cast<const uint8_t*>(buff), len);
stream.flush();
if (waitResponse(GF(GSM_NL "+CASEND:")) != 1) {
return 0;
}
if (waitResponse(GF(GSM_NL "+CASEND:")) != 1) { return 0; }
streamSkipUntil(','); // Skip mux
if (streamGetIntBefore(',') != 0) {
return 0;
} // If result != success
if (streamGetIntBefore(',') != 0) { return 0; } // If result != success
return streamGetIntBefore('\n');
}
@@ -742,9 +733,7 @@ public:
sendAT(GF("+CASTATE?"));
int8_t readMux = -1;
while (readMux != mux) {
if (waitResponse(3000, GF("+CASTATE:"),GF(GSM_OK)) != 1) {
return 0;
}
if (waitResponse(3000, GF("+CASTATE:"), GFP(GSM_OK)) != 1) { return 0; }
readMux = streamGetIntBefore(',');
}
int8_t res = streamGetIntBefore('\n');
@@ -857,8 +846,7 @@ public:
int8_t mux = streamGetIntBefore(',');
int8_t state = streamGetIntBefore('\n');
if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) {
if (state != 1)
{
if (state != 1) {
sockets[mux]->sock_connected = false;
DBG("### Closed: ", mux);
}