-
Notifications
You must be signed in to change notification settings - Fork 7.6k
WiFiGeneric: add fallback Network‑event typedefs (ESP32‑C6 fix) #11266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
// COMPATIBILITY SHIM for ESP32‑C6 / Arduino‑Core v3.x // If the NetworkEvent typedefs are not visible at this point, // provide minimal stand‑ins so the compilation succeeds.
👋 Hello OneNeutrino, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
@OneNeutrino Why not just change the include order ? Can you give an example where this might be an issue ? |
|
Please provide minimal example sketch to demonstrate the issue you are trying to fix |
|
|
@me-no-dev, |
@OneNeutrino given that you now use pioarduino and latest cores, can you still encounter an error? If so, can you provide a new example so we can also reproduce it? |
@me-no-dev I switched the platform in my [env:esp32c6]
# platform = espressif32@6.10.0
# platform_packages =
# framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.17
platform = pioarduino
board = esp32-c6-devkitc-1
board_build.flash_mode = dio
upload_speed = 921600
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
build_flags =
-DARDUINO_USB_CDC_ON_BOOT=1
-D MQTT_MAX_PACKET_SIZE=1024
-D MQTT_MAX_TRANSFER_SIZE=1024
-DASYNC_TCP_SSL_ENABLED=0
-D LOG_LEVEL=DEBUG
-D MQTT_DISABLE_ENCRYPTION
-D ESP32
lib_deps =
https://github.com/ESPresense/ESPAsyncWebServer.git
https://github.com/ESPresense/qrcode.git
ESP Async WebServer
PubSubClient
ArduinoJson
Preferences
Update
build_type = debug Unfortunately, the build still fails with the same type of compilation errors as when using the standard In file included from C:/Users/Stark/.platformio/packages/framework-arduinoespressif32@src-6738aaddd9fb901216d5f60e093380b6/libraries/WiFi/src/WiFiGeneric.h:33,
from C:/Users/Stark/.platformio/packages/framework-arduinoespressif32@src-6738aaddd9fb901216d5f60e093380b6/libraries/WiFi/src/WiFiSTA.h:28,
from C:/Users/Stark/.platformio/packages/framework-arduinoespressif32@src-6738aaddd9fb901216d5f60e093380b6/libraries/WiFi/src/WiFi.h:32,
from lib/ESPAsyncWebServer/src/ESPAsyncWebServer.h:40,
from lib/ESPAsyncWebServer/src/AsyncWebSocket.h:32,
from lib/ESPAsyncWebServer/src/AsyncWebSocket.cpp:30:
C:/Users/Stark/.platformio/packages/framework-arduinoespressif32@src-6738aaddd9fb901216d5f60e093380b6/libraries/Ethernet/src/ETH.h:154:42: error: expected class-name before '{' token
154 | class EthernetNetworkInterface : public NetworkInterface {
| ^~~~~~~~~~~~~~~~
C:/Users/Stark/.platformio/packages/framework-arduinoespressif32@src-6738aaddd9fb901216d5f60e093380b6/libraries/Ethernet/src/ETH.h:254:3: error: 'network_event_handle_t' does not name a type; did you mean 'network_prov_event_handler_t'?
254 | network_event_handle_t _network_event_handle;
| ^~~~~~~~~~~~~~~~~~~~~~
| network_prov_event_handler_t ... and many similar errors related to networking classes and types in This confirms what others have found (e.g., in ESPresense Issue #1270: Support for ESP32-C6):
The project needs code-level updates to adapt to the Arduino Core v3 API changes before it can compile successfully for the ESP32-C6. For completeness, I also confirmed that forcing the standard It looks like the path forward requires code modifications within ESPresense to achieve Core v3 compatibility. Issue #1270 seems to be the main place tracking C6 support. |
@OneNeutrino it seems to me your |
@OneNeutrino Corrected
|
The issue you encounter is caused by the lib There is nothing which needs to be fixed. |
Working example with lib
and
|
Hi @Jason2866, Thanks for taking the time to look into this and provide suggestions. I've performed a detailed investigation based on your comments to understand why the build was failing for the ESP32-C6 environment and to test your proposed solutions. Here's a breakdown of the steps I took and the results: Test 1: Using Your Recommended
|
@OneNeutrino Your Platformio setup is broken. See https://github.com/Jason2866/test-pio-setup-esp32/tree/issue_11266 which compiles successfully https://github.com/Jason2866/test-pio-setup-esp32/actions/runs/14600142625 Forget the Esprecence project with Arduino Core 3.x.x. It needs a lot of Updates. |
@Jason2866 It appears to me you're dismissing this issue too easily. I've tested your exact suggestion by implementing a new test environment in my platformio.ini that uses:
Here's the exact configuration I added: [env:esp32c6_jason_test]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20/platform-espressif32.zip
framework = arduino
board = esp32-c6-devkitc-1
lib_ldf_mode = chain
lib_compat_mode = strict
upload_speed = 921600
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
build_flags =
${common.build_flags}
lib_deps =
https://github.com/me-no-dev/AsyncTCP.git
https://github.com/ESP32Async/ESPAsyncWebServer/archive/refs/tags/v3.7.7.zip
https://github.com/ESPresense/HeadlessWiFiSettings.git#v1.1.7
https://github.com/ESPresense/NimBLE-Arduino.git
marvinroger/AsyncMqttClient@^0.9.0
bblanchon/ArduinoJson@^6.21.3
kitesurfer1404/WS2812FX@^1.4.2
board_build.partitions = partitions_singleapp.csv
extra_scripts = update_ts.py Result: The build still failed with the exact same core error messages as before: C:/Users/Stark/.platformio/packages/framework-arduinoespressif32@src-6738aaddd9fb901216d5f60e093380b6/libraries/Ethernet/src/ETH.h:154:42: error: expected class-name before '{' token
154 | class ETHClass : public NetworkInterface {
| ^
C:/Users/Stark/.platformio/packages/framework-arduinoespressif32@src-6738aaddd9fb901216d5f60e093380b6/libraries/WiFi/src/WiFiSTA.h:45:42: error: expected class-name before '{' token
45 | class STAClass : public NetworkInterface {
| ^ After reviewing your test repository at https://github.com/Jason2866/test-pio-setup-esp32/tree/issue_11266, I think I understand the difference: your test code doesn't actually use the problematic code paths. Your test code simply includes the headers without using the classes in a meaningful way: #include <Arduino.h>
#include <AsyncTCP.h>
#include <WiFi.h>
#include <ESPAsyncWebServer.h>
//WiFiClass WiFi; // Use WiFi object - commented out
// Dummy handler
void WiFiEventHandler(arduino_event_id_t event) {
Serial.printf("[WiFi-event] event: %d\n", event);
}
void setup() {
Serial.begin(115200);
Serial.println("Minimal ESP32-C6 Network Event Type Test");
}
void loop() {
delay(1000);
} This minimal test doesn't reproduce the problem because:
The ESPresense project is much more complex and properly exercises these network classes, which is why it encounters the real-world header dependency issues addressed by this PR. I understand the complexity of supporting ESPresense with Arduino Core 3.x.x may involve other challenges, but this particular issue with network header dependencies is real and affects any non-trivial application using these components. Would it be possible to reconsider the PR based on this additional evidence? Or perhaps suggest a more comprehensive fix for the header dependency issues in the core? |
Update after further investigation: After digging deeper into both codebases, I understand better the scope of the challenge. The ESPresense project has a custom network implementation (
I can see why you suggested "Forget the ESPresence project with Arduino Core 3.x.x" - this is not a simple fix that can be addressed by a single PR. It would require substantial adaptation or refactoring of ESPresense's networking layer. My original PR focused on a specific issue that could help simpler projects that depend on the correct inclusion of networking-related headers when using both I appreciate your time and feedback on this issue. |
You hit the point. The major Arduino version increase from 2 to 3 is there for a reason. About ESPresense everything in this universe is outdated and not maintained. Not a good idea to try to use modern espressif MCU like the C6 with any of the stuff there. |
https://github.com/search?q=repo%3AESPresense%2FESPresense+Network.&type=code Actually not that much to rename in the project to be compatible with Core3 |
Still it uses old |
Description
ESP32-C6 builds using Arduino Core v3.x can fail when
WiFiGeneric.h
is included beforeNetworkEvents.h
(e.g., ifWiFi.h
is included directly withoutNetwork.h
orETH.h
first). This leaves network event types likeNetworkEventCb
andarduino_event_id_t
undefined. Projects like ESPresense can encounter this scenario.This patch adds minimal, compatible fallback typedefs directly within
<WiFiGeneric.h>
, guarded by#if ESP_ARDUINO_VERSION_MAJOR >= 3
. These fallbacks ensure the types have some definition known to the preprocessor when the#define
aliases (like#define WiFiEventCb NetworkEventCb
) are encountered, regardless of whether<NetworkEvents.h>
was included first.This prevents the "not declared" errors and ensures wider compatibility for projects compiling against Core v3.x, especially on newer targets like the C6, with no effect on other chips/cores where
<NetworkEvents.h>
is included normally.Additional Context (PlatformIO Users)
Based on feedback from @me-no-dev, it's important to note that the Arduino-ESP32 core team no longer officially supports the standard PlatformIO
espressif32
platform package.Users encountering general build failures (like
"Error: This board doesn't support arduino framework!"
) when trying to use Arduino Core v3.x with PlatformIO, especially for newer chips (C6, S3, C3, etc.), are advised to switch to the community-maintainedpioarduino
platform package: https://github.com/pioarduino/platform-espressif32This specific PR addresses the typedef issue within the Arduino core files themselves, which is relevant regardless of the PlatformIO platform used, but the
pioarduino
package is the recommended way to use the latest Arduino cores within the PlatformIO ecosystem.