From 868f5357c1b7cc5953b1cea33001f23baa70bfe5 Mon Sep 17 00:00:00 2001 From: Alexandr Pyslar <34306652+CCChelios@users.noreply.github.com> Date: Sun, 20 Oct 2024 08:23:20 +0000 Subject: [PATCH] clang-format --- esphome/components/modem/__init__.py | 8 ++++-- esphome/components/modem/modem_component.cpp | 28 +++++++++++--------- esphome/components/modem/modem_component.h | 5 ++-- esphome/components/network/util.cpp | 6 ++--- esphome/const.py | 2 +- esphome/core/__init__.py | 2 +- esphome/idf_component.yml | 2 +- 7 files changed, 30 insertions(+), 23 deletions(-) diff --git a/esphome/components/modem/__init__.py b/esphome/components/modem/__init__.py index 6813ad106f..20f61f1b0d 100644 --- a/esphome/components/modem/__init__.py +++ b/esphome/components/modem/__init__.py @@ -61,8 +61,12 @@ CONFIG_SCHEMA = cv.All( cv.Optional( CONF_UART_EVENT_TASK_STACK_SIZE, default=2048 ): cv.positive_not_null_int, - cv.Optional(CONF_UART_EVENT_TASK_PRIORITY, default=5): cv.positive_not_null_int, - cv.Optional(CONF_UART_EVENT_QUEUE_SIZE, default=30): cv.positive_not_null_int, + cv.Optional( + CONF_UART_EVENT_TASK_PRIORITY, default=5 + ): cv.positive_not_null_int, + cv.Optional( + CONF_UART_EVENT_QUEUE_SIZE, default=30 + ): cv.positive_not_null_int, cv.Optional(CONF_TX_BUFFER_SIZE, default=512): cv.positive_not_null_int, cv.Optional(CONF_RX_BUFFER_SIZE, default=1024): cv.positive_not_null_int, cv.Optional(CONF_DOMAIN, default=".local"): cv.domain_name, diff --git a/esphome/components/modem/modem_component.cpp b/esphome/components/modem/modem_component.cpp index e477ffd05b..e13cc07546 100644 --- a/esphome/components/modem/modem_component.cpp +++ b/esphome/components/modem/modem_component.cpp @@ -1,11 +1,12 @@ +#ifdef USE_ESP32 +#ifdef USE_ESP_IDF + #include "modem_component.h" #include "esphome/core/log.h" #include "esphome/core/util.h" #include "esphome/core/application.h" -#ifdef USE_ESP32 - #include "esp_modem_c_api_types.h" #include "esp_netif_ppp.h" #include "cxx_include/esp_modem_types.hpp" @@ -64,7 +65,7 @@ void ModemComponent::setup() { err = esp_event_loop_create_default(); ESPHL_ERROR_CHECK(err, "modem event loop error"); ESP_LOGCONFIG(TAG, "Initing netif"); - esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, &ModemComponent::got_ip_event_handler, NULL); + esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, &ModemComponent::got_ip_event_handler, nullptr); ESP_LOGD(TAG, "Initializing esp_modem"); this->modem_netif_init(); this->dte_init(); @@ -230,15 +231,14 @@ bool ModemComponent::check_modem_component_state_timings() { } void ModemComponent::set_state(ModemComponentState state) { - // execute before transition to state - switch (state) - { - case ModemComponentState::SYNC: - this->dce_init(); - break; - - default: - break; + // execute before transition to state + switch (state) { + case ModemComponentState::SYNC: + this->dce_init(); + break; + + default: + break; } ESP_LOGCONFIG(TAG, "Modem component change state from %s to %s", this->state_to_string(this->state_), this->state_to_string(state)); @@ -278,7 +278,8 @@ void ModemComponent::dump_config() { ESP_LOGCONFIG(TAG, " Type: %d", this->type_); ESP_LOGCONFIG(TAG, " Power pin : %s", (this->power_pin_) ? this->power_pin_->dump_summary().c_str() : "Not defined"); ESP_LOGCONFIG(TAG, " Reset pin : %s", (this->reset_pin_) ? this->reset_pin_->dump_summary().c_str() : "Not defined"); - ESP_LOGCONFIG(TAG, " Pwrkey pin : %s", (this->pwrkey_pin_) ? this->pwrkey_pin_->dump_summary().c_str() : "Not defined"); + ESP_LOGCONFIG(TAG, " Pwrkey pin : %s", + (this->pwrkey_pin_) ? this->pwrkey_pin_->dump_summary().c_str() : "Not defined"); ESP_LOGCONFIG(TAG, " APN: %s", this->apn_.c_str()); ESP_LOGCONFIG(TAG, " TX Pin: %d", this->tx_pin_); ESP_LOGCONFIG(TAG, " RX Pin: %d", this->rx_pin_); @@ -385,4 +386,5 @@ void ModemComponent::set_use_address(const std::string &use_address) { this->use } // namespace modem } // namespace esphome +#endif // USE_ESP_IDF #endif // USE_ESP32 diff --git a/esphome/components/modem/modem_component.h b/esphome/components/modem/modem_component.h index acb2bbbfed..c4f2148daa 100644 --- a/esphome/components/modem/modem_component.h +++ b/esphome/components/modem/modem_component.h @@ -1,4 +1,6 @@ #pragma once +#ifdef USE_ESP32 +#ifdef USE_ESP_IDF #include "esphome/core/component.h" #include "esphome/core/log.h" @@ -6,8 +8,6 @@ #include "esphome/core/hal.h" #include "esphome/components/network/ip_address.h" -#ifdef USE_ESP32 - #include using esphome::esp_log_printf_; @@ -132,4 +132,5 @@ extern ModemComponent *global_modem_component; } // namespace modem } // namespace esphome +#endif // USE_ESP_IDF #endif // USE_ESP32 diff --git a/esphome/components/network/util.cpp b/esphome/components/network/util.cpp index 4b51539f66..7aa0fa0fbe 100644 --- a/esphome/components/network/util.cpp +++ b/esphome/components/network/util.cpp @@ -32,9 +32,9 @@ bool is_connected() { #endif #ifdef USE_MODEM -if (modem::global_modem_component != nullptr && modem::global_modem_component->is_connected()){ - return true; -} + if (modem::global_modem_component != nullptr && modem::global_modem_component->is_connected()) { + return true; + } #endif return false; } diff --git a/esphome/const.py b/esphome/const.py index b395eb5e1a..b8110dfb3b 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -269,7 +269,6 @@ CONF_ESP8266_DISABLE_SSL_SUPPORT = "esp8266_disable_ssl_support" CONF_ESPHOME = "esphome" CONF_ETHANOL = "ethanol" CONF_ETHERNET = "ethernet" -CONF_MODEM = "modem" CONF_EVENT = "event" CONF_EVENT_TYPE = "event_type" CONF_EVENT_TYPES = "event_types" @@ -516,6 +515,7 @@ CONF_MODE = "mode" CONF_MODE_COMMAND_TOPIC = "mode_command_topic" CONF_MODE_STATE_TOPIC = "mode_state_topic" CONF_MODEL = "model" +CONF_MODEM = "modem" CONF_MOISTURE = "moisture" CONF_MONTH = "month" CONF_MONTHS = "months" diff --git a/esphome/core/__init__.py b/esphome/core/__init__.py index 958664ef8c..654b4b1160 100644 --- a/esphome/core/__init__.py +++ b/esphome/core/__init__.py @@ -565,7 +565,7 @@ class EsphomeCore: if CONF_ETHERNET in self.config: return self.config[CONF_ETHERNET][CONF_USE_ADDRESS] - + if CONF_MODEM in self.config: return self.config[CONF_MODEM][CONF_USE_ADDRESS] diff --git a/esphome/idf_component.yml b/esphome/idf_component.yml index 53316cae06..c3fe8ad206 100644 --- a/esphome/idf_component.yml +++ b/esphome/idf_component.yml @@ -13,4 +13,4 @@ dependencies: - if: "idf_version >=5.0" esp_modem: git: https://github.com/espressif/esp-protocols.git - path: components/esp_modem \ No newline at end of file + path: components/esp_modem