RTU_ALL_AI/src/system/libweb_server/inc/web_server.h

60 lines
1.5 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.

/**
* @file web_server.h
* @brief Web 管理服务模块 — HTTP REST API + WebSocket 实时数据通道
* @details 基于 mongoose v7.22 实现嵌入式 Web 服务器。
* 作为 RTU X-Macro 框架的线程模块运行。
*
* 功能:
* - HTTP 静态文件服务packed_fs 内嵌前端)
* - WebSocket 信号实时推送(增量更新)
* - 5 种信号类型增删改查out/in/yk/ao/param
* - 远程命令执行(捕获 stdout 回传)
* - 文件上传/下载
* - 异步命令输出通道
*/
#ifndef _WEB_SERVER_H_
#define _WEB_SERVER_H_
#include "myBase.h"
#include "mySystem.h"
#ifdef __cplusplus
extern "C"
{
#endif
#define MODULE_WEB_SERVER "web_server"
/** WebSocket 信号类型 */
typedef enum
{
WS_SIG_OUT = 0,
WS_SIG_IN,
WS_SIG_YK,
WS_SIG_AO,
WS_SIG_PARAM,
WS_SIG_MAX
} enum_ws_sig_type;
struct mg_connection;
/* ---- X-Macro 框架入口 ---- */
int app_web_server_init1(void *arg);
int app_web_server_init2(void *arg);
void *app_web_server(void *arg);
/* ---- 广播/单播发送 ---- */
void ws_send_all(const char *p_tx, size_t tx_len);
bool ws_send_one(unsigned long conn_id, const char *p_tx, size_t tx_len);
bool ws_send_binary(unsigned long conn_id, const void *data, size_t len);
/* ---- 异步命令通道 ---- */
void ws_set_async_cmd_conn(const char *module, unsigned long conn_id);
unsigned long ws_get_async_cmd_conn(const char *module);
#ifdef __cplusplus
}
#endif
#endif /* _WEB_SERVER_H_ */