cc
Diff: SPWFSA01.cpp
- Revision:
- 8:a4425b8dd2e4
- Parent:
- 7:551de95939e2
- Child:
- 10:580379efe167
diff -r 551de95939e2 -r a4425b8dd2e4 SPWFSA01.cpp --- a/SPWFSA01.cpp Thu Jun 30 10:52:43 2016 +0000 +++ b/SPWFSA01.cpp Mon Jul 04 12:14:14 2016 +0000 @@ -43,7 +43,7 @@ reset(); /*set local echo to 0*/ - if(!(_parser.send("AT+S.SCFG=localecho1,%d", 0) && _parser.recv("OK"))) + if(!(_parser.send("AT+S.SCFG=localecho1,%d\r", 0) && _parser.recv("OK"))) { printf("\r\nerror local echo set\n"); return false; @@ -89,7 +89,7 @@ { if(!_parser.send("AT+CFUN=1")) return false; while(1) { - if (_parser.recv("+WIND:32:WiFi Hardware Started")) { + if (_parser.recv("+WIND:32:WiFi Hardware Started\r")) { return true; } } @@ -151,13 +151,10 @@ reset(); while(1) - if((_parser.recv("+WIND:24:WiFi Up:%u.%u.%u.%u",&n1, &n2, &n3, &n4))) - //if((_parser.recv("+WIND:24:WiFi Up:%[^\\r]",_ip_buffer))) + if((_parser.recv("+WIND:24:WiFi Up:%u.%u.%u.%u\r",&n1, &n2, &n3, &n4))) { break; - } - - //printf("\r\nip address:%u.%u.%u.%u\n",n1, n2, n3, n4); + } return true; } @@ -251,7 +248,6 @@ //if(timeout) return false; //TODO: deal with errors like "ERROR: Failed to resolve name" } - //printf("\r\nsock id = %d\r\n", *id); return true; } @@ -277,9 +273,9 @@ if (!(_parser.recv("+WIND:55:Pending Data:%d:%u", &recv_id, &recv_amount) && recv_id == id - //&& _parser.send("AT+S.SOCKQ=%d", id)//send a query (will be required for secure sockets) - //&& _parser.recv(" DATALEN: %d", &recv_amount) - //&& _parser.recv("OK") + && _parser.send("AT+S.SOCKQ=%d", id)//send a query (will be required for secure sockets) + && _parser.recv(" DATALEN: %u", &recv_amount) + && _parser.recv("OK") && recv_amount <= amount && _parser.send("AT+S.SOCKR=%d,%d", id, recv_amount) && _parser.read((char*)data, recv_amount)