feat(gateway): add ESP-Touch smartconfig provisioning support and enhance network management

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Tony
2026-04-30 18:49:38 +08:00
parent 4ce3513dd2
commit ae4669e1b3
10 changed files with 338 additions and 43 deletions
@@ -2,6 +2,7 @@
#include <array>
#include <cstdint>
#include <optional>
#include <string>
#include <vector>
@@ -13,6 +14,7 @@
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "freertos/task.h"
#include "gateway_runtime.hpp"
#include "lwip/sockets.h"
namespace gateway {
@@ -20,12 +22,14 @@ namespace gateway {
class GatewayController;
class DaliDomainService;
struct DaliRawFrame;
class GatewayRuntime;
struct GatewayNetworkServiceConfig {
bool wifi_enabled{true};
bool espnow_setup_enabled{true};
bool espnow_setup_startup_enabled{false};
bool smartconfig_enabled{true};
bool smartconfig_startup_enabled{false};
uint8_t smartconfig_timeout_sec{60};
bool http_enabled{true};
bool udp_enabled{true};
uint16_t http_port{80};
@@ -65,6 +69,8 @@ class GatewayNetworkService {
esp_err_t ensureNetworkStack();
esp_err_t startWifi();
esp_err_t startSetupAp();
esp_err_t startSmartconfig();
void stopSmartconfig();
esp_err_t startEspNow();
void stopEspNow();
esp_err_t addEspNowPeer(const uint8_t* mac, bool broadcast = false);
@@ -96,8 +102,12 @@ class GatewayNetworkService {
esp_netif_t* wifi_sta_netif_{nullptr};
esp_netif_t* wifi_ap_netif_{nullptr};
bool wifi_started_{false};
bool wifi_event_handlers_registered_{false};
bool setup_ap_started_{false};
bool espnow_started_{false};
bool smartconfig_started_{false};
bool smartconfig_event_handler_registered_{false};
std::optional<WirelessInfo> smartconfig_pending_wireless_;
bool espnow_connected_{false};
std::array<uint8_t, 6> espnow_peer_{};
TaskHandle_t boot_button_task_handle_{nullptr};