#include <Adafruit_ssd1306syp.h>
#define SDA_PIN A4
#define SCL_PIN A5
int led = 13;
Adafruit_ssd1306syp display(SDA_PIN, SCL_PIN);
void setup()
{
display.initialize();
display.clear();
display.setCursor(0, 0);
display.println("Connect TX..");
display.update();
pinMode(led, OUTPUT);
delay(5000);
Serial.begin(115200);
// Set up Wifi
Serial.println("AT");
delay(800);
if (Serial.find("OK")) {
display.println("WIFI Ok:");
display.update();
Serial.println("AT+CIFSR");
delay(800);
display.println(Serial.readString());
display.update();
delay(2000);
display.clear();
display.update();
} else {
display.println("WIFI Failed to initialize");
}
}
void loop()
{
Serial.println("AT+CIPMUX=1");
delay(300);
getResponse();
Serial.println("AT+CIPSTART=4,\"TCP\",\"192.168.1.250\",8081");
delay(2000);
getResponse();
Serial.println("AT+CIPSEND=4,400");
delay(2000);
getResponse();
String data;
data = "GET /index.html HTTP/1.1\r\n";
data += "Host: 192.168.1.250 \r\n";
data += "Content-Length: 400 \r\n";
data += "content-type:application/x-www-form-urlencoded;charset=utf-8\r\n";
Serial.println(data);
delay (2000);
getResponse();
delay (2000);
Serial.println("AT+CIPCLOSE=4");
getResponse();
delay(5000);
display.setCursor(0, 0);
}
void getResponse() {
display.clear();
display.update();
display.setCursor(0, 0);
display.println(Serial.readString());
display.update();
Serial.flush();
}
+IPD,4,422
However, I am getting 400 Bad Request. Here is my request string:
String data;
data = "GET /index.html HTTP/1.1\r\n\r\n";
data += "Host: 192.168.1.250 \r\n";
data += "Content-Length: 400 \r\n";
data += "content-type:application/x-www-form-urlencoded;charset=utf-8\r\n";
Serial.println(data);
Thanks for the help
String data;
data = "GET /index.html HTTP/1.0\r\n\r\n";
data += "Host: 192.168.1.250 \r\n";
data += "Content-Length: 150 \r\n";
data += "Content-Type:application/x-www-form-urlencoded;charset=utf-8\r\n";
Serial.println(data);
Thanks again!