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