From 08166b15aba5001fc88b39f168f073f18deec870 Mon Sep 17 00:00:00 2001 From: ovizro Date: Sun, 12 Jan 2025 18:13:55 +0800 Subject: [PATCH] refactor(external-interface): update telemetry configuration and transport settings - Reorder and rename configuration options for better clarity - Set default local host to 0.0.0.0 for both HostInfo and Telemetry - Update default UDP ports to 12500 for both HostInfo and Telemetry - Fix port value parsing in external_interface.cpp --- config/exint.cfg | 18 +++++++++++------- src/external_interface.cpp | 6 +++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/config/exint.cfg b/config/exint.cfg index 4d844d1..2a044a6 100644 --- a/config/exint.cfg +++ b/config/exint.cfg @@ -6,17 +6,21 @@ Log_Level = DEBUG Enable_Alarm_Code = 1 ; 0: Disable, 1: Enable HostInfo_Transport_Open = 1 ; 0: Disable, 1: Enable -HostInfo_Transport_Mode = COM ; COM, UDP, UNIX_UDP +HostInfo_Enable_Telemetry = 1 ; 0: Disable, 1: Enable +HostInfo_Transport_Mode = UDP ; COM, UDP, UNIX_UDP HostInfo_COM_Path = /dev/ttyUSB0 HostInfo_COM_Baudrate = 115200 -HostInfo_Enable_Telemetry = 1 ; 0: Disable, 1: Enable +HostInfo_UDP_Local_Host = 0.0.0.0 +HostInfo_UDP_Local_Port = 12500 +HostInfo_UDP_Remote_Host = localhost +HostInfo_UDP_Remote_Port = 12500 Telemetry_Transport_Open = 1 ; 0: Disable, 1: Enable -Telemetry_Transport_Mode = UDP ; COM, UDP, UNIX_UDP +Telemetry_Enable_Telemetry = 1 ; 0: Disable, 1: Enable +Telemetry_Transport_Mode = COM ; COM, UDP, UNIX_UDP Telemetry_COM_Path = /dev/ttyUSB1 Telemetry_COM_Baudrate = 115200 -Telemetry_UDP_Local_Host = localhost -Telemetry_UDP_Local_Port = 5000 +Telemetry_UDP_Local_Host = 0.0.0.0 +Telemetry_UDP_Local_Port = 12500 Telemetry_UDP_Remote_Host = localhost -Telemetry_UDP_Remote_Port = 5001 -Telemetry_Enable_Telemetry = 1 ; 0: Disable, 1: Enable +Telemetry_UDP_Remote_Port = 12500 diff --git a/src/external_interface.cpp b/src/external_interface.cpp index fe296c7..5931257 100644 --- a/src/external_interface.cpp +++ b/src/external_interface.cpp @@ -83,12 +83,12 @@ static int read_config(const char* config_path) { transport_var = std::unique_ptr(\ new transport::SerialPortTransport(com_path, baudrate)\ );\ - } else if (strcasecmp(transport_mode, "datagram") == 0 || strcasecmp(transport_mode, "udp")) {\ + } else if (strcasecmp(transport_mode, "datagram") == 0 || strcasecmp(transport_mode, "udp") == 0) {\ const char* host = "0.0.0.0";\ if (!config.getValue(config_section, #prefix "_UDP_Local_Host", host)) {\ logger.error("failed to read [%s]:" #prefix "_UDP_Local_Host in %s", config_section, config_path); \ }\ - long port = 5000; \ + long port = 125000; \ if (!config.getIntValue(config_section, #prefix "_UDP_Local_Port", port)) {\ logger.error("failed to read [%s]:" #prefix "_UDP_Local_Port in %s", config_section, config_path); \ }\ @@ -96,7 +96,7 @@ static int read_config(const char* config_path) { if (!config.getValue(config_section, #prefix "_UDP_Remote_Host", remote_host)) {\ logger.error("failed to read [%s]:" #prefix "_UDP_Remote_Host in %s", config_section, config_path); \ }\ - long remote_port = 5000; \ + long remote_port = 125000; \ if (!config.getIntValue(config_section, #prefix "_UDP_Remote_Port", remote_port)) {\ logger.error("failed to read [%s]:" #prefix "_UDP_Remote_Port in %s", config_section, config_path); \ }\