ESP8266 plugged into the Arduino Mega 2560. I want to download the contents of the page. Listing:
#define ESP8266 Serial3
#define SERVER "192.168.1.8"
void setup()
{
Serial.begin(9600);
ESP8266.begin(115200);
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += SERVER;
cmd += "\",8095";
ESP8266.println(cmd);
Serial.println(cmd);
if(ESP8266.find("Error")) return;
cmd = "GET /api HTTP/1.1\r\nHost:192.168.1.8:8095\r\nApiCode:8273\r\nContent-Type: application/json\r\nConnection: keep-alive\r\n\r\n";
ESP8266.print("AT+CIPSEND=");
ESP8266.println(cmd.length());
if (ESP8266.find(">"))
{
Serial.print(">");
}
else
{
ESP8266.println("AT+CIPCLOSE");
Serial.println("connected timeout");
delay (1000);
return;
}
ESP8266.print(cmd);
delay(350);
while(ESP8266.available())
{
char c = ESP8266.read();
Serial.print(c);
}
}
void loop()
{
}
result in the serial monitor:
AT+CIPSTART="TCP","192.168.1.8",8095
>
Recv 114 bytes
SEND OK
+IPD,203:HTTP/1.1 200 OK
Conte
In fact, only reads the word "Conte", cut the headline does not mention the content.
How to read the entire contents?