Thanks @kuriko for your reply!
With this informations I tried with this pins without success :
#define INT_GPIO 35
#define MOSI_GPIO 23
#define MISO_GPIO 38
#define SCK_GPIO 18
#define CS_GPIO 33
I think there must be weird things happening in the SPI initialization with M5.begin() and all that, in any case this code doesn't work:
#include <Arduino.h>
#include <M5Unified.h>
#include <M5Module_LAN.h>
#include <SPI.h>
#define _ASYNC_WEBSERVER_LOGLEVEL_ 2
M5Module_LAN LAN;
//////////////////////////////////////////////////////////
// Optional values to override default settings
// Don't change unless you know what you're doing
#define ETH_SPI_HOST SPI3_HOST
#define SPI_CLOCK_MHZ 25
// Must connect INT to GPIOxx or not working
#define INT_GPIO 35
#define MOSI_GPIO 23
#define MISO_GPIO 38
#define SCK_GPIO 18
#define CS_GPIO 33
//////////////////////////////////////////////////////////
#include <AsyncTCP.h>
#include <AsyncWebServer_ESP32_W5500.h>
AsyncWebServer server(80);
const char *PARAM_MESSAGE = "message";
void notFound(AsyncWebServerRequest *request)
{
request->send(404, "text/plain", "Not found");
}
void setup()
{
M5.begin();
Serial.begin(115200);
if (esp_netif_init() != ESP_OK)
{
Serial.println("main::setup(): Error: Unable to initialize network interface");
}
uint8_t cs_pin = 33;
uint8_t rst_pin = 0;
uint8_t int_pin = 35;
SPI.begin(SCK, MISO, MOSI, -1);
LAN.setResetPin(rst_pin);
LAN.reset();
LAN.init(cs_pin);
Serial.print(F("\nStart AsyncSimpleServer_ESP32_W5500 on "));
Serial.print(ARDUINO_BOARD);
Serial.print(F(" with "));
Serial.println(SHIELD_TYPE);
Serial.println(ASYNC_WEBSERVER_ESP32_W5500_VERSION);
Serial.println("Default SPI pinout:");
Serial.println("SPI_HOST:" + String(ETH_SPI_HOST));
Serial.println("MOSI:" + String(MOSI_GPIO));
Serial.println("MISO:" + String(MISO_GPIO));
Serial.println("SCK:" + String(SCK_GPIO));
Serial.println("CS:" + String(CS_GPIO));
Serial.println("INT:" + String(INT_GPIO));
Serial.println("SPI Clock (MHz):" + String(SPI_CLOCK_MHZ));
Serial.println("=========================");
///////////////////////////////////
// To be called before ETH.begin()
ESP32_W5500_onEvent();
// bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ,
// int SPI_HOST, uint8_t *W5500_Mac = W5500_Default_Mac);
// ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST );
Serial.print("Network::connectEthernet(): Connecting to Ethernet with DHCP ");
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
if (!Ethernet.begin(mac))
{
Serial.println("Network::connectEthernet(): DHCP failed, aborting");
}
EthernetLinkStatus linkStatus;
while ((linkStatus = Ethernet.linkStatus()) != LinkON)
{
Serial.print(".");
delay(100);
}
Serial.println(" ...Connection established!");
Serial.println("Network::connectEthernet(): IP address : " + LAN.localIP().toString());
Serial.println("Network::connectEthernet(): Subnet mask : " + LAN.subnetMask().toString());
Serial.println("Network::connectEthernet(): Gateway IP : " + LAN.gatewayIP().toString());
Serial.println("Network::connectEthernet(): DNS : " + LAN.dnsServerIP().toString());
ESP32_W5500_waitForConnect();
///////////////////////////////////
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
{ request->send(200, "text/plain", "Hello, world from AsyncSimpleServer_ESP32_W5500"); });
// Send a GET request to <IP>/get?message=<message>
server.on("/get", HTTP_GET, [](AsyncWebServerRequest *request)
{
String message;
if (request->hasParam(PARAM_MESSAGE))
{
message = request->getParam(PARAM_MESSAGE)->value();
}
else
{
message = "No message sent";
}
request->send(200, "text/plain", "Hello, GET: " + message); });
// Send a POST request to <IP>/post with a form field message set to <message>
server.on("/post", HTTP_POST, [](AsyncWebServerRequest *request)
{
String message;
if (request->hasParam(PARAM_MESSAGE, true))
{
message = request->getParam(PARAM_MESSAGE, true)->value();
}
else
{
message = "No message sent";
}
request->send(200, "text/plain", "Hello, POST: " + message); });
server.onNotFound(notFound);
server.begin();
}
void loop()
{
delay(1000);
}