fix: start only enabled links and move config buffers off stack

This commit is contained in:
2026-04-23 00:00:06 +08:00
parent e3450fd0ad
commit eeccfb84a0
3 changed files with 59 additions and 54 deletions
+8 -8
View File
@@ -23,6 +23,8 @@ static device_config_t g_config;
static volatile bool g_reset_requested;
static volatile bool g_uart1_tx_busy;
static uint8_t g_uart1_rx_buffer[CONFIG_RX_BUFFER_SIZE];
static char g_config_cmd_buffer[CONFIG_CMD_MAX_LEN];
static char g_config_response_buffer[CONFIG_TX_BUFFER_SIZE];
static uint32_t config_calc_crc(const device_config_t *cfg)
{
@@ -632,8 +634,6 @@ static void config_respond_to_uart(route_msg_t *msg, const char *response)
void ConfigTask(void *argument)
{
route_msg_t *msg;
char cmd[CONFIG_CMD_MAX_LEN];
char response[CONFIG_TX_BUFFER_SIZE];
at_result_t result;
(void)argument;
@@ -646,14 +646,14 @@ void ConfigTask(void *argument)
continue;
}
if (msg->len >= sizeof(cmd)) {
msg->len = sizeof(cmd) - 1u;
if (msg->len >= sizeof(g_config_cmd_buffer)) {
msg->len = sizeof(g_config_cmd_buffer) - 1u;
}
memcpy(cmd, msg->data, msg->len);
cmd[msg->len] = '\0';
memcpy(g_config_cmd_buffer, msg->data, msg->len);
g_config_cmd_buffer[msg->len] = '\0';
result = config_process_at_cmd(cmd, response, sizeof(response));
config_respond_to_uart(msg, response);
result = config_process_at_cmd(g_config_cmd_buffer, g_config_response_buffer, sizeof(g_config_response_buffer));
config_respond_to_uart(msg, g_config_response_buffer);
if (result == AT_NEED_REBOOT) {
config_respond_to_uart(msg, "Note: Use AT+SAVE then AT+RESET to apply changes\r\n");
}
+4
View File
@@ -192,6 +192,7 @@ static void uart_send_tcp_msg_to_uarts(route_msg_t *msg)
static void uart_route_mux_frame(uart_channel_t source_channel, const uart_mux_frame_t *frame)
{
const device_config_t *cfg = config_get();
uint32_t i;
uint8_t source_conn = (source_channel == UART_CHANNEL_U1) ? ROUTE_CONN_UART3 : ROUTE_CONN_UART2;
uint8_t out_frame[ROUTE_MSG_MAX_PAYLOAD + 6u];
@@ -209,6 +210,9 @@ static void uart_route_mux_frame(uart_channel_t source_channel, const uart_mux_f
}
for (i = 0; i < CONFIG_LINK_COUNT; ++i) {
if (cfg->links[i].enabled == 0u) {
continue;
}
uint8_t endpoint = config_link_index_to_endpoint((uint8_t)i);
if ((frame->dst_mask & endpoint) != 0u) {
(void)route_send(xLinkTxQueues[i], frame->src_id, endpoint, source_conn, frame->payload, frame->payload_len, pdMS_TO_TICKS(10));