PaulStoffregen / Ethernet

Ethernet library for Teensy (Wiznet W5100 / W5200 / W5500)
http://www.pjrc.com/teensy/td_libs_Ethernet.html
130 stars 83 forks source link

ESP32 + W5500 + WiFi does not work #42

Closed mzanettin closed 4 years ago

mzanettin commented 4 years ago

Hi,

I'm using the ethernet library with ESP32 + W5500, but I'm facing a problem when we try to compile (using the WebServer.ino - Library sample code).

Error:


WebServer:33:16: error: cannot declare variable 'server' to be of abstract type 'EthernetServer'

EthernetServer server(80);

            ^

In file included from C:\Users\PROJET~1\AppData\Local\Temp\arduino_modified_sketch_80062\WebServer.ino:21:0:

C:\Users\Projetista01\Documents\Arduino\libraries\Ethernet\src/Ethernet.h:253:7: note: because the following virtual functions are pure within 'EthernetServer':

class EthernetServer : public Server {

   ^

In file included from C:\Users\Projetista01\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:152:0,

             from C:\Users\PROJET~1\AppData\Local\Temp\arduino_build_390745\sketch\WebServer.ino.cpp:1:

C:\Users\Projetista01\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Server.h:28:18: note: virtual void Server::begin(uint16_t)

 virtual void begin(uint16_t port=0) =0;

              ^

Using library SPI at version 1.0 in folder: C:\Users\Projetista01\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\SPI Using library Ethernet at version 2.0.0 in folder: C:\Users\Projetista01\Documents\Arduino\libraries\Ethernet exit status 1 cannot declare variable 'server' to be of abstract type 'EthernetServer'


I saw in other forum an option to change the line 28 in the "Server.h" file: "virtual void begin(uint16_t port=0) =0;" to " virtual void begin() =0;"

I change the "Server.h" file and it works.

Server.h


`#ifndef server_h

define server_h

include "Print.h"

class Server: public Print { public: //virtual void begin(uint16_t port=0) =0; virtual void begin() =0; };

endif`


With this "correction", if I try to compile an ESP32 WiFi sample like "SimpleWiFiServer" (ESP32 library) it raise the error:


SimpleWiFiServer:33:12: error: cannot declare variable 'server' to be of abstract type 'WiFiServer'

WiFiServer server(80);

        ^

In file included from C:\Users\Projetista01\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi\src/WiFi.h:38:0,

             from C:\Users\Projetista01\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi\examples\SimpleWiFiServer\SimpleWiFiServer.ino:28:

C:\Users\Projetista01\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi\src/WiFiServer.h:26:7: note: because the following virtual functions are pure within 'WiFiServer':

class WiFiServer : public Server {

   ^

In file included from C:\Users\Projetista01\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:152:0,

             from C:\Users\PROJET~1\AppData\Local\Temp\arduino_build_832535\sketch\SimpleWiFiServer.ino.cpp:1:

C:\Users\Projetista01\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Server.h:29:15: note: virtual void Server::begin()

virtual void begin() =0;

           ^

Multiple libraries were found for "WiFi.h" Used: C:\Users\Projetista01\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi Not used: C:\Program Files (x86)\Arduino\libraries\WiFi Using library WiFi at version 1.0 in folder: C:\Users\Projetista01\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi exit status 1 cannot declare variable 'server' to be of abstract type 'WiFiServer'


To put this code to work again I need change back the "Server.h" file, like you can see below:

Server.h


`#ifndef server_h

define server_h

include "Print.h"

class Server: public Print { public: virtual void begin(uint16_t port=0) =0; //virtual void begin() =0; };

endif`


Is there a way to compile to both (Ethernet + WiFi) without get error?

I need put to work Ethernet + WiFi in the same code.

Thank you.

PaulStoffregen commented 4 years ago

This is the wrong place for reporting any ESP32 problem.

Report it on ESP's issue tracker.