HTTP server on ESP32-P4-ETH over Ethernet

I’ve previously written code to use an ESP32 board as a simple HTTP POST server which works fine except for the unreliability of WiFi, so I’ve bought an ESP32-P4-ETH with an onboard Ethernet phy.

Using examples, I can get this to connect to my network and respond to ping etc., but can’t figure out how to get it to hear and respond to a POST message.

The working code from the Wifi board is shown below. I’ve stripped out all of the stuff which I don’t think is needed to help me with my problem;

Any help greatly appreciated.

#include <WiFi.h>

WiFiServer Server(80);

void loopHTTP()
{
  char postMsg[128] = "";
  int i=0;
  WiFiClient loxListen = Server.available();
  if (loxListen) 
  {
    boolean currentLineIsBlank = true;
    while (loxListen.connected()) 
    {
      while(loxListen.available()) 
      {
        
        char c = loxListen.read();
        if (c == '\n' && currentLineIsBlank) 
        {
          while(loxListen.available())
            postMsg[i++] = loxListen.read();
          ProcessReceivedMessage(); //Process the received message
          loxListen.println("HTTP/1.0 200 OK");
          loxListen.println("Content-Type: text/html");
          loxListen.println();
          loxListen.println("<HTML><BODY>OK</BODY></HTML>");
          loxListen.stop();
        }
        else if (c == '\n')
          currentLineIsBlank = true;
        else if (c != '\r') 
          currentLineIsBlank = false;
      }
    }
  }
}

void setup() 
{
  WiFi.begin("myssid", "mypassword");
  Server.begin();
}
  
void loop() 
{
  loopHTTP();
  delay(100);
}


Juraj, thanks for the reply. That has got me up and running. I had to change ethernet phy pins in EMACDriver.h line 43 to

EMACDriver(EthPhyType phyType, int mdcPin = 31, int mdioPin = 52, int powerPin = 51, emac_rmii_clock_gpio_t clockPin = 50, emac_rmii_clock_mode_t clockMode = EMAC_CLK_EXT_IN);

and make a few changes to HelloServer.ino but got there quite quickly.

I can post my working example if anyone would like it.

Thanks again

those are default values for the parameters. don't change them.
supply your settings in the sketch as constructor parameters