mirror of
				https://github.com/esphome/esphome.git
				synced 2025-11-04 00:51:49 +00:00 
			
		
		
		
	[ethernet] Consolidate error handling to reduce flash usage
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)
 | 
			
		||||
 | 
			
		||||
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) \
 | 
			
		||||
  if ((err) != ESP_OK) { \
 | 
			
		||||
    ESP_LOGE(TAG, message ": (%d) %s", err, esp_err_to_name(err)); \
 | 
			
		||||
    this->mark_failed(); \
 | 
			
		||||
    this->log_error_and_mark_failed_(err, message); \
 | 
			
		||||
    return; \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
#define ESPHL_ERROR_CHECK_RET(err, message, ret) \
 | 
			
		||||
  if ((err) != ESP_OK) { \
 | 
			
		||||
    ESP_LOGE(TAG, message ": (%d) %s", err, esp_err_to_name(err)); \
 | 
			
		||||
    this->mark_failed(); \
 | 
			
		||||
    this->log_error_and_mark_failed_(err, message); \
 | 
			
		||||
    return ret; \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -106,6 +106,7 @@ class EthernetComponent : public Component {
 | 
			
		||||
  void start_connect_();
 | 
			
		||||
  void finish_connect_();
 | 
			
		||||
  void dump_connect_params_();
 | 
			
		||||
  void log_error_and_mark_failed_(esp_err_t err, const char *message);
 | 
			
		||||
#ifdef USE_ETHERNET_KSZ8081
 | 
			
		||||
  /// @brief Set `RMII Reference Clock Select` bit for KSZ8081.
 | 
			
		||||
  void ksz8081_set_clock_reference_(esp_eth_mac_t *mac);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user