diff --git a/esphome/components/modem/__init__.py b/esphome/components/modem/__init__.py index ee47af3477..ab8a3272fd 100644 --- a/esphome/components/modem/__init__.py +++ b/esphome/components/modem/__init__.py @@ -1,23 +1,23 @@ import logging +from esphome import automation, pins +import esphome.codegen as cg +from esphome.components.esp32 import add_idf_component, add_idf_sdkconfig_option +import esphome.config_validation as cv from esphome.const import ( + CONF_ENABLE_ON_BOOT, CONF_ID, - CONF_USE_ADDRESS, - CONF_TX_PIN, - CONF_RX_PIN, - CONF_USERNAME, - CONF_PASSWORD, CONF_MODEL, - CONF_TRIGGER_ID, CONF_ON_CONNECT, CONF_ON_DISCONNECT, - CONF_ENABLE_ON_BOOT, + CONF_PASSWORD, + CONF_RX_PIN, + CONF_TRIGGER_ID, + CONF_TX_PIN, + CONF_USE_ADDRESS, + CONF_USERNAME, ) -import esphome.codegen as cg -import esphome.config_validation as cv from esphome.core import coroutine_with_priority -from esphome.components.esp32 import add_idf_component, add_idf_sdkconfig_option -from esphome import pins, automation _LOGGER = logging.getLogger(__name__) @@ -25,7 +25,7 @@ CODEOWNERS = ["@oarcher"] DEPENDENCIES = ["esp32"] AUTO_LOAD = ["network"] # following should be removed if conflicts are resolved (so we can have a wifi ap using modem) -CONFLICTS_WITH = ["wifi", "captive_portal", "ethernet"] +CONFLICTS_WITH = ["captive_portal", "ethernet"] CONF_PIN_CODE = "pin_code" CONF_APN = "apn" @@ -131,7 +131,6 @@ async def to_code(config): path="components/esp_modem", ) - add_idf_sdkconfig_option("CONFIG_LWIP_DHCPS", False) add_idf_sdkconfig_option("CONFIG_PPP", True) add_idf_sdkconfig_option("CONFIG_LWIP_PPP_SUPPORT", True) add_idf_sdkconfig_option("CONFIG_PPP_PAP_SUPPORT", True) diff --git a/esphome/components/modem/modem_component.cpp b/esphome/components/modem/modem_component.cpp index 91a3ed635e..66ea110140 100644 --- a/esphome/components/modem/modem_component.cpp +++ b/esphome/components/modem/modem_component.cpp @@ -21,7 +21,7 @@ #include #ifndef USE_MODEM_MODEL -#define USE_MODEM_MODEL UNKNOWN +#define USE_MODEM_MODEL "UNKNOWN" #endif #define ESPHL_ERROR_CHECK(err, message) \ @@ -36,10 +36,10 @@ ESP_LOGE(TAG, message ": %s", command_result_to_string(err).c_str()); \ } -static const size_t CONFIG_MODEM_UART_RX_BUFFER_SIZE = 2048; -static const size_t CONFIG_MODEM_UART_TX_BUFFER_SIZE = 1024; +static const size_t CONFIG_MODEM_UART_RX_BUFFER_SIZE = 32768; +static const size_t CONFIG_MODEM_UART_TX_BUFFER_SIZE = 32768; static const uint8_t CONFIG_MODEM_UART_EVENT_QUEUE_SIZE = 30; -static const size_t CONFIG_MODEM_UART_EVENT_TASK_STACK_SIZE = 2048; +static const size_t CONFIG_MODEM_UART_EVENT_TASK_STACK_SIZE = 32768; static const uint8_t CONFIG_MODEM_UART_EVENT_TASK_PRIORITY = 5; namespace esphome { @@ -56,7 +56,7 @@ ModemComponent::ModemComponent() { void ModemComponent::dump_config() { this->dump_connect_params_(); } -float ModemComponent::get_setup_priority() const { return setup_priority::WIFI; } // FIXME AFTER_WIFI +float ModemComponent::get_setup_priority() const { return setup_priority::WIFI + 1; } // just before WIFI bool ModemComponent::can_proceed() { return this->is_connected(); } @@ -406,7 +406,7 @@ void ModemComponent::loop() { // assert(this->dce->set_mode(modem_mode::COMMAND_MODE)); // OK on 7600, nok on 7670... this->dce->set_mode(modem_mode::COMMAND_MODE); } - delay(500); + delay(200); // NOLINT ESP_LOGD(TAG, "Hanging up connection after %.1fmin", float(this->connect_begin_) / (1000 * 60)); if (this->dce->hang_up() != command_result::OK) { ESP_LOGW(TAG, "Unable to hang up modem. Trying to continue anyway.");