mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2026-03-09 13:30:20 +00:00
chore(format): initial formatting
This commit is contained in:
parent
fa08fcfe65
commit
008c79852b
21 changed files with 1021 additions and 1082 deletions
|
|
@ -1,8 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@
|
|||
static const char *TAG = "STORAGE";
|
||||
static const char *LITTLEFS_MOUNT_POINT = "/data";
|
||||
|
||||
esp_err_t storage_init(void)
|
||||
{
|
||||
esp_err_t storage_init(void) {
|
||||
esp_vfs_littlefs_conf_t conf = {
|
||||
.base_path = LITTLEFS_MOUNT_POINT,
|
||||
.partition_label = "storage",
|
||||
|
|
@ -18,18 +17,12 @@ esp_err_t storage_init(void)
|
|||
|
||||
esp_err_t ret = esp_vfs_littlefs_register(&conf);
|
||||
|
||||
if (ret != ESP_OK)
|
||||
{
|
||||
if (ret == ESP_FAIL)
|
||||
{
|
||||
if (ret != ESP_OK) {
|
||||
if (ret == ESP_FAIL) {
|
||||
ESP_LOGE(TAG, "Failed to mount LittleFS or format filesystem");
|
||||
}
|
||||
else if (ret == ESP_ERR_INVALID_STATE)
|
||||
{
|
||||
} else if (ret == ESP_ERR_INVALID_STATE) {
|
||||
ESP_LOGE(TAG, "ESP_ERR_INVALID_STATE");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to initialize LittleFS: %s", esp_err_to_name(ret));
|
||||
}
|
||||
return ret;
|
||||
|
|
@ -37,20 +30,14 @@ esp_err_t storage_init(void)
|
|||
|
||||
size_t total = 0, used = 0;
|
||||
ret = esp_littlefs_info(conf.partition_label, &total, &used);
|
||||
if (ret == ESP_OK)
|
||||
{
|
||||
if (ret == ESP_OK) {
|
||||
ESP_LOGI(TAG, "LittleFS mounted at %s. Total: %d bytes, Used: %d bytes",
|
||||
LITTLEFS_MOUNT_POINT, total, used);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to get LittleFS information");
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
const char *storage_get_mount_point(void)
|
||||
{
|
||||
return LITTLEFS_MOUNT_POINT;
|
||||
}
|
||||
const char *storage_get_mount_point(void) { return LITTLEFS_MOUNT_POINT; }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/**
|
||||
* @file web_server.h
|
||||
* @brief Simple HTTP web server component for ESP32 with async FreeRTOS support.
|
||||
* @brief Simple HTTP web server component for ESP32 with async FreeRTOS
|
||||
* support.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
@ -8,15 +9,13 @@
|
|||
#include "esp_http_server.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Web server configuration structure.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
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
|
||||
|
|
@ -27,7 +26,8 @@ extern "C"
|
|||
* @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.
|
||||
* 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.
|
||||
|
|
@ -51,7 +51,8 @@ extern "C"
|
|||
* @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);
|
||||
esp_err_t webserver_register_handler(httpd_handle_t server,
|
||||
const httpd_uri_t *uri_handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
esp_err_t wifi_start_ap(const char *ssid, const char *password, uint8_t channel, uint8_t max_connections);
|
||||
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
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ static TaskHandle_t s_server_task_handle = NULL;
|
|||
/**
|
||||
* @brief Get MIME type based on file extension
|
||||
*/
|
||||
static const char *get_mime_type(const char *filename)
|
||||
{
|
||||
static const char *get_mime_type(const char *filename) {
|
||||
const char *dot = strrchr(filename, '.');
|
||||
if (!dot)
|
||||
return "application/octet-stream";
|
||||
|
|
@ -64,21 +63,20 @@ static const char *get_mime_type(const char *filename)
|
|||
/**
|
||||
* @brief HTTP handler for static files from LittleFS
|
||||
*/
|
||||
static esp_err_t static_file_handler(httpd_req_t *req)
|
||||
{
|
||||
static esp_err_t static_file_handler(httpd_req_t *req) {
|
||||
// Build the file path
|
||||
char filepath[1024];
|
||||
snprintf(filepath, sizeof(filepath), "%s%s", storage_get_mount_point(), req->uri);
|
||||
snprintf(filepath, sizeof(filepath), "%s%s", storage_get_mount_point(),
|
||||
req->uri);
|
||||
|
||||
// Handle root path
|
||||
if (strcmp(req->uri, "/") == 0)
|
||||
{
|
||||
snprintf(filepath, sizeof(filepath), "%s/index.html", storage_get_mount_point());
|
||||
if (strcmp(req->uri, "/") == 0) {
|
||||
snprintf(filepath, sizeof(filepath), "%s/index.html",
|
||||
storage_get_mount_point());
|
||||
}
|
||||
|
||||
FILE *f = fopen(filepath, "r");
|
||||
if (!f)
|
||||
{
|
||||
if (!f) {
|
||||
ESP_LOGW(TAG, "File not found: %s", filepath);
|
||||
httpd_resp_send_404(req);
|
||||
return ESP_OK;
|
||||
|
|
@ -91,10 +89,8 @@ static esp_err_t static_file_handler(httpd_req_t *req)
|
|||
// Send file in chunks
|
||||
char buf[1024];
|
||||
size_t read_len;
|
||||
while ((read_len = fread(buf, 1, sizeof(buf), f)) > 0)
|
||||
{
|
||||
if (httpd_resp_send_chunk(req, buf, read_len) != ESP_OK)
|
||||
{
|
||||
while ((read_len = fread(buf, 1, sizeof(buf), f)) > 0) {
|
||||
if (httpd_resp_send_chunk(req, buf, read_len) != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Failed to send data chunk for %s", filepath);
|
||||
break;
|
||||
}
|
||||
|
|
@ -108,8 +104,7 @@ static esp_err_t static_file_handler(httpd_req_t *req)
|
|||
/**
|
||||
* @brief HTTP handler for API health check (GET /api/health)
|
||||
*/
|
||||
static esp_err_t health_check_handler(httpd_req_t *req)
|
||||
{
|
||||
static esp_err_t health_check_handler(httpd_req_t *req) {
|
||||
httpd_resp_set_type(req, "application/json");
|
||||
httpd_resp_sendstr(req, "{\"status\":\"ok\"}");
|
||||
return ESP_OK;
|
||||
|
|
@ -119,14 +114,12 @@ static esp_err_t health_check_handler(httpd_req_t *req)
|
|||
* @brief FreeRTOS task function for the HTTP server.
|
||||
* Allows non-blocking server operation and future extensibility.
|
||||
*/
|
||||
static void webserver_task(void *arg)
|
||||
{
|
||||
static void webserver_task(void *arg) {
|
||||
(void)arg; // Unused parameter
|
||||
ESP_LOGI(TAG, "Web server task started");
|
||||
|
||||
// Keep task alive - the server runs in the background
|
||||
while (s_server_handle != NULL)
|
||||
{
|
||||
while (s_server_handle != NULL) {
|
||||
vTaskDelay(pdMS_TO_TICKS(10000)); // 10 second check interval
|
||||
}
|
||||
|
||||
|
|
@ -134,18 +127,15 @@ static void webserver_task(void *arg)
|
|||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
httpd_handle_t webserver_start(const webserver_config_t *config)
|
||||
{
|
||||
if (s_server_handle != NULL)
|
||||
{
|
||||
httpd_handle_t webserver_start(const webserver_config_t *config) {
|
||||
if (s_server_handle != NULL) {
|
||||
ESP_LOGW(TAG, "Web server already running");
|
||||
return s_server_handle;
|
||||
}
|
||||
|
||||
// Initialize LittleFS
|
||||
esp_err_t ret = storage_init();
|
||||
if (ret != ESP_OK)
|
||||
{
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to initialize storage");
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -156,8 +146,7 @@ httpd_handle_t webserver_start(const webserver_config_t *config)
|
|||
size_t stack_size = WEBSERVER_DEFAULT_STACK_SIZE;
|
||||
UBaseType_t task_priority = WEBSERVER_DEFAULT_TASK_PRIORITY;
|
||||
|
||||
if (config)
|
||||
{
|
||||
if (config) {
|
||||
port = config->port;
|
||||
max_handlers = config->max_uri_handlers;
|
||||
stack_size = config->stack_size;
|
||||
|
|
@ -173,8 +162,7 @@ httpd_handle_t webserver_start(const webserver_config_t *config)
|
|||
|
||||
// Start HTTP server
|
||||
ret = httpd_start(&s_server_handle, &http_config);
|
||||
if (ret != ESP_OK)
|
||||
{
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to start HTTP server: %s", esp_err_to_name(ret));
|
||||
s_server_handle = NULL;
|
||||
return NULL;
|
||||
|
|
@ -202,17 +190,13 @@ httpd_handle_t webserver_start(const webserver_config_t *config)
|
|||
httpd_register_uri_handler(s_server_handle, &file_uri);
|
||||
|
||||
// Create FreeRTOS task for the server
|
||||
// This allows other tasks to continue running and makes the server async-ready
|
||||
BaseType_t task_ret = xTaskCreate(
|
||||
webserver_task,
|
||||
"webserver",
|
||||
stack_size,
|
||||
(void *)s_server_handle,
|
||||
task_priority,
|
||||
// This allows other tasks to continue running and makes the server
|
||||
// async-ready
|
||||
BaseType_t task_ret = xTaskCreate(webserver_task, "webserver", stack_size,
|
||||
(void *)s_server_handle, task_priority,
|
||||
&s_server_task_handle);
|
||||
|
||||
if (task_ret != pdPASS)
|
||||
{
|
||||
if (task_ret != pdPASS) {
|
||||
ESP_LOGE(TAG, "Failed to create web server task");
|
||||
httpd_stop(s_server_handle);
|
||||
s_server_handle = NULL;
|
||||
|
|
@ -223,10 +207,8 @@ httpd_handle_t webserver_start(const webserver_config_t *config)
|
|||
return s_server_handle;
|
||||
}
|
||||
|
||||
void webserver_stop(httpd_handle_t server)
|
||||
{
|
||||
if (server == NULL)
|
||||
{
|
||||
void webserver_stop(httpd_handle_t server) {
|
||||
if (server == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -234,8 +216,7 @@ void webserver_stop(httpd_handle_t server)
|
|||
s_server_handle = NULL;
|
||||
|
||||
// Wait for task to finish
|
||||
if (s_server_task_handle != NULL)
|
||||
{
|
||||
if (s_server_task_handle != NULL) {
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
s_server_task_handle = NULL;
|
||||
}
|
||||
|
|
@ -243,21 +224,19 @@ void webserver_stop(httpd_handle_t server)
|
|||
ESP_LOGI(TAG, "Web server stopped");
|
||||
}
|
||||
|
||||
esp_err_t webserver_register_handler(httpd_handle_t server, const httpd_uri_t *uri_handler)
|
||||
{
|
||||
if (server == NULL || uri_handler == NULL)
|
||||
{
|
||||
esp_err_t webserver_register_handler(httpd_handle_t server,
|
||||
const httpd_uri_t *uri_handler) {
|
||||
if (server == NULL || uri_handler == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
esp_err_t ret = httpd_register_uri_handler(server, uri_handler);
|
||||
if (ret == ESP_OK)
|
||||
{
|
||||
ESP_LOGI(TAG, "Registered handler: %s [%d]", uri_handler->uri, uri_handler->method);
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGE(TAG, "Failed to register handler %s: %s", uri_handler->uri, esp_err_to_name(ret));
|
||||
if (ret == ESP_OK) {
|
||||
ESP_LOGI(TAG, "Registered handler: %s [%d]", uri_handler->uri,
|
||||
uri_handler->method);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to register handler %s: %s", uri_handler->uri,
|
||||
esp_err_to_name(ret));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -11,32 +11,28 @@
|
|||
static const char *TAG = "WIFI";
|
||||
static bool s_wifi_started = false;
|
||||
|
||||
esp_err_t wifi_start_ap(const char *ssid, const char *password, uint8_t channel, uint8_t max_connections)
|
||||
{
|
||||
if (s_wifi_started)
|
||||
{
|
||||
esp_err_t wifi_start_ap(const char *ssid, const char *password, uint8_t channel,
|
||||
uint8_t max_connections) {
|
||||
if (s_wifi_started) {
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (!ssid || strlen(ssid) == 0 || strlen(ssid) > 32)
|
||||
{
|
||||
if (!ssid || strlen(ssid) == 0 || strlen(ssid) > 32) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
const bool has_password = password && strlen(password) > 0;
|
||||
if (has_password && strlen(password) < 8)
|
||||
{
|
||||
if (has_password && strlen(password) < 8) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
esp_err_t err = nvs_flash_init();
|
||||
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND)
|
||||
{
|
||||
if (err == ESP_ERR_NVS_NO_FREE_PAGES ||
|
||||
err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
err = nvs_flash_init();
|
||||
}
|
||||
if (err != ESP_OK)
|
||||
{
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
@ -48,11 +44,13 @@ esp_err_t wifi_start_ap(const char *ssid, const char *password, uint8_t channel,
|
|||
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
||||
|
||||
wifi_config_t wifi_config = {
|
||||
.ap = {
|
||||
.ap =
|
||||
{
|
||||
.channel = channel,
|
||||
.max_connection = max_connections,
|
||||
.authmode = has_password ? WIFI_AUTH_WPA2_PSK : WIFI_AUTH_OPEN,
|
||||
.pmf_cfg = {
|
||||
.pmf_cfg =
|
||||
{
|
||||
.required = false,
|
||||
},
|
||||
},
|
||||
|
|
@ -61,9 +59,9 @@ esp_err_t wifi_start_ap(const char *ssid, const char *password, uint8_t channel,
|
|||
strlcpy((char *)wifi_config.ap.ssid, ssid, sizeof(wifi_config.ap.ssid));
|
||||
wifi_config.ap.ssid_len = strlen(ssid);
|
||||
|
||||
if (has_password)
|
||||
{
|
||||
strlcpy((char *)wifi_config.ap.password, password, sizeof(wifi_config.ap.password));
|
||||
if (has_password) {
|
||||
strlcpy((char *)wifi_config.ap.password, password,
|
||||
sizeof(wifi_config.ap.password));
|
||||
}
|
||||
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
|
||||
|
|
@ -75,10 +73,8 @@ esp_err_t wifi_start_ap(const char *ssid, const char *password, uint8_t channel,
|
|||
return ESP_OK;
|
||||
}
|
||||
|
||||
void wifi_stop_ap(void)
|
||||
{
|
||||
if (!s_wifi_started)
|
||||
{
|
||||
void wifi_stop_ap(void) {
|
||||
if (!s_wifi_started) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
|
|
@ -60,11 +60,7 @@
|
|||
<div class="card">
|
||||
<span>Signalstärke</span>
|
||||
<span class="centered-vertical">
|
||||
<img
|
||||
class="connection-icon small"
|
||||
src=""
|
||||
alt=""
|
||||
/>
|
||||
<img class="connection-icon small" src="" alt="" />
|
||||
<span><span class="rssi"></span> dBm</span>
|
||||
</span>
|
||||
</div>
|
||||
|
|
@ -95,9 +91,7 @@
|
|||
|
||||
<div class="card">
|
||||
<span>PSRAM</span>
|
||||
<span
|
||||
><span class="psram-percentage"></span> %</span
|
||||
>
|
||||
<span><span class="psram-percentage"></span> %</span>
|
||||
<span
|
||||
><span class="psram-used"></span> /
|
||||
<span class="psram-total"></span
|
||||
|
|
@ -208,15 +202,8 @@
|
|||
title="Netzwerk"
|
||||
required
|
||||
></select>
|
||||
<button
|
||||
type="button"
|
||||
id="refresh-networks"
|
||||
class="icon-button"
|
||||
>
|
||||
<img
|
||||
src="/icons/refresh.svg"
|
||||
alt="Neu laden"
|
||||
/>
|
||||
<button type="button" id="refresh-networks" class="icon-button">
|
||||
<img src="/icons/refresh.svg" alt="Neu laden" />
|
||||
</button>
|
||||
</label>
|
||||
</div>
|
||||
|
|
@ -309,9 +296,7 @@
|
|||
required
|
||||
>
|
||||
<option value="0">Nichts</option>
|
||||
<option value="1">
|
||||
Konfiguration zurücksetzen
|
||||
</option>
|
||||
<option value="1">Konfiguration zurücksetzen</option>
|
||||
<option value="2">Neustart</option>
|
||||
</select>
|
||||
</label>
|
||||
|
|
|
|||
|
|
@ -4,18 +4,18 @@ const dynamicInputs = form.querySelectorAll("[data-field][data-values]");
|
|||
document.addEventListener("change", updateVisibility);
|
||||
|
||||
function updateVisibility() {
|
||||
dynamicInputs.forEach((element) => {
|
||||
dynamicInputs.forEach(element => {
|
||||
const input = form.querySelector(`#${element.dataset.field}`);
|
||||
if (element.dataset.values.split("|").includes(input.value)) {
|
||||
element.classList.remove("hidden");
|
||||
element
|
||||
.querySelectorAll("input, select, button, textarea")
|
||||
.forEach((childInput) => (childInput.disabled = false));
|
||||
.forEach(childInput => (childInput.disabled = false));
|
||||
} else {
|
||||
element.classList.add("hidden");
|
||||
element
|
||||
.querySelectorAll("input, select, button, textarea")
|
||||
.forEach((childInput) => (childInput.disabled = true));
|
||||
.forEach(childInput => (childInput.disabled = true));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
document.querySelector("form.config").addEventListener("input", (event) => {
|
||||
document.querySelector("form.config").addEventListener("input", event => {
|
||||
if (event.target.classList.contains("range")) {
|
||||
updateValue(event.target);
|
||||
}
|
||||
|
|
@ -9,6 +9,6 @@ function updateValue(slider) {
|
|||
slider.nextElementSibling.innerText = `${percentage}%`;
|
||||
}
|
||||
|
||||
document.querySelectorAll("input[type='range'].range").forEach((element) => {
|
||||
document.querySelectorAll("input[type='range'].range").forEach(element => {
|
||||
updateValue(element);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { updateConfig } from "/submit.js";
|
|||
|
||||
const form = document.querySelector("form.config");
|
||||
|
||||
form.addEventListener("reset", async (event) => {
|
||||
form.addEventListener("reset", async event => {
|
||||
event.preventDefault();
|
||||
|
||||
const ok = confirm(
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ function setStatus(status) {
|
|||
|
||||
setValue("rssi", status.connection.signalStrength);
|
||||
const icon = selectConnectionIcon(status.connection.signalStrength);
|
||||
document.querySelectorAll(".connection-icon").forEach((img) => {
|
||||
document.querySelectorAll(".connection-icon").forEach(img => {
|
||||
img.src = `/icons/${icon}`;
|
||||
});
|
||||
|
||||
|
|
@ -29,10 +29,7 @@ function setStatus(status) {
|
|||
const usedHeap = status.heap.total - status.heap.free;
|
||||
setValue("heap-used", formatBytes(usedHeap));
|
||||
setValue("heap-total", formatBytes(status.heap.total));
|
||||
setValue(
|
||||
"heap-percentage",
|
||||
Math.round((usedHeap / status.heap.total) * 100)
|
||||
);
|
||||
setValue("heap-percentage", Math.round((usedHeap / status.heap.total) * 100));
|
||||
|
||||
const usedPsram = status.psram.total - status.psram.free;
|
||||
setValue("psram-used", formatBytes(usedPsram));
|
||||
|
|
@ -48,7 +45,7 @@ function setStatus(status) {
|
|||
}
|
||||
|
||||
function setValue(className, value) {
|
||||
document.querySelectorAll("." + className).forEach((element) => {
|
||||
document.querySelectorAll("." + className).forEach(element => {
|
||||
element.innerText = value;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ function parseValue(input) {
|
|||
return input.value;
|
||||
}
|
||||
|
||||
form.addEventListener("submit", (event) => {
|
||||
form.addEventListener("submit", event => {
|
||||
event.preventDefault();
|
||||
const inputFields = document.querySelectorAll(
|
||||
"form :is(input, select, textarea):not(:disabled)"
|
||||
|
|
|
|||
|
|
@ -12,18 +12,18 @@ export function initWebSocket() {
|
|||
console.info("WebSocket connection opened");
|
||||
};
|
||||
|
||||
ws.onclose = (event) => {
|
||||
ws.onclose = event => {
|
||||
console.info("WebSocket connection closed, reason:", event.reason);
|
||||
ws = null;
|
||||
};
|
||||
|
||||
ws.onerror = (event) => {
|
||||
ws.onerror = event => {
|
||||
console.warn("WebSocket encountered error, closing socket.", event);
|
||||
ws.close();
|
||||
ws = null;
|
||||
};
|
||||
|
||||
ws.onmessage = (event) => {
|
||||
ws.onmessage = event => {
|
||||
const message = JSON.parse(event.data);
|
||||
console.log("received websocket data", message);
|
||||
if (message.type in callbacks) {
|
||||
|
|
|
|||
|
|
@ -9,21 +9,18 @@
|
|||
|
||||
static const char *TAG = "MAIN";
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
void app_main(void) {
|
||||
ESP_LOGI(TAG, "DMX Interface starting...");
|
||||
|
||||
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));
|
||||
return;
|
||||
}
|
||||
|
||||
// Start HTTP web server
|
||||
httpd_handle_t server = webserver_start(NULL);
|
||||
if (server == NULL)
|
||||
{
|
||||
if (server == NULL) {
|
||||
ESP_LOGE(TAG, "Failed to start web server!");
|
||||
return;
|
||||
}
|
||||
|
|
@ -32,8 +29,7 @@ void app_main(void)
|
|||
ESP_LOGI(TAG, "Open http://192.168.4.1 in your browser");
|
||||
|
||||
// Keep the app running
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
idf:
|
||||
version: '>=4.1.0'
|
||||
version: ">=4.1.0"
|
||||
joltwallet/littlefs: ==1.20.2
|
||||
someweisguy/esp_dmx:
|
||||
git: https://github.com/davispolito/esp_dmx.git
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue