1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-17 07:15:48 +00:00

Merge branch 'integration' into memory_api

This commit is contained in:
J. Nick Koston
2025-11-11 14:24:46 -06:00
2 changed files with 27 additions and 23 deletions

View File

@@ -331,7 +331,7 @@ async def to_code(configs):
# This must be done after all widgets are created
for comp in helpers.lvgl_components_required:
cg.add_define(f"USE_LVGL_{comp.upper()}")
if "transform_angle" in styles_used:
if {"transform_angle", "transform_zoom"} & styles_used:
add_define("LV_COLOR_SCREEN_TRANSP", "1")
for use in helpers.lv_uses:
add_define(f"LV_USE_{use.upper()}")

View File

@@ -413,8 +413,10 @@ void WiFiComponent::start() {
void WiFiComponent::restart_adapter() {
ESP_LOGW(TAG, "Restarting adapter");
this->wifi_mode_(false, {});
delay(100); // NOLINT
// Enter cooldown state to allow WiFi hardware to stabilize after restart
// Don't set retry_phase_ or num_retried_ here - state machine handles transitions
this->state_ = WIFI_COMPONENT_STATE_COOLDOWN;
this->action_started_ = millis();
}
void WiFiComponent::loop() {
@@ -435,19 +437,11 @@ void WiFiComponent::loop() {
case WIFI_COMPONENT_STATE_COOLDOWN: {
this->status_set_warning(LOG_STR("waiting to reconnect"));
if (millis() - this->action_started_ > 5000) {
// After cooldown, connect based on current retry phase
this->reset_selected_ap_to_first_if_invalid_();
// Check if we need to trigger a scan first
if (this->needs_scan_results_() && !this->all_networks_hidden_()) {
// Need scan results or no matching networks found - scan/rescan
ESP_LOGD(TAG, "Scanning required for phase %s", LOG_STR_ARG(retry_phase_to_log_string(this->retry_phase_)));
this->start_scanning();
} else {
// Have everything we need to connect (or all networks are hidden, skip scanning)
WiFiAP params = this->build_params_for_current_phase_();
this->start_connecting(params, false);
}
// After cooldown we either restarted the adapter because of
// a failure, or something tried to connect over and over
// so we entered cooldown. In both cases we call
// check_connecting_finished to continue the state machine.
this->check_connecting_finished();
}
break;
}
@@ -1011,8 +1005,6 @@ void WiFiComponent::check_scanning_finished() {
this->transition_to_phase_(WiFiRetryPhase::RETRY_HIDDEN);
// If no hidden networks to try, skip connection attempt (will be handled on next loop)
if (this->selected_sta_index_ == -1) {
this->state_ = WIFI_COMPONENT_STATE_COOLDOWN;
this->action_started_ = millis();
return;
}
// Now start connection attempt in hidden mode
@@ -1094,12 +1086,18 @@ void WiFiComponent::check_connecting_finished() {
uint32_t now = millis();
if (now - this->action_started_ > 30000) {
ESP_LOGW(TAG, "Connection timeout");
// Move from STA_CONNECTING_2 back to STA_CONNECTING state
// since we know the connection attempt has failed
this->state_ = WIFI_COMPONENT_STATE_STA_CONNECTING;
this->retry_connect();
return;
}
if (this->error_from_callback_) {
ESP_LOGW(TAG, "Connecting to network failed");
ESP_LOGW(TAG, "Connecting to network failed (callback)");
// Move from STA_CONNECTING_2 back to STA_CONNECTING state
// since we know the connection attempt is finished
this->state_ = WIFI_COMPONENT_STATE_STA_CONNECTING;
this->retry_connect();
return;
}
@@ -1108,6 +1106,9 @@ void WiFiComponent::check_connecting_finished() {
return;
}
// Move from STA_CONNECTING_2 back to STA_CONNECTING state
// since we know the connection attempt is finished
this->state_ = WIFI_COMPONENT_STATE_STA_CONNECTING;
if (status == WiFiSTAConnectStatus::ERROR_NETWORK_NOT_FOUND) {
ESP_LOGW(TAG, "Network no longer found");
this->retry_connect();
@@ -1476,15 +1477,13 @@ void WiFiComponent::advance_to_next_target_or_increment_retry_() {
void WiFiComponent::retry_connect() {
this->log_and_adjust_priority_for_failed_connect_();
delay(10);
// Determine next retry phase based on current state
WiFiRetryPhase current_phase = this->retry_phase_;
WiFiRetryPhase next_phase = this->determine_next_phase_();
// Handle phase transitions (transition_to_phase_ handles same-phase no-op internally)
if (this->transition_to_phase_(next_phase)) {
return; // Wait for scan to complete
return; // Scan started or adapter restarted (which sets its own state)
}
if (next_phase == current_phase) {
@@ -1502,11 +1501,16 @@ void WiFiComponent::retry_connect() {
this->state_ = WIFI_COMPONENT_STATE_STA_CONNECTING_2;
WiFiAP params = this->build_params_for_current_phase_();
this->start_connecting(params, true);
return;
}
// No valid target - fall through to set state to allow phase transition
return;
}
// If we can't progress forward its likely because scanning failed
// or the stack is in a bad state after restart so we cooldown first
// and once it finishes, cooldown will call check_connecting_finished()
// which will progress the state machine
ESP_LOGD(TAG, "Entering cooldown from state %d and phase %s", this->state_,
LOG_STR_ARG(retry_phase_to_log_string(this->retry_phase_)));
this->state_ = WIFI_COMPONENT_STATE_COOLDOWN;
this->action_started_ = millis();
}