offer some API for GPRS use, such as call / sms / tcp connect
Fork of GPRS by
Revision 5:ac2342f162fa, committed 2014-01-22
- Comitter:
- lawliet
- Date:
- Wed Jan 22 02:04:57 2014 +0000
- Parent:
- 4:63a2619b423b
- Child:
- 6:e508f9ee7922
- Commit message:
- version 2.1 (add network APN setting)
Changed in this revision
gprs.cpp | Show annotated file Show diff for this revision Revisions of this file |
gprs.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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;
--- a/gprs.h Tue Jan 21 06:44:58 2014 +0000 +++ b/gprs.h Wed Jan 22 02:04:57 2014 +0000 @@ -135,6 +135,12 @@ */ int loopHandle(void); + /** gprs network init + * @param *apn Access Point Name to connect network + * @param *userName general is empty + * @param *passWord general is empty + */ + int networkInit(char* apn, char* userName = NULL, char* passWord = NULL); /** build TCP connect * @param *ip ip address which will connect to * @param *port TCP server' port number