3.27_433:修改并验证了IO脚状态反馈逻辑,及时将IO脚状态变化反馈通过RF433发送。
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
|
||||
#include "io_monitor.h"
|
||||
#include "uart2_print.h"
|
||||
#include "multi_uart_router.h"
|
||||
#include "main.h"
|
||||
#include <string.h>
|
||||
|
||||
@ -195,17 +196,19 @@ static void send_di_event(uint8_t channel, uint8_t state)
|
||||
/* 将校验和追加到消息末尾,格式为两位十六进制数 */
|
||||
snprintf(msg + len, sizeof(msg) - len, "%02X\r\n", cs);
|
||||
|
||||
/* 根据是否设置回调函数选择发送方式 */
|
||||
if (g_event_callback != NULL) {
|
||||
/* 通过回调函数发送,支持多端口路由 */
|
||||
g_event_callback(channel, state, msg);
|
||||
} else {
|
||||
/* 默认发送到UART2 */
|
||||
UART2_Print_String(msg);
|
||||
}
|
||||
|
||||
/* 输出调试日志,记录状态变化 */
|
||||
/* 输出调试日志到UART2,记录状态变化 */
|
||||
DEBUG_LOG("CH%d -> %s", channel + 1, state ? "HIGH" : "LOW");
|
||||
|
||||
/* 向UART1(RF433)发送状态变化事件 */
|
||||
MultiUART_SendString(PORT_UART1, msg);
|
||||
|
||||
/* 输出完整消息到UART2,方便调试查看 */
|
||||
DEBUG_LOG("RF433 TX: \"%s\"", msg);
|
||||
|
||||
/* 如果设置了回调函数,也通过回调发送 */
|
||||
if (g_event_callback != NULL) {
|
||||
g_event_callback(channel, state, msg);
|
||||
}
|
||||
}
|
||||
|
||||
/*==============================================================================
|
||||
|
||||
Reference in New Issue
Block a user