mirror of
https://github.com/esphome/esphome.git
synced 2025-10-10 05:43:48 +01:00
warnings strings flash
This commit is contained in:
@@ -148,7 +148,7 @@ void WiFiComponent::loop() {
|
|||||||
|
|
||||||
switch (this->state_) {
|
switch (this->state_) {
|
||||||
case WIFI_COMPONENT_STATE_COOLDOWN: {
|
case WIFI_COMPONENT_STATE_COOLDOWN: {
|
||||||
this->status_set_warning("waiting to reconnect");
|
this->status_set_warning(LOG_STR("waiting to reconnect"));
|
||||||
if (millis() - this->action_started_ > 5000) {
|
if (millis() - this->action_started_ > 5000) {
|
||||||
if (this->fast_connect_ || this->retry_hidden_) {
|
if (this->fast_connect_ || this->retry_hidden_) {
|
||||||
if (!this->selected_ap_.get_bssid().has_value())
|
if (!this->selected_ap_.get_bssid().has_value())
|
||||||
@@ -161,13 +161,13 @@ void WiFiComponent::loop() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WIFI_COMPONENT_STATE_STA_SCANNING: {
|
case WIFI_COMPONENT_STATE_STA_SCANNING: {
|
||||||
this->status_set_warning("scanning for networks");
|
this->status_set_warning(LOG_STR("scanning for networks"));
|
||||||
this->check_scanning_finished();
|
this->check_scanning_finished();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WIFI_COMPONENT_STATE_STA_CONNECTING:
|
case WIFI_COMPONENT_STATE_STA_CONNECTING:
|
||||||
case WIFI_COMPONENT_STATE_STA_CONNECTING_2: {
|
case WIFI_COMPONENT_STATE_STA_CONNECTING_2: {
|
||||||
this->status_set_warning("associating to network");
|
this->status_set_warning(LOG_STR("associating to network"));
|
||||||
this->check_connecting_finished();
|
this->check_connecting_finished();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -278,15 +278,29 @@ bool Component::is_ready() const {
|
|||||||
bool Component::can_proceed() { return true; }
|
bool Component::can_proceed() { return true; }
|
||||||
bool Component::status_has_warning() const { return this->component_state_ & STATUS_LED_WARNING; }
|
bool Component::status_has_warning() const { return this->component_state_ & STATUS_LED_WARNING; }
|
||||||
bool Component::status_has_error() const { return this->component_state_ & STATUS_LED_ERROR; }
|
bool Component::status_has_error() const { return this->component_state_ & STATUS_LED_ERROR; }
|
||||||
void Component::status_set_warning(const char *message) {
|
|
||||||
|
void Component::status_set_warning_flag_() {
|
||||||
// Don't spam the log. This risks missing different warning messages though.
|
// Don't spam the log. This risks missing different warning messages though.
|
||||||
if ((this->component_state_ & STATUS_LED_WARNING) != 0)
|
if ((this->component_state_ & STATUS_LED_WARNING) != 0)
|
||||||
return;
|
return;
|
||||||
this->component_state_ |= STATUS_LED_WARNING;
|
this->component_state_ |= STATUS_LED_WARNING;
|
||||||
App.app_state_ |= STATUS_LED_WARNING;
|
App.app_state_ |= STATUS_LED_WARNING;
|
||||||
ESP_LOGW(TAG, "%s set Warning flag: %s", LOG_STR_ARG(this->get_component_log_str()),
|
|
||||||
message ? message : UNSPECIFIED_MESSAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Component::status_set_warning(const char *message) {
|
||||||
|
this->status_set_warning_flag_();
|
||||||
|
if ((this->component_state_ & STATUS_LED_WARNING) != 0)
|
||||||
|
ESP_LOGW(TAG, "%s set Warning flag: %s", LOG_STR_ARG(this->get_component_log_str()),
|
||||||
|
message ? message : UNSPECIFIED_MESSAGE);
|
||||||
|
}
|
||||||
|
#ifdef USE_STORE_LOG_STR_IN_FLASH
|
||||||
|
void Component::status_set_warning(const LogString *message) {
|
||||||
|
this->status_set_warning_flag_();
|
||||||
|
if ((this->component_state_ & STATUS_LED_WARNING) != 0)
|
||||||
|
ESP_LOGW(TAG, "%s set Warning flag: %s", LOG_STR_ARG(this->get_component_log_str()),
|
||||||
|
message ? LOG_STR_ARG(message) : UNSPECIFIED_MESSAGE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
void Component::status_set_error(const char *message) {
|
void Component::status_set_error(const char *message) {
|
||||||
if ((this->component_state_ & STATUS_LED_ERROR) != 0)
|
if ((this->component_state_ & STATUS_LED_ERROR) != 0)
|
||||||
return;
|
return;
|
||||||
|
@@ -204,6 +204,9 @@ class Component {
|
|||||||
bool status_has_error() const;
|
bool status_has_error() const;
|
||||||
|
|
||||||
void status_set_warning(const char *message = nullptr);
|
void status_set_warning(const char *message = nullptr);
|
||||||
|
#ifdef USE_STORE_LOG_STR_IN_FLASH
|
||||||
|
void status_set_warning(const LogString *message);
|
||||||
|
#endif
|
||||||
|
|
||||||
void status_set_error(const char *message = nullptr);
|
void status_set_error(const char *message = nullptr);
|
||||||
|
|
||||||
@@ -240,6 +243,9 @@ class Component {
|
|||||||
/// Helper to set component state (clears state bits and sets new state)
|
/// Helper to set component state (clears state bits and sets new state)
|
||||||
void set_component_state_(uint8_t state);
|
void set_component_state_(uint8_t state);
|
||||||
|
|
||||||
|
/// Helper to set warning flag without duplicating logic
|
||||||
|
void status_set_warning_flag_();
|
||||||
|
|
||||||
/** Set an interval function with a unique name. Empty name means no cancelling possible.
|
/** Set an interval function with a unique name. Empty name means no cancelling possible.
|
||||||
*
|
*
|
||||||
* This will call f every interval ms. Can be cancelled via CancelInterval().
|
* This will call f every interval ms. Can be cancelled via CancelInterval().
|
||||||
|
Reference in New Issue
Block a user