Open SunboX opened 3 years ago
I tried the same code using a TTGO T-Call 1.4 and it works perfectly. Seems only to be related to the A6 Modem.
I don't have an A6, so I'm guessing here.
It might be incorrectly reporting the socket state (ie, it's already closed) meaning that the close command fails. The module might just not recover well after the first command fails, leading to the second failure. In order to allow all characters to be read, the TinyGSM will report the socket as connected as long as there's anything available on the socket (even if the socket has been closed externally). Since your function short-cuts out as soon as it finds the table it's looking for, it's probably leaving stuff in the buffer. The stop function you're calling when you exit your loop should dump everything out of the buffer for you, but since the A6 is a slow talker, it might still be reporting out the message after it's been told to stop. Try re-writing your function to continue reading until there's nothing available and only then returning with the table in question.
I'm Having a similar problem using:
Modem: SIM7000G Main processor board: ESP32 TinyGSM version: 0.11.7
I'm using this function:
bool acknowledgeOrder(String token, String stat, String message){
bool res=false;
if (connectModem(false)) {
ConsoleLog("Acknowledging order with status: " + stat);
String postData = "{\"status\":\""+ stat + "\", \"message\":\""+ message + "\"}";
http.beginRequest();
http.post(api_endpoint + "/sensur_order/" + token + "/");
http.sendHeader("Content-Type", "application/json");
http.sendHeader("Content-Length", postData.length());
http.beginBody();
http.print(postData);
http.endRequest();
// read the status code and body of the response
int statusCode = http.responseStatusCode();
String response = http.responseBody();
if (statusCode == 200){
ConsoleLog("Acknowledge sent");
res= true;
}else{
delay(500);
ConsoleLog("Connect failed: " + String(statusCode));
ConsoleLog("Response: " + response);
}
while (http.available()){
http.read(); //clean the buffer
}
http.flush();
http.stop();
}
else {
ConsoleLog("acknowledgeOrder: Modem connect fail");
}
return res;
}
The first time I call it it works perfectly but the second time the connection fails giving me -3 response status code
[ x] I have read the Troubleshooting section of the ReadMe
What type of issues is this?
[ x] Bug or issue with library functionality (ie, sending data over TCP/IP) [ x] Question or request for help
What are you working with?
Modem: A6 Main processor board: ESP32 TinyGSM version: latest
Baud rate is set to 9600 already (fixed) and 2ms yield is also defined! External stable power source (5V / 2A) is connected.
Code:
Scenario, steps to reproduce
try to execute the code twice
Expected result
both requests work
Actual result
second code execute fails (see logs below)
Debug and AT command log
First connection:
Second connection: