-->
Page 1 of 1

ESP8266 on Arduino IDE Error using ESP8266WiFi.h library

PostPosted: Tue Jul 11, 2017 12:01 pm
by Marty
Trying to get one ESP8266 to send data to another ESP8266 over WiFi. As a template, I started with the github ESP8266/Arduino example: WiFiWebServer.ino.

Worked fine using my home network. However, I wanted the server ESP8266 to be an access point, so I included the ESP8266WebServer.h library.

Once I did that I got an error 'class ESP8266WebServer' has no member named 'available' on the line WiFiClient client = server.available();. It seems it is accessing the wrong library, ESP8266WebServer, instead of ESP8266WiFi.h. I have included the code here stripped down to the essentials:

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

ESP8266WebServer server(50009);

const char *ssid = "SomeSSID";
const char *password = "SomePassword";

void setup() { 
  WiFi.softAP(ssid, password);
  WiFi.mode(WIFI_AP); 
  server.begin();
}

void loop() {
  //listen for incoming server
  WiFiClient client = server.available();
  if (!client){
    return;
  }
  //do something here

  //close connection
  client.stop();
}


Any help will be appreciated. Thanks.

Re: ESP8266 on Arduino IDE Error using ESP8266WiFi.h library

PostPosted: Tue Jul 11, 2017 3:19 pm
by martinayotte
The ESP8266 as nothing related to AP, it is simply a web server that could used either under AP or STA.
Look at this example how to provide web page handling :
https://github.com/esp8266/Arduino/blob ... Server.ino

The available() function is only in WiFi class, therefore the WebServer library is using it directly :
https://github.com/esp8266/Arduino/blob ... r.cpp#L168

In other words, the ESP8266WebServer sit on top of ESP8266WiFi, it doesn't replace it.