I'm using PlatformIO IDE to program a WeMos D1 Mini ESP32.
My goal is for the ESP32 to be able to send/receive UDP packets via ethernet, but I also need to be able to update the firmware with a web updater OTA. I was able to achieve this while using Wi-Fi, but not while using ethernet.
Here is my code:
Code: Select all
/*
Rui Santos
Complete project details
- Arduino IDE: https://RandomNerdTutorials.com/esp32-ota-over-the-air-arduino/
- VS Code: https://RandomNerdTutorials.com/esp32-ota-over-the-air-vs-code/
This sketch shows a Basic example from the AsyncElegantOTA library: ESP32_Async_Demo
https://github.com/ayushsharma82/AsyncElegantOTA
*/
#define LISTEN_PORT 4004
#include <Arduino.h>
#include <ESPAsyncWebServer.h>
#include <AsyncElegantOTA.h>
#include <AsyncUDP.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
uint8_t eth_MAC[] = { 0x02, 0xF0, 0x0D, 0xBE, 0xEF, 0x01 };
IPAddress myIP(192, 168, 167, 101);
IPAddress myGW(192, 168, 167, 1);
IPAddress mySN(255, 255, 255, 0);
IPAddress myDNS(8, 8, 8, 8);
EthernetUDP Udp;
AsyncWebServer server(80);
void setup(void) {
Serial.begin(115200);
Ethernet.init(5);
Serial.println("Starting ETHERNET connection...");
Ethernet.begin(eth_MAC, myIP, myDNS, myGW, mySN);
delay(200);
Serial.print("Ethernet IP is: ");
Serial.println(Ethernet.localIP());
Serial.print("Local port is: ");
Serial.println(LISTEN_PORT);
Udp.begin(LISTEN_PORT);
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(200, "text/plain", "Hi! I am ESP32.");
});
AsyncElegantOTA.begin(&server); // Start ElegantOTA
Serial.println("I'm about to crash!");
server.begin();
Serial.println("HTTP server started");
}
void loop(void) {
}
Here is what the serial monitor shows when I run the program:
Code: Select all
Starting ETHERNET connection...
Ethernet IP is: 192.168.167.101
Local port is: 4004
I'm about to crash!
assertion "Invalid mbox" failed: file "/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/api/tcpip.c", line 416, function: tcpip_api_call
abort() was called at PC 0x400e3a0b on core 1
ELF file SHA256: 0000000000000000
Backtrace: 0x400852a4:0x3ffb1e30 0x40085521:0x3ffb1e50 0x400e3a0b:0x3ffb1e70 0x4011f063:0x3ffb1ea0 0x4011485c:0x3ffb1ed0 0x400d6966:0x3ffb1f20 0x400d224e:0x3ffb1f40 0x400e1686:0x3ffb1fb0 0x40086532:0x3ffb1fd0
Rebooting...