Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix for ESP32 3.x NetworkClient, Client interface #180

Closed

Conversation

brentru
Copy link

@brentru brentru commented Sep 9, 2024

@facchinm @andreagilardoni Hi - this pull request allows this library to be used with the ESP32 board support package 3.x (Arduino ESP32 v3.0 based on ESP-IDF v5.1)by adding two extra connect() definitions into this library's HTTPClient.h to match the updated Client-type interfaces within ESP32, NetworkClient and NetworkSecureClient.

Since the bug only impacts devices running ESP32 on ESP-IDF 5.x or greater, I've provided a macro to detect the ESP-IDF version and a conditional inclusion guard around these two virtual connect() header-only interfaces.

The PR fixes the following compiler error (compiled with ESP Arduino 3.1.0 RC1):

src/wifi/AdafruitIO_ESP32.cpp:26:52: error: invalid new-expression of abstract class type 'HttpClient'
   26 |   _http = new HttpClient(_client, _host, _http_port);
      |                                                    ^
In file included from /Users/brentrubell/Documents/Arduino/libraries/ArduinoHttpClient/src/ArduinoHttpClient.h:8,
                 from /Users/brentrubell/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/AdafruitIO.h:27,
                 from /Users/brentrubell/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/wifi/AdafruitIO_ESP32.h:20:
/Users/brentrubell/Documents/Arduino/libraries/ArduinoHttpClient/src/HttpClient.h:41:7: note:   because the following virtual functions are pure within 'HttpClient':
   41 | class HttpClient : public Client
      |       ^~~~~~~~~~
In file included from /Users/brentrubell/Library/Arduino15/packages/esp32/hardware/esp32/3.1.0-RC1/cores/esp32/Arduino.h:197,
                 from /Users/brentrubell/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/AdafruitIO_Dashboard.h:19,
                 from /Users/brentrubell/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/AdafruitIO.h:19:
/Users/brentrubell/Library/Arduino15/packages/esp32/hardware/esp32/3.1.0-RC1/cores/esp32/Client.h:29:15: note:     'virtual int Client::connect(IPAddress, uint16_t, int32_t)'
   29 |   virtual int connect(IPAddress ip, uint16_t port, int32_t timeout) = 0;
      |               ^~~~~~~
/Users/brentrubell/Library/Arduino15/packages/esp32/hardware/esp32/3.1.0-RC1/cores/esp32/Client.h:31:15: note:     'virtual int Client::connect(const char*, uint16_t, int32_t)'
   31 |   virtual int connect(const char *host, uint16_t port, int32_t timeout) = 0;
      |               ^~~

@CLAassistant
Copy link

CLAassistant commented Sep 9, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

github-actions bot commented Sep 9, 2024

Memory usage change @ 770bc04

Board flash % RAM for global variables %
arduino:samd:mkr1000 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board examples/BasicAuthGet
flash
% examples/BasicAuthGet
RAM for global variables
% examples/CustomHeader
flash
% examples/CustomHeader
RAM for global variables
% examples/DweetGet
flash
% examples/DweetGet
RAM for global variables
% examples/DweetPost
flash
% examples/DweetPost
RAM for global variables
% examples/HueBlink
flash
% examples/HueBlink
RAM for global variables
% examples/ParseURL
flash
% examples/ParseURL
RAM for global variables
% examples/PostWithHeaders
flash
% examples/PostWithHeaders
RAM for global variables
% examples/SimpleDelete
flash
% examples/SimpleDelete
RAM for global variables
% examples/SimpleGet
flash
% examples/SimpleGet
RAM for global variables
% examples/SimpleHttpExample
flash
% examples/SimpleHttpExample
RAM for global variables
% examples/SimplePost
flash
% examples/SimplePost
RAM for global variables
% examples/SimplePut
flash
% examples/SimplePut
RAM for global variables
% examples/SimpleWebSocket
flash
% examples/SimpleWebSocket
RAM for global variables
%
arduino:samd:mkr1000 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
Click for full report CSV
Board,examples/BasicAuthGet<br>flash,%,examples/BasicAuthGet<br>RAM for global variables,%,examples/CustomHeader<br>flash,%,examples/CustomHeader<br>RAM for global variables,%,examples/DweetGet<br>flash,%,examples/DweetGet<br>RAM for global variables,%,examples/DweetPost<br>flash,%,examples/DweetPost<br>RAM for global variables,%,examples/HueBlink<br>flash,%,examples/HueBlink<br>RAM for global variables,%,examples/ParseURL<br>flash,%,examples/ParseURL<br>RAM for global variables,%,examples/PostWithHeaders<br>flash,%,examples/PostWithHeaders<br>RAM for global variables,%,examples/SimpleDelete<br>flash,%,examples/SimpleDelete<br>RAM for global variables,%,examples/SimpleGet<br>flash,%,examples/SimpleGet<br>RAM for global variables,%,examples/SimpleHttpExample<br>flash,%,examples/SimpleHttpExample<br>RAM for global variables,%,examples/SimplePost<br>flash,%,examples/SimplePost<br>RAM for global variables,%,examples/SimplePut<br>flash,%,examples/SimplePut<br>RAM for global variables,%,examples/SimpleWebSocket<br>flash,%,examples/SimpleWebSocket<br>RAM for global variables,%
arduino:samd:mkr1000,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0

@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Sep 9, 2024
@per1234 per1234 linked an issue Dec 17, 2024 that may be closed by this pull request
@aspymid
Copy link

aspymid commented Dec 17, 2024

Thankx per1234! That was quick.
The patch works for me!

Copy link

@per1234 per1234 left a comment

Choose a reason for hiding this comment

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

Thanks for your pull request @brentru!

I thought I should add a note that a proposal has now been submitted to revert the breaking change in the esp32 platform's Client API: espressif/arduino-esp32#10776

If accepted, that would render this pull request superfluous, with the exception of providing compatibility with esp32 platform version 3.1.0 specifically.

@brentru
Copy link
Author

brentru commented Dec 26, 2024

Yup, let's close this in favor of the platform Client API PR.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Library compilation fails with "esp32" boards platform version 3.1.0
5 participants