10#define OVE_NET_HTTPD_H
27#include "ove_config.h"
35#ifdef CONFIG_OVE_NET_HTTPD
38#define OVE_HTTPD_MAX_ROUTES 16
41#define OVE_HTTPD_MAX_SEGMENTS 8
108#ifdef CONFIG_OVE_AUDIO
114#ifdef CONFIG_OVE_INFER
157 const void *body,
size_t len);
161 const void *body,
size_t len);
168#ifdef CONFIG_OVE_NET_HTTPD_WS
int ove_httpd_ws_is_upgrade(const char *headers)
Return non-zero if the HTTP headers request a WebSocket upgrade.
int ove_httpd_resp_html(ove_httpd_resp_t *resp, int status, const char *html, size_t len)
Send an HTML response.
void ove_httpd_set_netif(ove_netif_t netif)
Set the network interface used by built-in dashboard routes.
int(* ove_httpd_handler_t)(ove_httpd_req_t *req, ove_httpd_resp_t *resp)
Route handler callback.
Definition net_httpd.h:53
const char * ove_httpd_req_query(ove_httpd_req_t *req)
Get the query string after '?' (or NULL).
struct ove_httpd_req ove_httpd_req_t
Opaque HTTP request.
Definition net_httpd.h:44
int ove_httpd_ws_broadcast(const char *path, const void *data, size_t len)
Broadcast a text message to all WebSocket connections on a path.
const char * ove_httpd_req_segment(ove_httpd_req_t *req, int idx)
Get a path segment by index.
void ove_httpd_stop(void)
Stop the HTTP server and close the listening socket.
void(* ove_httpd_ws_handler_t)(ove_httpd_ws_conn_t *conn, const void *data, size_t len)
WebSocket message callback.
Definition net_httpd.h:179
void ove_httpd_ws_poll(void)
Drive the WS subsystem from the httpd task's poll loop.
void(* ove_httpd_ws_close_handler_t)(ove_httpd_ws_conn_t *conn)
WebSocket close callback.
Definition net_httpd.h:185
int ove_httpd_ws_route(const char *path, ove_httpd_ws_handler_t on_message, ove_httpd_ws_close_handler_t on_close)
Register a WebSocket route.
int ove_httpd_resp_error(ove_httpd_resp_t *resp, int status, const char *message)
Send a JSON error response.
int ove_httpd_resp_send(ove_httpd_resp_t *resp, int status, const char *content_type, const void *body, size_t len)
Send a response with arbitrary content type.
size_t ove_httpd_req_body_len(ove_httpd_req_t *req)
Get the request body length.
const char * ove_httpd_req_method(ove_httpd_req_t *req)
Get the HTTP method string ("GET" or "POST").
const char * ove_httpd_req_path(ove_httpd_req_t *req)
Get the full request path (e.g. "/api/leds/0").
int ove_httpd_ws_send(ove_httpd_ws_conn_t *conn, const void *data, size_t len)
Send a text message to a WebSocket connection.
int ove_httpd_ws_active_count(void)
Return the number of active WebSocket connections.
struct ove_httpd_ws_conn ove_httpd_ws_conn_t
Opaque WebSocket connection handle.
Definition net_httpd.h:171
int ove_httpd_start(const ove_httpd_config_t *cfg)
Start the HTTP server.
void ove_httpd_set_audio_graph(struct ove_audio_graph *g)
Set the audio graph for /api/audio/stats.
const char * ove_httpd_req_body(ove_httpd_req_t *req)
Get the request body (or NULL).
void ove_httpd_log_append(const char *line)
Feed a log line into the httpd log ring buffer.
int ove_httpd_ws_handshake(const char *headers, size_t headers_len, const char *path, ove_socket_t sock, ove_socket_storage_t *storage)
Complete the WebSocket upgrade handshake on sock.
int ove_httpd_resp_json(ove_httpd_resp_t *resp, int status, const char *json)
Send a JSON response.
int ove_httpd_resp_send_gz(ove_httpd_resp_t *resp, int status, const char *content_type, const void *body, size_t len)
Send a pre-gzipped response (adds Content-Encoding: gzip).
int ove_httpd_route(const char *method, const char *path, ove_httpd_handler_t handler)
Register a route handler.
struct ove_httpd_resp ove_httpd_resp_t
Opaque HTTP response.
Definition net_httpd.h:47
void ove_httpd_set_model(ove_model_t model)
Set the ML model for /api/infer/stats.
void ove_httpd_register_builtin_routes(void)
Register built-in dashboard routes (/api/info, /api/leds, etc.).
struct ove_netif * ove_netif_t
Opaque handle for a network interface.
Definition types.h:250
struct ove_socket * ove_socket_t
Opaque handle for a network socket.
Definition types.h:247
struct ove_model * ove_model_t
Opaque handle for an ML inference model session.
Definition types.h:244
@ OVE_ERR_NOT_SUPPORTED
Definition types.h:98
Audio processing graph instance.
Definition audio.h:96
HTTP server configuration.
Definition net_httpd.h:58
int max_body_size
Definition net_httpd.h:60
uint16_t port
Definition net_httpd.h:59