Compiling errors with WiFi.h

Hello,

i am using the WiFi.h library with ESP32S3 (Arduion IDE 2.2.1) to get the dynamic MAC-Address of the ESP32S3.
I need the MAC-Address to establish a communication through Ethernet.
I had no problem with that till yesterday.
Since that when i compile with the WiFi.h library i get a lot of error messages.
I will put some of them here:

C:\Users\user\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\WiFi\src/WiFiGeneric.h:44:25: error: 'network_event_handle_t' does not name a type; did you mean 'esp_event_handler_t'?
   44 | #define wifi_event_id_t network_event_handle_t
C:\Users\user\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\WiFi\src/WiFiGeneric.h:41:25: error: 'NetworkEventCb' has not been declared
   41 | #define WiFiEventCb     NetworkEventCb
C:\Users\user\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\WiFi\src/WiFiGeneric.h:80:41: error: 'arduino_event_id_t' has not been declared
   80 |   void removeEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
C:\Users\user\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\WiFi\src/WiFiGeneric.h:43:25: error: 'NetworkEventSysCb' has not been declared
   43 | #define WiFiEventSysCb  NetworkEventSysCb

And so on.
I changed the Additional Board manager URL that i have, it didn't help.
I searched on the net and found some threads having similar problem.
They suggest to delete the folder in this path:

C:\Users\user\Arduino\hardware\espressif\esp32\

and then add the URL (Stable release link) newly from the espressif site.
But i do not have such a path.

Any help is appreciated.

what Ethernet?

what exact ESP32-core-version do you use?
espressif made breaking changes from core-Version 2.0.16 to core-version 3.0

I think you should post the complete code that is giving you this problem.
The errors you reported point to code that is part of the core, so if the installation of the release v3.0.1 was done successfully, you should have no problems with these sources.

If in doubt, try to completely delete the C:\Users\user\AppData\Local\Arduino15\packages\esp32 folder and do a new core installation from scratch.

1 Like

Try rolling back your Board platform -- probably "esp32" -- from 3.0.1 to 2.0.17. Avoid major version upgrades in the middle of a project.

It's odd that the error is for this macro #define: "if you see this text, replace it with this other text". Why is that replacement text being evaluated here?

One of the changes in v3 is renaming WiFi stuff to Network stuff; e.g. WiFiClient is now NetworkClient. This name is accurately covers more kinds of networking. These macros are declaring substitutions from the old types to the new types, so that they work with existing code. Just above those lines is

#include "Network.h"

which can be found in /libraries/Network/src, and that file contains

#include "NetworkEvents.h"

which is in the same directory, and defines NetworkEventSysCb and the others. Usually if an included file is missing the compile will terminate on that, because there's really no point going further.

Thank you all for your replies.
@Juraj i am using W5500.
@StefanL38 core-Version 3.0.1
@cotestatnt i have tried that and deleted the completely folder, that didn't help.
@kenb4 i did what you have suggested but not the hole core, only the wifi library i downgraded to 1.2.5
Now i do not get those error messages.

The idea behind this is the following:
I want to retrive the dynamic MAC-Address when power is on and this save it to the falsh and use it with the Ethernet.
The problem is what if i do not have i WiFi nezwork, then how can i get the dynamic mac with the Ethernet?
I am using the "EthernetWebServer.h" which do need a mac-address at the beggining to connect.
Any ideas please.


#include "updatefirmware.h"
#include <EthernetWebServer.h>
#include <Arduino_JSON.h>
#include <cjson/cJSON.h>
#include "LittleFS.h"
#include <inttypes.h>
#include <WiFi.h>



#define SCK       12    //37
#define SS        10    //38
#define MOSI      11    //35
#define MISO      13    //36
#define SPI_FREQ  32000000   // Frequenz für Ethernet

led_info_type ledti4;

// MAC and IP address for the Ethernet communication
char baseMACchar[18] = {0};
byte wmac[6];
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 10, 225, 150);

extern network_settings_type nst;             // Instanz für Netzwerk
extern user_settings_type ust;                // Instanz für Benutzer

extern String htmlContent;
extern String globalUsername;                 // Variable zum Speichern vom aktiven Benutzer


void setup() {
  // put your setup code here, to run once:
  // Some sound that indicates the setup begins
  noTone(BUZZER_PIN);
  tone(BUZZER_PIN, 480, 150);   // Play a note for 150ms

  noTone(BUZZER_PIN);

  Serial.begin(9600);  // Nur für debug

  while (!Serial);                    // Wait till serial get ready

  // Setting SPI for Ethernet
  SPI.begin(SCK, MISO, MOSI, SS);
  SPI.setFrequency(SPI_FREQ);
  Ethernet.init(SS);
  
  delay(200);

  readIPAddress(&nst);      // Lesen der auf der Flash gespeicherten Netzwerk Parameters
  readSubnetMask(&nst);
  readGateway(&nst);
  readUsername(&ust);
  readPassword(&ust);

  delay(200);

  // Start the ethernet connection and the server:
  // Ethernet.begin(mac);
  // Ethernet.begin(mac, ip);
  Ethernet.begin(mac, nst.m_ethernetSettings.m_IpAddress);

  delay(200);
  
  if (Ethernet.hardwareStatus() == EthernetNoHardware)
  {
    Serial.println("No Ethernet Hardware!");
    while (true)
    {
      delay(1); // do nothing, no point running without Ethernet hardware
    }
  }

  if (Ethernet.linkStatus() == 2)
  {
    Serial.println("No Ethernet Cable!");
  }

  Serial.println();
  Serial.print("DHCP IP-Address: ");
  Serial.println(Ethernet.localIP()); 

  WiFi.macAddress(wmac);
  // esp_read_mac(wmac, ESP_MAC_ETH);
  // Ethernet.MACAddress(wmac);
  Serial.print("Dynamic retriven MAC-Address: ");
  for(int i = 0; i < 6; i++){
    if(wmac[i] < 16){
      Serial.print("0");
    }
    Serial.print(wmac[i], HEX);
    if(i < 5){
      Serial.print(":");
    }
  }
  Serial.println();

  if(!LittleFS.begin()){
    // Do something
    Serial.println("LittleFS has failed!");
  }
  else {
    // Do sometihng else
    Serial.println("LittleFS successfully worked!");
    delay(500);
  }

  
  // Start the ethernet server
  ethernetServer.on("/", HTTP_GET, handleUpdate);
  ethernetServer.on("/update", HTTP_POST, handlePostUpdate, handleFileUpload);   //update

  ethernetServer.begin();

  // Main user who controls every thing, can not be deleted or changed
  /*
  changeUsername(&ust, username_admin.c_str());
  changePassword(&ust, adminpassword.c_str());
  ust.userLevel = 1; 
  */

  displayIPAddress(nst);
  displaySubnetMask(nst);
  displayGateway(nst);

  displayUserSettings(ust);
  displayAllUsers();

// Some sound that indicates the setup is done
  noTone(BUZZER_PIN);
  tone(BUZZER_PIN, 280, 200);   // Play a note for 100ms

  noTone(BUZZER_PIN);
}

void loop() {
  ethernetServer.handleClient();
}

You're confusing it. The MAC address is a "hardware" code that uniquely identifies an ethernet device and you do not need to be online precisely because it is a property of the device itself.

You are using a W5500 shield, so basically you have to set MAC address via software and you can use whatever you like.
If you want to make sure you use an address that won't cause you problems, you might think about using the MAC address of the WiFi adapter already included in your ESP32 card, but it's just a refinement.

use my new EthernetESP32 library with the WebServer bundled with the esp32 platform. there is an example in the EthernetESP32 library.

@cotestatnt

Yes you have right, but i do not know how to read that unigue mac-address which is given to the esp32 from the manufacturers.

Using Espressif system API:

Using Arduino framework:

@cotestatnt

Thank you, that was helpfull.
Thank you all.

1 Like

did you see my comment?

Yes i did.
It is not so easy for me to replace the library i am using with a new one, but i will give it a try.
You may provide an example related to the issue here, please.
Thanks

with EthernetESP32 you don't have to provide the MAC address. it is set in the library

OK.
I want that the ESP32 keeps the unique MAC that it has gotten from the manufacturers.
I do not want to set any MACs, i just wanted to read the original one.
But i will try your library.

yes it reads and uses the ESP32 MAC as recommended by Espressif

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.