Browse Source

Deactivate contexts on Monarch

Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
v_master
Sara Damiano 4 years ago
parent
commit
e1c9c2517b
3 changed files with 17 additions and 18 deletions
  1. +1
    -0
      .gitignore
  2. +3
    -5
      src/TinyGsmClientSIM800.h
  3. +13
    -13
      src/TinyGsmClientSequansMonarch.h

+ 1
- 0
.gitignore View File

@ -24,6 +24,7 @@ extra_envs.ini
lib/readme.txt
include/readme.txt
.atomrc.cson
.history
# VSCode
.vscode/*


+ 3
- 5
src/TinyGsmClientSIM800.h View File

@ -383,7 +383,7 @@ class TinyGsmSim800 : public TinyGsmModem<TinyGsmSim800>,
sendAT(GF("+CIPSHUT"));
if (waitResponse(60000L) != 1) { return false; }
sendAT(GF("+CGATT=0")); // Deactivate the bearer context
sendAT(GF("+CGATT=0")); // Detach from GPRS
if (waitResponse(60000L) != 1) { return false; }
return true;
@ -396,9 +396,7 @@ class TinyGsmSim800 : public TinyGsmModem<TinyGsmSim800>,
// May not return the "+CCID" before the number
String getSimCCIDImpl() {
sendAT(GF("+CCID"));
if (waitResponse(GF(GSM_NL)) != 1) {
return "";
}
if (waitResponse(GF(GSM_NL)) != 1) { return ""; }
String res = stream.readStringUntil('\n');
waitResponse();
// Trim out the CCID header in case it is there
@ -739,7 +737,7 @@ class TinyGsmSim800 : public TinyGsmModem<TinyGsmSim800>,
}
public:
Stream& stream;
Stream& stream;
protected:
GsmClientSim800* sockets[TINY_GSM_MUX_COUNT];


+ 13
- 13
src/TinyGsmClientSequansMonarch.h View File

@ -367,8 +367,12 @@ class TinyGsmSequansMonarch
}
bool gprsDisconnectImpl() {
// Detach from PS network
sendAT(GF("+CGATT=0"));
if (waitResponse(60000L) != 1) { return false; }
// Dectivate all PDP contexts
sendAT(GF("+CGACT=0"));
if (waitResponse(60000L) != 1) { return false; }
return true;
}
@ -572,9 +576,7 @@ class TinyGsmSequansMonarch
// six possible sockets.
sendAT(GF("+SQNSS"));
for (int muxNo = 1; muxNo <= TINY_GSM_MUX_COUNT; muxNo++) {
if (waitResponse(GFP(GSM_OK), GF(GSM_NL "+SQNSS: ")) != 2) {
break;
}
if (waitResponse(GFP(GSM_OK), GF(GSM_NL "+SQNSS: ")) != 2) { break; }
uint8_t status = 0;
// if (streamGetIntBefore(',') != muxNo) { // check the mux no
// DBG("### Warning: misaligned mux numbers!");
@ -593,9 +595,9 @@ class TinyGsmSequansMonarch
// SOCK_OPENING = 6,
GsmClientSequansMonarch* sock = sockets[mux % TINY_GSM_MUX_COUNT];
if (sock) {
sock->sock_connected =
((status != SOCK_CLOSED) && (status != SOCK_INCOMING) &&
(status != SOCK_OPENING));
sock->sock_connected = ((status != SOCK_CLOSED) &&
(status != SOCK_INCOMING) &&
(status != SOCK_OPENING));
}
}
waitResponse(); // Should be an OK at the end
@ -624,7 +626,7 @@ class TinyGsmSequansMonarch
String r5s(r5); r5s.trim();
DBG("### ..:", r1s, ",", r2s, ",", r3s, ",", r4s, ",", r5s);*/
data.reserve(64);
uint8_t index = 0;
uint8_t index = 0;
uint32_t startMillis = millis();
do {
TINY_GSM_YIELD();
@ -654,11 +656,11 @@ class TinyGsmSequansMonarch
index = 5;
goto finish;
} else if (data.endsWith(GF(GSM_NL "+SQNSRING:"))) {
int8_t mux = streamGetIntBefore(',');
int8_t mux = streamGetIntBefore(',');
int16_t len = streamGetIntBefore('\n');
if (mux >= 0 && mux < TINY_GSM_MUX_COUNT &&
sockets[mux % TINY_GSM_MUX_COUNT]) {
sockets[mux % TINY_GSM_MUX_COUNT]->got_data = true;
sockets[mux % TINY_GSM_MUX_COUNT]->got_data = true;
sockets[mux % TINY_GSM_MUX_COUNT]->sock_available = len;
}
data = "";
@ -677,9 +679,7 @@ class TinyGsmSequansMonarch
finish:
if (!index) {
data.trim();
if (data.length()) {
DBG("### Unhandled:", data);
}
if (data.length()) { DBG("### Unhandled:", data); }
data = "";
}
// data.replace(GSM_NL, "/");
@ -717,7 +717,7 @@ class TinyGsmSequansMonarch
protected:
GsmClientSequansMonarch* sockets[TINY_GSM_MUX_COUNT];
const char* gsmNL = GSM_NL;
const char* gsmNL = GSM_NL;
};
#endif // SRC_TINYGSMCLIENTSEQUANSMONARCH_H_

Loading…
Cancel
Save