-->
Page 1 of 1

ESP8266 WiFiClient/Webserver error

PostPosted: Mon Dec 25, 2017 10:09 am
by dilipk
Hello everyone, I need someone to help me fix this error. This is my first post here, so let me know if I missed anything while posting here. I get this string of errors while running the basic Hello Web Server example off of ESP8266WebServer library.

Arduino version - 1.8.5
ESP board manager URL - http://arduino.esp8266.com/stable/packa ... index.json

Error:

In file included from /Users/user1/Documents/Arduino/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp:27:0:
/Users/user1/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi/src/WiFiClient.h: In instantiation of 'size_t WiFiClient::write(T&, size_t) [with T = char*; size_t = unsigned int]':
/Users/user1/Documents/Arduino/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp:334:56: required from here
/Users/user1/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi/src/WiFiClient.h:123:36: error: request for member 'available' in 'source', which is of non-class type 'char*'
size_t left = source.available();
^
/Users/user1/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi/src/WiFiClient.h:127:5: error: request for member 'read' in 'source', which is of non-class type 'char*'
source.read(buffer.get(), will_send);
^
/Users/user1/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi/src/WiFiClient.h: In instantiation of 'size_t WiFiClient::write(T&, size_t) [with T = unsigned char [1460]; size_t = unsigned int]':
/Users/user1/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi/src/WiFiClient.h:84:55: required from 'size_t WiFiClient::write(T&) [with T = fs::File; size_t = unsigned int]'
/Users/user1/Documents/Arduino/libraries/ESP8266WebServer/src/ESP8266WebServer.h:133:35: required from 'size_t ESP8266WebServer::streamFile(T&, const String&) [with T = fs::File; size_t = unsigned int]'
/Users/user1/Documents/Arduino/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h:114:41: required from here
/Users/user1/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi/src/WiFiClient.h:123:36: error: request for member 'available' in 'source', which is of non-class type 'unsigned char [1460]'
size_t left = source.available();
^
/Users/user1/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi/src/WiFiClient.h:127:5: error: request for member 'read' in 'source', which is of non-class type 'unsigned char [1460]'
source.read(buffer.get(), will_send);
^
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).


Code: Select all#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

const char* ssid = "SSID-name";
const char* password = "xxxxxxxx";

ESP8266WebServer server(80);

const int led = 13;

void handleRoot() {
  digitalWrite(led, 1);
  server.send(200, "text/plain", "hello from esp8266!");
  digitalWrite(led, 0);
}

void handleNotFound(){
  digitalWrite(led, 1);
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i=0; i<server.args(); i++){
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
  digitalWrite(led, 0);
}

void setup(void){
  pinMode(led, OUTPUT);
  digitalWrite(led, 0);
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  if (MDNS.begin("esp8266")) {
    Serial.println("MDNS responder started");
  }

  server.on("/", handleRoot);

  server.on("/inline", [](){
    server.send(200, "text/plain", "this works as well");
  });

  server.onNotFound(handleNotFound);

  server.begin();
  Serial.println("HTTP server started");
}

void loop(void){
  server.handleClient();
}