a library to use GPRS like ethernet or wifi, which makes it possible to connect to the internet with your GPRS module
Dependencies: BufferedSerial
Dependents: ThinkSpeak_Test roam_v1 roam_v2 finalv3
Fork of GPRSInterface by
Revision 11:0184e407128e, committed 2015-03-10
- Comitter:
- yihui
- Date:
- Tue Mar 10 03:04:27 2015 +0000
- Parent:
- 10:652c23d73373
- Child:
- 12:47488369a980
- Commit message:
- GPRS::is_connected() checks connection state again (<=3 times) if state is not sure
Changed in this revision
GPRS/GPRS.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/GPRS/GPRS.cpp Tue Mar 10 02:57:52 2015 +0000 +++ b/GPRS/GPRS.cpp Tue Mar 10 03:04:27 2015 +0000 @@ -144,16 +144,20 @@ char cmd[16]; char resp[96]; snprintf(cmd,16,"AT+CIPSTATUS=%d\r\n",socket); - sendCmd(cmd); - readBuffer(resp,sizeof(resp),DEFAULT_TIMEOUT); - if(NULL != strstr(resp,"CONNECTED")) { - //+CIPSTATUS: 1,0,"TCP","216.52.233.120","80","CONNECTED" - return true; - } else { - //+CIPSTATUS: 1,0,"TCP","216.52.233.120","80","CLOSED" - //+CIPSTATUS: 0,,"","","","INITIAL" - return false; + for (int i = 0; i < 3; i++) { + sendCmd(cmd); + readBuffer(resp,sizeof(resp),DEFAULT_TIMEOUT); + if(NULL != strstr(resp,"CONN")) { + //+CIPSTATUS: 1,0,"TCP","216.52.233.120","80","CONNECTED" + return true; + } else if (NULL != strstr(resp,"CLOSE")) { + //+CIPSTATUS: 1,0,"TCP","216.52.233.120","80","CLOSED" + //+CIPSTATUS: 0,,"","","","INITIAL" + return false; + } } + + return false; } void GPRS::reset()