diff --git a/esphome/components/debug/debug_component.cpp b/esphome/components/debug/debug_component.cpp index 67b07237b7..b21c21953b 100644 --- a/esphome/components/debug/debug_component.cpp +++ b/esphome/components/debug/debug_component.cpp @@ -1,11 +1,11 @@ #include "debug_component.h" #include -#include "esphome/core/log.h" +#include #include "esphome/core/hal.h" #include "esphome/core/helpers.h" +#include "esphome/core/log.h" #include "esphome/core/version.h" -#include #ifdef USE_ESP32 @@ -355,7 +355,7 @@ void DebugComponent::dump_config() { ESP_LOGD(TAG, "Reset Reason: %s", lt_get_reboot_reason_name(lt_get_reboot_reason())); device_info += "|Version: "; - device_info += LT_BANNER_STR + 10; + device_info += <_BANNER_STR[10]; device_info += "|Reset Reason: "; device_info += lt_get_reboot_reason_name(lt_get_reboot_reason()); device_info += "|Chip Name: "; diff --git a/esphome/components/libretiny/core.cpp b/esphome/components/libretiny/core.cpp index b22740f02a..eaddb6d1fd 100644 --- a/esphome/components/libretiny/core.cpp +++ b/esphome/components/libretiny/core.cpp @@ -6,9 +6,6 @@ #include "esphome/core/helpers.h" #include "preferences.h" -void setup(); -void loop(); - namespace esphome { void IRAM_ATTR HOT yield() { ::yield(); } @@ -27,7 +24,7 @@ void arch_init() { void arch_restart() { lt_reboot(); - while (1) { + while (true) { } } void IRAM_ATTR HOT arch_feed_wdt() { lt_wdt_feed(); } diff --git a/esphome/components/libretiny/lt_component.cpp b/esphome/components/libretiny/lt_component.cpp index ec4b60eaeb..3dbafbea42 100644 --- a/esphome/components/libretiny/lt_component.cpp +++ b/esphome/components/libretiny/lt_component.cpp @@ -11,12 +11,12 @@ static const char *const TAG = "lt.component"; void LTComponent::dump_config() { ESP_LOGCONFIG(TAG, "LibreTiny:"); - ESP_LOGCONFIG(TAG, " Version: %s", LT_BANNER_STR + 10); + ESP_LOGCONFIG(TAG, " Version: %s", <_BANNER_STR[10]); ESP_LOGCONFIG(TAG, " Loglevel: %u", LT_LOGLEVEL); #ifdef USE_TEXT_SENSOR if (this->version_ != nullptr) { - this->version_->publish_state(LT_BANNER_STR + 10); + this->version_->publish_state(<_BANNER_STR[10]); } #endif // USE_TEXT_SENSOR } diff --git a/esphome/components/libretiny/preferences.cpp b/esphome/components/libretiny/preferences.cpp index ceeb30baf5..13c8a338a9 100644 --- a/esphome/components/libretiny/preferences.cpp +++ b/esphome/components/libretiny/preferences.cpp @@ -1,12 +1,12 @@ #ifdef USE_LIBRETINY #include "esphome/core/preferences.h" -#include "esphome/core/helpers.h" -#include "esphome/core/log.h" #include #include -#include #include +#include +#include "esphome/core/helpers.h" +#include "esphome/core/log.h" namespace esphome { namespace libretiny { @@ -74,7 +74,7 @@ class LibreTinyPreferences : public ESPPreferences { void open() { // - fdb_err_t err = fdb_kvdb_init(&db, "esphome", "kvs", NULL, NULL); + fdb_err_t err = fdb_kvdb_init(&db, "esphome", "kvs", nullptr, nullptr); if (err != FDB_NO_ERR) { LT_E("fdb_kvdb_init(...) failed: %d", err); } else { diff --git a/esphome/components/uart/uart_component_libretiny.cpp b/esphome/components/uart/uart_component_libretiny.cpp index c5e299e9d1..16b7ed319a 100644 --- a/esphome/components/uart/uart_component_libretiny.cpp +++ b/esphome/components/uart/uart_component_libretiny.cpp @@ -1,10 +1,10 @@ #ifdef USE_LIBRETINY +#include "uart_component_libretiny.h" #include "esphome/core/application.h" #include "esphome/core/defines.h" #include "esphome/core/helpers.h" #include "esphome/core/log.h" -#include "uart_component_libretiny.h" #ifdef USE_LOGGER #include "esphome/components/logger/logger.h" @@ -53,27 +53,25 @@ void LibreTinyUARTComponent::setup() { bool tx_inverted = tx_pin_ != nullptr && tx_pin_->is_inverted(); bool rx_inverted = rx_pin_ != nullptr && rx_pin_->is_inverted(); - if (false) - return; #if LT_HW_UART0 - else if ((tx_pin == -1 || tx_pin == PIN_SERIAL0_TX) && (rx_pin == -1 || rx_pin == PIN_SERIAL0_RX)) { + if ((tx_pin == -1 || tx_pin == PIN_SERIAL0_TX) && (rx_pin == -1 || rx_pin == PIN_SERIAL0_RX)) { this->serial_ = &Serial0; this->hardware_idx_ = 0; - } + } else #endif #if LT_HW_UART1 - else if ((tx_pin == -1 || tx_pin == PIN_SERIAL1_TX) && (rx_pin == -1 || rx_pin == PIN_SERIAL1_RX)) { + if ((tx_pin == -1 || tx_pin == PIN_SERIAL1_TX) && (rx_pin == -1 || rx_pin == PIN_SERIAL1_RX)) { this->serial_ = &Serial1; this->hardware_idx_ = 1; - } + } else #endif #if LT_HW_UART2 - else if ((tx_pin == -1 || tx_pin == PIN_SERIAL2_TX) && (rx_pin == -1 || rx_pin == PIN_SERIAL2_RX)) { + if ((tx_pin == -1 || tx_pin == PIN_SERIAL2_TX) && (rx_pin == -1 || rx_pin == PIN_SERIAL2_RX)) { this->serial_ = &Serial2; this->hardware_idx_ = 2; - } + } else #endif - else { + { #if LT_ARD_HAS_SOFTSERIAL this->serial_ = new SoftwareSerial(rx_pin, tx_pin, rx_inverted || tx_inverted); #else diff --git a/esphome/components/wifi/wifi_component_libretiny.cpp b/esphome/components/wifi/wifi_component_libretiny.cpp index abad5aca9c..b67f0e5912 100644 --- a/esphome/components/wifi/wifi_component_libretiny.cpp +++ b/esphome/components/wifi/wifi_component_libretiny.cpp @@ -2,16 +2,16 @@ #ifdef USE_LIBRETINY -#include #include -#include "lwip/ip_addr.h" -#include "lwip/err.h" +#include #include "lwip/dns.h" +#include "lwip/err.h" +#include "lwip/ip_addr.h" +#include "esphome/core/application.h" +#include "esphome/core/hal.h" #include "esphome/core/helpers.h" #include "esphome/core/log.h" -#include "esphome/core/hal.h" -#include "esphome/core/application.h" #include "esphome/core/util.h" namespace esphome { @@ -112,9 +112,9 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) { s_sta_connecting = true; - WiFiStatus status = WiFi.begin(ap.get_ssid().c_str(), ap.get_password().empty() ? NULL : ap.get_password().c_str(), + WiFiStatus status = WiFi.begin(ap.get_ssid().c_str(), ap.get_password().empty() ? nullptr : ap.get_password().c_str(), ap.get_channel().has_value() ? *ap.get_channel() : 0, - ap.get_bssid().has_value() ? ap.get_bssid()->data() : NULL); + ap.get_bssid().has_value() ? ap.get_bssid()->data() : nullptr); if (status != WL_CONNECTED) { ESP_LOGW(TAG, "esp_wifi_connect failed! %d", status); return false; @@ -438,7 +438,7 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) { yield(); - return WiFi.softAP(ap.get_ssid().c_str(), ap.get_password().empty() ? NULL : ap.get_password().c_str(), + return WiFi.softAP(ap.get_ssid().c_str(), ap.get_password().empty() ? nullptr : ap.get_password().c_str(), ap.get_channel().value_or(1), ap.get_hidden()); } network::IPAddress WiFiComponent::wifi_soft_ap_ip() { return {WiFi.softAPIP()}; }