Files
STM32F4-Base/Drivers/BSP/UI/ui_net_sink.h
T
2026-08-30 08:57:07 +08:00

58 lines
1.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* 模块名称:UI Network Sink (RemoDispBus 服务端)
* 模块功能:实现 RemoDispBus 协议服务端,接收远端连接与导航按键,回送 1bpp 帧缓冲
* 适用平台:STM32F407ZGTx + CH395F 以太网
* 作者:王建锋
* 创建日期:2026-08-29
* 修改记录:
* 2026-08-29 王建锋 创建初始版本
* 2026-08-29 王建锋 修正监听端口为 7003,与 DTU-RemoteLCD 客户端默认端口对齐
*/
#ifndef __UI_NET_SINK_H
#define __UI_NET_SINK_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* RemoDispBus 标签与命令 */
#define UI_REMO_TAG_CLIENT 0xAA
#define UI_REMO_TAG_DEVICE 0xBB
#define UI_REMO_CMD_KEEP 0
#define UI_REMO_CMD_INIT 1
#define UI_REMO_CMD_KEY 2
#define UI_REMO_CMD_LCDMEM 3
/* UI 推流监听端口(须与 DTU-RemoteLCD 客户端默认端口 7003 一致) */
#define UI_NET_SINK_PORT 7003
/*
* 函数功能:启动 UI 专用 TCP 监听 Socket
* 入口参数:port - 监听端口号 uint16_t 1 - 65535
* 返回值:0 - 成功,其他 - 失败(socket 创建/绑定/监听失败)
* 限定条件:net_init() 已完成,网络子系统就绪
* 函数说明:1. 创建流式 Socket 并绑定到指定端口与任意本地地址
* 2. 进入监听状态,等待远端客户端连接
* 3. 调用前需确保 CH395F 网络已初始化
*/
int ui_net_sink_start(uint16_t port);
/*
* 函数功能:非阻塞轮询 RemoDispBus 协议
* 入口参数:无
* 返回值:无
* 限定条件:ui_net_sink_start() 已成功调用
* 函数说明:1. 无客户端时尝试接受连接,成功即上报 INIT
* 2. 有客户端时用 DONTWAIT 收帧并解析(KEEPLIVE/INIT/KEY/LCDMEM)
* 3. 对端关闭或异常时复位客户端,等待下次重监听,不阻塞 LVGL 刷新
*/
void ui_net_sink_poll(void);
#ifdef __cplusplus
}
#endif
#endif /* __UI_NET_SINK_H */