mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2026-03-09 13:30:20 +00:00
add(web_server): init basic webserver
This commit is contained in:
parent
4d8be45e48
commit
7ea7944e91
10 changed files with 447 additions and 1 deletions
58
components/web_server/include/web_server.h
Normal file
58
components/web_server/include/web_server.h
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* @file web_server.h
|
||||
* @brief Simple HTTP web server component for ESP32 with async FreeRTOS support.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_http_server.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Web server configuration structure.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t port; ///< HTTP server port (default: 80)
|
||||
size_t max_uri_handlers; ///< Maximum number of URI handlers
|
||||
size_t stack_size; ///< FreeRTOS task stack size
|
||||
UBaseType_t task_priority; ///< FreeRTOS task priority
|
||||
} webserver_config_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize and start the HTTP web server.
|
||||
*
|
||||
* This function creates a FreeRTOS task that manages the HTTP server.
|
||||
* It serves static files from the data/ folder and supports dynamic handler registration.
|
||||
*
|
||||
* @param config Configuration structure. If NULL, default values are used.
|
||||
* @return HTTP server handle on success, NULL on failure.
|
||||
*/
|
||||
httpd_handle_t webserver_start(const webserver_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Stop the web server and cleanup resources.
|
||||
*
|
||||
* @param server HTTP server handle returned by webserver_start().
|
||||
* Safe to pass NULL.
|
||||
*/
|
||||
void webserver_stop(httpd_handle_t server);
|
||||
|
||||
/**
|
||||
* @brief Register a custom URI handler.
|
||||
*
|
||||
* This allows dynamic registration of API endpoints and other custom handlers.
|
||||
*
|
||||
* @param server HTTP server handle.
|
||||
* @param uri_handler Pointer to httpd_uri_t structure.
|
||||
* @return ESP_OK on success, error code otherwise.
|
||||
*/
|
||||
esp_err_t webserver_register_handler(httpd_handle_t server, const httpd_uri_t *uri_handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
15
components/web_server/include/wifi.h
Normal file
15
components/web_server/include/wifi.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
esp_err_t wifi_start_ap(const char *ssid, const char *password, uint8_t channel, uint8_t max_connections);
|
||||
void wifi_stop_ap(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue