mirror of
https://github.com/esphome/esphome.git
synced 2025-10-08 12:53:45 +01:00
[ethernet] Consolidate error handling to reduce flash usage (#11019)
This commit is contained in:
@@ -41,17 +41,20 @@ static const char *const TAG = "ethernet";
|
|||||||
|
|
||||||
EthernetComponent *global_eth_component; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
EthernetComponent *global_eth_component; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||||
|
|
||||||
|
void EthernetComponent::log_error_and_mark_failed_(esp_err_t err, const char *message) {
|
||||||
|
ESP_LOGE(TAG, "%s: (%d) %s", message, err, esp_err_to_name(err));
|
||||||
|
this->mark_failed();
|
||||||
|
}
|
||||||
|
|
||||||
#define ESPHL_ERROR_CHECK(err, message) \
|
#define ESPHL_ERROR_CHECK(err, message) \
|
||||||
if ((err) != ESP_OK) { \
|
if ((err) != ESP_OK) { \
|
||||||
ESP_LOGE(TAG, message ": (%d) %s", err, esp_err_to_name(err)); \
|
this->log_error_and_mark_failed_(err, message); \
|
||||||
this->mark_failed(); \
|
|
||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ESPHL_ERROR_CHECK_RET(err, message, ret) \
|
#define ESPHL_ERROR_CHECK_RET(err, message, ret) \
|
||||||
if ((err) != ESP_OK) { \
|
if ((err) != ESP_OK) { \
|
||||||
ESP_LOGE(TAG, message ": (%d) %s", err, esp_err_to_name(err)); \
|
this->log_error_and_mark_failed_(err, message); \
|
||||||
this->mark_failed(); \
|
|
||||||
return ret; \
|
return ret; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -106,6 +106,7 @@ class EthernetComponent : public Component {
|
|||||||
void start_connect_();
|
void start_connect_();
|
||||||
void finish_connect_();
|
void finish_connect_();
|
||||||
void dump_connect_params_();
|
void dump_connect_params_();
|
||||||
|
void log_error_and_mark_failed_(esp_err_t err, const char *message);
|
||||||
#ifdef USE_ETHERNET_KSZ8081
|
#ifdef USE_ETHERNET_KSZ8081
|
||||||
/// @brief Set `RMII Reference Clock Select` bit for KSZ8081.
|
/// @brief Set `RMII Reference Clock Select` bit for KSZ8081.
|
||||||
void ksz8081_set_clock_reference_(esp_eth_mac_t *mac);
|
void ksz8081_set_clock_reference_(esp_eth_mac_t *mac);
|
||||||
|
Reference in New Issue
Block a user