From e491d35b655c05f0494252a3e15836e3a70ec91b Mon Sep 17 00:00:00 2001 From: jaka87 Date: Sat, 28 Nov 2020 21:33:29 +0100 Subject: [PATCH 1/5] changed timeout --- src/GPRS.cpp | 18 +++++++++--------- src/Http.cpp | 6 +++--- src/Sim800.cpp | 4 ++-- src/Sim800.h | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/GPRS.cpp b/src/GPRS.cpp index b5416f9..7d3428f 100644 --- a/src/GPRS.cpp +++ b/src/GPRS.cpp @@ -52,12 +52,12 @@ Result openGPRSContext(SIM800 *sim800, const char *apn) sim800->sendATTest(); - while ((sim800->sendCmdAndWaitForResp_P(REGISTRATION_STATUS, CONNECTED, 2000) != TRUE && - sim800->sendCmdAndWaitForResp_P(REGISTRATION_STATUS, ROAMING, 2000) != TRUE) && + while ((sim800->sendCmdAndWaitForResp_P(REGISTRATION_STATUS, CONNECTED, 5000) != TRUE && + sim800->sendCmdAndWaitForResp_P(REGISTRATION_STATUS, ROAMING, 5000) != TRUE) && attempts < MAX_ATTEMPTS) { - sim800->sendCmdAndWaitForResp_P(READ_VOLTAGE, AT_OK, 1000); - sim800->sendCmdAndWaitForResp_P(SIGNAL_QUALITY, AT_OK, 1000); + sim800->sendCmdAndWaitForResp_P(READ_VOLTAGE, AT_OK, 2000); + sim800->sendCmdAndWaitForResp_P(SIGNAL_QUALITY, AT_OK, 2000); attempts++; delay(1000 * attempts); if (attempts == MAX_ATTEMPTS) @@ -67,20 +67,20 @@ Result openGPRSContext(SIM800 *sim800, const char *apn) } } - if (sim800->sendCmdAndWaitForResp_P(BEARER_PROFILE_GPRS, AT_OK, 2000) == FALSE) + if (sim800->sendCmdAndWaitForResp_P(BEARER_PROFILE_GPRS, AT_OK, 8000) == FALSE) result = ERROR_BEARER_PROFILE_GPRS; char httpApn[64]; char tmp[24]; strcpy_P(tmp, apn); sprintf_P(httpApn, BEARER_PROFILE_APN, tmp); - if (sim800->sendCmdAndWaitForResp(httpApn, AT_OK_, 2000) == FALSE) + if (sim800->sendCmdAndWaitForResp(httpApn, AT_OK_, 6000) == FALSE) result = ERROR_BEARER_PROFILE_APN; - while (sim800->sendCmdAndWaitForResp_P(QUERY_BEARER, BEARER_OPEN, 2000) == FALSE && attempts < MAX_ATTEMPTS) + while (sim800->sendCmdAndWaitForResp_P(QUERY_BEARER, BEARER_OPEN, 6000) == FALSE && attempts < MAX_ATTEMPTS) { attempts++; - if (sim800->sendCmdAndWaitForResp_P(OPEN_GPRS_CONTEXT, AT_OK, 2000) == FALSE) + if (sim800->sendCmdAndWaitForResp_P(OPEN_GPRS_CONTEXT, AT_OK, 6000) == FALSE) { result = ERROR_OPEN_GPRS_CONTEXT; } @@ -97,7 +97,7 @@ Result closeGPRSContext(SIM800 *sim800) { Result result = SUCCESS; - if (sim800->sendCmdAndWaitForResp_P(CLOSE_GPRS_CONTEXT, AT_OK, 2000) == FALSE) + if (sim800->sendCmdAndWaitForResp_P(CLOSE_GPRS_CONTEXT, AT_OK, 4000) == FALSE) result = ERROR_CLOSE_GPRS_CONTEXT; return result; diff --git a/src/Http.cpp b/src/Http.cpp index 43fc25d..9fcbbbb 100644 --- a/src/Http.cpp +++ b/src/Http.cpp @@ -55,7 +55,7 @@ Result HTTP::connect(const char *apn) { Result result = openGPRSContext(this, apn); - if (sendCmdAndWaitForResp_P(HTTP_INIT, AT_OK, 2000) == FALSE) + if (sendCmdAndWaitForResp_P(HTTP_INIT, AT_OK, 5000) == FALSE) result = ERROR_HTTP_INIT; return result; @@ -65,7 +65,7 @@ Result HTTP::disconnect() { Result result = closeGPRSContext(this); - if (sendCmdAndWaitForResp_P(HTTP_CLOSE, AT_OK, 2000) == FALSE) + if (sendCmdAndWaitForResp_P(HTTP_CLOSE, AT_OK, 4000) == FALSE) result = ERROR_HTTP_CLOSE; return result; @@ -83,7 +83,7 @@ Result HTTP::post(const char *uri, const char *body, char *response) sprintf_P(buffer, HTTP_DATA, strlen(body), delayToDownload); strcpy_P(resp, DOWNLOAD); - sendCmdAndWaitForResp(buffer, resp, 2000); + sendCmdAndWaitForResp(buffer, resp, 4000); purgeSerial(); sendCmd(body); diff --git a/src/Sim800.cpp b/src/Sim800.cpp index ab2ac14..dd7d0e9 100644 --- a/src/Sim800.cpp +++ b/src/Sim800.cpp @@ -203,11 +203,11 @@ void SIM800::sleep(bool force) { if (force) { - sendCmdAndWaitForResp_P(SLEEP_MODE_1, AT_OK, 2000); + sendCmdAndWaitForResp_P(SLEEP_MODE_1, AT_OK, 4000); } else { - sendCmdAndWaitForResp_P(SLEEP_MODE_2, AT_OK, 2000); + sendCmdAndWaitForResp_P(SLEEP_MODE_2, AT_OK, 4000); } } diff --git a/src/Sim800.h b/src/Sim800.h index f699526..e1e6ec0 100644 --- a/src/Sim800.h +++ b/src/Sim800.h @@ -37,7 +37,7 @@ #define DEFAULT_TIMEOUT 5000 // Comment or uncomment this to debug the library -// #define DEBUG true + #define DEBUG true /** SIM800 class. * Used for SIM800 communication. attention that SIM800 module communicate with MCU in serial protocol @@ -143,4 +143,4 @@ class SIM800 unsigned int resetPin; }; -#endif \ No newline at end of file +#endif From fc0154670f512ca19a5b8f125a4c9318ec8f189f Mon Sep 17 00:00:00 2001 From: jaka87 Date: Sat, 28 Nov 2020 21:37:21 +0100 Subject: [PATCH 2/5] hide debug --- src/Sim800.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sim800.h b/src/Sim800.h index e1e6ec0..5288253 100644 --- a/src/Sim800.h +++ b/src/Sim800.h @@ -37,7 +37,7 @@ #define DEFAULT_TIMEOUT 5000 // Comment or uncomment this to debug the library - #define DEBUG true +//#define DEBUG true /** SIM800 class. * Used for SIM800 communication. attention that SIM800 module communicate with MCU in serial protocol From f728e350cfc1c9d0758525dab62aa44f458dfc4b Mon Sep 17 00:00:00 2001 From: jaka87 Date: Sun, 29 Nov 2020 06:49:36 +0100 Subject: [PATCH 3/5] increase http int timeout --- src/GPRS.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/GPRS.cpp b/src/GPRS.cpp index 7d3428f..5a4aef9 100644 --- a/src/GPRS.cpp +++ b/src/GPRS.cpp @@ -67,14 +67,14 @@ Result openGPRSContext(SIM800 *sim800, const char *apn) } } - if (sim800->sendCmdAndWaitForResp_P(BEARER_PROFILE_GPRS, AT_OK, 8000) == FALSE) + if (sim800->sendCmdAndWaitForResp_P(BEARER_PROFILE_GPRS, AT_OK, 10000) == FALSE) result = ERROR_BEARER_PROFILE_GPRS; char httpApn[64]; char tmp[24]; strcpy_P(tmp, apn); sprintf_P(httpApn, BEARER_PROFILE_APN, tmp); - if (sim800->sendCmdAndWaitForResp(httpApn, AT_OK_, 6000) == FALSE) + if (sim800->sendCmdAndWaitForResp(httpApn, AT_OK_, 8000) == FALSE) result = ERROR_BEARER_PROFILE_APN; while (sim800->sendCmdAndWaitForResp_P(QUERY_BEARER, BEARER_OPEN, 6000) == FALSE && attempts < MAX_ATTEMPTS) From add9265a4dcc944b5b9263b5994b9c5e693e4f3c Mon Sep 17 00:00:00 2001 From: jaka87 Date: Wed, 9 Dec 2020 09:36:56 +0100 Subject: [PATCH 4/5] increase timeout --- src/Ftp.h | 1 + src/GPRS.cpp | 10 +++++----- src/Http.cpp | 6 +++--- src/Sim800.h | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Ftp.h b/src/Ftp.h index e63031d..bbc29fd 100644 --- a/src/Ftp.h +++ b/src/Ftp.h @@ -31,6 +31,7 @@ #include "Sim800.h" #include "Result.h" + class FTP : public SIM800 { diff --git a/src/GPRS.cpp b/src/GPRS.cpp index 5a4aef9..d970aac 100644 --- a/src/GPRS.cpp +++ b/src/GPRS.cpp @@ -52,8 +52,8 @@ Result openGPRSContext(SIM800 *sim800, const char *apn) sim800->sendATTest(); - while ((sim800->sendCmdAndWaitForResp_P(REGISTRATION_STATUS, CONNECTED, 5000) != TRUE && - sim800->sendCmdAndWaitForResp_P(REGISTRATION_STATUS, ROAMING, 5000) != TRUE) && + while ((sim800->sendCmdAndWaitForResp_P(REGISTRATION_STATUS, CONNECTED, 10000) != TRUE && + sim800->sendCmdAndWaitForResp_P(REGISTRATION_STATUS, ROAMING, 10000) != TRUE) && attempts < MAX_ATTEMPTS) { sim800->sendCmdAndWaitForResp_P(READ_VOLTAGE, AT_OK, 2000); @@ -67,7 +67,7 @@ Result openGPRSContext(SIM800 *sim800, const char *apn) } } - if (sim800->sendCmdAndWaitForResp_P(BEARER_PROFILE_GPRS, AT_OK, 10000) == FALSE) + if (sim800->sendCmdAndWaitForResp_P(BEARER_PROFILE_GPRS, AT_OK, 12000) == FALSE) result = ERROR_BEARER_PROFILE_GPRS; char httpApn[64]; @@ -77,10 +77,10 @@ Result openGPRSContext(SIM800 *sim800, const char *apn) if (sim800->sendCmdAndWaitForResp(httpApn, AT_OK_, 8000) == FALSE) result = ERROR_BEARER_PROFILE_APN; - while (sim800->sendCmdAndWaitForResp_P(QUERY_BEARER, BEARER_OPEN, 6000) == FALSE && attempts < MAX_ATTEMPTS) + while (sim800->sendCmdAndWaitForResp_P(QUERY_BEARER, BEARER_OPEN, 8000) == FALSE && attempts < MAX_ATTEMPTS) { attempts++; - if (sim800->sendCmdAndWaitForResp_P(OPEN_GPRS_CONTEXT, AT_OK, 6000) == FALSE) + if (sim800->sendCmdAndWaitForResp_P(OPEN_GPRS_CONTEXT, AT_OK, 8000) == FALSE) { result = ERROR_OPEN_GPRS_CONTEXT; } diff --git a/src/Http.cpp b/src/Http.cpp index 9fcbbbb..7c1e4a0 100644 --- a/src/Http.cpp +++ b/src/Http.cpp @@ -55,7 +55,7 @@ Result HTTP::connect(const char *apn) { Result result = openGPRSContext(this, apn); - if (sendCmdAndWaitForResp_P(HTTP_INIT, AT_OK, 5000) == FALSE) + if (sendCmdAndWaitForResp_P(HTTP_INIT, AT_OK, 6000) == FALSE) result = ERROR_HTTP_INIT; return result; @@ -65,7 +65,7 @@ Result HTTP::disconnect() { Result result = closeGPRSContext(this); - if (sendCmdAndWaitForResp_P(HTTP_CLOSE, AT_OK, 4000) == FALSE) + if (sendCmdAndWaitForResp_P(HTTP_CLOSE, AT_OK, 5000) == FALSE) result = ERROR_HTTP_CLOSE; return result; @@ -83,7 +83,7 @@ Result HTTP::post(const char *uri, const char *body, char *response) sprintf_P(buffer, HTTP_DATA, strlen(body), delayToDownload); strcpy_P(resp, DOWNLOAD); - sendCmdAndWaitForResp(buffer, resp, 4000); + sendCmdAndWaitForResp(buffer, resp, 5000); purgeSerial(); sendCmd(body); diff --git a/src/Sim800.h b/src/Sim800.h index 5288253..0dbf2f8 100644 --- a/src/Sim800.h +++ b/src/Sim800.h @@ -37,7 +37,7 @@ #define DEFAULT_TIMEOUT 5000 // Comment or uncomment this to debug the library -//#define DEBUG true +// #define DEBUG true /** SIM800 class. * Used for SIM800 communication. attention that SIM800 module communicate with MCU in serial protocol From 4680a7b9cee44ec9f3c37d3932e7f1905e33d817 Mon Sep 17 00:00:00 2001 From: jaka87 Date: Fri, 11 Dec 2020 18:27:29 +0100 Subject: [PATCH 5/5] timeout for bad weather --- src/GPRS.cpp | 12 ++++++------ src/Http.cpp | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/GPRS.cpp b/src/GPRS.cpp index d970aac..d25b603 100644 --- a/src/GPRS.cpp +++ b/src/GPRS.cpp @@ -52,8 +52,8 @@ Result openGPRSContext(SIM800 *sim800, const char *apn) sim800->sendATTest(); - while ((sim800->sendCmdAndWaitForResp_P(REGISTRATION_STATUS, CONNECTED, 10000) != TRUE && - sim800->sendCmdAndWaitForResp_P(REGISTRATION_STATUS, ROAMING, 10000) != TRUE) && + while ((sim800->sendCmdAndWaitForResp_P(REGISTRATION_STATUS, CONNECTED, 12000) != TRUE && + sim800->sendCmdAndWaitForResp_P(REGISTRATION_STATUS, ROAMING, 12000) != TRUE) && attempts < MAX_ATTEMPTS) { sim800->sendCmdAndWaitForResp_P(READ_VOLTAGE, AT_OK, 2000); @@ -67,20 +67,20 @@ Result openGPRSContext(SIM800 *sim800, const char *apn) } } - if (sim800->sendCmdAndWaitForResp_P(BEARER_PROFILE_GPRS, AT_OK, 12000) == FALSE) + if (sim800->sendCmdAndWaitForResp_P(BEARER_PROFILE_GPRS, AT_OK, 14000) == FALSE) result = ERROR_BEARER_PROFILE_GPRS; char httpApn[64]; char tmp[24]; strcpy_P(tmp, apn); sprintf_P(httpApn, BEARER_PROFILE_APN, tmp); - if (sim800->sendCmdAndWaitForResp(httpApn, AT_OK_, 8000) == FALSE) + if (sim800->sendCmdAndWaitForResp(httpApn, AT_OK_, 10000) == FALSE) result = ERROR_BEARER_PROFILE_APN; - while (sim800->sendCmdAndWaitForResp_P(QUERY_BEARER, BEARER_OPEN, 8000) == FALSE && attempts < MAX_ATTEMPTS) + while (sim800->sendCmdAndWaitForResp_P(QUERY_BEARER, BEARER_OPEN, 10000) == FALSE && attempts < MAX_ATTEMPTS) { attempts++; - if (sim800->sendCmdAndWaitForResp_P(OPEN_GPRS_CONTEXT, AT_OK, 8000) == FALSE) + if (sim800->sendCmdAndWaitForResp_P(OPEN_GPRS_CONTEXT, AT_OK, 10000) == FALSE) { result = ERROR_OPEN_GPRS_CONTEXT; } diff --git a/src/Http.cpp b/src/Http.cpp index 7c1e4a0..53fcf54 100644 --- a/src/Http.cpp +++ b/src/Http.cpp @@ -55,7 +55,7 @@ Result HTTP::connect(const char *apn) { Result result = openGPRSContext(this, apn); - if (sendCmdAndWaitForResp_P(HTTP_INIT, AT_OK, 6000) == FALSE) + if (sendCmdAndWaitForResp_P(HTTP_INIT, AT_OK, 8000) == FALSE) result = ERROR_HTTP_INIT; return result; @@ -83,7 +83,7 @@ Result HTTP::post(const char *uri, const char *body, char *response) sprintf_P(buffer, HTTP_DATA, strlen(body), delayToDownload); strcpy_P(resp, DOWNLOAD); - sendCmdAndWaitForResp(buffer, resp, 5000); + sendCmdAndWaitForResp(buffer, resp, 7000); purgeSerial(); sendCmd(body); @@ -108,7 +108,7 @@ Result HTTP::get(const char *uri, char *response) Result result; setHTTPSession(uri); - if (sendCmdAndWaitForResp_P(HTTP_GET, HTTP_2XX, 2000) == TRUE) + if (sendCmdAndWaitForResp_P(HTTP_GET, HTTP_2XX, 7000) == TRUE) { char buffer[16]; strcpy_P(buffer, HTTP_READ);