From 31a6193273cd56906d1e6a6b8e9bae45ee470a80 Mon Sep 17 00:00:00 2001 From: Pascal Brunot Date: Sun, 21 Jul 2024 09:54:19 +0200 Subject: [PATCH 1/3] Compiler warnings fixes --- include/SavedConfig.hpp | 2 +- src/main.cpp | 2 +- src/mock/MockMQTTBroker.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/SavedConfig.hpp b/include/SavedConfig.hpp index 68832ffe..26eec00a 100644 --- a/include/SavedConfig.hpp +++ b/include/SavedConfig.hpp @@ -97,7 +97,7 @@ namespace fabomatic [[nodiscard]] static auto DefaultConfig() -> SavedConfig; /// @brief Increments the boot count and saves it to EEPROM - static auto IncrementBootCount() -> size_t; + [[maybe_unused]] static auto IncrementBootCount() -> size_t; }; } // namespace fabomatic diff --git a/src/main.cpp b/src/main.cpp index 42469b0e..c24491a9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -441,7 +441,7 @@ void setup() auto hw_init = logic.configure(rfid, lcd); hw_init &= logic.initBoard(); - const auto count = fabomatic::SavedConfig::IncrementBootCount(); + [[maybe_unused]] const auto count = fabomatic::SavedConfig::IncrementBootCount(); ESP_LOGI(TAG, "Boot count: %d, reset reason: %d", count, esp_reset_reason()); logic.changeStatus(Status::Booting); diff --git a/src/mock/MockMQTTBroker.cpp b/src/mock/MockMQTTBroker.cpp index 6430970d..f4115ce0 100644 --- a/src/mock/MockMQTTBroker.cpp +++ b/src/mock/MockMQTTBroker.cpp @@ -50,7 +50,7 @@ namespace fabomatic case NewClient_sMQTTEventType: { // Handle new client connection event - auto *e = static_cast(event); + [[maybe_unused]] auto *e = static_cast(event); ESP_LOGD(TAG2, "MQTT BROKER: client connected, id:%s", e->Client()->getClientId().c_str()); } break; @@ -69,7 +69,7 @@ namespace fabomatic case RemoveClient_sMQTTEventType: { // Handle client removal event - auto *e = static_cast(event); + [[maybe_unused]] auto *e = static_cast(event); ESP_LOGD(TAG2, "MQTT BROKER: removed client id: %s", e->Client()->getClientId().c_str()); } break; @@ -83,14 +83,14 @@ namespace fabomatic case Subscribe_sMQTTEventType: { // Handle subscription event - auto *e = static_cast(event); + [[maybe_unused]] auto *e = static_cast(event); ESP_LOGD(TAG2, "MQTT BROKER: client %s subscribed to %s", e->Client()->getClientId().c_str(), e->Topic().c_str()); } break; case UnSubscribe_sMQTTEventType: { // Handle unsubscription event - auto *e = static_cast(event); + [[maybe_unused]] auto *e = static_cast(event); ESP_LOGD(TAG2, "MQTT BROKER: got unsubscribe from %s", e->Topic().c_str()); } break; From 3899ca58a71b1b11b8743f2e995e0b15182191a5 Mon Sep 17 00:00:00 2001 From: Pascal Brunot Date: Sun, 21 Jul 2024 09:54:29 +0200 Subject: [PATCH 2/3] Dependencies update --- platformio.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 09a337f7..f9b6d81b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -24,11 +24,11 @@ monitor_filters = esp32_exception_decoder colorize lib_ldf_mode = deep lib_deps = https://github.com/PBrunot/LiquidCrystal.git#use_const - https://github.com/bblanchon/ArduinoJson.git#v7.0.4 + https://github.com/bblanchon/ArduinoJson.git#v7.1.0 256dpi/MQTT https://github.com/OSSLibraries/Arduino_MFRC522v2.git#2.0.4 Wire - adafruit/Adafruit NeoPixel@^1.12.2 + adafruit/Adafruit NeoPixel@^1.12.3 https://github.com/tzapu/WiFiManager.git@2.0.17 https://github.com/terrorsl/sMQTTBroker.git ArduinoOTA From 5586f17b38278ba7ff5c2c8fba47ce08c8325275 Mon Sep 17 00:00:00 2001 From: Pascal Brunot Date: Sun, 21 Jul 2024 10:06:35 +0200 Subject: [PATCH 3/3] Config: using C++ constexpr sort --- include/PinsConfig.hpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/include/PinsConfig.hpp b/include/PinsConfig.hpp index 40adb06d..123c7917 100644 --- a/include/PinsConfig.hpp +++ b/include/PinsConfig.hpp @@ -96,20 +96,28 @@ namespace fabomatic pins.led.blue_pin, pins.buttons.factory_defaults_pin}; - // No constexpr std::sort available - for (auto i = 0; i < pin_nums.size(); ++i) + // C++20 provides constexpr sorting + std::sort(pin_nums.begin(), pin_nums.end()); + + uint8_t previous = NO_PIN; + for (const auto pin : pin_nums) { - if (pin_nums[i] == NO_PIN) + if (pin == NO_PIN) + { continue; + } - for (auto j = i + 1; j < pin_nums.size(); ++j) + if (pin == previous) { - if (pin_nums[i] == pin_nums[j]) - return false; + return false; } + + previous = pin; + // Check pins numbers are convertible to gpio_num_t - static_cast(pin_nums[i]); + [[maybe_unused]] auto test = static_cast(pin); } + return true; }