ESP32 with Ethernet and MQTT [SOLVED]

SOLVED For those who come after me…

WiFiClient espClient;
PubSubClient mqttClient(espClient);

ORIGINAL QUESTION
I got my hands on an Olimex ESP32-EVB board with ethernet. Fantastic board. I’m just having a bit of a hard time understanding the ethernet library.

When I connect to the pubsubclient with ESP32/ESP8266 wifi, I will do something like this towards the top of the sketch…

WiFiClient ethClient;
PubSubClient client(ethClient);

If I’m using something like a 5100 shield on an uno/mega (which uses <Ethernet.h>), I would do

EthernetClient ethClient;
PubSubClient client(ethClient);

However, the ESP32 uses <ETH.h> and I cannot for the life of me figure out how to define that client so I can use it with the pubsubclient. I see examples like

ETH.setHostname("esp32-ethernet");

or

WiFiClient client;  //which still seems to refer to ethernet in this context

(See example sketch https://github.com/OLIMEX/ESP32-POE/blob/master/SOFTWARE/ARDUINO/ESP32_PoE_Ethernet_Arduino/ESP32_PoE_Ethernet_Arduino.ino)

However anytime I use something like WiFiClient client; with ETH.h, it freaks out if I’m using it outside of a function.

Can someone point me in the right direction. Obviously I’m over my head on this one. Thanks in advance.

As the Olimex board uses the LAN8710A PHY you should be able to use the ETH_LAN8720.ino example that comes with the ESP32 WiFi library.

pylon:
As the Olimex board uses the LAN8710A PHY you should be able to use the ETH_LAN8720.ino example that comes with the ESP32 WiFi library.

I did look at that and I don't have any problem connecting it to the internet, it just didn't work with MQTT. I do have an answer that I'll post.

pylon:
As the Olimex board uses the LAN8710A PHY you should be able to use the ETH_LAN8720.ino example that comes with the ESP32 WiFi library.

Thanks for responding though. This one had me stumped.