mirror of
https://github.com/esphome/esphome.git
synced 2025-10-13 15:23:49 +01:00
fix
This commit is contained in:
@@ -40,9 +40,6 @@ void ESP32ImprovComponent::setup() {
|
|||||||
#endif
|
#endif
|
||||||
global_ble_server->on_disconnect([this](uint16_t conn_id) { this->set_error_(improv::ERROR_NONE); });
|
global_ble_server->on_disconnect([this](uint16_t conn_id) { this->set_error_(improv::ERROR_NONE); });
|
||||||
|
|
||||||
// Listen for WiFi connections to detect when provisioning happens via captive portal or other means
|
|
||||||
wifi::global_wifi_component->get_connect_trigger()->add_callback([this]() { this->on_wifi_connected_(); });
|
|
||||||
|
|
||||||
// Start with loop disabled - will be enabled by start() when needed
|
// Start with loop disabled - will be enabled by start() when needed
|
||||||
this->disable_loop();
|
this->disable_loop();
|
||||||
}
|
}
|
||||||
@@ -146,6 +143,7 @@ void ESP32ImprovComponent::loop() {
|
|||||||
#else
|
#else
|
||||||
this->set_state_(improv::STATE_AUTHORIZED);
|
this->set_state_(improv::STATE_AUTHORIZED);
|
||||||
#endif
|
#endif
|
||||||
|
this->check_wifi_connection_();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case improv::STATE_AUTHORIZED: {
|
case improv::STATE_AUTHORIZED: {
|
||||||
@@ -159,10 +157,12 @@ void ESP32ImprovComponent::loop() {
|
|||||||
if (!this->check_identify_()) {
|
if (!this->check_identify_()) {
|
||||||
this->set_status_indicator_state_((now % 1000) < 500);
|
this->set_status_indicator_state_((now % 1000) < 500);
|
||||||
}
|
}
|
||||||
|
this->check_wifi_connection_();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case improv::STATE_PROVISIONING: {
|
case improv::STATE_PROVISIONING: {
|
||||||
this->set_status_indicator_state_((now % 200) < 100);
|
this->set_status_indicator_state_((now % 200) < 100);
|
||||||
|
this->check_wifi_connection_();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case improv::STATE_PROVISIONED: {
|
case improv::STATE_PROVISIONED: {
|
||||||
@@ -374,6 +374,12 @@ void ESP32ImprovComponent::on_wifi_connect_timeout_() {
|
|||||||
wifi::global_wifi_component->clear_sta();
|
wifi::global_wifi_component->clear_sta();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ESP32ImprovComponent::check_wifi_connection_() {
|
||||||
|
if (wifi::global_wifi_component->is_connected()) {
|
||||||
|
this->on_wifi_connected_();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ESP32ImprovComponent::on_wifi_connected_() {
|
void ESP32ImprovComponent::on_wifi_connected_() {
|
||||||
// Handle WiFi connection, whether from Improv provisioning or external (e.g., captive portal)
|
// Handle WiFi connection, whether from Improv provisioning or external (e.g., captive portal)
|
||||||
if (this->state_ == improv::STATE_PROVISIONING) {
|
if (this->state_ == improv::STATE_PROVISIONING) {
|
||||||
|
@@ -112,6 +112,7 @@ class ESP32ImprovComponent : public Component {
|
|||||||
void process_incoming_data_();
|
void process_incoming_data_();
|
||||||
void on_wifi_connect_timeout_();
|
void on_wifi_connect_timeout_();
|
||||||
void on_wifi_connected_();
|
void on_wifi_connected_();
|
||||||
|
void check_wifi_connection_();
|
||||||
bool check_identify_();
|
bool check_identify_();
|
||||||
void advertise_service_data_();
|
void advertise_service_data_();
|
||||||
#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG
|
#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG
|
||||||
|
Reference in New Issue
Block a user