Files
mimiclaw/main/gateway/ws_server.h
crispyberry 9435302063 feat: add WebSocket gateway on port 18789
JSON protocol server using esp_http_server with WS upgrade.
Supports up to 4 concurrent clients, auto-assigned chat_id,
routes messages through the agent via message bus.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 18:55:49 +08:00

26 lines
682 B
C

#pragma once
#include "esp_err.h"
/**
* Initialize and start the WebSocket server on MIMI_WS_PORT.
* Allows external clients to interact with the Agent via JSON messages.
*
* Protocol:
* Inbound: {"type":"message","content":"hello","chat_id":"ws_client1"}
* Outbound: {"type":"response","content":"Hi!","chat_id":"ws_client1"}
*/
esp_err_t ws_server_start(void);
/**
* Send a text message to a specific WebSocket client by chat_id.
* @param chat_id Client identifier (assigned on connection)
* @param text Message text
*/
esp_err_t ws_server_send(const char *chat_id, const char *text);
/**
* Stop the WebSocket server.
*/
esp_err_t ws_server_stop(void);