From 7f87d0fc3aa80fcc6584da8ccb4e443816ee8836 Mon Sep 17 00:00:00 2001 From: Me No Dev Date: Wed, 9 Jun 2021 12:56:12 +0300 Subject: [PATCH] Fix compilation for use as IDF component (#5265) --- CMakeLists.txt | 4 +++- docs/esp-idf_component.md | 6 +++--- libraries/LITTLEFS/src/LITTLEFS.cpp | 10 +++++++--- libraries/RainMaker/src/RMaker.cpp | 2 +- libraries/RainMaker/src/RMaker.h | 2 +- libraries/RainMaker/src/RMakerDevice.cpp | 2 +- libraries/RainMaker/src/RMakerDevice.h | 2 +- libraries/RainMaker/src/RMakerNode.cpp | 2 +- libraries/RainMaker/src/RMakerNode.h | 2 +- libraries/RainMaker/src/RMakerParam.cpp | 2 +- libraries/RainMaker/src/RMakerParam.h | 2 +- libraries/RainMaker/src/RMakerQR.h | 2 +- libraries/RainMaker/src/RMakerType.cpp | 2 +- libraries/RainMaker/src/RMakerType.h | 2 +- libraries/RainMaker/src/RMakerUtils.h | 2 +- libraries/WiFiClientSecure/src/ssl_client.cpp | 6 ++++-- 16 files changed, 29 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 663795be..1c24e7e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,7 +170,9 @@ if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_ArduinoO list(APPEND priv_requires esp_https_ota) endif() if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_LITTLEFS) - list(APPEND priv_requires esp_littlefs) + if(CONFIG_LITTLEFS_PAGE_SIZE) + list(APPEND priv_requires esp_littlefs) + endif() endif() idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires}) diff --git a/docs/esp-idf_component.md b/docs/esp-idf_component.md index 7fd4225d..17bfd66e 100644 --- a/docs/esp-idf_component.md +++ b/docs/esp-idf_component.md @@ -18,9 +18,9 @@ For a simplified method, see [lib-builder](lib_builder.md) cd arduino && \ git submodule update --init --recursive && \ cd ../.. && \ - make menuconfig + idf.py menuconfig ``` -- ```make menuconfig``` has some Arduino options +- ```idf.py menuconfig``` has some Arduino options - "Autostart Arduino setup and loop on boot" - If you enable this options, your main.cpp should be formated like any other sketch @@ -60,7 +60,7 @@ For a simplified method, see [lib-builder](lib_builder.md) - "Autoconnect WiFi on boot" - If enabled, WiFi will start with the last known configuration - Else it will wait for WiFi.begin -- ```make flash monitor``` will build, upload and open serial monitor to your board +- ```idf.py -p flash monitor``` will build, upload and open serial monitor to your board ## Logging To Serial diff --git a/libraries/LITTLEFS/src/LITTLEFS.cpp b/libraries/LITTLEFS/src/LITTLEFS.cpp index d14f1ee1..5c101729 100644 --- a/libraries/LITTLEFS/src/LITTLEFS.cpp +++ b/libraries/LITTLEFS/src/LITTLEFS.cpp @@ -20,11 +20,15 @@ extern "C" { #include #include #include -#include "esp_littlefs.h" } - +#include "sdkconfig.h" #include "LITTLEFS.h" +#ifdef CONFIG_LITTLEFS_PAGE_SIZE +extern "C" { + #include "esp_littlefs.h" +} + using namespace fs; class LITTLEFSImpl : public VFSImpl @@ -137,4 +141,4 @@ size_t LITTLEFSFS::usedBytes() } LITTLEFSFS LITTLEFS; - +#endif diff --git a/libraries/RainMaker/src/RMaker.cpp b/libraries/RainMaker/src/RMaker.cpp index 0a6239a1..de6903c0 100644 --- a/libraries/RainMaker/src/RMaker.cpp +++ b/libraries/RainMaker/src/RMaker.cpp @@ -1,5 +1,5 @@ #include "RMaker.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_IDF_TARGET_ESP32 +#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 #include #include bool wifiLowLevelInit(bool persistent); diff --git a/libraries/RainMaker/src/RMaker.h b/libraries/RainMaker/src/RMaker.h index 4a9ec4f6..53c60bce 100644 --- a/libraries/RainMaker/src/RMaker.h +++ b/libraries/RainMaker/src/RMaker.h @@ -1,5 +1,5 @@ #include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_IDF_TARGET_ESP32 +#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 #include "Arduino.h" #include "RMakerNode.h" diff --git a/libraries/RainMaker/src/RMakerDevice.cpp b/libraries/RainMaker/src/RMakerDevice.cpp index de30d68b..e0108c32 100644 --- a/libraries/RainMaker/src/RMakerDevice.cpp +++ b/libraries/RainMaker/src/RMakerDevice.cpp @@ -1,5 +1,5 @@ #include "RMakerDevice.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_IDF_TARGET_ESP32 +#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 static esp_err_t err; typedef void (*deviceWriteCb)(Device*, Param*, const param_val_t val, void *priv_data, write_ctx_t *ctx); diff --git a/libraries/RainMaker/src/RMakerDevice.h b/libraries/RainMaker/src/RMakerDevice.h index 97e6fcb7..13cb67ac 100644 --- a/libraries/RainMaker/src/RMakerDevice.h +++ b/libraries/RainMaker/src/RMakerDevice.h @@ -1,5 +1,5 @@ #include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_IDF_TARGET_ESP32 +#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 #include "RMakerParam.h" #include diff --git a/libraries/RainMaker/src/RMakerNode.cpp b/libraries/RainMaker/src/RMakerNode.cpp index 82c0bde2..3f2555f8 100644 --- a/libraries/RainMaker/src/RMakerNode.cpp +++ b/libraries/RainMaker/src/RMakerNode.cpp @@ -1,5 +1,5 @@ #include "RMakerNode.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_IDF_TARGET_ESP32 +#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 static esp_err_t err; esp_err_t Node::addDevice(Device device) diff --git a/libraries/RainMaker/src/RMakerNode.h b/libraries/RainMaker/src/RMakerNode.h index cf9aad44..733ca407 100644 --- a/libraries/RainMaker/src/RMakerNode.h +++ b/libraries/RainMaker/src/RMakerNode.h @@ -1,5 +1,5 @@ #include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_IDF_TARGET_ESP32 +#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 #include "RMakerDevice.h" diff --git a/libraries/RainMaker/src/RMakerParam.cpp b/libraries/RainMaker/src/RMakerParam.cpp index 0677c43f..e1de7740 100644 --- a/libraries/RainMaker/src/RMakerParam.cpp +++ b/libraries/RainMaker/src/RMakerParam.cpp @@ -1,5 +1,5 @@ #include "RMakerParam.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_IDF_TARGET_ESP32 +#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 static esp_err_t err; diff --git a/libraries/RainMaker/src/RMakerParam.h b/libraries/RainMaker/src/RMakerParam.h index 5708f5d9..0bd9aedb 100644 --- a/libraries/RainMaker/src/RMakerParam.h +++ b/libraries/RainMaker/src/RMakerParam.h @@ -1,5 +1,5 @@ #include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_IDF_TARGET_ESP32 +#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 #include "RMakerType.h" diff --git a/libraries/RainMaker/src/RMakerQR.h b/libraries/RainMaker/src/RMakerQR.h index 1cdeee16..fd5053d0 100644 --- a/libraries/RainMaker/src/RMakerQR.h +++ b/libraries/RainMaker/src/RMakerQR.h @@ -1,5 +1,5 @@ #include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_IDF_TARGET_ESP32 +#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 #include diff --git a/libraries/RainMaker/src/RMakerType.cpp b/libraries/RainMaker/src/RMakerType.cpp index 47419057..a4f6f2f3 100644 --- a/libraries/RainMaker/src/RMakerType.cpp +++ b/libraries/RainMaker/src/RMakerType.cpp @@ -1,5 +1,5 @@ #include "RMakerType.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_IDF_TARGET_ESP32 +#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 param_val_t value(int ival) { diff --git a/libraries/RainMaker/src/RMakerType.h b/libraries/RainMaker/src/RMakerType.h index f6f6e4a2..09029f9e 100644 --- a/libraries/RainMaker/src/RMakerType.h +++ b/libraries/RainMaker/src/RMakerType.h @@ -1,5 +1,5 @@ #include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_IDF_TARGET_ESP32 +#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 #include #include diff --git a/libraries/RainMaker/src/RMakerUtils.h b/libraries/RainMaker/src/RMakerUtils.h index 671e600f..41745d2e 100644 --- a/libraries/RainMaker/src/RMakerUtils.h +++ b/libraries/RainMaker/src/RMakerUtils.h @@ -1,5 +1,5 @@ #include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_IDF_TARGET_ESP32 +#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 #include diff --git a/libraries/WiFiClientSecure/src/ssl_client.cpp b/libraries/WiFiClientSecure/src/ssl_client.cpp index d8cc264f..3bd9b260 100644 --- a/libraries/WiFiClientSecure/src/ssl_client.cpp +++ b/libraries/WiFiClientSecure/src/ssl_client.cpp @@ -20,8 +20,8 @@ #include "WiFi.h" #ifndef MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED -# error "Please configure IDF framework to include mbedTLS -> Enable pre-shared-key ciphersuites and activate at least one cipher" -#endif +# warning "Please configure IDF framework to include mbedTLS -> Enable pre-shared-key ciphersuites and activate at least one cipher" +#else const char *pers = "esp32-tls"; @@ -459,3 +459,5 @@ bool verify_ssl_dn(sslclient_context *ssl_client, const char* domain_name) return false; } +#endif +