mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2026-04-07 10:22:21 +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
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file logger.h
|
* @file logger.h
|
||||||
* @brief Project-wide logging macros based on ESP-IDF's logging library.
|
* @brief Project-wide logging macros based on ESP-IDF's logging library.
|
||||||
|
|
@ -27,8 +26,12 @@
|
||||||
|
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef LOG_TAG
|
#ifndef LOG_TAG
|
||||||
#define LOG_TAG "CHAOS"
|
#define LOG_TAG "CHAOS" ///< Default log tag
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @brief Log a message at Error level. */
|
/** @brief Log a message at Error level. */
|
||||||
|
|
@ -41,3 +44,7 @@
|
||||||
#define LOGD(...) ESP_LOGD(LOG_TAG, __VA_ARGS__)
|
#define LOGD(...) ESP_LOGD(LOG_TAG, __VA_ARGS__)
|
||||||
/** @brief Log a message at Verbose level. */
|
/** @brief Log a message at Verbose level. */
|
||||||
#define LOGV(...) ESP_LOGV(LOG_TAG, __VA_ARGS__)
|
#define LOGV(...) ESP_LOGV(LOG_TAG, __VA_ARGS__)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
#ifndef STORAGE_H
|
#pragma once
|
||||||
#define STORAGE_H
|
|
||||||
|
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
|
|
||||||
|
|
@ -24,5 +23,3 @@ const char *storage_get_mount_point(void);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* STORAGE_H */
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
#define LOG_TAG "STORE"
|
#define LOG_TAG "STORE" ///< "STORE" log tag for this file
|
||||||
|
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
#include "esp_littlefs.h"
|
#include "esp_littlefs.h"
|
||||||
#include "esp_vfs.h"
|
#include "esp_vfs.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
||||||
static const char *LITTLEFS_MOUNT_POINT = "/data";
|
static const char *LITTLEFS_MOUNT_POINT =
|
||||||
|
"/data"; ///< Mount point for LittleFS filesystem
|
||||||
|
|
||||||
esp_err_t storage_init(void) {
|
esp_err_t storage_init(void) {
|
||||||
esp_vfs_littlefs_conf_t conf = {
|
esp_vfs_littlefs_conf_t conf = {
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,26 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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,
|
esp_err_t wifi_start_ap(const char *ssid, const char *password, uint8_t channel,
|
||||||
uint8_t max_connections);
|
uint8_t max_connections);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Stop WiFi Access Point (AP) mode.
|
||||||
|
*
|
||||||
|
* Deinitializes and stops the WiFi AP.
|
||||||
|
*/
|
||||||
void wifi_stop_ap(void);
|
void wifi_stop_ap(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,10 @@
|
||||||
#define LOG_TAG "WEBSRV"
|
#define LOG_TAG "WEBSRV"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def LOG_TAG
|
||||||
|
* @brief Tag used for web server logging.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "web_server.h"
|
#include "web_server.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
@ -14,12 +19,34 @@
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
|
|
||||||
// Default configuration values
|
// Default configuration values
|
||||||
|
/**
|
||||||
|
* @brief Default port for the web server.
|
||||||
|
*/
|
||||||
#define WEBSERVER_DEFAULT_PORT 80
|
#define WEBSERVER_DEFAULT_PORT 80
|
||||||
|
/**
|
||||||
|
* @brief Default port for the web server.
|
||||||
|
*/
|
||||||
#define WEBSERVER_DEFAULT_MAX_HANDLERS 32
|
#define WEBSERVER_DEFAULT_MAX_HANDLERS 32
|
||||||
|
/**
|
||||||
|
* @brief Default maximum number of URI handlers.
|
||||||
|
*/
|
||||||
#define WEBSERVER_DEFAULT_STACK_SIZE (8 * 1024)
|
#define WEBSERVER_DEFAULT_STACK_SIZE (8 * 1024)
|
||||||
|
/**
|
||||||
|
* @brief Default stack size for the web server task.
|
||||||
|
*/
|
||||||
#define WEBSERVER_DEFAULT_TASK_PRIORITY 5
|
#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;
|
static httpd_handle_t s_server_handle = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Handle for the FreeRTOS web server task.
|
||||||
|
*/
|
||||||
static TaskHandle_t s_server_task_handle = NULL;
|
static TaskHandle_t s_server_task_handle = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -127,6 +154,15 @@ static void webserver_task(void *arg) {
|
||||||
vTaskDelete(NULL);
|
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) {
|
httpd_handle_t webserver_start(const webserver_config_t *config) {
|
||||||
if (s_server_handle != NULL) {
|
if (s_server_handle != NULL) {
|
||||||
LOGW("Web server already running");
|
LOGW("Web server already running");
|
||||||
|
|
@ -207,6 +243,13 @@ httpd_handle_t webserver_start(const webserver_config_t *config) {
|
||||||
return s_server_handle;
|
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) {
|
void webserver_stop(httpd_handle_t server) {
|
||||||
if (server == NULL) {
|
if (server == NULL) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -224,6 +267,14 @@ void webserver_stop(httpd_handle_t server) {
|
||||||
LOGI("Web server stopped");
|
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,
|
esp_err_t webserver_register_handler(httpd_handle_t server,
|
||||||
const httpd_uri_t *uri_handler) {
|
const httpd_uri_t *uri_handler) {
|
||||||
if (server == NULL || uri_handler == NULL) {
|
if (server == NULL || uri_handler == NULL) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
#define LOG_TAG "WIFI"
|
#define LOG_TAG "WIFI" ///< "WIFI" log tag for this file
|
||||||
|
|
||||||
#include "wifi.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
@ -9,9 +7,25 @@
|
||||||
#include "esp_wifi.h"
|
#include "esp_wifi.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "nvs_flash.h"
|
#include "nvs_flash.h"
|
||||||
|
#include "wifi.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Indicates whether the WiFi AP is started.
|
||||||
|
*/
|
||||||
static bool s_wifi_started = false;
|
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,
|
esp_err_t wifi_start_ap(const char *ssid, const char *password, uint8_t channel,
|
||||||
uint8_t max_connections) {
|
uint8_t max_connections) {
|
||||||
if (s_wifi_started) {
|
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;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Stop WiFi Access Point (AP) mode.
|
||||||
|
*
|
||||||
|
* Deinitializes and stops the WiFi AP.
|
||||||
|
*/
|
||||||
void wifi_stop_ap(void) {
|
void wifi_stop_ap(void) {
|
||||||
if (!s_wifi_started) {
|
if (!s_wifi_started) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,8 @@
|
||||||
idf_component_register(SRCS "dmx-interface.c" INCLUDE_DIRS "." REQUIRES
|
idf_component_register(
|
||||||
web_server)
|
SRCS
|
||||||
|
"dmx-interface.c"
|
||||||
|
INCLUDE_DIRS
|
||||||
|
"."
|
||||||
|
REQUIRES
|
||||||
|
web_server
|
||||||
|
logger)
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,38 @@
|
||||||
|
#define LOG_TAG "MAIN" ///< "MAIN" log tag for this file
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
#include "esp_log.h"
|
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
|
#include "logger.h"
|
||||||
#include "web_server.h"
|
#include "web_server.h"
|
||||||
#include "wifi.h"
|
#include "wifi.h"
|
||||||
|
|
||||||
static const char *TAG = "MAIN";
|
/**
|
||||||
|
* @brief Main entry point for the DMX Interface application.
|
||||||
|
*
|
||||||
|
* Initializes WiFi Access Point and starts the web server.
|
||||||
|
* Keeps the application running indefinitely.
|
||||||
|
*/
|
||||||
void app_main(void) {
|
void app_main(void) {
|
||||||
ESP_LOGI(TAG, "DMX Interface starting...");
|
LOGI("DMX Interface starting...");
|
||||||
|
|
||||||
esp_err_t wifi_err = wifi_start_ap("DMX", "mbgmbgmbg", 1, 4);
|
esp_err_t wifi_err = wifi_start_ap("DMX", "mbgmbgmbg", 1, 4);
|
||||||
if (wifi_err != ESP_OK) {
|
if (wifi_err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to start WiFi AP: %s", esp_err_to_name(wifi_err));
|
LOGE("Failed to start WiFi AP: %s", esp_err_to_name(wifi_err));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start HTTP web server
|
// Start HTTP web server
|
||||||
httpd_handle_t server = webserver_start(NULL);
|
httpd_handle_t server = webserver_start(NULL);
|
||||||
if (server == NULL) {
|
if (server == NULL) {
|
||||||
ESP_LOGE(TAG, "Failed to start web server!");
|
LOGE("Failed to start web server!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Web server started successfully");
|
LOGI("Web server started successfully");
|
||||||
ESP_LOGI(TAG, "Open http://192.168.4.1 in your browser");
|
LOGI("Open http://192.168.4.1 in your browser");
|
||||||
|
|
||||||
// Keep the app running
|
// Keep the app running
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue