modified by ohneta
Fork of ESP8266 by
Diff: ESP8266.cpp
- Revision:
- 14:71474261a9d7
- Parent:
- 13:4c014a7f0c63
- Child:
- 15:1ff5d44d5e30
--- a/ESP8266.cpp Wed Aug 05 21:57:41 2015 +0000 +++ b/ESP8266.cpp Tue Nov 10 14:42:20 2015 +0000 @@ -81,7 +81,8 @@ bool ESP8266::getIPAddress(char* ip) { - return (atParser.send("AT+CIPSTA?") && atParser.recv("+CIPSTA:\"%[^\"]\"", ip)); + return (atParser.send("AT+CIPSTA?") && atParser.recv("+CIPSTA:ip:\"%[^\"]\"", ip)); + } bool ESP8266::isConnected(void) @@ -129,9 +130,16 @@ { int length; int id; - if (!(atParser.recv("+IPD,%d,%d:", &id, &length) && atParser.read((char*)data, length) && atParser.recv("OK"))) { + + if (!(atParser.recv("+IPD,%d,%d:", &id, &length) && atParser.read((char*)data, length))) { return 0; } + + char idstr[2]; + sprintf(idstr, "%d", id); + string close_command = (string)idstr + ",CLOSED"; + atParser.recv(close_command.c_str()); + return length; } @@ -144,8 +152,10 @@ char idstr[2]; sprintf(idstr,"%d",id); string close_command = "AT+CIPCLOSE="+(string)idstr; + string closed_response = (string)idstr + ",CLOSED OK"; - return (atParser.send(close_command.c_str()) && atParser.recv("OK")); + //return (atParser.send(close_command.c_str()) && atParser.recv("OK")); + return (atParser.send(close_command.c_str()) && atParser.recv(closed_response.c_str())); } void ESP8266::setTimeout(uint32_t timeout_ms)