From 4680a7b9cee44ec9f3c37d3932e7f1905e33d817 Mon Sep 17 00:00:00 2001 From: jaka87 Date: Fri, 11 Dec 2020 18:27:29 +0100 Subject: [PATCH] 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);