2026-08-27 调试完成版本
- FC 控制指令域修正:payload 14→18 字节,纵倾/横倾姿态拆分为数据1/数据2 - WebServer 广播改为待发队列模式,修复 mongoose 跨线程调用问题 - build-board.sh 增加板卡组网说明(/23 掩码方案)、pCCU 服务部署与 mission 同步 - 同步 0824 协议文档更新
This commit is contained in:
@@ -32,6 +32,8 @@ public:
|
||||
bool isRunning() const { return m_running; }
|
||||
|
||||
// 向所有 WebSocket 客户端广播文本
|
||||
// 线程安全:mongoose 非线程安全,本接口只把文本放入待发队列,
|
||||
// 由 Web 线程在 mg_mgr_poll 返回后统一发送(禁止跨线程直接 mg_ws_send)
|
||||
void broadcast(const std::string& text);
|
||||
|
||||
// 新客户端连接时调用,返回初始快照
|
||||
@@ -44,14 +46,17 @@ private:
|
||||
static bool serverThreadCB(void* pParam);
|
||||
bool serverThreadFunc();
|
||||
void handleEvent(struct mg_connection* c, int ev, void* ev_data);
|
||||
// Web 线程内:把待发队列中的快照推给所有 WS 客户端(仅本线程触碰连接列表)
|
||||
void flushPending();
|
||||
|
||||
struct mg_mgr m_mgr;
|
||||
int m_port = 0;
|
||||
std::atomic<bool> m_running{false};
|
||||
std::thread m_thread;
|
||||
|
||||
std::mutex m_wsMutex;
|
||||
std::vector<mg_connection*> m_wsConnections;
|
||||
std::mutex m_pendingMutex; // 保护 m_pending
|
||||
std::string m_pending; // 最新待广播快照(新快照覆盖旧快照)
|
||||
std::vector<mg_connection*> m_wsConnections; // 仅 Web 线程访问
|
||||
std::function<std::string()> m_onOpen;
|
||||
std::function<std::string(const std::string&, const std::string&)> m_apiHandler;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user