Skip to content

Commit d3d9759

Browse files
committed
New delay in order to fix some comunnication problems
1 parent baa0937 commit d3d9759

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

Http.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,17 @@ Result HTTP::configureBearer(const char *apn){
8989
Result HTTP::connect() {
9090

9191
Result result = SUCCESS;
92+
unsigned int attempts = 0;
93+
unsigned int MAX_ATTEMPTS = 10;
9294

93-
if (sendCmdAndWaitForResp(QUERY_BEARER, BEARER_OPEN, 2000) == FALSE){
94-
if (sendCmdAndWaitForResp(OPEN_GPRS_CONTEXT, OK, 6000) == FALSE){
95+
while (sendCmdAndWaitForResp(QUERY_BEARER, BEARER_OPEN, 2000) == FALSE && attempts < MAX_ATTEMPTS){
96+
attempts ++;
97+
if (sendCmdAndWaitForResp(OPEN_GPRS_CONTEXT, OK, 2000) == FALSE){
9598
result = ERROR_OPEN_GPRS_CONTEXT;
9699
}
100+
else {
101+
result = SUCCESS;
102+
}
97103
}
98104

99105
if (sendCmdAndWaitForResp(HTTP_INIT, OK, 2000) == FALSE)
@@ -128,7 +134,6 @@ Result HTTP::post(const char *uri, const char *body, char *response) {
128134
purgeSerial();
129135
delay(500);
130136
sendCmd(body);
131-
delay(1000);
132137

133138
if (sendCmdAndWaitForResp(HTTP_POST, HTTP_200, delayToDownload) == TRUE) {
134139
sendCmd(HTTP_READ);

Sim800.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ void SIM800::sendEndMark(void)
129129

130130
int SIM800::sendCmdAndWaitForResp(const char* cmd, const char *resp, unsigned timeout)
131131
{
132+
delay(1000);
132133
sendCmd(cmd);
133134
return waitForResp(resp,timeout);
134135
}

0 commit comments

Comments
 (0)