feat(gateway): enhance GatewayNetworkService with HTTP and UDP support, add status LED control

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Tony
2026-04-30 00:54:53 +08:00
parent 52aa2fc129
commit 3d8d00c3dd
10 changed files with 599 additions and 30 deletions
+40
View File
@@ -258,4 +258,44 @@ config GATEWAY_DALI_BAUDRATE
help
Runtime baudrate used when initializing the local DALI bus.
menu "Gateway Network Services"
config GATEWAY_NETWORK_HTTP_ENABLED
bool "Enable HTTP gateway API"
default y
help
Enables Lua-compatible HTTP gateway routes such as /info and /dali/cmd.
config GATEWAY_NETWORK_HTTP_PORT
int "HTTP API port"
depends on GATEWAY_NETWORK_HTTP_ENABLED
range 1 65535
default 80
config GATEWAY_NETWORK_UDP_ROUTER_ENABLED
bool "Enable UDP IP router"
default y
help
Enables raw gateway command ingress and notification replies on UDP port 2020 by default.
config GATEWAY_NETWORK_UDP_PORT
int "UDP IP router port"
depends on GATEWAY_NETWORK_UDP_ROUTER_ENABLED
range 1 65535
default 2020
config GATEWAY_STATUS_LED_GPIO
int "Status LED GPIO"
range -1 48
default -1
help
GPIO used by the HTTP /led/1 and /led/0 routes. Set to -1 to disable GPIO control.
config GATEWAY_STATUS_LED_ACTIVE_HIGH
bool "Status LED is active high"
depends on GATEWAY_STATUS_LED_GPIO >= 0
default y
endmenu
endmenu
+29
View File
@@ -16,6 +16,18 @@
#define CONFIG_GATEWAY_CHANNEL_COUNT 2
#endif
#ifndef CONFIG_GATEWAY_NETWORK_HTTP_PORT
#define CONFIG_GATEWAY_NETWORK_HTTP_PORT 80
#endif
#ifndef CONFIG_GATEWAY_NETWORK_UDP_PORT
#define CONFIG_GATEWAY_NETWORK_UDP_PORT 2020
#endif
#ifndef CONFIG_GATEWAY_STATUS_LED_GPIO
#define CONFIG_GATEWAY_STATUS_LED_GPIO -1
#endif
namespace {
constexpr const char* kProjectName = "DALI_485_Gateway";
constexpr const char* kProjectVersion = "0.1.0";
@@ -266,8 +278,25 @@ extern "C" void app_main(void) {
if (profile.enable_wifi || profile.enable_eth) {
gateway::GatewayNetworkServiceConfig network_config;
network_config.wifi_enabled = profile.enable_wifi;
#ifdef CONFIG_GATEWAY_NETWORK_HTTP_ENABLED
network_config.http_enabled = true;
#else
network_config.http_enabled = false;
#endif
#ifdef CONFIG_GATEWAY_NETWORK_UDP_ROUTER_ENABLED
network_config.udp_enabled = true;
#else
network_config.udp_enabled = false;
#endif
network_config.http_port = static_cast<uint16_t>(CONFIG_GATEWAY_NETWORK_HTTP_PORT);
network_config.udp_port = static_cast<uint16_t>(CONFIG_GATEWAY_NETWORK_UDP_PORT);
network_config.status_led_gpio = CONFIG_GATEWAY_STATUS_LED_GPIO;
#ifdef CONFIG_GATEWAY_STATUS_LED_ACTIVE_HIGH
network_config.status_led_active_high = true;
#else
network_config.status_led_active_high = false;
#endif
s_network = std::make_unique<gateway::GatewayNetworkService>(*s_controller, *s_runtime,
network_config);
ESP_ERROR_CHECK(s_network->start());