mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2026-04-09 03:11:29 +00:00
add doxygen and header guards
This commit is contained in:
parent
f30fa4f130
commit
472b478afe
8 changed files with 126 additions and 21 deletions
|
|
@ -6,8 +6,26 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Start WiFi Access Point (AP) mode.
|
||||
*
|
||||
* Initializes and starts the WiFi AP with the given SSID and password.
|
||||
*
|
||||
* @param ssid SSID for the AP (1-32 characters)
|
||||
* @param password Password for the AP (min. 8 characters, optional)
|
||||
* @param channel WiFi channel to use
|
||||
* @param max_connections Maximum number of client connections
|
||||
* @return ESP_OK on success, ESP_ERR_INVALID_ARG or other error codes on
|
||||
* failure
|
||||
*/
|
||||
esp_err_t wifi_start_ap(const char *ssid, const char *password, uint8_t channel,
|
||||
uint8_t max_connections);
|
||||
|
||||
/**
|
||||
* @brief Stop WiFi Access Point (AP) mode.
|
||||
*
|
||||
* Deinitializes and stops the WiFi AP.
|
||||
*/
|
||||
void wifi_stop_ap(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
#define LOG_TAG "WEBSRV"
|
||||
|
||||
/**
|
||||
* @def LOG_TAG
|
||||
* @brief Tag used for web server logging.
|
||||
*/
|
||||
|
||||
#include "web_server.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
|
@ -14,12 +19,34 @@
|
|||
#include "storage.h"
|
||||
|
||||
// Default configuration values
|
||||
/**
|
||||
* @brief Default port for the web server.
|
||||
*/
|
||||
#define WEBSERVER_DEFAULT_PORT 80
|
||||
/**
|
||||
* @brief Default port for the web server.
|
||||
*/
|
||||
#define WEBSERVER_DEFAULT_MAX_HANDLERS 32
|
||||
/**
|
||||
* @brief Default maximum number of URI handlers.
|
||||
*/
|
||||
#define WEBSERVER_DEFAULT_STACK_SIZE (8 * 1024)
|
||||
/**
|
||||
* @brief Default stack size for the web server task.
|
||||
*/
|
||||
#define WEBSERVER_DEFAULT_TASK_PRIORITY 5
|
||||
/**
|
||||
* @brief Default task priority for the web server task.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Handle for the HTTP server instance.
|
||||
*/
|
||||
static httpd_handle_t s_server_handle = NULL;
|
||||
|
||||
/**
|
||||
* @brief Handle for the FreeRTOS web server task.
|
||||
*/
|
||||
static TaskHandle_t s_server_task_handle = NULL;
|
||||
|
||||
/**
|
||||
|
|
@ -127,6 +154,15 @@ static void webserver_task(void *arg) {
|
|||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Start the web server with the given configuration.
|
||||
*
|
||||
* Initializes storage, configures the HTTP server, registers default handlers,
|
||||
* and starts the FreeRTOS task for async operation.
|
||||
*
|
||||
* @param config Pointer to webserver configuration struct (optional)
|
||||
* @return Handle to the running HTTP server, or NULL on failure
|
||||
*/
|
||||
httpd_handle_t webserver_start(const webserver_config_t *config) {
|
||||
if (s_server_handle != NULL) {
|
||||
LOGW("Web server already running");
|
||||
|
|
@ -207,6 +243,13 @@ httpd_handle_t webserver_start(const webserver_config_t *config) {
|
|||
return s_server_handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Stop the web server and clean up resources.
|
||||
*
|
||||
* Stops the HTTP server and deletes the FreeRTOS task.
|
||||
*
|
||||
* @param server Handle to the HTTP server instance
|
||||
*/
|
||||
void webserver_stop(httpd_handle_t server) {
|
||||
if (server == NULL) {
|
||||
return;
|
||||
|
|
@ -224,6 +267,14 @@ void webserver_stop(httpd_handle_t server) {
|
|||
LOGI("Web server stopped");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Register a URI handler with the web server.
|
||||
*
|
||||
* @param server Handle to the HTTP server instance
|
||||
* @param uri_handler Pointer to the URI handler struct
|
||||
* @return ESP_OK on success, ESP_ERR_INVALID_ARG or other error codes on
|
||||
* failure
|
||||
*/
|
||||
esp_err_t webserver_register_handler(httpd_handle_t server,
|
||||
const httpd_uri_t *uri_handler) {
|
||||
if (server == NULL || uri_handler == NULL) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
#define LOG_TAG "WIFI"
|
||||
|
||||
#include "wifi.h"
|
||||
#define LOG_TAG "WIFI" ///< "WIFI" log tag for this file
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
|
@ -9,9 +7,25 @@
|
|||
#include "esp_wifi.h"
|
||||
#include "logger.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "wifi.h"
|
||||
|
||||
/**
|
||||
* @brief Indicates whether the WiFi AP is started.
|
||||
*/
|
||||
static bool s_wifi_started = false;
|
||||
|
||||
/**
|
||||
* @brief Start WiFi Access Point (AP) mode.
|
||||
*
|
||||
* Initializes and starts the WiFi AP with the given SSID and password.
|
||||
*
|
||||
* @param ssid SSID for the AP (1-32 characters)
|
||||
* @param password Password for the AP (min. 8 characters, optional)
|
||||
* @param channel WiFi channel to use
|
||||
* @param max_connections Maximum number of client connections
|
||||
* @return ESP_OK on success, ESP_ERR_INVALID_ARG or other error codes on
|
||||
* failure
|
||||
*/
|
||||
esp_err_t wifi_start_ap(const char *ssid, const char *password, uint8_t channel,
|
||||
uint8_t max_connections) {
|
||||
if (s_wifi_started) {
|
||||
|
|
@ -74,6 +88,11 @@ esp_err_t wifi_start_ap(const char *ssid, const char *password, uint8_t channel,
|
|||
return ESP_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Stop WiFi Access Point (AP) mode.
|
||||
*
|
||||
* Deinitializes and stops the WiFi AP.
|
||||
*/
|
||||
void wifi_stop_ap(void) {
|
||||
if (!s_wifi_started) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue