mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	[wireguard] Fix boot loop when CONFIG_LWIP_TCPIP_CORE_LOCKING is enabled (#9637)
This commit is contained in:
		| @@ -8,6 +8,7 @@ | |||||||
| #include "esphome/core/log.h" | #include "esphome/core/log.h" | ||||||
| #include "esphome/core/time.h" | #include "esphome/core/time.h" | ||||||
| #include "esphome/components/network/util.h" | #include "esphome/components/network/util.h" | ||||||
|  | #include "esphome/core/helpers.h" | ||||||
|  |  | ||||||
| #include <esp_wireguard.h> | #include <esp_wireguard.h> | ||||||
| #include <esp_wireguard_err.h> | #include <esp_wireguard_err.h> | ||||||
| @@ -42,7 +43,10 @@ void Wireguard::setup() { | |||||||
|  |  | ||||||
|   this->publish_enabled_state(); |   this->publish_enabled_state(); | ||||||
|  |  | ||||||
|   this->wg_initialized_ = esp_wireguard_init(&(this->wg_config_), &(this->wg_ctx_)); |   { | ||||||
|  |     LwIPLock lock; | ||||||
|  |     this->wg_initialized_ = esp_wireguard_init(&(this->wg_config_), &(this->wg_ctx_)); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   if (this->wg_initialized_ == ESP_OK) { |   if (this->wg_initialized_ == ESP_OK) { | ||||||
|     ESP_LOGI(TAG, "Initialized"); |     ESP_LOGI(TAG, "Initialized"); | ||||||
| @@ -249,7 +253,10 @@ void Wireguard::start_connection_() { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   ESP_LOGD(TAG, "Starting connection"); |   ESP_LOGD(TAG, "Starting connection"); | ||||||
|   this->wg_connected_ = esp_wireguard_connect(&(this->wg_ctx_)); |   { | ||||||
|  |     LwIPLock lock; | ||||||
|  |     this->wg_connected_ = esp_wireguard_connect(&(this->wg_ctx_)); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   if (this->wg_connected_ == ESP_OK) { |   if (this->wg_connected_ == ESP_OK) { | ||||||
|     ESP_LOGI(TAG, "Connection started"); |     ESP_LOGI(TAG, "Connection started"); | ||||||
| @@ -280,7 +287,10 @@ void Wireguard::start_connection_() { | |||||||
| void Wireguard::stop_connection_() { | void Wireguard::stop_connection_() { | ||||||
|   if (this->wg_initialized_ == ESP_OK && this->wg_connected_ == ESP_OK) { |   if (this->wg_initialized_ == ESP_OK && this->wg_connected_ == ESP_OK) { | ||||||
|     ESP_LOGD(TAG, "Stopping connection"); |     ESP_LOGD(TAG, "Stopping connection"); | ||||||
|     esp_wireguard_disconnect(&(this->wg_ctx_)); |     { | ||||||
|  |       LwIPLock lock; | ||||||
|  |       esp_wireguard_disconnect(&(this->wg_ctx_)); | ||||||
|  |     } | ||||||
|     this->wg_connected_ = ESP_FAIL; |     this->wg_connected_ = ESP_FAIL; | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user