Skip to content

Commit

Permalink
ESP32: Prep for Arduino-esp32 v1.0.5 (#473)
Browse files Browse the repository at this point in the history
* Adjust the ESP-IDF version detection logic.

The original logic worked with ESP-IDF v3.2 and v4.0+ due to `ESP_IDF_VERSION_MAJOR` only being defined in v4.0+. With arduino-esp32 v1.0.5 picking up ESP-IDF v3.3 this is no longer working due to ESP-IDF v3.3 now defining this constant.

Shifting to use __has_include to switch between the new and old include paths with fallback to use old paths when __has_include is not usable (though it always should be with GCC). This will need to be revisited as part of the ESP-IDF v4.x rework that I have in progress since there are a few other breaking API changes starting with ESP-IDF v4.1.

* Update Esp32WiFiManager.cxx
  • Loading branch information
atanisoft authored Nov 25, 2020
1 parent 2e5358e commit d3f829c
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions src/freertos_drivers/esp32/Esp32WiFiManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,42 @@
#include <mdns.h>
#include <tcpip_adapter.h>

// ESP-IDF v4+ has a slightly different directory structure to previous
// versions.
#ifdef ESP_IDF_VERSION_MAJOR
// ESP-IDF v4+
// Starting in ESP-IDF v4.0 a few header files have been relocated so we need
// to adjust the include paths accordingly. If the __has_include preprocessor
// directive is defined we can use it to find the appropriate header files.
// If it is not usable then we will default the older header filenames.
#if defined(__has_include)

// rom/crc.h was relocated to esp32/rom/crc.h in ESP-IDF v4.0
// TODO: This will need to be platform specific in IDF v4.1 since this is
// exposed in unique header paths for each supported platform. Detecting the
// operating platform (ESP32, ESP32-S2, ESP32-S3, etc) can be done by checking
// for the presence of one of the following defines:
// CONFIG_IDF_TARGET_ESP32 -- ESP32
// CONFIG_IDF_TARGET_ESP32S2 -- ESP32-S2
// CONFIG_IDF_TARGET_ESP32S3 -- ESP32-S3
// If none of these are defined it means the ESP-IDF version is v4.0 or
// earlier.
#if __has_include("esp32/rom/crc.h")
#include <esp32/rom/crc.h>
#else
#include <rom/crc.h>
#endif

// esp_wifi_internal.h was relocated to esp_private/wifi.h in ESP-IDF v4.0
#if __has_include("esp_private/wifi.h")
#include <esp_private/wifi.h>
#else
// ESP-IDF v3.x
#include <esp_wifi_internal.h>
#endif

#else

// We are unable to use __has_include, default to the old include paths.
#include <esp_wifi_internal.h>
#include <rom/crc.h>
#endif // ESP_IDF_VERSION_MAJOR

#endif // defined __has_include

using openlcb::NodeID;
using openlcb::SimpleCanStack;
Expand Down

0 comments on commit d3f829c

Please sign in to comment.