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());
+16 -6
View File
@@ -562,13 +562,13 @@ CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_ESPTOOLPY_FLASHFREQ="80m"
# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set
# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set
# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set
# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
# CONFIG_ESPTOOLPY_FLASHSIZE_32MB is not set
# CONFIG_ESPTOOLPY_FLASHSIZE_64MB is not set
# CONFIG_ESPTOOLPY_FLASHSIZE_128MB is not set
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
CONFIG_ESPTOOLPY_FLASHSIZE="16MB"
# CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE is not set
CONFIG_ESPTOOLPY_BEFORE_RESET=y
# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set
@@ -584,11 +584,11 @@ CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
#
# CONFIG_PARTITION_TABLE_SINGLE_APP is not set
# CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE is not set
CONFIG_PARTITION_TABLE_TWO_OTA=y
# CONFIG_PARTITION_TABLE_TWO_OTA is not set
# CONFIG_PARTITION_TABLE_TWO_OTA_LARGE is not set
# CONFIG_PARTITION_TABLE_CUSTOM is not set
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions_two_ota.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_OFFSET=0x8000
CONFIG_PARTITION_TABLE_MD5=y
# end of Partition Table
@@ -619,6 +619,16 @@ CONFIG_GATEWAY_CHANNEL2_PHY_DISABLED=y
# end of Gateway Channel 2
# CONFIG_GATEWAY_ENABLE_DALI_BUS is not set
#
# Gateway Network Services
#
CONFIG_GATEWAY_NETWORK_HTTP_ENABLED=y
CONFIG_GATEWAY_NETWORK_HTTP_PORT=80
CONFIG_GATEWAY_NETWORK_UDP_ROUTER_ENABLED=y
CONFIG_GATEWAY_NETWORK_UDP_PORT=2020
CONFIG_GATEWAY_STATUS_LED_GPIO=-1
# end of Gateway Network Services
# end of Gateway App
#