diff options
Diffstat (limited to 'fw/src/http.c')
-rw-r--r-- | fw/src/http.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/fw/src/http.c b/fw/src/http.c index 96a70fe..b9a76ba 100644 --- a/fw/src/http.c +++ b/fw/src/http.c @@ -13,6 +13,8 @@ #include <zephyr/net/http/service.h> #include <zephyr/net/http/status.h> +#include "ws.h" + LOG_MODULE_REGISTER(http); @@ -59,11 +61,24 @@ static struct http_resource_detail_dynamic favicon_resource_detail = { .user_data = NULL, }; +static uint8_t websocket_read_buffer[1024]; + +struct http_resource_detail_websocket websocket_resource_detail = { + .common = { + .type = HTTP_RESOURCE_TYPE_WEBSOCKET, + .bitmask_of_supported_http_methods = BIT(HTTP_GET), + }, + .cb = ws_upgrade_handler, + .data_buffer = websocket_read_buffer, + .data_buffer_len = sizeof(websocket_read_buffer), +}; + static uint16_t http_port = 80; HTTP_SERVICE_DEFINE(http_service, NULL, &http_port, 1, 10, NULL, NULL); HTTP_RESOURCE_DEFINE(index_resource, http_service, "/", &index_resource_detail); +HTTP_RESOURCE_DEFINE(websocket_resource, http_service, "/", &websocket_resource_detail); HTTP_RESOURCE_DEFINE(favicon_resource, http_service, "/favicon.ico", &favicon_resource_detail); int init_http_server(void) { |