ghrh
Diff: gprs.cpp
- Revision:
- 5:ac2342f162fa
- Parent:
- 4:63a2619b423b
- Child:
- 7:1278e9dde24e
--- a/gprs.cpp Tue Jan 21 06:44:58 2014 +0000 +++ b/gprs.cpp Wed Jan 22 02:04:57 2014 +0000 @@ -281,15 +281,26 @@ } } +int GPRS::networkInit(char* apn, char* userName, char* passWord) +{ + char cstt[64]; + snprintf(cstt,sizeof(cstt),"AT+CSTT=\"%s\",\"%s\",\"%s\"\r\n",apn,userName,passWord); + if(0 != sendCmdAndWaitForResp(cstt, "OK", DEFAULT_TIMEOUT)) { + return -1; + } + return 0; +} int GPRS::connectTCP(char *ip, char *port) { - char cipstart[50]; + char cipstart[64]; +#if 0 if(0 != sendCmdAndWaitForResp("AT+CSTT=\"CMNET\",\"\",\"\"\r\n", "OK", 5)) { return -1; } +#endif sprintf(cipstart, "AT+CIPSTART=\"TCP\",\"%s\",\"%s\"\r\n", ip, port); - if(0 != sendCmdAndWaitForResp(cipstart, "OK", 5)) { + if(0 != sendCmdAndWaitForResp(cipstart, "OK", DEFAULT_TIMEOUT)) { return -1; } return 0;