I am trying to open load a webpage from ESP8266 that displays temperature and humidity of my room if I only type root URL:192.168.1.89
GET / HTTP/1.1
Host: 192.168.1.89
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Safari/602.1.50
Accept-Language: en-us
DNT: 1
Accept-Encoding: gzip, deflate
to do that in my esp8266 sketch I am trying this logic:
bool readRequest(WiFiClient& client) {
bool currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (c == "GET / HTTP/1.1"){
Serial.println("Got root");
client.println(handleRoot()); // where handle root contains web page
}
else{
Serial.println("Did not got root.");
}
if (c == '\n' && currentLineIsBlank) {
return true;
} else if (c == '\n') {
currentLineIsBlank = true;
} else if (c != '\r') {
currentLineIsBlank = false;
}
}
}
return false;
}
but the condition to check if it met GET / HTTP/1.1
never validates.
asked Nov 23, 2017 at 14:47
c
is a char. You can't compare a char to a string. Andc == "GET...
is not how you compare string in C, anyway.ESP8266WebServer
but I want ed to give a try toWiFiServer server(80);
while sticking withArduinoJson.h
library as well.ESP8266WebServer.h
however I cannot passArduinoJson.h
's jsonObject toserver.send(...)
arduino.stackexchange.com/q/46961/27363