|
|
ChaosDMX
Open-Source DMX-Interface
|
#include "web_server.h"#include <ctype.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "esp_err.h"#include "freertos/FreeRTOS.h"#include "freertos/task.h"#include "logger.h"#include "storage.h"Go to the source code of this file.
Macros | |
| #define | LOG_TAG "WEBSRV" |
| Tag used for web server logging. | |
| #define | WEBSERVER_DEFAULT_PORT 80 |
| Default port for the web server. | |
| #define | WEBSERVER_DEFAULT_MAX_HANDLERS 32 |
| Default port for the web server. | |
| #define | WEBSERVER_DEFAULT_STACK_SIZE (8 * 1024) |
| Default maximum number of URI handlers. | |
| #define | WEBSERVER_DEFAULT_TASK_PRIORITY 5 |
| Default stack size for the web server task. | |
Functions | |
| static const char * | get_mime_type (const char *filename) |
| Get MIME type based on file extension. | |
| static esp_err_t | static_file_handler (httpd_req_t *req) |
| HTTP handler for static files from LittleFS. | |
| static esp_err_t | health_check_handler (httpd_req_t *req) |
| HTTP handler for API health check (GET /api/health). | |
| static void | webserver_task (void *arg) |
| FreeRTOS task function for the HTTP server. Allows non-blocking server operation and future extensibility. | |
| httpd_handle_t | webserver_start (const webserver_config_t *config) |
| Start the web server with the given configuration. | |
| void | webserver_stop (httpd_handle_t server) |
| Stop the web server and clean up resources. | |
| esp_err_t | webserver_register_handler (httpd_handle_t server, const httpd_uri_t *uri_handler) |
| Register a URI handler with the web server. | |
Variables | |
| static httpd_handle_t | s_server_handle = NULL |
| Default task priority for the web server task. | |
| static TaskHandle_t | s_server_task_handle = NULL |
| Handle for the FreeRTOS web server task. | |
| #define LOG_TAG "WEBSRV" |
Tag used for web server logging.
Definition at line 1 of file web_server.c.
| #define WEBSERVER_DEFAULT_MAX_HANDLERS 32 |
Default port for the web server.
Definition at line 29 of file web_server.c.
Referenced by webserver_start().
| #define WEBSERVER_DEFAULT_PORT 80 |
Default port for the web server.
Definition at line 25 of file web_server.c.
Referenced by webserver_start().
| #define WEBSERVER_DEFAULT_STACK_SIZE (8 * 1024) |
Default maximum number of URI handlers.
Definition at line 33 of file web_server.c.
Referenced by webserver_start().
| #define WEBSERVER_DEFAULT_TASK_PRIORITY 5 |
Default stack size for the web server task.
Definition at line 37 of file web_server.c.
Referenced by webserver_start().
|
static |
Get MIME type based on file extension.
Definition at line 55 of file web_server.c.
Referenced by static_file_handler().
|
static |
HTTP handler for API health check (GET /api/health).
Definition at line 134 of file web_server.c.
Referenced by webserver_start().
|
static |
HTTP handler for static files from LittleFS.
Definition at line 93 of file web_server.c.
References get_mime_type(), LOGW, and storage_get_mount_point().
Referenced by webserver_start().
| esp_err_t webserver_register_handler | ( | httpd_handle_t | server, |
| const httpd_uri_t * | uri_handler ) |
Register a URI handler with the web server.
Register a custom URI handler.
| server | Handle to the HTTP server instance |
| uri_handler | Pointer to the URI handler struct |
Definition at line 278 of file web_server.c.
| httpd_handle_t webserver_start | ( | const webserver_config_t * | config | ) |
Start the web server with the given configuration.
Initialize and start the HTTP web server.
Initializes storage, configures the HTTP server, registers default handlers, and starts the FreeRTOS task for async operation.
| config | Pointer to webserver configuration struct (optional) |
Definition at line 166 of file web_server.c.
References health_check_handler(), LOGE, LOGI, LOGW, s_server_handle, s_server_task_handle, static_file_handler(), storage_init(), WEBSERVER_DEFAULT_MAX_HANDLERS, WEBSERVER_DEFAULT_PORT, WEBSERVER_DEFAULT_STACK_SIZE, WEBSERVER_DEFAULT_TASK_PRIORITY, and webserver_task().
Referenced by app_main().
| void webserver_stop | ( | httpd_handle_t | server | ) |
Stop the web server and clean up resources.
Stop the web server and cleanup resources.
Stops the HTTP server and deletes the FreeRTOS task.
| server | Handle to the HTTP server instance |
Definition at line 253 of file web_server.c.
References LOGI, s_server_handle, and s_server_task_handle.
|
static |
FreeRTOS task function for the HTTP server. Allows non-blocking server operation and future extensibility.
Definition at line 144 of file web_server.c.
References LOGI, and s_server_handle.
Referenced by webserver_start().
|
static |
Default task priority for the web server task.
Handle for the HTTP server instance.
Definition at line 45 of file web_server.c.
Referenced by webserver_start(), webserver_stop(), and webserver_task().
|
static |
Handle for the FreeRTOS web server task.
Definition at line 50 of file web_server.c.
Referenced by webserver_start(), and webserver_stop().