govorox / SSLClient

SSLClient - generic secure client Arduino library using mbedtls
GNU General Public License v3.0
83 stars 39 forks source link

Discussion: regarding Arduino IDE example code using arduino-esp32 v3 #96

Closed GotRobbd closed 1 month ago

GotRobbd commented 1 month ago

I have noticed that people may stumble upon using the library properly when using the latest version of arduino-esp32 (currently at 3.0.3). This has been caused by an external library named ArduinoHttpClient, which fails to build.

This is due to the GCC compiler's byte class and the Arduino's byte typedef clashing with each other, causing ambiguity. This is not an issue when using arduino-esp32 v2.0.17 and lower, however. This problem is arising now because arduino-esp32 v3 is using GCC 12.2.0, whilst arduino-esp32 v2 is using is using GCC 8.4.0. This is important because the former is using the C++17 standard or higher, which introduce the byte class in the language. The latter is still using C++11, which does not have such class.

The problem not only affects ArduinoHttpClient, but any other Arduino library using the byte typedef, including TinyGsm.

The good news is that there is an easy workaround. When opening one of the examples in ArduinoIDE from this library, look for #include <ArduinoHttpClient.h> and put it as the first include. This should fix the issue and the code should compile just fine. If it still does not work, try and put it in between the other includes until the code compiles.

Original https_wifi example code in ArduinoIDE, fails to compile due to "byte" definition ambiguity: image

Modified https_wifi example code in ArduinoIDE, compiles fine: image

github-actions[bot] commented 1 month ago

The following fields are missing: Description, Steps to Reproduce, Expected Behavior, Actual Behavior, Environment, IDE. Please update the issue with this information.

RobertByrnes commented 1 month ago

Hi @GotRobbd About to make 1.3.1 release - please try it. Should fix both PlatformIO and Arduino IDE for both 2.0.17 and 3.0.2

duyle1402 commented 1 month ago

Hi @RobertByrnes, @GotRobbd

The error reference to 'byte' is still ambiguous in the Arduino example regarding the TinyGsm library. Does anyone have any ideas on how to debug this issue? Should we raise an issue in the arduino-esp32 and TinyGsm repositories to include information about the ambiguity between the new GCC byte class and Arduino's byte typedef in the ESP32 migration guide?

RobertByrnes commented 1 month ago

Hi @duyle1402 Which version of this lib? 1.3.0?

I have just released 1.3.1 which should fix this as all the examples for Arduino now compile with esp@3.0.2 - This hasn't appeared in my Arduino IDE yet but as soon as it does! I will test again.

duyle1402 commented 1 month ago

Sorry for the lack of information. I mean the Arduino example using the MQTTand TinyGsmlibraries. I have see the commit and dont see anychanges regarding mqtt_secure_gsm_SIM7000 example in 1.3.1

duyle1402 commented 1 month ago

Nevermind, sorry for the confusion. I see that you used using namespace std; in release 1.3.1. I just tested it again and it works well. Sorry again @RobertByrnes

RobertByrnes commented 1 month ago

Hey @duyle1402 No trouble - just glad it is sorted!