Skip to content

Conversation

@gnalbandian
Copy link

Added preprocessor macros to detect and separate ESP-IDF vs Arduino.

I've done some minor code refactor to enable the use of the library without any dependency on behalf of Arduino framework, but keeping it functional with it if the user intends to make use of Arduino.

The NO use of the Arduino framework is basically done by the following macro. Maybe it could be done in some other way:

#if defined(ESP_PLATFORM) && (ESP_IDF_VERSION_MAJOR >= 5) && !defined(ARDUINO)
  #define USING_PURE_ESP_IDF_V5_PLUS

The idea behind this, was to preserved as much code as possible intact, and just change what was necessary to make it work in esp-idf.

I've created some other macros for handling Arduino log_x and the use of millis():

#if defined(USING_PURE_ESP_IDF_V5_PLUS)
  #define log_e(...) ESP_LOGE(__FILE__, __VA_ARGS__)
  #define log_w(...) ESP_LOGW(__FILE__, __VA_ARGS__)
  #define log_i(...) ESP_LOGI(__FILE__, __VA_ARGS__)
  #define log_d(...) ESP_LOGD(__FILE__, __VA_ARGS__)
  #define log_v(...) ESP_LOGV(__FILE__, __VA_ARGS__)

  #define millis() (esp_timer_get_time() / 1000ULL)
#else
  #include "Arduino.h"
  #if(ESP_IDF_VERSION_MAJOR >= 5)
    #include <NetworkInterface.h>
  #endif
#endif

Again, this is a proof of concept, and surely could be done more elegantly.
For what is worth, what triggered this effort was to find out that there is no proper maintained async web server library for esp-idf (!Arduino) and it seemed the right way to start. The original discussion can be found here

I hope we can merge this so as to continue the same work with ESPAsyncWebServer.

- Added preprocessor macros to detect and separate ESP-IDF vs Arduino
@mathieucarbou
Copy link
Member

Thanks @gnalbandian ! I will have a look.

@mathieucarbou
Copy link
Member

@gnalbandian : did you tested your PR ? Build does not pass and there are a lot of issues in the IDE regardng Arduino.

@mathieucarbou mathieucarbou marked this pull request as draft April 11, 2025 07:56
@mathieucarbou mathieucarbou changed the base branch from main to async_tcp_no_arduino April 11, 2025 08:18
@mathieucarbou
Copy link
Member

@gnalbandian : there are no many tings to fix and change in this PR, so I am merging it in a development branch and I eill take over it.

@mathieucarbou mathieucarbou merged commit c332c09 into ESP32Async:async_tcp_no_arduino Apr 11, 2025
1 of 18 checks passed
@mathieucarbou
Copy link
Member

Replaced by #48

@mathieucarbou
Copy link
Member

@gnalbandian : can you please test PR #48 and give feedback ? Thanks!

@ESP32Async ESP32Async locked and limited conversation to collaborators Apr 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants