[wireguard] Fix boot loop when CONFIG_LWIP_TCPIP_CORE_LOCKING is enabled (#9637)

This commit is contained in:
J. Nick Koston 2025-07-17 13:00:56 -10:00 committed by Jesse Hills
parent 21e66b76e4
commit 4a43f922c6
No known key found for this signature in database
GPG Key ID: BEAAE804EFD8E83A

View File

@ -8,6 +8,7 @@
#include "esphome/core/log.h"
#include "esphome/core/time.h"
#include "esphome/components/network/util.h"
#include "esphome/core/helpers.h"
#include <esp_wireguard.h>
#include <esp_wireguard_err.h>
@ -42,7 +43,10 @@ void Wireguard::setup() {
this->publish_enabled_state();
{
LwIPLock lock;
this->wg_initialized_ = esp_wireguard_init(&(this->wg_config_), &(this->wg_ctx_));
}
if (this->wg_initialized_ == ESP_OK) {
ESP_LOGI(TAG, "Initialized");
@ -249,7 +253,10 @@ void Wireguard::start_connection_() {
}
ESP_LOGD(TAG, "Starting connection");
{
LwIPLock lock;
this->wg_connected_ = esp_wireguard_connect(&(this->wg_ctx_));
}
if (this->wg_connected_ == ESP_OK) {
ESP_LOGI(TAG, "Connection started");
@ -280,7 +287,10 @@ void Wireguard::start_connection_() {
void Wireguard::stop_connection_() {
if (this->wg_initialized_ == ESP_OK && this->wg_connected_ == ESP_OK) {
ESP_LOGD(TAG, "Stopping connection");
{
LwIPLock lock;
esp_wireguard_disconnect(&(this->wg_ctx_));
}
this->wg_connected_ = ESP_FAIL;
}
}