Keep getting this "error: 'class ESP8266WebServer' has no member named 'available'
WiFiClient client = server.available();
^
exit status 1
'class ESP8266WebServer' has no member named 'available' "
When i try to compile this code, tryed to remove all lib and reinstall them no luck, tryed to use the staging board manager to.
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <ArduinoOTA.h>
#include <ESP8266WebServer.h>
const char* ssid = "........";
const char* password = "........";
ESP8266WebServer server(80);
const char* www_username = "admin";
const char* www_password = "esp8266";
int ledPin = D7;
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
digitalWrite(D7, LOW);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
if(WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("WiFi Connect Failed! Rebooting...");
delay(1000);
ESP.restart();
}
ArduinoOTA.begin();
server.on("/", [](){
if(!server.authenticate(www_username, www_password))
return server.requestAuthentication();
server.send(200, "text/plain", "Login OK");
});
server.begin();
Serial.print("Open http://");
Serial.print(WiFi.localIP());
Serial.println("/ in your browser to see it working");
}
void loop() {
ArduinoOTA.handle();
server.handleClient();
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
while (!client.available()) {
delay(1);
}
// Read the first line of the request
String req = client.readStringUntil('\r');
client.flush();
// Match the request
if (req.indexOf("") != -10) { //checks if you're on the main page
if (req.indexOf("/OFF") != -1) { //checks if you clicked OFF
digitalWrite(ledPin, LOW);
Serial.println("You clicked OFF");
}
if (req.indexOf("/ON") != -1) { //checks if you clicked ON
digitalWrite(ledPin, HIGH);
Serial.println("You clicked ON");
}
}
else {
Serial.println("invalid request");
client.stop();
return;
}
// Prepare the response
String s = "HTTP/1.1 200 OK\r\n";
s += "Content-Type: text/html\r\n\r\n";
s += "<!DOCTYPE HTML>\r\n<html>\r\n";
s += "
<input type=\"button\" name=\"bl\" value=\"Turn LED ON \" onclick=\"location.href='/ON'\">";
s += "
";
s += "
<input type=\"button\" name=\"bl\" value=\"Turn LED OFF\" onclick=\"location.href='/OFF'\">";
s += "</html>\n";
client.flush();
// Send the response to the client
client.print(s);
delay(1);
}