Skip to content

fixed NetworkInterface.h include for ESPHOME #78

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

Closed
wants to merge 1 commit into from

Conversation

Tysonpower
Copy link

I had issues in ESPHome because the newer arduino core is also based on ESP IDF 5.x.

Because of that it tries to find the NetworkInterface.h file in arduino core what is not possible.

This will not include the file if arduino is in use.

regards,
Manuel

@@ -10,7 +10,7 @@
#ifdef ARDUINO
#include <esp32-hal.h>
#include <esp32-hal-log.h>
#if (ESP_IDF_VERSION_MAJOR >= 5)
#if (ESP_IDF_VERSION_MAJOR >= 5) && !defined(ARDUINO)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is part of Arduino so your comparison is wrong. All ESP32 Arduino based on IDF5 has this file

Copy link
Author

@Tysonpower Tysonpower Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you are right, is the header file really needed?

I use ESPHome and compiling fails because of the lib, even if i only add the lib without anything that uses it.
Below is the log, it uses Arduino core 3.1.3 based on IDF 5.3.2.250210 internaly over pio, so the file should exist but it doesen't or can't be referenced.

Your lib is used in many ESPHome components like web server or wifi ap.

With my fix above it compiles just fine, so this is why i wonder if this file is needed.

INFO ESPHome 2025.7.1
INFO Reading configuration /config/esphome/hcp-test.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing test (board: adafruit_feather_esp32s3; framework: arduino; platform: https://github.com/pioarduino/platform-espressif32/releases/download/53.03.13/platform-espressif32.zip)
--------------------------------------------------------------------------------
Library Manager: Installing ESP32Async/AsyncTCP
INFO Installing ESP32Async/AsyncTCP
Unpacking  [####################################]  100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
HARDWARE: ESP32S3 240MHz, 320KB RAM, 4MB Flash
 - framework-arduinoespressif32 @ 3.1.3 
 - framework-arduinoespressif32-libs @ 5.3.0+sha.489d7a2b3a 
 - tool-esptoolpy @ 4.8.6 
 - tool-mklittlefs @ 3.2.0 
 - tool-riscv32-esp-elf-gdb @ 14.2.0+20240403 
 - tool-xtensa-esp-elf-gdb @ 14.2.0+20240403 
 - toolchain-riscv32-esp @ 13.2.0+20240530 
 - toolchain-xtensa-esp-elf @ 13.2.0+20240530
Dependency Graph
|-- AsyncTCP @ 3.4.5
Compiling .pioenvs/test/FrameworkArduinoVariant/variant.cpp.o
Compiling .pioenvs/test/src/esphome/components/esp32/core.cpp.o
Compiling .pioenvs/test/src/esphome/components/esp32/gpio.cpp.o
Compiling .pioenvs/test/src/esphome/components/esp32/helpers.cpp.o
Compiling .pioenvs/test/src/esphome/components/esp32/preferences.cpp.o
Compiling .pioenvs/test/src/esphome/core/application.cpp.o
Compiling .pioenvs/test/src/esphome/core/color.cpp.o
Compiling .pioenvs/test/src/esphome/core/component.cpp.o
Compiling .pioenvs/test/src/esphome/core/component_iterator.cpp.o
Compiling .pioenvs/test/src/esphome/core/controller.cpp.o
Compiling .pioenvs/test/src/esphome/core/entity_base.cpp.o
Compiling .pioenvs/test/src/esphome/core/helpers.cpp.o
Compiling .pioenvs/test/src/esphome/core/log.cpp.o
Compiling .pioenvs/test/src/esphome/core/ring_buffer.cpp.o
Compiling .pioenvs/test/src/esphome/core/scheduler.cpp.o
Compiling .pioenvs/test/src/esphome/core/string_ref.cpp.o
Compiling .pioenvs/test/src/esphome/core/time.cpp.o
Compiling .pioenvs/test/src/esphome/core/util.cpp.o
Compiling .pioenvs/test/src/main.cpp.o
Building .pioenvs/test/bootloader.bin
Generating partitions .pioenvs/test/partitions.bin
Creating esp32s3 image...
Successfully created esp32s3 image.
Compiling .pioenvs/test/lib562/AsyncTCP/AsyncTCP.cpp.o
Compiling .pioenvs/test/FrameworkArduino/ColorFormat.c.o
.piolibdeps/test/AsyncTCP/src/AsyncTCP.cpp:14:10: fatal error: NetworkInterface.h: No such file or directory

**************************************************************************
* Looking for NetworkInterface.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:NetworkInterface.h"
* Web  > https://registry.platformio.org/search?q=header:NetworkInterface.h
*
**************************************************************************

   14 | #include <NetworkInterface.h>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
Compiling .pioenvs/test/FrameworkArduino/Esp.cpp.o
*** [.pioenvs/test/lib562/AsyncTCP/AsyncTCP.cpp.o] Error 1
========================= [FAILED] Took 61.36 seconds =========================

yaml file:

esphome:
  name: "test"
  platformio_options:
    board_build.f_cpu: 240000000L
    board_build.flash_mode: qio
    monitor_speed: 9600
    monitor_filters: esp32_exception_decoder
    lib_ldf_mode: deep+
    # board_build.f_flash: 40000000L
    lib_deps:
      - ESP32Async/AsyncTCP

esp32:
  board: adafruit_feather_esp32s3
  framework:
    type: arduino

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can not say why it is failing for you, but you should look into that reason instead of removing the requirement here. All versions of Arduino that are 3+ have this file and should be includable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not failing only for me but for multiple people that use ESPHome see issue in my repo below.

I will open an issue in esphome and further investigate, with my suggested fix it does build.

Tysonpower/HCPBridgeMqtt_tynet#25

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a compilation issue in ESPHome by preventing the inclusion of NetworkInterface.h when Arduino is being used, even with ESP-IDF version 5.x or higher. The change addresses a conflict where newer Arduino cores based on ESP-IDF 5.x would attempt to include a header file that doesn't exist in the Arduino environment.

  • Modified the conditional compilation directive to exclude NetworkInterface.h inclusion when Arduino is defined

@@ -10,7 +10,7 @@
#ifdef ARDUINO
#include <esp32-hal.h>
#include <esp32-hal-log.h>
Copy link
Preview

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional logic is becoming complex. Consider adding a comment explaining why NetworkInterface.h should not be included in Arduino environments with ESP-IDF 5.x to help future maintainers understand this specific exclusion.

Suggested change
#include <esp32-hal-log.h>
#include <esp32-hal-log.h>
// Exclude <NetworkInterface.h> in Arduino environments with ESP-IDF 5.x due to compatibility issues.

Copilot uses AI. Check for mistakes.

@mathieucarbou mathieucarbou marked this pull request as draft July 18, 2025 15:11
@Tysonpower
Copy link
Author

found the issue, ESPHome has a platformio flag called lib_ldf_mode: deep+ that seems to make strange stuff with the current IDF version.

@Tysonpower Tysonpower closed this Jul 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants