thingsboard / thingsboard-client-sdk

Client SDK to connect with ThingsBoard IoT Platform from IoT devices (Arduino, Espressif, etc.)
MIT License
158 stars 123 forks source link

.pio\libdeps\esp32dev\ThingsBoard\src\Arduino_ESP32_Updater.cpp:9:20: fatal error: Update.h: No such file or directory #171

Closed donskytech closed 4 months ago

donskytech commented 10 months ago

Hey, I am trying out the Thingsboard SDK client on an old Windows 10 laptop but I am getting the error above.

I am using PlatformIO IDE but I cannot get past the Build Task

This is my platform.ini file.

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps = 
    thingsboard/ThingsBoard@^0.12.2
    mikalhart/TinyGPSPlus@^1.0.3
    thingsboard/TBPubSubClient@^2.9.3
    bblanchon/ArduinoJson@^6.21.4
    https://github.com/bblanchon/ArduinoStreamUtils.git

What am I missing? Thanks

donskytech commented 10 months ago

While trying to search for solution on the internet, I saw this guy (https://community.platformio.org/t/error-linking-a-specific-library/33813) changed his platform.ini file into this by adding the Update in the lib_deps

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps = 
    Update
    thingsboard/ThingsBoard@^0.12.2
    mikalhart/TinyGPSPlus@^1.0.3
    thingsboard/TBPubSubClient@^2.9.3
    bblanchon/ArduinoJson@^6.21.4
    https://github.com/bblanchon/ArduinoStreamUtils.git

I tried it and the error was gone, however I run into the following new errors.

Library Manager: Installing thingsboard/pubsubclient @ ^2.9.3
Library Manager: Warning! Could not install `{'owner': 'thingsboard', 'name': 'pubsubclient', 'version': '^2.9.3'}` dependency for the`ThingsBoard` package
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (3.5.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.10006.210326 (1.0.6)
 - tool-esptoolpy @ 1.30100.210531 (3.1.0)
 - toolchain-xtensa32 @ 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 34 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Update @ 1.0
|-- ThingsBoard @ 0.12.2
|-- TinyGPSPlus @ 1.0.3
|-- TBPubSubClient @ 2.9.3
|-- ArduinoJson @ 6.21.4
|-- StreamUtils @ 1.8.0+sha.03fafbb
|-- WiFi @ 1.0
|-- WiFiClientSecure @ 1.0
Building in release mode
Compiling .pio\build\esp32dev\src\GPS_API.cpp.o
Compiling .pio\build\esp32dev\src\main.cpp.o
Generating partitions .pio\build\esp32dev\partitions.bin
Compiling .pio\build\esp32dev\lib9e5\Update\HttpsOTAUpdate.cpp.o
Compiling .pio\build\esp32dev\lib9e5\Update\Updater.cpp.o
Compiling .pio\build\esp32dev\libdbe\ArduinoHttpClient\HttpClient.cpp.o
Compiling .pio\build\esp32dev\libdbe\ArduinoHttpClient\URLEncoder.cpp.o
Archiving .pio\build\esp32dev\lib9e5\libUpdate.a
Indexing .pio\build\esp32dev\lib9e5\libUpdate.a
Compiling .pio\build\esp32dev\libdbe\ArduinoHttpClient\WebSocketClient.cpp.o
Compiling .pio\build\esp32dev\libdbe\ArduinoHttpClient\b64.cpp.o
Compiling .pio\build\esp32dev\libe9c\TBPubSubClient\PubSubClient.cpp.o
Compiling .pio\build\esp32dev\lib41c\EEPROM\EEPROM.cpp.o
Archiving .pio\build\esp32dev\libdbe\libArduinoHttpClient.a
Compiling .pio\build\esp32dev\lib39f\Ticker\Ticker.cpp.o
Indexing .pio\build\esp32dev\libdbe\libArduinoHttpClient.a
Archiving .pio\build\esp32dev\lib39f\libTicker.a
Indexing .pio\build\esp32dev\lib39f\libTicker.a
Compiling .pio\build\esp32dev\lib4d3\ThingsBoard\Arduino_ESP32_Updater.cpp.o
Archiving .pio\build\esp32dev\libe9c\libTBPubSubClient.a
Indexing .pio\build\esp32dev\libe9c\libTBPubSubClient.a
Compiling .pio\build\esp32dev\lib4d3\ThingsBoard\Arduino_ESP8266_Updater.cpp.o
Compiling .pio\build\esp32dev\lib4d3\ThingsBoard\Arduino_HTTP_Client.cpp.o
Archiving .pio\build\esp32dev\lib41c\libEEPROM.a
Compiling .pio\build\esp32dev\lib4d3\ThingsBoard\Arduino_MQTT_Client.cpp.o
Indexing .pio\build\esp32dev\lib41c\libEEPROM.a
Compiling .pio\build\esp32dev\lib4d3\ThingsBoard\Attribute_Request_Callback.cpp.o
Compiling .pio\build\esp32dev\lib4d3\ThingsBoard\Callback_Watchdog.cpp.o
.pio\libdeps\esp32dev\ThingsBoard\src\Callback_Watchdog.cpp: In member function 'void Callback_Watchdog::create_timer()':
.pio\libdeps\esp32dev\ThingsBoard\src\Callback_Watchdog.cpp:76:5: error: 'const esp_timer_create_args_t' has no non-static data member named 'skip_unhandled_events'
     };
     ^
Compiling .pio\build\esp32dev\lib4d3\ThingsBoard\Espressif_MQTT_Client.cpp.o
Compiling .pio\build\esp32dev\lib4d3\ThingsBoard\Espressif_Updater.cpp.o
*** [.pio\build\esp32dev\lib4d3\ThingsBoard\Callback_Watchdog.cpp.o] Error 1
.pio\libdeps\esp32dev\ThingsBoard\src\Espressif_Updater.cpp: In member function 'virtual void Espressif_Updater::reset()':
.pio\libdeps\esp32dev\ThingsBoard\src\Espressif_Updater.cpp:55:37: error: 'esp_ota_abort' was not declared in this scope
     (void)esp_ota_abort(m_ota_handle);
                                     ^
*** [.pio\build\esp32dev\lib4d3\ThingsBoard\Espressif_Updater.cpp.o] Error 1
.pio\libdeps\esp32dev\ThingsBoard\src\Espressif_MQTT_Client.cpp: In member function 'virtual bool Espressif_MQTT_Client::publish(const char*, const uint8_t*, const size_t&)':
.pio\libdeps\esp32dev\ThingsBoard\src\Espressif_MQTT_Client.cpp:215:128: error: 'esp_mqtt_client_enqueue' was not declared in this scope
         message_id = esp_mqtt_client_enqueue(m_mqtt_client, topic, reinterpret_cast<const char*>(payload), length, 0U, 0U, true);

          ^
*** [.pio\build\esp32dev\lib4d3\ThingsBoard\Espressif_MQTT_Client.cpp.o] Error 1
============================================ [FAILED] Took 19.24 seconds ============================================

 *  The terminal process "C:\Users\DONSKY\.platformio\penv\Scripts\platformio.exe 'run', '--environment', 'esp32dev'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

Any hints?

MathewHDYT commented 10 months ago

I think I got the error. It seems you are using the arduino framework, but it is using an older version of espressif in the background that is not supported.

The example implementations that are being loaded are not meant for Espressif Version before v4.0, which seems to be the case here.

To fix that you have to override the automatic configuration flags that enable those components, this will cause the components to not be loaded, which will remove the aforementioned issues. Luckily because you are on Arduino you do not need the Espressif_,... components anyway, they are meant for users that use the espressif framework.


Simply add these flags before including ThingsBoard.h.

#define THINGSBOARD_USE_ESP_TIMER 0
#define THINGSBOARD_USE_ESP_MQTT 0
#define THINGSBOARD_USE_MBED_TLS 0
#define THINGSBOARD_USE_ESP_PARTITION 0

#include <ThingsBoard.h>
sdrshnptl commented 10 months ago

Hey, I am trying out the Thingsboard SDK client on an old Windows 10 laptop but I am getting the error above.

I am using PlatformIO IDE but I cannot get past the Build Task

This is my platform.ini file.

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps = 
  thingsboard/ThingsBoard@^0.12.2
  mikalhart/TinyGPSPlus@^1.0.3
  thingsboard/TBPubSubClient@^2.9.3
  bblanchon/ArduinoJson@^6.21.4
  https://github.com/bblanchon/ArduinoStreamUtils.git

What am I missing? Thanks

Hello @donskytech ,

Use this

#include <Arduino.h>
#ifdef ESP8266
#include <ESP8266WiFi.h>
// Disable PROGMEM because the ESP8266WiFi library,
// does not support flash strings.
#define THINGSBOARD_ENABLE_PROGMEM 0
#else
#ifdef ESP32
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include "Update.h" //<<---------------- Add this
#endif // ESP32
#endif // ESP8266

#include <Arduino_MQTT_Client.h>
#include <ThingsBoard.h>
donskytech commented 10 months ago

Hi, I tried out the two solutions above but they do not work for different errors.

Maybe updating my espressif is the only solution. I am just worried about my other code not working so I am not updating it yet. I will do it once I am done.

For now, I have switched to using the Arduino IDE 2 as it is working there.

MathewHDYT commented 10 months ago

@donskytech Can you add why overriding the internal configurations does not compile, perhaps that issue can be resolved as well?

donskytech commented 10 months ago

@donskytech Can you add why overriding the internal configurations does not compile, perhaps that issue can be resolved as well?

Hello, I tried your solution also but I still get the error about missing "Update.h"

And tried this

define THINGSBOARD_USE_ESP_TIMER 0

define THINGSBOARD_USE_ESP_MQTT 0

define THINGSBOARD_USE_MBED_TLS 0

define THINGSBOARD_USE_ESP_PARTITION 0

include

Maybe my Espressif framework might be old so that is why it is not compiling.

MathewHDYT commented 10 months ago

Is that the case even if you add Update to the lib-deps in the plattformio.ini file.

sdrshnptl commented 10 months ago

Try this platformio.ini settings

env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
lib_deps = 
    thingsboard/ThingsBoard
    mikalhart/TinyGPSPlus
    thingsboard/TBPubSubClient
    bblanchon/ArduinoJson
    https://github.com/bblanchon/ArduinoStreamUtils.git
donskytech commented 10 months ago

Is that the case even if you add Update to the lib-deps in the plattformio.ini file.

Right now, this is my platform.ini

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps = 
    Update
    mikalhart/TinyGPSPlus@^1.0.3
    bblanchon/ArduinoJson@^6.21.4
    thingsboard/ThingsBoard@^0.12.2
    thingsboard/TBPubSubClient@^2.9.3
    beegee-tokyo/DHT sensor library for ESPx@^1.19
    pfeerick/elapsedMillis@^1.0.6
    https://github.com/Seeed-Studio/Seeed_Arduino_mbedtls.git
    https://github.com/bblanchon/ArduinoStreamUtils.git

I am copying my whole build sequence. I hope we could figure it out also as working with the Arduino IDE 2 is really hard compare to VSCode PlatformIO.

 *  Executing task: C:\Users\DONSKY\.platformio\penv\Scripts\platformio.exe run --environment esp32dev 

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------Library Manager: Installing thingsboard/pubsubclient @ ^2.9.3
Library Manager: Warning! Could not install `{'owner': 'thingsboard', 'name': 'pubsubclient', 'version': '^2.9.3'}` dependency for the`ThingsBoard` package
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (3.5.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.10006.210326 (1.0.6)
 - tool-esptoolpy @ 1.30100.210531 (3.1.0)
 - toolchain-xtensa32 @ 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 37 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Update @ 1.0
|-- TinyGPSPlus @ 1.0.3
|-- ArduinoJson @ 6.21.4
|-- ThingsBoard @ 0.12.2
|-- TBPubSubClient @ 2.9.3
|-- DHT sensor library for ESPx @ 1.19.0
|-- elapsedMillis @ 1.0.6
|-- Seeed_Arduino_mbedtls @ 3.0.1+sha.6e87101
|-- StreamUtils @ 1.8.0+sha.03fafbb
|-- WiFi @ 1.0
|-- WiFiClientSecure @ 1.0
Building in release mode
Compiling .pio\build\esp32dev\src\GPS_API.cpp.o
Compiling .pio\build\esp32dev\src\main.cpp.o
Generating partitions .pio\build\esp32dev\partitions.bin
Compiling .pio\build\esp32dev\lib9e5\Update\HttpsOTAUpdate.cpp.o
Compiling .pio\build\esp32dev\lib9e5\Update\Updater.cpp.o
src\main.cpp:36:0: warning: "THINGSBOARD_USE_ESP_TIMER" redefined
 #define THINGSBOARD_USE_ESP_TIMER 0
 ^
In file included from .pio\libdeps\esp32dev\ThingsBoard\src/IMQTT_Client.h:5:0,
                 from .pio\libdeps\esp32dev\ThingsBoard\src/Arduino_MQTT_Client.h:7,
                 from src\main.cpp:32:
.pio\libdeps\esp32dev\ThingsBoard\src/Configuration.h:59:0: note: this is the location of the previous definition
 #        define THINGSBOARD_USE_ESP_TIMER 1
 ^
src\main.cpp:37:0: warning: "THINGSBOARD_USE_ESP_MQTT" redefined
 #define THINGSBOARD_USE_ESP_MQTT 0
 ^
In file included from .pio\libdeps\esp32dev\ThingsBoard\src/IMQTT_Client.h:5:0,
                 from .pio\libdeps\esp32dev\ThingsBoard\src/Arduino_MQTT_Client.h:7,
                 from src\main.cpp:32:
.pio\libdeps\esp32dev\ThingsBoard\src/Configuration.h:75:0: note: this is the location of the previous definition
 #        define THINGSBOARD_USE_ESP_MQTT 1
 ^
src\main.cpp:38:0: warning: "THINGSBOARD_USE_MBED_TLS" redefined
 #define THINGSBOARD_USE_MBED_TLS 0
 ^
In file included from .pio\libdeps\esp32dev\ThingsBoard\src/IMQTT_Client.h:5:0,
                 from .pio\libdeps\esp32dev\ThingsBoard\src/Arduino_MQTT_Client.h:7,
                 from src\main.cpp:32:
.pio\libdeps\esp32dev\ThingsBoard\src/Configuration.h:91:0: note: this is the location of the previous definition
 #        define THINGSBOARD_USE_MBED_TLS 1
 ^
src\main.cpp:39:0: warning: "THINGSBOARD_USE_ESP_PARTITION" redefined
 #define THINGSBOARD_USE_ESP_PARTITION 0
 ^
In file included from .pio\libdeps\esp32dev\ThingsBoard\src/IMQTT_Client.h:5:0,
                 from .pio\libdeps\esp32dev\ThingsBoard\src/Arduino_MQTT_Client.h:7,
                 from src\main.cpp:32:
.pio\libdeps\esp32dev\ThingsBoard\src/Configuration.h:107:0: note: this is the location of the previous definition
 #        define THINGSBOARD_USE_ESP_PARTITION 1
 ^
Compiling .pio\build\esp32dev\liba9f\TinyGPSPlus\TinyGPS++.cpp.o
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\HttpClient.cpp.o
Archiving .pio\build\esp32dev\lib9e5\libUpdate.a
Indexing .pio\build\esp32dev\lib9e5\libUpdate.a
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\URLEncoder.cpp.o
Archiving .pio\build\esp32dev\liba9f\libTinyGPSPlus.a
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\WebSocketClient.cpp.o
Indexing .pio\build\esp32dev\liba9f\libTinyGPSPlus.a
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\b64.cpp.o
Compiling .pio\build\esp32dev\lib773\TBPubSubClient\PubSubClient.cpp.o
Compiling .pio\build\esp32dev\lib41c\EEPROM\EEPROM.cpp.o
Archiving .pio\build\esp32dev\libf50\libArduinoHttpClient.a
Indexing .pio\build\esp32dev\libf50\libArduinoHttpClient.a
Compiling .pio\build\esp32dev\lib39f\Ticker\Ticker.cpp.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\aes.c.o
Archiving .pio\build\esp32dev\lib39f\libTicker.a
Indexing .pio\build\esp32dev\lib39f\libTicker.a
Archiving .pio\build\esp32dev\lib41c\libEEPROM.a
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\aesni.c.o
Indexing .pio\build\esp32dev\lib41c\libEEPROM.a
Archiving .pio\build\esp32dev\lib773\libTBPubSubClient.a
Indexing .pio\build\esp32dev\lib773\libTBPubSubClient.a
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\arc4.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\aria.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\asn1parse.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\asn1write.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\base64.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\bignum.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\blowfish.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\camellia.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ccm.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\certs.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\chacha20.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\chachapoly.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\cipher.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\cipher_wrap.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\cmac.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ctr_drbg.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\debug.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\des.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\dhm.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecdh.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecdsa.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecjpake.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecp.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecp_curves.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\entropy.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\error.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\gcm.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\havege.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\hkdf.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\hmac_drbg.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md2.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md4.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md5.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md_wrap.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\memory_buffer_alloc.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\nist_kw.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\oid.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\padlock.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pem.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pk.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pk_wrap.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkcs11.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkcs12.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkcs5.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkparse.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkwrite.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\platform.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\platform_util.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\poly1305.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ripemd160.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\rsa.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\rsa_internal.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\sha1.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\sha256.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\sha512.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_cache.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_ciphersuites.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_cli.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_cookie.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_srv.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_ticket.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_tls.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\threading.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\version.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\version_features.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509_create.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509_crl.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509_crt.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509_csr.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509write_crt.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509write_csr.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\xtea.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\port\esp_hardware.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\port\esp_mem.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\port\mbedtls_debug.c.o
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c: In function 'mbedtls_esp_enable_debug_log':
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c:33:19: warning: variable 'level' set but not used [-Wunused-but-set-variable]
     unsigned char level = 0;
                   ^
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c: In function 'mbedtls_esp_debug':
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c:68:9: warning: implicit declaration of function 'xprintf' [-Wimplicit-function-declaration]
         xprintf("%s:%d %s\r\n", file, line, str);
         ^
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c:83:9: warning: implicit declaration of function 'ESP_LOGE' [-Wimplicit-function-declaration]
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Arduino_ESP32_Updater.cpp.o
         ESP_LOGE(TAG, "Unexpected log level %d: %s", level, str);
         ^
Archiving .pio\build\esp32dev\lib348\libSeeed_Arduino_mbedtls.a
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Arduino_ESP8266_Updater.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Arduino_HTTP_Client.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Arduino_MQTT_Client.cpp.o
Indexing .pio\build\esp32dev\lib348\libSeeed_Arduino_mbedtls.a
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Attribute_Request_Callback.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Callback_Watchdog.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Espressif_MQTT_Client.cpp.o
.pio\libdeps\esp32dev\ThingsBoard\src\Callback_Watchdog.cpp: In member function 'void Callback_Watchdog::create_timer()':
.pio\libdeps\esp32dev\ThingsBoard\src\Callback_Watchdog.cpp:76:5: error: 'const esp_timer_create_args_t' has no non-static data member named 'skip_unhandled_events'
     };
     ^
*** [.pio\build\esp32dev\liba78\ThingsBoard\Callback_Watchdog.cpp.o] Error 1
.pio\libdeps\esp32dev\ThingsBoard\src\Espressif_MQTT_Client.cpp: In member function 'virtual bool Espressif_MQTT_Client::publish(const char*, const uint8_t*, const size_t&)':
.pio\libdeps\esp32dev\ThingsBoard\src\Espressif_MQTT_Client.cpp:215:128: error: 'esp_mqtt_client_enqueue' was not declared in this scope
         message_id = esp_mqtt_client_enqueue(m_mqtt_client, topic, reinterpret_cast<const char*>(payload), length, 0U, 0U, true);
                                                                                                                                ^
*** [.pio\build\esp32dev\liba78\ThingsBoard\Espressif_MQTT_Client.cpp.o] Error 1
======================================================= [FAILED] Took 57.55 seconds =======================================================
 *  The terminal process "C:\Users\DONSKY\.platformio\penv\Scripts\platformio.exe 'run', '--environment', 'esp32dev'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 
donskytech commented 10 months ago

lib_deps = thingsboard/ThingsBoard mikalhart/TinyGPSPlus thingsboard/TBPubSubClient bblanchon/ArduinoJson https://github.com/bblanchon/ArduinoStreamUtils.git

I tried this platform.ini settings also. I did a Full Clean and Build Task. Below is the result

 *  Executing task: C:\Users\DONSKY\.platformio\penv\Scripts\platformio.exe run --environment esp32dev 

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------Library Manager: Installing thingsboard/pubsubclient @ ^2.9.3
Library Manager: Warning! Could not install `{'owner': 'thingsboard', 'name': 'pubsubclient', 'version': '^2.9.3'}` dependency for the`ThingsBoard` package
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (3.5.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.10006.210326 (1.0.6)
 - tool-esptoolpy @ 1.30100.210531 (3.1.0)
 - toolchain-xtensa32 @ 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 37 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Update @ 1.0
|-- TinyGPSPlus @ 1.0.3
|-- ArduinoJson @ 6.21.4
|-- ThingsBoard @ 0.12.2
|-- TBPubSubClient @ 2.9.3
|-- DHT sensor library for ESPx @ 1.19.0
|-- elapsedMillis @ 1.0.6
|-- Seeed_Arduino_mbedtls @ 3.0.1+sha.6e87101
|-- StreamUtils @ 1.8.0+sha.03fafbb
|-- WiFi @ 1.0
|-- WiFiClientSecure @ 1.0
Building in release mode
Compiling .pio\build\esp32dev\src\GPS_API.cpp.o
Compiling .pio\build\esp32dev\src\main.cpp.o
Generating partitions .pio\build\esp32dev\partitions.bin
Compiling .pio\build\esp32dev\lib9e5\Update\HttpsOTAUpdate.cpp.o
Compiling .pio\build\esp32dev\lib9e5\Update\Updater.cpp.o
src\main.cpp:36:0: warning: "THINGSBOARD_USE_ESP_TIMER" redefined
 #define THINGSBOARD_USE_ESP_TIMER 0
 ^
In file included from .pio\libdeps\esp32dev\ThingsBoard\src/IMQTT_Client.h:5:0,
                 from .pio\libdeps\esp32dev\ThingsBoard\src/Arduino_MQTT_Client.h:7,
                 from src\main.cpp:32:
.pio\libdeps\esp32dev\ThingsBoard\src/Configuration.h:59:0: note: this is the location of the previous definition
 #        define THINGSBOARD_USE_ESP_TIMER 1
 ^
src\main.cpp:37:0: warning: "THINGSBOARD_USE_ESP_MQTT" redefined
 #define THINGSBOARD_USE_ESP_MQTT 0
 ^
In file included from .pio\libdeps\esp32dev\ThingsBoard\src/IMQTT_Client.h:5:0,
                 from .pio\libdeps\esp32dev\ThingsBoard\src/Arduino_MQTT_Client.h:7,
                 from src\main.cpp:32:
.pio\libdeps\esp32dev\ThingsBoard\src/Configuration.h:75:0: note: this is the location of the previous definition
 #        define THINGSBOARD_USE_ESP_MQTT 1
 ^
src\main.cpp:38:0: warning: "THINGSBOARD_USE_MBED_TLS" redefined
 #define THINGSBOARD_USE_MBED_TLS 0
 ^
In file included from .pio\libdeps\esp32dev\ThingsBoard\src/IMQTT_Client.h:5:0,
                 from .pio\libdeps\esp32dev\ThingsBoard\src/Arduino_MQTT_Client.h:7,
                 from src\main.cpp:32:
.pio\libdeps\esp32dev\ThingsBoard\src/Configuration.h:91:0: note: this is the location of the previous definition
 #        define THINGSBOARD_USE_MBED_TLS 1
 ^
src\main.cpp:39:0: warning: "THINGSBOARD_USE_ESP_PARTITION" redefined
 #define THINGSBOARD_USE_ESP_PARTITION 0
 ^
In file included from .pio\libdeps\esp32dev\ThingsBoard\src/IMQTT_Client.h:5:0,
                 from .pio\libdeps\esp32dev\ThingsBoard\src/Arduino_MQTT_Client.h:7,
                 from src\main.cpp:32:
.pio\libdeps\esp32dev\ThingsBoard\src/Configuration.h:107:0: note: this is the location of the previous definition
 #        define THINGSBOARD_USE_ESP_PARTITION 1
 ^
Compiling .pio\build\esp32dev\liba9f\TinyGPSPlus\TinyGPS++.cpp.o
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\HttpClient.cpp.o
Archiving .pio\build\esp32dev\lib9e5\libUpdate.a
Indexing .pio\build\esp32dev\lib9e5\libUpdate.a
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\URLEncoder.cpp.o
Archiving .pio\build\esp32dev\liba9f\libTinyGPSPlus.a
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\WebSocketClient.cpp.o
Indexing .pio\build\esp32dev\liba9f\libTinyGPSPlus.a
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\b64.cpp.o
Compiling .pio\build\esp32dev\lib773\TBPubSubClient\PubSubClient.cpp.o
Compiling .pio\build\esp32dev\lib41c\EEPROM\EEPROM.cpp.o
Archiving .pio\build\esp32dev\libf50\libArduinoHttpClient.a
Indexing .pio\build\esp32dev\libf50\libArduinoHttpClient.a
Compiling .pio\build\esp32dev\lib39f\Ticker\Ticker.cpp.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\aes.c.o
Archiving .pio\build\esp32dev\lib39f\libTicker.a
Indexing .pio\build\esp32dev\lib39f\libTicker.a
Archiving .pio\build\esp32dev\lib41c\libEEPROM.a
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\aesni.c.o
Indexing .pio\build\esp32dev\lib41c\libEEPROM.a
Archiving .pio\build\esp32dev\lib773\libTBPubSubClient.a
Indexing .pio\build\esp32dev\lib773\libTBPubSubClient.a
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\arc4.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\aria.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\asn1parse.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\asn1write.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\base64.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\bignum.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\blowfish.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\camellia.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ccm.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\certs.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\chacha20.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\chachapoly.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\cipher.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\cipher_wrap.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\cmac.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ctr_drbg.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\debug.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\des.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\dhm.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecdh.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecdsa.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecjpake.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecp.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecp_curves.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\entropy.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\error.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\gcm.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\havege.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\hkdf.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\hmac_drbg.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md2.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md4.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md5.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md_wrap.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\memory_buffer_alloc.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\nist_kw.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\oid.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\padlock.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pem.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pk.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pk_wrap.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkcs11.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkcs12.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkcs5.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkparse.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkwrite.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\platform.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\platform_util.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\poly1305.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ripemd160.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\rsa.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\rsa_internal.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\sha1.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\sha256.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\sha512.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_cache.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_ciphersuites.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_cli.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_cookie.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_srv.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_ticket.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_tls.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\threading.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\version.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\version_features.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509_create.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509_crl.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509_crt.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509_csr.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509write_crt.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509write_csr.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\xtea.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\port\esp_hardware.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\port\esp_mem.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\port\mbedtls_debug.c.o
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c: In function 'mbedtls_esp_enable_debug_log':
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c:33:19: warning: variable 'level' set but not used [-Wunused-but-set-variable]
     unsigned char level = 0;
                   ^
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c: In function 'mbedtls_esp_debug':
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c:68:9: warning: implicit declaration of function 'xprintf' [-Wimplicit-function-declaration]
         xprintf("%s:%d %s\r\n", file, line, str);
         ^
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c:83:9: warning: implicit declaration of function 'ESP_LOGE' [-Wimplicit-function-declaration]
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Arduino_ESP32_Updater.cpp.o
         ESP_LOGE(TAG, "Unexpected log level %d: %s", level, str);
         ^
Archiving .pio\build\esp32dev\lib348\libSeeed_Arduino_mbedtls.a
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Arduino_ESP8266_Updater.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Arduino_HTTP_Client.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Arduino_MQTT_Client.cpp.o
Indexing .pio\build\esp32dev\lib348\libSeeed_Arduino_mbedtls.a
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Attribute_Request_Callback.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Callback_Watchdog.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Espressif_MQTT_Client.cpp.o
.pio\libdeps\esp32dev\ThingsBoard\src\Callback_Watchdog.cpp: In member function 'void Callback_Watchdog::create_timer()':
.pio\libdeps\esp32dev\ThingsBoard\src\Callback_Watchdog.cpp:76:5: error: 'const esp_timer_create_args_t' has no non-static data member named 'skip_unhandled_events'
     };
     ^
*** [.pio\build\esp32dev\liba78\ThingsBoard\Callback_Watchdog.cpp.o] Error 1
.pio\libdeps\esp32dev\ThingsBoard\src\Espressif_MQTT_Client.cpp: In member function 'virtual bool Espressif_MQTT_Client::publish(const char*, const uint8_t*, const size_t&)':
.pio\libdeps\esp32dev\ThingsBoard\src\Espressif_MQTT_Client.cpp:215:128: error: 'esp_mqtt_client_enqueue' was not declared in this scope
         message_id = esp_mqtt_client_enqueue(m_mqtt_client, topic, reinterpret_cast<const char*>(payload), length, 0U, 0U, true);
                                                                                                                                ^
*** [.pio\build\esp32dev\liba78\ThingsBoard\Espressif_MQTT_Client.cpp.o] Error 1
======================================================= [FAILED] Took 57.55 seconds =======================================================
 *  The terminal process "C:\Users\DONSKY\.platformio\penv\Scripts\platformio.exe 'run', '--environment', 'esp32dev'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: C:\Users\DONSKY\.platformio\penv\Scripts\platformio.exe run --environment esp32dev 

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------Library Manager: Installing thingsboard/ThingsBoard
Unpacking  [####################################]  100%
Library Manager: ThingsBoard@0.12.2 has been installed!
Library Manager: Resolving dependencies...
Library Manager: Installing thingsboard/pubsubclient @ ^2.9.3
Library Manager: Warning! Could not install `{'owner': 'thingsboard', 'name': 'pubsubclient', 'version': '^2.9.3'}` dependency for the`ThingsBoard` package
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (3.5.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.10006.210326 (1.0.6)
 - tool-esptoolpy @ 1.30100.210531 (3.1.0)
 - toolchain-xtensa32 @ 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 34 compatible libraries
Scanning dependencies...
Dependency Graph
|-- ThingsBoard @ 0.12.2
|-- TinyGPSPlus @ 1.0.3
|-- TBPubSubClient @ 2.9.3
|-- ArduinoJson @ 6.21.4
|-- StreamUtils @ 1.8.0+sha.03fafbb
|-- Update @ 1.0
|-- WiFi @ 1.0
|-- WiFiClientSecure @ 1.0
Building in release mode
Compiling .pio\build\esp32dev\src\GPS_API.cpp.o
Compiling .pio\build\esp32dev\src\main.cpp.o
Generating partitions .pio\build\esp32dev\partitions.bin
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\HttpClient.cpp.o
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\URLEncoder.cpp.o
src\main.cpp:13:20: fatal error: DHTesp.h: No such file or directory

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

compilation terminated.
*** [.pio\build\esp32dev\src\main.cpp.o] Error 1
============================================== [FAILED] Took 27.40 seconds ==============================================

 *  The terminal process "C:\Users\DONSKY\.platformio\penv\Scripts\platformio.exe 'run', '--environment', 'esp32dev'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: C:\Users\DONSKY\.platformio\penv\Scripts\platformio.exe run --environment esp32dev 

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------Library Manager: Installing thingsboard/pubsubclient @ ^2.9.3
Library Manager: Warning! Could not install `{'owner': 'thingsboard', 'name': 'pubsubclient', 'version': '^2.9.3'}` dependency for the`ThingsBoard` package
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (3.5.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.10006.210326 (1.0.6)
 - tool-esptoolpy @ 1.30100.210531 (3.1.0)
 - toolchain-xtensa32 @ 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 34 compatible libraries
Scanning dependencies...
Dependency Graph
|-- ThingsBoard @ 0.12.2
|-- TinyGPSPlus @ 1.0.3
|-- TBPubSubClient @ 2.9.3
|-- ArduinoJson @ 6.21.4
|-- StreamUtils @ 1.8.0+sha.03fafbb
|-- Update @ 1.0
|-- WiFi @ 1.0
|-- WiFiClientSecure @ 1.0
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\WebSocketClient.cpp.o
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\b64.cpp.o
Compiling .pio\build\esp32dev\lib773\TBPubSubClient\PubSubClient.cpp.o
src\main.cpp:13:20: fatal error: DHTesp.h: No such file or directory

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

compilation terminated.
*** [.pio\build\esp32dev\src\main.cpp.o] Error 1
=============================================== [FAILED] Took 8.68 seconds ===============================================
 *  The terminal process "C:\Users\DONSKY\.platformio\penv\Scripts\platformio.exe 'run', '--environment', 'esp32dev'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 
MathewHDYT commented 10 months ago

It seems that the #defines are below an include that includes the Configuration.h file. Simply move the defines up to the top of the main.cpp file that should fix the errors shown in the console.

donskytech commented 10 months ago

It seems that the #defines are below an include that includes the Configuration.h file. Simply move the defines up to the top of the main.cpp file that should fix the errors shown in the console.

I think I have copied the example file from the SDK examples directory and modified it.

This works when using the Arduino IDE 2.

I am sharing my whole code for your reference

#ifdef ESP8266
#include <ESP8266WiFi.h>
// Disable PROGMEM because the ESP8266WiFi library,
// does not support flash strings.
#define THINGSBOARD_ENABLE_PROGMEM 0
#else
#ifdef ESP32
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include "Update.h"
#endif // ESP32
#endif // ESP8266
#include <DHTesp.h>
#include <elapsedMillis.h>
#include "GPS_API.h"

// Sending data can either be done over MQTT and the PubSubClient
// or HTTPS and the HTTPClient, when using the ESP32 or ESP8266
#define USING_HTTPS false

// Whether the given script is using encryption or not,
// generally recommended as it increases security (communication with the server is not in clear text anymore),
// it does come with an overhead tough as having an encrypted session requires a lot of memory,
// which might not be avaialable on lower end devices.
#define ENCRYPTED false

// Enables sending messages that are bigger than the predefined message size,
// where the message will be sent byte by byte as a fallback instead.
// Requires an additional library, see https://github.com/bblanchon/ArduinoStreamUtils for more information.
#define THINGSBOARD_ENABLE_STREAM_UTILS 0

#include <Arduino_MQTT_Client.h>
#if USING_HTTPS
#include <ThingsBoardHttp.h>
#else
#define THINGSBOARD_USE_ESP_TIMER 0
#define THINGSBOARD_USE_ESP_MQTT 0
#define THINGSBOARD_USE_MBED_TLS 0
#define THINGSBOARD_USE_ESP_PARTITION 0
#include <ThingsBoard.h>
#endif

// PROGMEM can only be added when using the ESP32 WiFiClient,
// will cause a crash if using the ESP8266WiFiSTAClass instead.
#if THINGSBOARD_ENABLE_PROGMEM
constexpr char PROGMEM WIFI_SSID[] = "<WIFI_SSID>";
constexpr char WIFI_PASSWORD[] PROGMEM = "<WIFI_PASSWORD>";
#else
constexpr char WIFI_SSID[] = "<WIFI_SSID>";
constexpr char WIFI_PASSWORD[] = "<WIFI_PASSWORD>";
#endif

// See https://thingsboard.io/docs/getting-started-guides/helloworld/
// to understand how to obtain an access token
#if THINGSBOARD_ENABLE_PROGMEM
constexpr char TOKEN[] PROGMEM = "L6YRs1LQWZU2QXUHAno8";
#else
constexpr char TOKEN[] = "L6YRs1LQWZU2QXUHAno8";
#endif

// Thingsboard we want to establish a connection too
#if THINGSBOARD_ENABLE_PROGMEM
constexpr char THINGSBOARD_SERVER[] PROGMEM = "thingsboard.cloud";
#else
constexpr char THINGSBOARD_SERVER[] = "thingsboard.cloud";
#endif

#if USING_HTTPS
// HTTP port used to communicate with the server, 80 is the default unencrypted HTTP port,
// whereas 443 would be the default encrypted SSL HTTPS port
#if ENCRYPTED
#if THINGSBOARD_ENABLE_PROGMEM
constexpr uint16_t THINGSBOARD_PORT PROGMEM = 443U;
#else
constexpr uint16_t THINGSBOARD_PORT = 443U;
#endif
#else
#if THINGSBOARD_ENABLE_PROGMEM
constexpr uint16_t THINGSBOARD_PORT PROGMEM = 80U;
#else
constexpr uint16_t THINGSBOARD_PORT = 80U;
#endif
#endif
#else
// MQTT port used to communicate with the server, 1883 is the default unencrypted MQTT port,
// whereas 8883 would be the default encrypted SSL MQTT port
#if ENCRYPTED
#if THINGSBOARD_ENABLE_PROGMEM
constexpr uint16_t THINGSBOARD_PORT PROGMEM = 8883U;
#else
constexpr uint16_t THINGSBOARD_PORT = 8883U;
#endif
#else
#if THINGSBOARD_ENABLE_PROGMEM
constexpr uint16_t THINGSBOARD_PORT PROGMEM = 1883U;
#else
constexpr uint16_t THINGSBOARD_PORT = 1883U;
#endif
#endif
#endif

// Maximum size packets will ever be sent or received by the underlying MQTT client,
// if the size is to small messages might not be sent or received messages will be discarded
#if THINGSBOARD_ENABLE_PROGMEM
constexpr uint16_t MAX_MESSAGE_SIZE PROGMEM = 128U;
#else
constexpr uint16_t MAX_MESSAGE_SIZE = 128U;
#endif

// Baud rate for the debugging serial connection
// If the Serial output is mangled, ensure to change the monitor speed accordingly to this variable
#if THINGSBOARD_ENABLE_PROGMEM
constexpr uint32_t SERIAL_DEBUG_BAUD PROGMEM = 115200U;
#else
constexpr uint32_t SERIAL_DEBUG_BAUD = 115200U;
#endif

#if ENCRYPTED
// See https://comodosslstore.com/resources/what-is-a-root-ca-certificate-and-how-do-i-download-it/
// on how to get the root certificate of the server we want to communicate with,
// this is needed to establish a secure connection and changes depending on the website.
#if THINGSBOARD_ENABLE_PROGMEM
constexpr char ROOT_CERT[] PROGMEM = R"(-----BEGIN CERTIFICATE-----
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC
B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv
KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWn
OlFuhjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTn
jh8BCNAw1FtxNrQHusEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbw
qHyGO0aoSCqI3Haadr8faqU9GY/rOPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CI
rU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY9umbbjANBgkq
hkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ
3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK
NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5
ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur
TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC
jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc
oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
-----END CERTIFICATE-----
)";
#else
constexpr char ROOT_CERT[] = R"(-----BEGIN CERTIFICATE-----
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC
B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv
KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWn
OlFuhjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTn
jh8BCNAw1FtxNrQHusEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbw
qHyGO0aoSCqI3Haadr8faqU9GY/rOPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CI
rU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY9umbbjANBgkq
hkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ
3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK
NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5
ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur
TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC
jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc
oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
-----END CERTIFICATE-----
)";
#endif
#endif

#if THINGSBOARD_ENABLE_PROGMEM
constexpr char TEMPERATURE_KEY[] PROGMEM = "temperature";
constexpr char HUMIDITY_KEY[] PROGMEM = "humidity";
constexpr char LATITUDE_KEY[] PROGMEM = "latitude";
constexpr char LONGITUDE_KEY[] PROGMEM = "longitude";
#else
constexpr char TEMPERATURE_KEY[] = "temperature";
constexpr char HUMIDITY_KEY[] = "humidity";
constexpr char LATITUDE_KEY[] PROGMEM = "latitude";
constexpr char LONGITUDE_KEY[] PROGMEM = "longitude";
#endif

// Initialize underlying client, used to establish a connection
#if ENCRYPTED
WiFiClientSecure espClient;
#else
WiFiClient espClient;
#endif
// Initalize the Mqtt client instance
Arduino_MQTT_Client mqttClient(espClient);
// Initialize ThingsBoard instance with the maximum needed buffer size
#if USING_HTTPS
ThingsBoardHttp tb(mqttClient, TOKEN, THINGSBOARD_SERVER, THINGSBOARD_PORT);
#else
ThingsBoard tb(mqttClient, MAX_MESSAGE_SIZE);
#endif

// DHT object
DHTesp dht;
// ESP32 pin used to query DHT22
#define DHT_PIN 23

// Timer to send
elapsedMillis timeElapsed;
const int SENSOR_READ_CYCLE_TIME = 10000;

// GPS data
GPSReader gpsReader;

/// @brief Initalizes WiFi connection,
// will endlessly delay until a connection has been successfully established
void InitWiFi()
{
#if THINGSBOARD_ENABLE_PROGMEM
  Serial.println(F("Connecting to AP DonskyTech ..."));
#else
  Serial.println("Connecting to AP ...");
#endif
  // Attempting to establish a connection to the given WiFi network
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.println("Attempting ...");
    // Delay 500ms until a connection has been successfully established
    delay(500);
#if THINGSBOARD_ENABLE_PROGMEM
    Serial.print(F("."));
#else
    Serial.print(".");
#endif
  }
#if THINGSBOARD_ENABLE_PROGMEM
  Serial.println(F("Connected to AP"));
#else
  Serial.println("Connected to AP");
#endif
#if ENCRYPTED
  espClient.setCACert(ROOT_CERT);
#endif

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

/// @brief Reconnects the WiFi uses InitWiFi if the connection has been removed
/// @return Returns true as soon as a connection has been established again
bool reconnect()
{
  // Check to ensure we aren't connected yet
  const wl_status_t status = WiFi.status();
  if (status == WL_CONNECTED)
  {
    return true;
  }

  // If we aren't establish a new connection to the given WiFi network
  InitWiFi();
  return true;
}

void setup()
{
  // If analog input pin 0 is unconnected, random analog
  // noise will cause the call to randomSeed() to generate
  // different seed numbers each time the sketch runs.
  // randomSeed() will then shuffle the random function.
  randomSeed(analogRead(0));
  // Initalize serial connection for debugging
  Serial.begin(SERIAL_DEBUG_BAUD);
  delay(1000);
  InitWiFi();

  dht.setup(DHT_PIN, DHTesp::DHT22);
}

void loop()
{
  delay(10000);

  if (!reconnect())
  {
    return;
  }

#if !USING_HTTPS
  Serial.println("Start connecting to Thingsboard Server");
  if (!tb.connected())
  {
    Serial.println("Not connected to Thingsboard Server");
    // Reconnect to the ThingsBoard server,
    // if a connection was disrupted or has not yet been established
    Serial.printf("Connecting to: (%s) with token (%s)\n", THINGSBOARD_SERVER, TOKEN);
    if (!tb.connect(THINGSBOARD_SERVER, TOKEN, THINGSBOARD_PORT))
    {
#if THINGSBOARD_ENABLE_PROGMEM
      Serial.println(F("Failed to connect"));
#else
      Serial.println("Failed to connect");
#endif
      return;
    }
  }
#endif

  // Uploads new telemetry to ThingsBoard using HTTP.
  // See https://thingsboard.io/docs/reference/http-api/#telemetry-upload-api
  // for more details
  if (timeElapsed > SENSOR_READ_CYCLE_TIME)
  {
    timeElapsed = 0;
    // Read GPS Location
    GPSCoordinates coordinates = gpsReader.getGPSLocation();
    if (coordinates.isGPSSensorActive)
    {
      Serial.print("Latitude ");
      Serial.println(coordinates.latitude);
      Serial.print("Longitude ");
      Serial.println(coordinates.longitude);
      tb.sendTelemetryData(LATITUDE_KEY, coordinates.latitude);
      tb.sendTelemetryData(LONGITUDE_KEY, coordinates.longitude);
    }
    else
    {
      Serial.println("GPS Sensor is not active...");
    }

    // Read DHT Temperature and Humidity
    TempAndHumidity lastValues = dht.getTempAndHumidity();
    if (isnan(lastValues.humidity) || isnan(lastValues.temperature))
    {
      Serial.println("Failed to read from DHT sensor!");
      return;
    }
    else
    {
      Serial.print("Temperature: ");
      Serial.println(lastValues.temperature);
      Serial.print("Humidity: ");
      Serial.println(lastValues.humidity);
      tb.sendTelemetryData(TEMPERATURE_KEY, lastValues.temperature);
      tb.sendTelemetryData(HUMIDITY_KEY, lastValues.humidity);
    }
  }

#if !USING_HTTPS
  tb.loop();
#endif
}
MathewHDYT commented 10 months ago

The Arduino_MQTT_Client.h also includes the Configuration.h file. Therefore the #define calls have to be above that include as well which is not the case currenlly. Therefore adjust your includes like shown below:

#define THINGSBOARD_USE_ESP_TIMER 0
#define THINGSBOARD_USE_ESP_MQTT 0
#define THINGSBOARD_USE_MBED_TLS 0
#define THINGSBOARD_USE_ESP_PARTITION 0

#include <Arduino_MQTT_Client.h>
#if USING_HTTPS
#include <ThingsBoardHttp.h>
#else
#include <ThingsBoard.h>
#endif
donskytech commented 10 months ago

I modified my code to look like this

#ifdef ESP8266
#include <ESP8266WiFi.h>
// Disable PROGMEM because the ESP8266WiFi library,
// does not support flash strings.
#define THINGSBOARD_ENABLE_PROGMEM 0
#else
#ifdef ESP32
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include "Update.h"
#endif // ESP32
#endif // ESP8266
#include <DHTesp.h>
#include <elapsedMillis.h>
#include "GPS_API.h"

// Sending data can either be done over MQTT and the PubSubClient
// or HTTPS and the HTTPClient, when using the ESP32 or ESP8266
#define USING_HTTPS false

// Whether the given script is using encryption or not,
// generally recommended as it increases security (communication with the server is not in clear text anymore),
// it does come with an overhead tough as having an encrypted session requires a lot of memory,
// which might not be avaialable on lower end devices.
#define ENCRYPTED false

// Enables sending messages that are bigger than the predefined message size,
// where the message will be sent byte by byte as a fallback instead.
// Requires an additional library, see https://github.com/bblanchon/ArduinoStreamUtils for more information.
#define THINGSBOARD_ENABLE_STREAM_UTILS 0

#define THINGSBOARD_USE_ESP_TIMER 0
#define THINGSBOARD_USE_ESP_MQTT 0
#define THINGSBOARD_USE_MBED_TLS 0
#define THINGSBOARD_USE_ESP_PARTITION 0

#include <Arduino_MQTT_Client.h>
#if USING_HTTPS
#include <ThingsBoardHttp.h>
#else
#include <ThingsBoard.h>
#endif

// PROGMEM can only be added when using the ESP32 WiFiClient,
// will cause a crash if using the ESP8266WiFiSTAClass instead.
#if THINGSBOARD_ENABLE_PROGMEM
constexpr char PROGMEM WIFI_SSID[] = "<WIFI_SSID>";
constexpr char WIFI_PASSWORD[] PROGMEM = "<WIFI_PASSWORD>";
#else
constexpr char WIFI_SSID[] = "<WIFI_SSID>";
constexpr char WIFI_PASSWORD[] = "<WIFI_PASSWORD>";
#endif

// See https://thingsboard.io/docs/getting-started-guides/helloworld/
// to understand how to obtain an access token
#if THINGSBOARD_ENABLE_PROGMEM
constexpr char TOKEN[] PROGMEM = "L6YRs1LQWZU2QXUHAno8";
#else
constexpr char TOKEN[] = "L6YRs1LQWZU2QXUHAno8";
#endif

// Thingsboard we want to establish a connection too
#if THINGSBOARD_ENABLE_PROGMEM
constexpr char THINGSBOARD_SERVER[] PROGMEM = "thingsboard.cloud";
#else
constexpr char THINGSBOARD_SERVER[] = "thingsboard.cloud";
#endif

#if USING_HTTPS
// HTTP port used to communicate with the server, 80 is the default unencrypted HTTP port,
// whereas 443 would be the default encrypted SSL HTTPS port
#if ENCRYPTED
#if THINGSBOARD_ENABLE_PROGMEM
constexpr uint16_t THINGSBOARD_PORT PROGMEM = 443U;
#else
constexpr uint16_t THINGSBOARD_PORT = 443U;
#endif
#else
#if THINGSBOARD_ENABLE_PROGMEM
constexpr uint16_t THINGSBOARD_PORT PROGMEM = 80U;
#else
constexpr uint16_t THINGSBOARD_PORT = 80U;
#endif
#endif
#else
// MQTT port used to communicate with the server, 1883 is the default unencrypted MQTT port,
// whereas 8883 would be the default encrypted SSL MQTT port
#if ENCRYPTED
#if THINGSBOARD_ENABLE_PROGMEM
constexpr uint16_t THINGSBOARD_PORT PROGMEM = 8883U;
#else
constexpr uint16_t THINGSBOARD_PORT = 8883U;
#endif
#else
#if THINGSBOARD_ENABLE_PROGMEM
constexpr uint16_t THINGSBOARD_PORT PROGMEM = 1883U;
#else
constexpr uint16_t THINGSBOARD_PORT = 1883U;
#endif
#endif
#endif

// Maximum size packets will ever be sent or received by the underlying MQTT client,
// if the size is to small messages might not be sent or received messages will be discarded
#if THINGSBOARD_ENABLE_PROGMEM
constexpr uint16_t MAX_MESSAGE_SIZE PROGMEM = 128U;
#else
constexpr uint16_t MAX_MESSAGE_SIZE = 128U;
#endif

// Baud rate for the debugging serial connection
// If the Serial output is mangled, ensure to change the monitor speed accordingly to this variable
#if THINGSBOARD_ENABLE_PROGMEM
constexpr uint32_t SERIAL_DEBUG_BAUD PROGMEM = 115200U;
#else
constexpr uint32_t SERIAL_DEBUG_BAUD = 115200U;
#endif

#if ENCRYPTED
// See https://comodosslstore.com/resources/what-is-a-root-ca-certificate-and-how-do-i-download-it/
// on how to get the root certificate of the server we want to communicate with,
// this is needed to establish a secure connection and changes depending on the website.
#if THINGSBOARD_ENABLE_PROGMEM
constexpr char ROOT_CERT[] PROGMEM = R"(-----BEGIN CERTIFICATE-----
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC
B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv
KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWn
OlFuhjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTn
jh8BCNAw1FtxNrQHusEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbw
qHyGO0aoSCqI3Haadr8faqU9GY/rOPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CI
rU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY9umbbjANBgkq
hkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ
3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK
NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5
ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur
TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC
jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc
oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
-----END CERTIFICATE-----
)";
#else
constexpr char ROOT_CERT[] = R"(-----BEGIN CERTIFICATE-----
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC
B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv
KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWn
OlFuhjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTn
jh8BCNAw1FtxNrQHusEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbw
qHyGO0aoSCqI3Haadr8faqU9GY/rOPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CI
rU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY9umbbjANBgkq
hkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ
3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK
NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5
ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur
TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC
jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc
oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
-----END CERTIFICATE-----
)";
#endif
#endif

#if THINGSBOARD_ENABLE_PROGMEM
constexpr char TEMPERATURE_KEY[] PROGMEM = "temperature";
constexpr char HUMIDITY_KEY[] PROGMEM = "humidity";
constexpr char LATITUDE_KEY[] PROGMEM = "latitude";
constexpr char LONGITUDE_KEY[] PROGMEM = "longitude";
#else
constexpr char TEMPERATURE_KEY[] = "temperature";
constexpr char HUMIDITY_KEY[] = "humidity";
constexpr char LATITUDE_KEY[] PROGMEM = "latitude";
constexpr char LONGITUDE_KEY[] PROGMEM = "longitude";
#endif

// Initialize underlying client, used to establish a connection
#if ENCRYPTED
WiFiClientSecure espClient;
#else
WiFiClient espClient;
#endif
// Initalize the Mqtt client instance
Arduino_MQTT_Client mqttClient(espClient);
// Initialize ThingsBoard instance with the maximum needed buffer size
#if USING_HTTPS
ThingsBoardHttp tb(mqttClient, TOKEN, THINGSBOARD_SERVER, THINGSBOARD_PORT);
#else
ThingsBoard tb(mqttClient, MAX_MESSAGE_SIZE);
#endif

// DHT object
DHTesp dht;
// ESP32 pin used to query DHT22
#define DHT_PIN 23

// Timer to send
elapsedMillis timeElapsed;
const int SENSOR_READ_CYCLE_TIME = 10000;

// GPS data
GPSReader gpsReader;

/// @brief Initalizes WiFi connection,
// will endlessly delay until a connection has been successfully established
void InitWiFi()
{
#if THINGSBOARD_ENABLE_PROGMEM
  Serial.println(F("Connecting to AP DonskyTech ..."));
#else
  Serial.println("Connecting to AP ...");
#endif
  // Attempting to establish a connection to the given WiFi network
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.println("Attempting ...");
    // Delay 500ms until a connection has been successfully established
    delay(500);
#if THINGSBOARD_ENABLE_PROGMEM
    Serial.print(F("."));
#else
    Serial.print(".");
#endif
  }
#if THINGSBOARD_ENABLE_PROGMEM
  Serial.println(F("Connected to AP"));
#else
  Serial.println("Connected to AP");
#endif
#if ENCRYPTED
  espClient.setCACert(ROOT_CERT);
#endif

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

/// @brief Reconnects the WiFi uses InitWiFi if the connection has been removed
/// @return Returns true as soon as a connection has been established again
bool reconnect()
{
  // Check to ensure we aren't connected yet
  const wl_status_t status = WiFi.status();
  if (status == WL_CONNECTED)
  {
    return true;
  }

  // If we aren't establish a new connection to the given WiFi network
  InitWiFi();
  return true;
}

void setup()
{
  // If analog input pin 0 is unconnected, random analog
  // noise will cause the call to randomSeed() to generate
  // different seed numbers each time the sketch runs.
  // randomSeed() will then shuffle the random function.
  randomSeed(analogRead(0));
  // Initalize serial connection for debugging
  Serial.begin(SERIAL_DEBUG_BAUD);
  delay(1000);
  InitWiFi();

  dht.setup(DHT_PIN, DHTesp::DHT22);
}

void loop()
{
  delay(10000);

  if (!reconnect())
  {
    return;
  }

#if !USING_HTTPS
  Serial.println("Start connecting to Thingsboard Server");
  if (!tb.connected())
  {
    Serial.println("Not connected to Thingsboard Server");
    // Reconnect to the ThingsBoard server,
    // if a connection was disrupted or has not yet been established
    Serial.printf("Connecting to: (%s) with token (%s)\n", THINGSBOARD_SERVER, TOKEN);
    if (!tb.connect(THINGSBOARD_SERVER, TOKEN, THINGSBOARD_PORT))
    {
#if THINGSBOARD_ENABLE_PROGMEM
      Serial.println(F("Failed to connect"));
#else
      Serial.println("Failed to connect");
#endif
      return;
    }
  }
#endif

  // Uploads new telemetry to ThingsBoard using HTTP.
  // See https://thingsboard.io/docs/reference/http-api/#telemetry-upload-api
  // for more details
  if (timeElapsed > SENSOR_READ_CYCLE_TIME)
  {
    timeElapsed = 0;
    // Read GPS Location
    GPSCoordinates coordinates = gpsReader.getGPSLocation();
    if (coordinates.isGPSSensorActive)
    {
      Serial.print("Latitude ");
      Serial.println(coordinates.latitude);
      Serial.print("Longitude ");
      Serial.println(coordinates.longitude);
      tb.sendTelemetryData(LATITUDE_KEY, coordinates.latitude);
      tb.sendTelemetryData(LONGITUDE_KEY, coordinates.longitude);
    }
    else
    {
      Serial.println("GPS Sensor is not active...");
    }

    // Read DHT Temperature and Humidity
    TempAndHumidity lastValues = dht.getTempAndHumidity();
    if (isnan(lastValues.humidity) || isnan(lastValues.temperature))
    {
      Serial.println("Failed to read from DHT sensor!");
      return;
    }
    else
    {
      Serial.print("Temperature: ");
      Serial.println(lastValues.temperature);
      Serial.print("Humidity: ");
      Serial.println(lastValues.humidity);
      tb.sendTelemetryData(TEMPERATURE_KEY, lastValues.temperature);
      tb.sendTelemetryData(HUMIDITY_KEY, lastValues.humidity);
    }
  }

#if !USING_HTTPS
  tb.loop();
#endif
}

Run a Full Clean and Build Task. Still getting errors.

 *  Executing task: C:\Users\DONSKY\.platformio\penv\Scripts\platformio.exe run --environment esp32dev 

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------Library Manager: Installing thingsboard/pubsubclient @ ^2.9.3
Library Manager: Warning! Could not install `{'owner': 'thingsboard', 'name': 'pubsubclient', 'version': '^2.9.3'}` dependency for the`ThingsBoard` package
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (3.5.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.10006.210326 (1.0.6)
 - tool-esptoolpy @ 1.30100.210531 (3.1.0)
 - toolchain-xtensa32 @ 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 37 compatible libraries
Scanning dependencies...
Dependency Graph
|-- TinyGPSPlus @ 1.0.3
|-- ArduinoJson @ 6.21.4
|-- ThingsBoard @ 0.12.2
|-- TBPubSubClient @ 2.9.3
|-- DHT sensor library for ESPx @ 1.19.0
|-- elapsedMillis @ 1.0.6
|-- Seeed_Arduino_mbedtls @ 3.0.1+sha.6e87101
|-- StreamUtils @ 1.8.0+sha.03fafbb
|-- Update @ 1.0
|-- WiFi @ 1.0
|-- WiFiClientSecure @ 1.0
Building in release mode
Compiling .pio\build\esp32dev\src\GPS_API.cpp.o
Compiling .pio\build\esp32dev\src\main.cpp.o
Generating partitions .pio\build\esp32dev\partitions.bin
Compiling .pio\build\esp32dev\liba9f\TinyGPSPlus\TinyGPS++.cpp.o
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\HttpClient.cpp.o
Archiving .pio\build\esp32dev\liba9f\libTinyGPSPlus.a
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\URLEncoder.cpp.o
Indexing .pio\build\esp32dev\liba9f\libTinyGPSPlus.a
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\WebSocketClient.cpp.o
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\b64.cpp.o
Compiling .pio\build\esp32dev\lib773\TBPubSubClient\PubSubClient.cpp.o
Archiving .pio\build\esp32dev\libf50\libArduinoHttpClient.a
Compiling .pio\build\esp32dev\lib41c\EEPROM\EEPROM.cpp.o
Indexing .pio\build\esp32dev\libf50\libArduinoHttpClient.a
Compiling .pio\build\esp32dev\lib39f\Ticker\Ticker.cpp.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\aes.c.o
Archiving .pio\build\esp32dev\lib773\libTBPubSubClient.a
Archiving .pio\build\esp32dev\lib39f\libTicker.a
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\aesni.c.o
Indexing .pio\build\esp32dev\lib39f\libTicker.a
Indexing .pio\build\esp32dev\lib773\libTBPubSubClient.a
Archiving .pio\build\esp32dev\lib41c\libEEPROM.a
Indexing .pio\build\esp32dev\lib41c\libEEPROM.a
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\arc4.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\aria.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\asn1parse.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\asn1write.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\base64.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\bignum.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\blowfish.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\camellia.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ccm.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\certs.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\chacha20.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\chachapoly.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\cipher.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\cipher_wrap.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\cmac.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ctr_drbg.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\debug.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\des.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\dhm.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecdh.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecdsa.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecjpake.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecp.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecp_curves.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\entropy.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\error.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\gcm.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\havege.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\hkdf.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\hmac_drbg.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md2.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md4.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md5.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md_wrap.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\memory_buffer_alloc.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\nist_kw.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\oid.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\padlock.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pem.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pk.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pk_wrap.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkcs11.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkcs12.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkcs5.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkparse.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkwrite.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\platform.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\platform_util.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\poly1305.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ripemd160.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\rsa.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\rsa_internal.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\sha1.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\sha256.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\sha512.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_cache.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_ciphersuites.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_cli.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_cookie.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_srv.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_ticket.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_tls.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\threading.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\version.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\version_features.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509_create.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509_crl.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509_crt.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509_csr.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509write_crt.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509write_csr.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\xtea.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\port\esp_hardware.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\port\esp_mem.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\port\mbedtls_debug.c.o
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c: In function 'mbedtls_esp_enable_debug_log':
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c:33:19: warning: variable 'level' set but not used [-Wunused-but-set-variable]
     unsigned char level = 0;
                   ^
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c: In function 'mbedtls_esp_debug':
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c:68:9: warning: implicit declaration of function 'xprintf' [-Wimplicit-function-declaration]
         xprintf("%s:%d %s\r\n", file, line, str);
         ^
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c:83:9: warning: implicit declaration of function 'ESP_LOGE' [-Wimplicit-function-declaration]
         ESP_LOGE(TAG, "Unexpected log level %d: %s", level, str);
         ^
Compiling .pio\build\esp32dev\lib9e5\Update\HttpsOTAUpdate.cpp.o
Archiving .pio\build\esp32dev\lib348\libSeeed_Arduino_mbedtls.a
Compiling .pio\build\esp32dev\lib9e5\Update\Updater.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Arduino_ESP32_Updater.cpp.o
Indexing .pio\build\esp32dev\lib348\libSeeed_Arduino_mbedtls.a
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Arduino_ESP8266_Updater.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Arduino_HTTP_Client.cpp.o
Archiving .pio\build\esp32dev\lib9e5\libUpdate.a
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Arduino_MQTT_Client.cpp.o
Indexing .pio\build\esp32dev\lib9e5\libUpdate.a
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Attribute_Request_Callback.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Callback_Watchdog.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Espressif_MQTT_Client.cpp.o
.pio\libdeps\esp32dev\ThingsBoard\src\Callback_Watchdog.cpp: In member function 'void Callback_Watchdog::create_timer()':
.pio\libdeps\esp32dev\ThingsBoard\src\Callback_Watchdog.cpp:76:5: error: 'const esp_timer_create_args_t' has no non-static data member named 'skip_unhandled_events'
     };
     ^
*** [.pio\build\esp32dev\liba78\ThingsBoard\Callback_Watchdog.cpp.o] Error 1
.pio\libdeps\esp32dev\ThingsBoard\src\Espressif_MQTT_Client.cpp: In member function 'virtual bool Espressif_MQTT_Client::publish(const char*, const uint8_t*, const size_t&)':
.pio\libdeps\esp32dev\ThingsBoard\src\Espressif_MQTT_Client.cpp:215:128: error: 'esp_mqtt_client_enqueue' was not declared in this scope
         message_id = esp_mqtt_client_enqueue(m_mqtt_client, topic, reinterpret_cast<const char*>(payload), length, 0U, 0U, true);

      ^
*** [.pio\build\esp32dev\liba78\ThingsBoard\Espressif_MQTT_Client.cpp.o] Error 1
============================================== [FAILED] Took 42.51 seconds ==============================================

 *  The terminal process "C:\Users\DONSKY\.platformio\penv\Scripts\platformio.exe 'run', '--environment', 'esp32dev'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 
MathewHDYT commented 10 months ago

Can you check the value of the define flags after the includes, because they should still be 0. Simply add this code and then hover over the specific lines, they should all show a value of 0.

#define THINGSBOARD_USE_ESP_TIMER 0
#define THINGSBOARD_USE_ESP_MQTT 0
#define THINGSBOARD_USE_MBED_TLS 0
#define THINGSBOARD_USE_ESP_PARTITION 0

#include <Arduino_MQTT_Client.h>
#if USING_HTTPS
#include <ThingsBoardHttp.h>
#else
#include <ThingsBoard.h>
#endif

// Hover over these values should all show 0.
int constexpr USE_ESP_TIMER = THINGSBOARD_USE_ESP_TIMER;
int constexpr USE_ESP_MQTT = THINGSBOARD_USE_ESP_MQTT;
int constexpr USE_MBED_TLS = THINGSBOARD_USE_MBED_TLS;
int constexpr USE_ESP_PARTITION = THINGSBOARD_USE_ESP_PARTITION;
donskytech commented 10 months ago

Here you go... they are all Zero(0)

image

MathewHDYT commented 10 months ago

That's weird because if they are 0 they should the aforementioned errors should not appear because that code is not compiled....

VsCode might show it as well. If you open Espressif_MQTT_Client.h is the code shown or is it greyed out?

donskytech commented 10 months ago

Here is the complete screenshot. image

MathewHDYT commented 10 months ago

I meant the file in the lib/ThingsBoard/src folder. There should be an Espressif_MQTT_Client.h, can you attach a screenshot of that. Sorry for the inconviences.

donskytech commented 10 months ago

I meant the file in the lib/ThingsBoard/src folder. There should be an Espressif_MQTT_Client.h, can you attach a screenshot of that. Sorry for the inconviences.

There is nothing in lib folder but in libdeps\esp32dev there is image

MathewHDYT commented 10 months ago

Ah sorry the folder you got was correct. But yeah looks bad the value here should be 0 and therefore all the code inside this file should be greyed out. Which it isn't ...

As a workaround can you simply replace #if THINGSBOARD_USE_ESP_MQTT with #if false and do the same in the EspressifMQTT.cpp.

Additionally in the Callback_Watchdog.h file replace #if THINGSBOARD_USE_ESP_TIMER with #if false and do the same for Callback_Watchdog.cpp


If that fixes the issue. I will add an additional check in the library to ensure the underlying Espressif components are compatible in the next release.

donskytech commented 10 months ago

New error pops up

Library Manager: Installing thingsboard/pubsubclient @ ^2.9.3
Library Manager: Warning! Could not install `{'owner': 'thingsboard', 'name': 'pubsubclient', 'version': '^2.9.3'}` dependency for the`ThingsBoard` package
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (3.5.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.10006.210326 (1.0.6)
 - tool-esptoolpy @ 1.30100.210531 (3.1.0) 
 - toolchain-xtensa32 @ 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 37 compatible libraries
Scanning dependencies...
Dependency Graph
|-- TinyGPSPlus @ 1.0.3
|-- ArduinoJson @ 6.21.4
|-- ThingsBoard @ 0.12.2
|-- TBPubSubClient @ 2.9.3
|-- DHT sensor library for ESPx @ 1.19.0
|-- elapsedMillis @ 1.0.6
|-- Seeed_Arduino_mbedtls @ 3.0.1+sha.6e87101
|-- StreamUtils @ 1.8.0+sha.03fafbb
|-- Update @ 1.0
|-- WiFi @ 1.0
|-- WiFiClientSecure @ 1.0
Building in release mode
Compiling .pio\build\esp32dev\src\GPS_API.cpp.o
Compiling .pio\build\esp32dev\src\main.cpp.o
Generating partitions .pio\build\esp32dev\partitions.bin
Compiling .pio\build\esp32dev\liba9f\TinyGPSPlus\TinyGPS++.cpp.o
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\HttpClient.cpp.o
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\URLEncoder.cpp.o
Archiving .pio\build\esp32dev\liba9f\libTinyGPSPlus.a
Indexing .pio\build\esp32dev\liba9f\libTinyGPSPlus.a
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\WebSocketClient.cpp.o
Compiling .pio\build\esp32dev\libf50\ArduinoHttpClient\b64.cpp.o
Compiling .pio\build\esp32dev\lib773\TBPubSubClient\PubSubClient.cpp.o
Compiling .pio\build\esp32dev\lib41c\EEPROM\EEPROM.cpp.o
Archiving .pio\build\esp32dev\libf50\libArduinoHttpClient.a
Indexing .pio\build\esp32dev\libf50\libArduinoHttpClient.a
Compiling .pio\build\esp32dev\lib39f\Ticker\Ticker.cpp.o
Archiving .pio\build\esp32dev\lib773\libTBPubSubClient.a
Archiving .pio\build\esp32dev\lib39f\libTicker.a
Indexing .pio\build\esp32dev\lib773\libTBPubSubClient.a
Indexing .pio\build\esp32dev\lib39f\libTicker.a
Archiving .pio\build\esp32dev\lib41c\libEEPROM.a
Indexing .pio\build\esp32dev\lib41c\libEEPROM.a
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\aes.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\aesni.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\arc4.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\aria.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\asn1parse.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\asn1write.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\base64.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\bignum.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\blowfish.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\camellia.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ccm.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\certs.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\chacha20.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\chachapoly.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\cipher.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\cipher_wrap.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\cmac.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ctr_drbg.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\debug.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\des.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\dhm.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecdh.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecdsa.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecjpake.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecp.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ecp_curves.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\entropy.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\error.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\gcm.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\havege.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\hkdf.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\hmac_drbg.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md2.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md4.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md5.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\md_wrap.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\memory_buffer_alloc.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\nist_kw.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\oid.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\padlock.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pem.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pk.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pk_wrap.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkcs11.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkcs12.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkcs5.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkparse.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\pkwrite.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\platform.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\platform_util.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\poly1305.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ripemd160.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\rsa.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\rsa_internal.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\sha1.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\sha256.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\sha512.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_cache.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_ciphersuites.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_cli.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_cookie.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_srv.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_ticket.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\ssl_tls.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\threading.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\version.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\version_features.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509_create.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509_crl.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509_crt.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509_csr.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509write_crt.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\x509write_csr.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\library\xtea.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\port\esp_hardware.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\port\esp_mem.c.o
Compiling .pio\build\esp32dev\lib348\Seeed_Arduino_mbedtls\port\mbedtls_debug.c.o
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c: In function 'mbedtls_esp_enable_debug_log':
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c:33:19: warning: variable 'level' set but not used [-Wunused-but-set-variable]
     unsigned char level = 0;
                   ^
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c: In function 'mbedtls_esp_debug':       
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c:68:9: warning: implicit declaration of function 'xprintf' [-Wimplicit-function-declaration]
         xprintf("%s:%d %s\r\n", file, line, str);
         ^
.pio\libdeps\esp32dev\Seeed_Arduino_mbedtls\src\port\mbedtls_debug.c:83:9: warning: implicit declaration of function 'ESP_LOGE' [-Wimplicit-function-declaration]
         ESP_LOGE(TAG, "Unexpected log level %d: %s", level, str);
         ^
Compiling .pio\build\esp32dev\lib9e5\Update\HttpsOTAUpdate.cpp.o
Archiving .pio\build\esp32dev\lib348\libSeeed_Arduino_mbedtls.a
Compiling .pio\build\esp32dev\lib9e5\Update\Updater.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Arduino_ESP32_Updater.cpp.o
Indexing .pio\build\esp32dev\lib348\libSeeed_Arduino_mbedtls.a
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Arduino_ESP8266_Updater.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Arduino_HTTP_Client.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Arduino_MQTT_Client.cpp.o
Archiving .pio\build\esp32dev\lib9e5\libUpdate.a
Indexing .pio\build\esp32dev\lib9e5\libUpdate.a
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Attribute_Request_Callback.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Callback_Watchdog.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Espressif_MQTT_Client.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\Espressif_Updater.cpp.o
Compiling .pio\build\esp32dev\liba78\ThingsBoard\HashGenerator.cpp.o
.pio\libdeps\esp32dev\ThingsBoard\src\Espressif_Updater.cpp: In member function 'virtual void Espressif_Updater::reset()':
.pio\libdeps\esp32dev\ThingsBoard\src\Espressif_Updater.cpp:55:37: error: 'esp_ota_abort' was not declared in this scope
     (void)esp_ota_abort(m_ota_handle);
                                     ^
*** [.pio\build\esp32dev\liba78\ThingsBoard\Espressif_Updater.cpp.o] Error 1
======================================== [FAILED] Took 34.25 seconds ========================================
 *  The terminal process "C:\Users\DONSKY\.platformio\penv\Scripts\platformio.exe 'run', '--environment', 'esp32dev'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

Espressif_MQTT_Client.h

#ifndef Espressif_MQTT_Client_h
#define Espressif_MQTT_Client_h

// Local include.
#include "Configuration.h"

#if false

// Local includes.
#include "IMQTT_Client.h"

// Library includes.
#include <mqtt_client.h>

/// @brief MQTT Client interface implementation that uses the offical ESP MQTT client from Espressif (https://github.com/espressif/esp-mqtt),
/// under the hood to establish and communicate over a MQTT connection. This component works with both Espressif IDF v4.X and v5.X, meaning it is version idependent, this is the case
/// because depending on the used version the implementation automatically adjusts to still initalize the client correctly.
/// Documentation about the specific use and caviates of the ESP MQTT client can be found here https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/protocols/mqtt.html
class Espressif_MQTT_Client : public IMQTT_Client {
  public:
    /// @brief Constructs a IMQTT_Client implementation which creates and empty esp_mqtt_client_config_t, which then has to be configured with the other methods in the class
    Espressif_MQTT_Client();

    /// @brief Destructor
    ~Espressif_MQTT_Client();

    /// @brief Configured the server certificate, which allows to connect to the MQTT broker over a secure TLS / SSL conenction instead of the default unencrypted channel.
    /// Has to be called before initally calling connect() on the client to ensure the certificate is set before the connection is established, if that is not done the connection will not be encrypted.
    /// Encryption is recommended if relevant data is sent or if the client receives and handles Remote Procedure Calls or Shared Attribute Update Callbacks from the server,
    /// because using an unencrpyted connection, will allow 3rd parties to listen to the communication and impersonate the server sending payloads which might influence the device in unexpected ways.
    /// However if Over the Air udpates are enabled secure communication should definetly be enabled, because if that is not done a 3rd party might impersonate the server sending a malicious payload,
    /// which is then flashed onto the device instead of the real firmware. Which depeding on the payload might even be able to destroy the device or make it otherwise unusable.
    /// See https://stackoverflow.blog/2020/12/14/security-considerations-for-ota-software-updates-for-iot-gateway-devices/ for more information on the aforementioned security risk
    /// @param server_certificate_pem Null-terminated string containg the root certificate in PEM format, of the server we are attempting to send to and receive MQTT data from
    /// @return Whether chaing the internal server certificate was successful or not, ensure to disconnect and reconnect to actually apply the change
    bool set_server_certificate(const char *server_certificate_pem);

    /// @brief Sets the keep alive timeout in seconds, if the value is 0 then the default of 120 seconds is used instead to disable the keep alive mechanism use set_disable_keep_alive() instead.
    /// The default timeout value ThingsBoard expectes to receive any message including a keep alive to not show the device as inactive can be found here https://thingsboard.io/docs/user-guide/install/config/#mqtt-server-parameters
    /// under the transport.sessions.inactivity_timeout section and is 300 seconds. Meaning a value bigger than 300 seconds with the default config defeats the purpose of the keep alive alltogether
    /// @param keep_alive_timeout_seconds Timeout until we send another PINGREQ control packet to the broker to establish that we are still connected
    /// @return Whether changing the internal keep alive timeout was successful or not
    bool set_keep_alive_timeout(const uint16_t& keep_alive_timeout_seconds); 

    /// @brief Whether to disable or enable the keep alive mechanism, meaning we do not send any PINGREQ control packets to the broker anymore, meaning if we do not send other packet the device will be marked as inactive.
    /// The default value is false meaning the keep alive mechanism is enabled.
    /// The default timeout value ThingsBoard expectes to receive any message including a keep alive to not show the device as inactive can be found here https://thingsboard.io/docs/user-guide/install/config/#mqtt-server-parameters
    /// under the transport.sessions.inactivity_timeout section and is 300 seconds. Meaning if we disable the keep alive mechanism and do not send another packet atleast every 300 seconds with the default config
    /// then the device will change states between active and inactive depending on when we send the packets
    /// @param disable_keep_alive Whether to enable or disable the internal keep alive mechanism, which sends PINGREQ control packets every keep alive timeout seconds, configurable in set_keep_alive_timeout()
    /// @return Whether enabling or disabling the internal keep alive mechanism was successful or not
    bool set_disable_keep_alive(const bool& disable_keep_alive);

    /// @brief Wheter to disable or enable that the MQTT client will reconnect to the server automatically if it errors or disconnects. The default is false meaning we will automatically reconnect
    /// @param disable_auto_reconnect Whether to automatically reconnect if the the client errors or disconnects
    /// @return Whether enabling or disabling the internal auto reconnect mechanism was successful or not
    bool set_disable_auto_reconnect(const bool& disable_auto_reconnect);

    /// @brief Sets the priority and stack size of the MQTT task running in the background, that is handling the receiving and sending of any outstanding MQTT messages to or from the broker.
    /// The default value for the priority is 5 and can also be changed in the ESP IDF menuconfig, whereas the default value for the stack size is 6144 bytes and can also be changed in the ESP IDF menuconfig
    /// @param priority Task priority with which the MQTT task should run, higher priority means it takes more precedence over other tasks, making it more important
    /// @param stack_size Task stack size meaning how much stack size the MQTT task can allocate before the device crashes with a StackOverflow, might need to be increased
    /// if the user allocates a lot of memory on the stack in a request callback method, because those functions are dispatched from the MQTT event task
    /// @return Whether changing the internal MQTT task configurations were successfull or not
    bool set_mqtt_task_configuration(const uint8_t& priority, const uint16_t& stack_size);

    /// @brief Sets the amount of time in milliseconds that we wait before we automatically reconnect to the MQTT broker if the connection has been lost. The default value is 10 seconds.
    /// Will be ignored if set_disable_auto_reconnect() has been set to true, because we will not reconnect automatically anymore, instead that would have to be done by the user themselves
    /// @param reconnect_timeout_milliseconds Time in milliseconds until we automatically reconnect to the MQTT broker
    /// @return Whether changing the internal reconnect timeout was successfull or not
    bool set_reconnect_timeout(const uint16_t& reconnect_timeout_milliseconds);

    /// @brief Sets the amount of time in millseconds that we wait until we expect a netowrk operation on the MQTT client to have successfully finished. The defalt value is 10 seconds.
    /// If that is not the case then the network operation will be aborted, might be useful to increase for devices that perform other high priority tasks and do not have enough CPU resources,
    /// to send bigger messages to the MQTT broker in time, which can cause disconnects and the sent message being discarded
    /// @param network_timeout_milliseconds Time in milliseconds that we wait until we abort the network operation if it has not completed yet
    /// @return Whether changing the internal network timeout was successfull or not
    bool set_network_timeout(const uint16_t& network_timeout_milliseconds);

    /// @brief Sets whether to enqueue published messages or not, enqueueing has to save them in the out buffer, meaning the internal buffer size might need to be increased,
    /// but the MQTT client can in exchange send the publish messages once the main MQTT task is running again, instead of blocking in the task that has called the publish method.
    /// This furthermore, allows to use nearly all internal ThingsBoard calls without having to worry about blocking the task the method was called for,
    /// or having to worry about CPU overhead.
    /// If enqueueing the messages to be published fails once this options has been enabled, then the internal buffer size might need to be increased. Ensure to call set_buffer_size() with a bigger value
    /// and check if enqueueing the messages to be published works successfully again
    /// @param enqueue_messages Whether to enqueue published messages or not, where setting the value to true means that the messages are enqueued and therefor non blocking on the called from task
    void set_enqueue_messages(const bool& enqueue_messages);

    void set_callback(function callback) override;

    bool set_buffer_size(const uint16_t& buffer_size) override;

    uint16_t get_buffer_size() override;

    void set_server(const char *domain, const uint16_t& port) override;

    bool connect(const char *client_id, const char *user_name, const char *password) override;

    void disconnect() override;

    bool loop() override;

    bool publish(const char *topic, const uint8_t *payload, const size_t& length) override;

    bool subscribe(const char *topic) override;

    bool unsubscribe(const char *topic) override;

    bool connected() override;

private:
    function m_received_data_callback;             // Callback that will be called as soon as the mqtt client receives any data
    bool m_connected;                              // Whether the client has received the connected or disconnected event
    bool m_enqueue_messages;                       // Whether we enqueue messages making nearly all ThingsBoard calls non blocking or wheter we publish instead
    esp_mqtt_client_config_t m_mqtt_configuration; // Configuration of the underlying mqtt client, saved as a private variable to allow changes after inital configuration with the same options for all non changed settings
    esp_mqtt_client_handle_t m_mqtt_client;        // Handle to the underlying mqtt client, used to establish the communication

    static Espressif_MQTT_Client *m_instance;      // Instance to the created class, will be set once the constructor has been called and reset once the destructor has been called, used to call private member method from static callback

    /// @brief Is internally used to allow changes to the underlying configuration of the esp_mqtt_client_handle_t after it has connected,
    /// to for example increase the buffer size or increase the timeouts or stack size, allows to change the underlying client configuration,
    /// without the need to completly disconnect and reconnect the client
    /// @return Whether updating the configuration with the changed settings was successfull or not
    bool update_configuration();

    /// @brief Event handler registered to receive MQTT events. Is called by the MQTT client event loop, whenever a new event occurs
    /// @param handler_args User data registered to the event
    /// @param base Event base for the handler
    /// @param event_id The id for the received event
    /// @param event_data The data for the event, esp_mqtt_event_handle_t
    void mqtt_event_handler(void *handler_args, esp_event_base_t base, const esp_mqtt_event_id_t& event_id, void *event_data);

    static void static_mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data);
};

#endif // THINGSBOARD_USE_ESP_MQTT

#endif // Espressif_MQTT_Client_h

Espressif_MQTT_Client.cpp

// Header include.
#include "Espressif_MQTT_Client.h"

#if false

// The error integer -1 means a general failure while handling the mqtt client,
// where as -2 means that the outbox is filled and the message can therefore not be sent.
// Therefore we have to check if the value is smaller or equal to the MQTT_FAILURE_MESSAGE_ID,
// to ensure other errors are indentified as well
constexpr int MQTT_FAILURE_MESSAGE_ID = -1;

Espressif_MQTT_Client *Espressif_MQTT_Client::m_instance = nullptr;

Espressif_MQTT_Client::Espressif_MQTT_Client() :
    m_received_data_callback(nullptr),
    m_connected(false),
    m_enqueue_messages(false),
    m_mqtt_configuration(),
    m_mqtt_client(nullptr)
{
    m_instance = this;
}

Espressif_MQTT_Client::~Espressif_MQTT_Client() {
    m_instance = nullptr;
    (void)esp_mqtt_client_destroy(m_mqtt_client);
}

bool Espressif_MQTT_Client::set_server_certificate(const char *server_certificate_pem) {
    // ESP_IDF_VERSION_MAJOR Version 5 is a major breaking changes were the complete esp_mqtt_client_config_t structure changed completely.
    // Because PEM format is expected for the server certificate we do not need to set the certificate_len,
    // because the PEM format expects a null-terminated string.
#if ESP_IDF_VERSION_MAJOR < 5
    m_mqtt_configuration.cert_pem = server_certificate_pem;
#else
    m_mqtt_configuration.broker.verification.certificate = server_certificate_pem;
#endif // ESP_IDF_VERSION_MAJOR < 5
    return update_configuration();
}

bool Espressif_MQTT_Client::set_keep_alive_timeout(const uint16_t& keep_alive_timeout_seconds) {
    // ESP_IDF_VERSION_MAJOR Version 5 is a major breaking changes were the complete esp_mqtt_client_config_t structure changed completely
#if ESP_IDF_VERSION_MAJOR < 5
    m_mqtt_configuration.keepalive = keep_alive_timeout_seconds;
#else
    m_mqtt_configuration.session.keepalive = keep_alive_timeout_seconds;
#endif // ESP_IDF_VERSION_MAJOR < 5
    return update_configuration();
}

bool Espressif_MQTT_Client::set_disable_keep_alive(const bool& disable_keep_alive) {
    // ESP_IDF_VERSION_MAJOR Version 5 is a major breaking changes were the complete esp_mqtt_client_config_t structure changed completely
#if ESP_IDF_VERSION_MAJOR < 5
    m_mqtt_configuration.disable_keepalive = disable_keep_alive;
#else
    m_mqtt_configuration.session.disable_keepalive = disable_keep_alive;
#endif // ESP_IDF_VERSION_MAJOR < 5
    return update_configuration();
}

bool Espressif_MQTT_Client::set_disable_auto_reconnect(const bool& disable_auto_reconnect) {
    // ESP_IDF_VERSION_MAJOR Version 5 is a major breaking changes were the complete esp_mqtt_client_config_t structure changed completely
#if ESP_IDF_VERSION_MAJOR < 5
    m_mqtt_configuration.disable_auto_reconnect = disable_auto_reconnect;
#else
    m_mqtt_configuration.network.disable_auto_reconnect = disable_auto_reconnect;
#endif // ESP_IDF_VERSION_MAJOR < 5
    return update_configuration();
}

bool Espressif_MQTT_Client::set_mqtt_task_configuration(const uint8_t& priority, const uint16_t& stack_size) {
    // ESP_IDF_VERSION_MAJOR Version 5 is a major breaking changes were the complete esp_mqtt_client_config_t structure changed completely
#if ESP_IDF_VERSION_MAJOR < 5
    m_mqtt_configuration.task_prio = priority;
    m_mqtt_configuration.task_stack = stack_size;
#else
    m_mqtt_configuration.task.priority = priority;
    m_mqtt_configuration.task.stack_size = stack_size;
#endif // ESP_IDF_VERSION_MAJOR < 5
    return update_configuration();
}

bool Espressif_MQTT_Client::set_reconnect_timeout(const uint16_t& reconnect_timeout_milliseconds) {
    // ESP_IDF_VERSION_MAJOR Version 5 is a major breaking changes were the complete esp_mqtt_client_config_t structure changed completely
#if ESP_IDF_VERSION_MAJOR < 5
    m_mqtt_configuration.reconnect_timeout_ms = reconnect_timeout_milliseconds;
#else
    m_mqtt_configuration.network.reconnect_timeout_ms = reconnect_timeout_milliseconds;
#endif // ESP_IDF_VERSION_MAJOR < 5
    return update_configuration();
}

bool Espressif_MQTT_Client::set_network_timeout(const uint16_t& network_timeout_milliseconds) {
    // ESP_IDF_VERSION_MAJOR Version 5 is a major breaking changes were the complete esp_mqtt_client_config_t structure changed completely
#if ESP_IDF_VERSION_MAJOR < 5
    m_mqtt_configuration.network_timeout_ms = network_timeout_milliseconds;
#else
    m_mqtt_configuration.network.timeout_ms = network_timeout_milliseconds;
#endif // ESP_IDF_VERSION_MAJOR < 5
    return update_configuration();
}

void Espressif_MQTT_Client::set_enqueue_messages(const bool& enqueue_messages) {
    m_enqueue_messages = enqueue_messages;
}

void Espressif_MQTT_Client::set_callback(function callback) {
    m_received_data_callback = callback;
}

bool Espressif_MQTT_Client::set_buffer_size(const uint16_t& buffer_size) {
    // ESP_IDF_VERSION_MAJOR Version 5 is a major breaking changes were the complete esp_mqtt_client_config_t structure changed completely
#if ESP_IDF_VERSION_MAJOR < 5
    m_mqtt_configuration.buffer_size = buffer_size;
#else
    m_mqtt_configuration.buffer.size = buffer_size;
#endif // ESP_IDF_VERSION_MAJOR < 5

    // Calls esp_mqtt_set_config(), which should adjust the underlying mqtt client to the changed values.
    // Which it does but not for the buffer_size, this results in the buffer size only being able to be changed when initally creating the mqtt client.
    // If the mqtt client is reinitalized this causes disconnected and reconnects tough and the connection becomes unstable.
    // Therefore this workaround can also not be used. Instead we expect the esp_mqtt_set_config(), to do what the name implies and therefore still call it
    // and created an issue revolving around the aformentioned problem so it might get fixed in future version of the esp_mqtt client.
    // See https://github.com/espressif/esp-mqtt/issues/267 for more information on the issue 
    return update_configuration();
}

uint16_t Espressif_MQTT_Client::get_buffer_size() {
    // ESP_IDF_VERSION_MAJOR Version 5 is a major breaking changes were the complete esp_mqtt_client_config_t structure changed completely
#if ESP_IDF_VERSION_MAJOR < 5
    return m_mqtt_configuration.buffer_size;
#else
    return m_mqtt_configuration.buffer.size;
#endif // ESP_IDF_VERSION_MAJOR < 5
}

void Espressif_MQTT_Client::set_server(const char *domain, const uint16_t& port) {
    // ESP_IDF_VERSION_MAJOR Version 5 is a major breaking changes were the complete esp_mqtt_client_config_t structure changed completely
#if ESP_IDF_VERSION_MAJOR < 5
    m_mqtt_configuration.host = domain;
    m_mqtt_configuration.port = port;
    // Decide transport depending on if a certificate was passed, because the set_server() method is called in the connect method meaning if the certificate has not been set yet,
    // it is to late as we attempt to establish the connection in the connect() method which is called directly after this one.
    const bool transport_over_sll = m_mqtt_configuration.cert_pem != nullptr;
#else
    m_mqtt_configuration.broker.address.hostname = domain;
    m_mqtt_configuration.broker.address.port = port;
    // Decide transport depending on if a certificate was passed, because the set_server() method is called in the connect method meaning if the certificate has not been set yet,
    // it is to late as we attempt to establish the connection in the connect() method which is called directly after this one.
    const bool transport_over_sll = m_mqtt_configuration.broker.verification.certificate != nullptr;
#endif // ESP_IDF_VERSION_MAJOR < 5

    const esp_mqtt_transport_t transport = (transport_over_sll ? esp_mqtt_transport_t::MQTT_TRANSPORT_OVER_SSL : esp_mqtt_transport_t::MQTT_TRANSPORT_OVER_TCP);

    // ESP_IDF_VERSION_MAJOR Version 5 is a major breaking changes were the complete esp_mqtt_client_config_t structure changed completely
#if ESP_IDF_VERSION_MAJOR < 5
    m_mqtt_configuration.transport = transport;
#else
    m_mqtt_configuration.broker.address.transport = transport;
#endif // ESP_IDF_VERSION_MAJOR < 5
}

bool Espressif_MQTT_Client::connect(const char *client_id, const char *user_name, const char *password) {
    // ESP_IDF_VERSION_MAJOR Version 5 is a major breaking changes were the complete esp_mqtt_client_config_t structure changed completely
#if ESP_IDF_VERSION_MAJOR < 5
    m_mqtt_configuration.client_id = client_id;
    m_mqtt_configuration.username = user_name;
    m_mqtt_configuration.password = password;
#else
    m_mqtt_configuration.credentials.client_id = client_id;
    m_mqtt_configuration.credentials.username = user_name;
    m_mqtt_configuration.credentials.authentication.password = password;
#endif // ESP_IDF_VERSION_MAJOR < 5
    // Update configuration is called to ensure that if we connected previously and call connect again with other credentials,
    // then we also update the client_id, username and password we connect with. Especially important for the provisioning workflow to work correctly
    update_configuration();

    // Check wheter the client has been initalzed before already, it it has we do not want to reinitalize,
    // but simply force reconnection with the client because it has lost that connection
    if (m_mqtt_client != nullptr) {
        const esp_err_t error = esp_mqtt_client_reconnect(m_mqtt_client);
        return error == ESP_OK;
    }

    // The client is first initalized once the connect has actually been called, this is done because the passed setting are required for the client inizialitation structure,
    // additionally before we attempt to connect with the client we have to ensure it is configued by then.
    m_mqtt_client = esp_mqtt_client_init(&m_mqtt_configuration);

    // The last argument may be used to pass data to the event handler, here that would be the static_mqtt_event_handler. But for our use case this is not needed,
    // because the static_mqtt_event_handler calls a private method on this class again anyway, meaning we already have access to all private member variables that are required
    esp_err_t error = esp_mqtt_client_register_event(m_mqtt_client, esp_mqtt_event_id_t::MQTT_EVENT_ANY, Espressif_MQTT_Client::static_mqtt_event_handler, nullptr);

    if (error != ESP_OK) {
        return false;
    }

    error = esp_mqtt_client_start(m_mqtt_client);
    return error == ESP_OK;
}

void Espressif_MQTT_Client::disconnect() {
    (void)esp_mqtt_client_disconnect(m_mqtt_client);
}

bool Espressif_MQTT_Client::loop() {
    // Unused because the esp mqtt client uses its own task to handle receiving and sending of data, therefore we do not need to do anything in the loop method.
    // Because the loop method is meant for clients that do not have their own process method but instead rely on the upper level code calling a loop method to provide processsing time.
    return m_connected;
}

bool Espressif_MQTT_Client::publish(const char *topic, const uint8_t *payload, const size_t& length) {
    int message_id = MQTT_FAILURE_MESSAGE_ID;

    if (m_enqueue_messages) {
        message_id = esp_mqtt_client_enqueue(m_mqtt_client, topic, reinterpret_cast<const char*>(payload), length, 0U, 0U, true);
        return message_id > MQTT_FAILURE_MESSAGE_ID;
    }

    // The blocking version esp_mqtt_client_publish() it is sent directly from the users task context.
    // This way is used to send messages to the cloud, because like that no internal buffer has to be used to store the message until it should be sent,
    // because all messages are sent with QoS level 0. If this is not wanted esp_mqtt_client_enqueue() could be used with store = true,
    // to ensure the sending is done in the mqtt event context instead of the users task context.
    // Allows to use the publish method without having to worry about any CPU overhead, so it can even be used in callbacks or high priority tasks, without starving other tasks,
    // but compared to the other method esp_mqtt_client_enqueue() requires to save the message in the outbox, which increases the memory requirements for the internal buffer size
    message_id = esp_mqtt_client_publish(m_mqtt_client, topic, reinterpret_cast<const char*>(payload), length, 0U, 0U);
    return message_id > MQTT_FAILURE_MESSAGE_ID;
}

bool Espressif_MQTT_Client::subscribe(const char *topic) {
    const int message_id = esp_mqtt_client_subscribe(m_mqtt_client, topic, 0U);
    return message_id > MQTT_FAILURE_MESSAGE_ID;
}

bool Espressif_MQTT_Client::unsubscribe(const char *topic) {
    const int message_id = esp_mqtt_client_unsubscribe(m_mqtt_client, topic);
    return message_id > MQTT_FAILURE_MESSAGE_ID;
}

bool Espressif_MQTT_Client::connected() {
    return m_connected;
}

bool Espressif_MQTT_Client::update_configuration() {
    // Check if the client has been initalized, because if it did not the value should still be nullptr
    // and updating the config makes no sense because the changed settings will be applied anyway when the client is first intialized
    if (m_mqtt_client == nullptr) {
        return true;
    }

    const esp_err_t error = esp_mqtt_set_config(m_mqtt_client, &m_mqtt_configuration);
    return error == ESP_OK;
}

void Espressif_MQTT_Client::mqtt_event_handler(void *handler_args, esp_event_base_t base, const esp_mqtt_event_id_t& event_id, void *event_data) {
    const esp_mqtt_event_handle_t event = static_cast<esp_mqtt_event_handle_t>(event_data);

    switch (event_id) {
        case esp_mqtt_event_id_t::MQTT_EVENT_CONNECTED:
            m_connected = true;
            break;
        case esp_mqtt_event_id_t::MQTT_EVENT_DISCONNECTED:
            m_connected = false;
            break;
        case esp_mqtt_event_id_t::MQTT_EVENT_SUBSCRIBED:
            // Nothing to do
            break;
        case esp_mqtt_event_id_t::MQTT_EVENT_UNSUBSCRIBED:
            // Nothing to do
            break;
        case esp_mqtt_event_id_t::MQTT_EVENT_PUBLISHED:
            // Nothing to do
            break;
        case esp_mqtt_event_id_t::MQTT_EVENT_DATA:
            // Check wheter the given message has not bee received completly, but instead would be received in multiple chunks,
            // if it were we discard the message because receiving a message over multiple chunks is currently not supported
            if (event->data_len != event->total_data_len) {
                break;
            }

            if (m_received_data_callback != nullptr) {
                m_received_data_callback(event->topic, reinterpret_cast<uint8_t*>(event->data), event->data_len);
            }
            break;
        case esp_mqtt_event_id_t::MQTT_EVENT_ERROR:
            // Nothing to do
            break;
        case esp_mqtt_event_id_t::MQTT_EVENT_BEFORE_CONNECT:
            // Nothing to do
            break;
        default:
            // Nothing to do
            break;
    }
}

void Espressif_MQTT_Client::static_mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) {
    if (m_instance == nullptr) {
        return;
    }

    m_instance->mqtt_event_handler(handler_args, base, static_cast<esp_mqtt_event_id_t>(event_id), event_data);
}

#endif // THINGSBOARD_USE_ESP_MQTT

Callback_Watchdog.h

#ifndef Callback_Watchdog_h
#define Callback_Watchdog_h

// Local include.
#include "Configuration.h"

#if THINGSBOARD_ENABLE_OTA

// Library includes.
#include <functional>
#if !false
#include <Ticker.h>
#endif // !false

/// @brief Wrapper class which allows to start a timer and if it is not stopped in the given time then the callback that was passed will be called,
/// which informs the user of the failure to stop the timer in time, meaning a timeout has occured.
/// The class wraps around either the Arduino Ticker class from Arduino (https://github.com/sstaub/Ticker) or the offical ESP Timer implementation from Espressif (https://github.com/espressif/esp-idf/tree/2bc1f2f574/examples/system/esp_timer), the latter takes precendence if it exists.
/// This is done because the usage is more efficient, under the hood we simply start and then stop and if needed start a oneshot timer again.
/// When using the esp timer directly the same timer can be reused to stop and start and therefore does not need to create a new timer everytime,
/// the Ticker in comparsion automatically deletes a timer once it has been stopped and we therefore need to create it again once the timer is started.
/// This causes a lot of overhead therefore if the esp timer exists we do not use the Ticker class but instead the esp timer directly.
/// For all other use cases where the esp timer does not exists we instead use the Ticker as a fallback, because in that case its implementation is completly different anyway.
/// The class instance is meant to be started with once() which will then call the registered callback after the timeout has passed,
/// if the detach() method has not been called yet.
/// This results in behaviour similair to a esp task watchdog but without as high of an accuracy and without restarting the device,
/// allowing to let it fail and handle the error case silently by the user in the callback method.
/// Documentation about the specific use and caviates of the ESP Timer implementation can be found here https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/esp_timer.html
class Callback_Watchdog {
  public:
    /// @brief Constructor
    /// @param callback Callback method that will be called if the timeout time passes without detach() being called
    Callback_Watchdog(std::function<void(void)> callback);

    /// @brief Destructor
    ~Callback_Watchdog();

    /// @brief Starts the watchdog timer once for the given timeout
    /// @param timeout_microseconds Amount of microseconds until the detach() method is excpected to have been called or the initally given callback method will be called
    void once(const uint64_t& timeout_microseconds);

    /// @brief Stops the currently ongoing watchdog timer and ensures the callback is not called. Timer can simply be restarted with calling once() again.
    void detach();

  private:
    std::function<void(void)> m_callback;
#if false
    void *m_oneshot_timer;                // ESP Timer handle that is used to start and stop the oneshot timer
#else
    Ticker m_oneshot_timer;               // Ticker instance that handles the timer under the hood, if possible we directly use esp timer instead because it is more efficient
#endif // false

    static Callback_Watchdog *m_instance; // Instance to the created class, will be set once the constructor has been called and reset once the destructor has been called, used to call private member method from static callback

#if false

    /// @brief Creates and initally configures the timer, has to be done once before either esp_timer_start_once or esp_timer_stop is called
    /// It can not be created in the constructor, because that would possibly be called before we have executed the main app code, meaning the esp timer base is not initalized yet.
    /// This would result in an invalid configuration which would cause crashes when used in combination with once() or detach()
    void create_timer();

#endif // false

    /// @brief Static callback used to call the initally subscribed callback, if the internal watchdog has not been reset in time with detach()
#if false
    /// @param arg Possible argument passed to the timer callback is always nullptr, because we simply forward the call to an internal member method instead
    static void oneshot_timer_callback(void *arg);
#else
    static void oneshot_timer_callback();
#endif // false
};

#endif // THINGSBOARD_ENABLE_OTA

#endif // Argument_Cache_h

Callback_Watchdog.cpp

// Header include.
#include "Callback_Watchdog.h"

#if THINGSBOARD_ENABLE_OTA

// Library includes.
#if false
#include <esp_timer.h>
#endif // false
#if THINGSBOARD_ENABLE_PROGMEM
#include <pgmspace.h>
#endif // THINGSBOARD_ENABLE_PROGMEM

#if THINGSBOARD_ENABLE_PROGMEM
constexpr char WATCHDOG_TIMER_NAME[] PROGMEM = "watchdog_timer";
#else
constexpr char WATCHDOG_TIMER_NAME[] = "watchdog_timer";
#endif // THINGSBOARD_ENABLE_PROGMEM

Callback_Watchdog *Callback_Watchdog::m_instance = nullptr;

Callback_Watchdog::Callback_Watchdog(std::function<void(void)> callback) :
    m_callback(callback),
#if false
    m_oneshot_timer(nullptr)
#else
    m_oneshot_timer()
#endif // false
{
    m_instance = this;
}

Callback_Watchdog::~Callback_Watchdog() {
#if false
    // Timer only has to deleted at the end of the lifetime of this object, to ensure no memory leak occurs.
    // But besides that the same timer can simply be stopped and restarted without needing to delete and create the timer again everytime.
    (void)esp_timer_delete(static_cast<esp_timer_handle_t>(m_oneshot_timer));
    m_oneshot_timer = nullptr;
#else
    m_oneshot_timer.detach();
#endif // false
    m_instance = nullptr;
}

void Callback_Watchdog::once(const uint64_t& timeout_microseconds) {
#if false
    create_timer();
    (void)esp_timer_start_once(static_cast<esp_timer_handle_t>(m_oneshot_timer), timeout_microseconds);
#else
    const uint32_t timeout_millis = timeout_microseconds / 1000U;
    m_oneshot_timer.once_ms(timeout_millis, &Callback_Watchdog::oneshot_timer_callback);
#endif // false
}

void Callback_Watchdog::detach() {
#if false
    (void)esp_timer_stop(static_cast<esp_timer_handle_t>(m_oneshot_timer));
#else
    m_oneshot_timer.detach();
#endif // false
}

#if false
void Callback_Watchdog::create_timer() {
    // Timer has already been created previously there is no need to create it again
    if (m_oneshot_timer != nullptr) {
        return;
    }

    const esp_timer_create_args_t oneshot_timer_args = {
        .callback = &oneshot_timer_callback,
        .arg = nullptr,
        .dispatch_method = esp_timer_dispatch_t::ESP_TIMER_TASK,
        .name = WATCHDOG_TIMER_NAME,
        .skip_unhandled_events = false
    };

    // Temporary handle is used, because it allows using a void* as the actual oneshot_timer,
    // allowing us to only include the esp_timer header in the defintion (.cpp) file,
    // instead of also needing to declare it in the declaration (.h) header file
    esp_timer_handle_t temp_handle;
    const esp_err_t error = esp_timer_create(&oneshot_timer_args, &temp_handle);
    if (error != ESP_OK) {
        return;
    }

    m_oneshot_timer = temp_handle;
}
#endif // false

#if false
void Callback_Watchdog::oneshot_timer_callback(void *arg) {
#else
void Callback_Watchdog::oneshot_timer_callback() {
#endif // false
    if (m_instance == nullptr) {
        return;
    }

    m_instance->m_callback();
}

#endif // THINGSBOARD_ENABLE_OTA
donskytech commented 10 months ago

I will get back to you again tomorrow as it is getting late here where I am (Manila) :)

MathewHDYT commented 10 months ago

If you still have a minute that worked the only thing that is missing is doing the same thing for the Espressif_Updater.h and Espressif_Updater.cpp file. Simply replace THINGSBOARD_USE_ESP_PARTITION with false as well.


And I'm very sure I know where the errors are coming from. The version you are currently using of both Arduino and Espressif is very old at least a few years. The library wasn't build with that in mind. That's why Arduino is missing the Updater and Espressif has a lot of errors, because the API changed a lot and a few methods have been renamed and changed between versions.

As mentioned above for future releases I will add a check that only compiles the Espressif files if the Espressif version is at least 4.0. That should fix most issues you experienced besides the missing Updater.

donskytech commented 10 months ago

Hey, Build is now successful after doing the last change.

MathewHDYT commented 10 months ago

Nice to know, for know you can keep the issue open. I will close it with the next Pull Request that integrates the automatic detection if the ESP Version is too low to be supported by this library and if it is it disabled that code.

donskytech commented 8 months ago

I think this is quite interesting.

I bought a new laptop workstation and tried downloading the Thingsboard SDK client.

I upgraded my PlatformIO platform for Espressif 32 to 6.5 but when I compiled the example program. I am encountering the following issue.

*  The terminal process "C:\Users\donsky\.platformio\penv\Scripts\platformio.exe 'run', '--environment', 'esp32dev'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: C:\Users\donsky\.platformio\penv\Scripts\platformio.exe run --environment esp32dev 

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Library Manager: Installing thingsboard/pubsubclient @ ^2.9.3
Library Manager: Warning! Could not install `{'owner': 'thingsboard', 'name': 'pubsubclient', 'version': '^2.9.3'}` dependency for the`ThingsBoard` package
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.5.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.20014.231204 (2.0.14)
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 40 compatible libraries
Scanning dependencies...
Dependency Graph
|-- ThingsBoard @ 0.12.2
|-- TBPubSubClient @ 2.9.3+sha.1bec7ad
|-- elapsedMillis @ 1.0.6
|-- DHT sensor library @ 1.4.6
|-- WiFi @ 2.0.0
|-- WiFiClientSecure @ 2.0.0
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
Compiling .pio\build\esp32dev\src\stepSequence.cpp.o
Building .pio\build\esp32dev\bootloader.bin
Generating partitions .pio\build\esp32dev\partitions.bin
Compiling .pio\build\esp32dev\lib855\ArduinoHttpClient\HttpClient.cpp.o
Compiling .pio\build\esp32dev\lib855\ArduinoHttpClient\URLEncoder.cpp.o
Compiling .pio\build\esp32dev\lib855\ArduinoHttpClient\WebSocketClient.cpp.o
Compiling .pio\build\esp32dev\lib855\ArduinoHttpClient\b64.cpp.o
esptool.py v4.5.1
Creating esp32 image...
Merged 1 ELF section
Successfully created esp32 image.
Compiling .pio\build\esp32dev\libf5b\TBPubSubClient\PubSubClient.cpp.o
Compiling .pio\build\esp32dev\lib2f3\Ticker\Ticker.cpp.o
Compiling .pio\build\esp32dev\libc40\ThingsBoard\Arduino_ESP32_Updater.cpp.o
Compiling .pio\build\esp32dev\libc40\ThingsBoard\Arduino_ESP8266_Updater.cpp.o
.pio/libdeps/esp32dev/ThingsBoard/src/Arduino_ESP32_Updater.cpp:9:10: fatal error: Update.h: No such file or directory```

Looks like this isn't about my Platform version.

Here is my platform.ini

[env:esp32dev] platform = espressif32 board = esp32dev framework = arduino monitor_speed = 115200 monitor_filters = esp32_exception_decoder, log2file lib_deps = thingsboard/ThingsBoard https://github.com/thingsboard/pubsubclient.git pfeerick/elapsedMillis@^1.0.6 adafruit/DHT sensor library@^1.4.6



Could I be missing something?
OptifySudarshanPatil commented 6 months ago

Hello All! I have update, this compilation fail issue occur randomly on individual setup Andresolve by- lib_compat_mode = strict And adding "Missing Dependency" to lib_deps manually

platfomrio.ini

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino

; Checks for the compatibility with frameworks and dev/platforms
lib_compat_mode = strict

; lib_ldf_mode cause to break more things, better keep it off
; lib_ldf_mode = chain+ 
; lib_ldf_mode = deep+

lib_deps = 
    https://github.com/OptifyIndustrialSolutions/thingsboard-arduino-sdk.git ; For Thingsboard OTA
    https://github.com/bblanchon/ArduinoStreamUtils.git ;No need, missing EEPROM.h error, disabled in main.cpp
    FS ; resolve thingsborad compilation issue

main.cpp

#include "Arduino.h"
#define USING_HTTPS false
#define ENCRYPTED false
#define THINGSBOARD_ENABLE_STREAM_UTILS 0
#define THINGSBOARD_ENABLE_PROGMEM 0

#include "Update.h" //resolve thingsborad compilation issue
#include <Arduino_MQTT_Client.h>

#include <ThingsBoard.h>