Skip to content

Commit

Permalink
Merge pull request #49 from jaka87/master
Browse files Browse the repository at this point in the history
Increased timeout
  • Loading branch information
carrascoacd authored Dec 28, 2020
2 parents a194c01 + 4680a7b commit f4f40b9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/Ftp.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "Sim800.h"
#include "Result.h"


class FTP : public SIM800
{

Expand Down
18 changes: 9 additions & 9 deletions src/GPRS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, 12000) != TRUE &&
sim800->sendCmdAndWaitForResp_P(REGISTRATION_STATUS, ROAMING, 12000) != 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)
Expand All @@ -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, 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_, 2000) == FALSE)
if (sim800->sendCmdAndWaitForResp(httpApn, AT_OK_, 10000) == 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, 10000) == 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, 10000) == FALSE)
{
result = ERROR_OPEN_GPRS_CONTEXT;
}
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/Http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, 8000) == FALSE)
result = ERROR_HTTP_INIT;

return result;
Expand All @@ -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, 5000) == FALSE)
result = ERROR_HTTP_CLOSE;

return result;
Expand All @@ -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, 7000);

purgeSerial();
sendCmd(body);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Sim800.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Sim800.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@ class SIM800
unsigned int resetPin;
};

#endif
#endif

0 comments on commit f4f40b9

Please sign in to comment.