ESP8266 + ENC28j60 + EthernetWebServer

Hello everyone!
I’m currently developing an application that requires a ESP8266 to be connected to the Ethernet and Wifi simultaneously.

I’ve installed Khoi Huan’s library (GitHub - khoih-prog/EthernetWebServer: This is simple yet complete WebServer library for AVR, Teensy, SAM DUE, SAMD21/SAMD51, nRF52, STM32, etc. boards running Ethernet shields. The functions are similar and compatible to ESP8266/ESP32 WebServer libraries to make life much easier to port sketches from ESP8266/ESP32.) and it works (kindof).

I’m able to connect my ENC28j60 shield and make a webserver work, so far so good, but the project does not build when adding Wifi simultaneously.

Theses and many other errors occur:

EthernetWebServer.h:83:6: error: multiple definition of 'enum HTTPMethod'
 enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };

There are some obvious clashes and re-definitions that prevent the build.

Does anyone know a fix for this issue?

Extra question: The EthernetWebServer stuff only works when included directly into main file. When i move this:

#warning Use ESP8266 architecture
#define ETHERNET_USE_ESP8266
#define BOARD_TYPE      "ESP8266"
#include <SPI.h>
#define USE_UIP_ETHERNET   true
#include <EthernetWebServer.h>

to a different class, it crashes.

Any ideia why the library only builds when in the main file?

Thank all in advanced!

try a different way. esp8266 arduino core experimental version has a library which works with ESP8266WebServer library.
you initialize the library and then you use network access the same way as over WiFi.

Thanks man but unfortunately same result.

This commit has basically the same WebServer files. What’s happening is:

The EthernetWebServer in:
/EthernetWebServer-master/src/EthernetWebServer.h → Has an Enum ‘enum HTTPMethod’

The WebServer from ESP8266 core (from the last commit from the pull request you sent) in:
<user Library packages esp … 2.6.3/libraries>/ESP8266WebServer/src/ESP8266WebServer.h → Has an Enum ‘enum HTTPMethod’

Previous definition, won’t compile.

remove EthernetWebServer use ESP8266WebServer with lwIP_enc28j60 library

But how's that gonna help me?

If I remove ESP8266WebServer the EthernetWebServer works

If I remove the EthernetWebServer the ESP8266WebServer works.

Is either wifi OR ethernet, but I need to use both libs at the same time.

tiagorosolen:
But how’s that gonna help me?

If I remove ESP8266WebServer the EthernetWebServer works

If I remove the EthernetWebServer the ESP8266WebServer works.

Is either wifi OR ethernet, but I need to use both libs at the same time.

with lwIP_enc28j60 you will use ESP8266WebServer for both or all 3 network interfaces. the lwIP_enc28j60 library will add a network interface on TCP/IP stack level. then you can use 3 network interfaces instead of the usual two (SoftAP and STA).