Fix disconnect for SARA R4
This commit is contained in:
@@ -328,7 +328,6 @@ TINY_GSM_MODEM_GET_SIMCCID_CCID()
|
|||||||
return SIM_ERROR;
|
return SIM_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TINY_GSM_MODEM_GET_REGISTRATION_XREG(CEREG)
|
TINY_GSM_MODEM_GET_REGISTRATION_XREG(CEREG)
|
||||||
|
|
||||||
TINY_GSM_MODEM_GET_OPERATOR_COPS()
|
TINY_GSM_MODEM_GET_OPERATOR_COPS()
|
||||||
@@ -501,7 +500,7 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t res = stream.readStringUntil(',').toInt();
|
int res = stream.readStringUntil(',').toInt();
|
||||||
int8_t percent = res*20; // return is 0-5
|
int8_t percent = res*20; // return is 0-5
|
||||||
// Wait for final OK
|
// Wait for final OK
|
||||||
waitResponse();
|
waitResponse();
|
||||||
@@ -576,8 +575,13 @@ protected:
|
|||||||
sockets[mux]->sock_connected = false;
|
sockets[mux]->sock_connected = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
bool success;
|
||||||
sendAT(GF("+USOCL="), mux);
|
sendAT(GF("+USOCL="), mux);
|
||||||
return 1 == waitResponse(120000L); // can take up to 120s to get a response
|
success = 1 == waitResponse(120000L); // can take up to 120s to get a response
|
||||||
|
if (success) {
|
||||||
|
sockets[mux]->sock_connected = false;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t modemSend(const void* buff, size_t len, uint8_t mux) {
|
int16_t modemSend(const void* buff, size_t len, uint8_t mux) {
|
||||||
@@ -629,12 +633,11 @@ protected:
|
|||||||
result = stream.readStringUntil('\n').toInt();
|
result = stream.readStringUntil('\n').toInt();
|
||||||
// if (result) DBG("### DATA AVAILABLE:", result, "on", mux);
|
// if (result) DBG("### DATA AVAILABLE:", result, "on", mux);
|
||||||
waitResponse();
|
waitResponse();
|
||||||
} else if (res == 3) {
|
|
||||||
streamSkipUntil('\n'); // Skip the error text
|
|
||||||
}
|
}
|
||||||
if (!result) {
|
if (!result) {
|
||||||
sockets[mux]->sock_connected = modemGetConnected(mux);
|
sockets[mux]->sock_connected = modemGetConnected(mux);
|
||||||
}
|
}
|
||||||
|
DBG("### AVAILABLE:", result, "on", mux);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -701,6 +704,9 @@ TINY_GSM_MODEM_STREAM_UTILITIES()
|
|||||||
goto finish;
|
goto finish;
|
||||||
} else if (r3 && data.endsWith(r3)) {
|
} else if (r3 && data.endsWith(r3)) {
|
||||||
index = 3;
|
index = 3;
|
||||||
|
if (r3 == GFP(GSM_CME_ERROR)) {
|
||||||
|
streamSkipUntil('\n'); // Read out the error
|
||||||
|
}
|
||||||
goto finish;
|
goto finish;
|
||||||
} else if (r4 && data.endsWith(r4)) {
|
} else if (r4 && data.endsWith(r4)) {
|
||||||
index = 4;
|
index = 4;
|
||||||
|
|||||||
@@ -108,11 +108,11 @@ TINY_GSM_CLIENT_CONNECT_OVERLOADS()
|
|||||||
at->modemDisconnect(mux);
|
at->modemDisconnect(mux);
|
||||||
}
|
}
|
||||||
|
|
||||||
TINY_GSM_CLIENT_WRITE() ;
|
TINY_GSM_CLIENT_WRITE()
|
||||||
|
|
||||||
TINY_GSM_CLIENT_AVAILABLE_WITH_BUFFER_CHECK() ;
|
TINY_GSM_CLIENT_AVAILABLE_WITH_BUFFER_CHECK()
|
||||||
|
|
||||||
TINY_GSM_CLIENT_READ_WITH_BUFFER_CHECK() ;
|
TINY_GSM_CLIENT_READ_WITH_BUFFER_CHECK()
|
||||||
|
|
||||||
TINY_GSM_CLIENT_PEEK_FLUSH_CONNECTED()
|
TINY_GSM_CLIENT_PEEK_FLUSH_CONNECTED()
|
||||||
|
|
||||||
@@ -575,8 +575,6 @@ protected:
|
|||||||
//waitResponse();
|
//waitResponse();
|
||||||
|
|
||||||
// connect on the allocated socket
|
// connect on the allocated socket
|
||||||
// TODO: Use faster "asynchronous" connection?
|
|
||||||
// We would have to wait for the +UUSOCO URC to verify connection
|
|
||||||
sendAT(GF("+USOCO="), *mux, ",\"", host, "\",", port);
|
sendAT(GF("+USOCO="), *mux, ",\"", host, "\",", port);
|
||||||
int rsp = waitResponse(timeout_ms);
|
int rsp = waitResponse(timeout_ms);
|
||||||
return (1 == rsp);
|
return (1 == rsp);
|
||||||
@@ -650,6 +648,7 @@ protected:
|
|||||||
if (!result) {
|
if (!result) {
|
||||||
sockets[mux]->sock_connected = modemGetConnected(mux);
|
sockets[mux]->sock_connected = modemGetConnected(mux);
|
||||||
}
|
}
|
||||||
|
DBG("### AVAILABLE:", result, "on", mux);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user