update web ui
Some checks failed
ESP-IDF Build / build (esp32c6, release-v5.4) (push) Failing after 4m6s
ESP-IDF Build / build (esp32c6, release-v5.5) (push) Failing after 4m19s
ESP-IDF Build / build (esp32s3, release-v5.4) (push) Failing after 3m52s
ESP-IDF Build / build (esp32s3, release-v5.5) (push) Failing after 4m4s
Some checks failed
ESP-IDF Build / build (esp32c6, release-v5.4) (push) Failing after 4m6s
ESP-IDF Build / build (esp32c6, release-v5.5) (push) Failing after 4m19s
ESP-IDF Build / build (esp32s3, release-v5.4) (push) Failing after 3m52s
ESP-IDF Build / build (esp32s3, release-v5.5) (push) Failing after 4m4s
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
idf_component_register(SRCS
|
idf_component_register(SRCS
|
||||||
src/api_server.c
|
src/api_server.c
|
||||||
|
src/common.c
|
||||||
src/api_handlers.c
|
src/api_handlers.c
|
||||||
src/websocket_handler.c
|
src/websocket_handler.c
|
||||||
INCLUDE_DIRS "include"
|
INCLUDE_DIRS "include"
|
||||||
|
|||||||
8
firmware/components/api-server/include/common.h
Normal file
8
firmware/components/api-server/include/common.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#ifndef COMMON_H
|
||||||
|
#define COMMON_H
|
||||||
|
|
||||||
|
#include <cJSON.h>
|
||||||
|
|
||||||
|
cJSON *create_light_status_json(void);
|
||||||
|
|
||||||
|
#endif // COMMON_H
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "api_handlers.h"
|
#include "api_handlers.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
#include <cJSON.h>
|
#include <cJSON.h>
|
||||||
#include <esp_http_server.h>
|
#include <esp_http_server.h>
|
||||||
@@ -102,6 +103,8 @@ esp_err_t api_wifi_scan_handler(httpd_req_t *req)
|
|||||||
cJSON *entry = cJSON_CreateObject();
|
cJSON *entry = cJSON_CreateObject();
|
||||||
cJSON_AddStringToObject(entry, "ssid", (const char *)ap_list[i].ssid);
|
cJSON_AddStringToObject(entry, "ssid", (const char *)ap_list[i].ssid);
|
||||||
cJSON_AddNumberToObject(entry, "rssi", ap_list[i].rssi);
|
cJSON_AddNumberToObject(entry, "rssi", ap_list[i].rssi);
|
||||||
|
bool secure = ap_list[i].authmode != WIFI_AUTH_OPEN;
|
||||||
|
cJSON_AddBoolToObject(entry, "secure", secure);
|
||||||
cJSON_AddItemToArray(json, entry);
|
cJSON_AddItemToArray(json, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -293,16 +296,12 @@ esp_err_t api_light_schema_handler(httpd_req_t *req)
|
|||||||
esp_err_t api_light_status_handler(httpd_req_t *req)
|
esp_err_t api_light_status_handler(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "GET /api/light/status");
|
ESP_LOGI(TAG, "GET /api/light/status");
|
||||||
|
cJSON *json = create_light_status_json();
|
||||||
// TODO: Implement actual light status retrieval
|
char *response = cJSON_PrintUnformatted(json);
|
||||||
const char *response = "{"
|
cJSON_Delete(json);
|
||||||
"\"on\":true,"
|
esp_err_t res = send_json_response(req, response);
|
||||||
"\"thunder\":false,"
|
free(response);
|
||||||
"\"mode\":\"simulation\","
|
return res;
|
||||||
"\"schema\":\"schema_01.csv\","
|
|
||||||
"\"color\":{\"r\":255,\"g\":240,\"b\":220}"
|
|
||||||
"}";
|
|
||||||
return send_json_response(req, response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|||||||
20
firmware/components/api-server/src/common.c
Normal file
20
firmware/components/api-server/src/common.c
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#include "common.h"
|
||||||
|
#include <cJSON.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
// Gibt ein cJSON-Objekt with dem aktuellen Lichtstatus zurück
|
||||||
|
cJSON *create_light_status_json(void)
|
||||||
|
{
|
||||||
|
cJSON *json = cJSON_CreateObject();
|
||||||
|
// TODO: Echte Werte einfügen, aktuell Dummy-Daten
|
||||||
|
cJSON_AddBoolToObject(json, "on", false);
|
||||||
|
cJSON_AddBoolToObject(json, "thunder", false);
|
||||||
|
cJSON_AddStringToObject(json, "mode", "day");
|
||||||
|
cJSON_AddStringToObject(json, "schema", "schema_03.csv");
|
||||||
|
cJSON *color = cJSON_CreateObject();
|
||||||
|
cJSON_AddNumberToObject(color, "r", 255);
|
||||||
|
cJSON_AddNumberToObject(color, "g", 240);
|
||||||
|
cJSON_AddNumberToObject(color, "b", 220);
|
||||||
|
cJSON_AddItemToObject(json, "color", color);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "websocket_handler.h"
|
#include "websocket_handler.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
#include <esp_http_server.h>
|
#include <esp_http_server.h>
|
||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
@@ -56,15 +57,11 @@ static esp_err_t handle_ws_message(httpd_req_t *req, httpd_ws_frame_t *ws_pkt)
|
|||||||
// For now, we just check if it's a status request
|
// For now, we just check if it's a status request
|
||||||
if (ws_pkt->payload != NULL && strstr((char *)ws_pkt->payload, "getStatus") != NULL)
|
if (ws_pkt->payload != NULL && strstr((char *)ws_pkt->payload, "getStatus") != NULL)
|
||||||
{
|
{
|
||||||
// Send status response
|
// Status-JSON generieren
|
||||||
// TODO: Get actual status values
|
cJSON *json = create_light_status_json();
|
||||||
const char *response = "{"
|
cJSON_AddStringToObject(json, "type", "status");
|
||||||
"\"type\":\"status\","
|
char *response = cJSON_PrintUnformatted(json);
|
||||||
"\"on\":true,"
|
cJSON_Delete(json);
|
||||||
"\"mode\":\"simulation\","
|
|
||||||
"\"schema\":\"schema_01.csv\","
|
|
||||||
"\"color\":{\"r\":255,\"g\":240,\"b\":220}"
|
|
||||||
"}";
|
|
||||||
|
|
||||||
httpd_ws_frame_t ws_resp = {.final = true,
|
httpd_ws_frame_t ws_resp = {.final = true,
|
||||||
.fragmented = false,
|
.fragmented = false,
|
||||||
@@ -72,7 +69,9 @@ static esp_err_t handle_ws_message(httpd_req_t *req, httpd_ws_frame_t *ws_pkt)
|
|||||||
.payload = (uint8_t *)response,
|
.payload = (uint8_t *)response,
|
||||||
.len = strlen(response)};
|
.len = strlen(response)};
|
||||||
|
|
||||||
return httpd_ws_send_frame(req, &ws_resp);
|
esp_err_t ret = httpd_ws_send_frame(req, &ws_resp);
|
||||||
|
free(response);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
<span class="mode-icon">🌙</span>
|
<span class="mode-icon">🌙</span>
|
||||||
<span class="mode-name" data-i18n="mode.night">Nacht</span>
|
<span class="mode-name" data-i18n="mode.night">Nacht</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="mode-btn active" id="mode-simulation" onclick="setMode('simulation')">
|
<button class="mode-btn" id="mode-simulation" onclick="setMode('simulation')">
|
||||||
<span class="mode-icon">🔄</span>
|
<span class="mode-icon">🔄</span>
|
||||||
<span class="mode-name" data-i18n="mode.simulation">Simulation</span>
|
<span class="mode-name" data-i18n="mode.simulation">Simulation</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Szenen Card -->
|
<!-- Szenen Card -->
|
||||||
<div class="card" id="scenes-control-card">
|
<div class="card" id="scenes-control-card" style="display: none;">
|
||||||
<h2 data-i18n="scenes.title">Szenen</h2>
|
<h2 data-i18n="scenes.title">Szenen</h2>
|
||||||
<div id="scenes-control-list" class="scenes-grid">
|
<div id="scenes-control-list" class="scenes-grid">
|
||||||
<!-- Wird dynamisch gefüllt -->
|
<!-- Wird dynamisch gefüllt -->
|
||||||
@@ -123,7 +123,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Externe Geräte Card -->
|
<!-- Externe Geräte Card -->
|
||||||
<div class="card" id="devices-control-card">
|
<div class="card" id="devices-control-card" style="display: none;">
|
||||||
<h2 data-i18n="devices.external">Externe Geräte</h2>
|
<h2 data-i18n="devices.external">Externe Geräte</h2>
|
||||||
<div id="devices-control-list" class="devices-control-grid">
|
<div id="devices-control-list" class="devices-control-grid">
|
||||||
<!-- Wird dynamisch gefüllt -->
|
<!-- Wird dynamisch gefüllt -->
|
||||||
|
|||||||
@@ -108,12 +108,16 @@ const translations = {
|
|||||||
'wifi.disconnected': '❌ Nicht verbunden',
|
'wifi.disconnected': '❌ Nicht verbunden',
|
||||||
'wifi.unavailable': '⚠️ Status nicht verfügbar',
|
'wifi.unavailable': '⚠️ Status nicht verfügbar',
|
||||||
'wifi.searching': 'Suche läuft...',
|
'wifi.searching': 'Suche läuft...',
|
||||||
'wifi.scan.error': 'Fehler beim Scannen',
|
'wifi.scan.error': 'Fehler beim WLAN-Scan',
|
||||||
'wifi.scan.failed': 'Netzwerksuche fehlgeschlagen',
|
'wifi.scan.failed': 'Netzwerksuche fehlgeschlagen',
|
||||||
'wifi.saved': 'WLAN-Konfiguration gespeichert! Gerät verbindet sich...',
|
'wifi.saved': 'WLAN-Konfiguration gespeichert! Gerät verbindet sich...',
|
||||||
'wifi.error.ssid': 'Bitte WLAN-Name eingeben',
|
'wifi.error.ssid': 'Bitte WLAN-Name eingeben',
|
||||||
'wifi.error.save': 'Fehler beim Speichern',
|
'wifi.error.save': 'Fehler beim Speichern',
|
||||||
'wifi.networks.found': '{count} Netzwerk(e) gefunden',
|
'wifi.networks.found': '{count} Netzwerk(e) gefunden',
|
||||||
|
'wifi.networks.notfound': 'Keine Netzwerke gefunden.',
|
||||||
|
'wifi.signal': 'Signal',
|
||||||
|
'wifi.secure': 'Gesichert',
|
||||||
|
'wifi.open': 'Offen',
|
||||||
|
|
||||||
// Schema Editor
|
// Schema Editor
|
||||||
'schema.editor.title': 'Licht-Schema Editor',
|
'schema.editor.title': 'Licht-Schema Editor',
|
||||||
@@ -285,6 +289,10 @@ const translations = {
|
|||||||
'wifi.error.ssid': 'Please enter WiFi name',
|
'wifi.error.ssid': 'Please enter WiFi name',
|
||||||
'wifi.error.save': 'Error saving',
|
'wifi.error.save': 'Error saving',
|
||||||
'wifi.networks.found': '{count} network(s) found',
|
'wifi.networks.found': '{count} network(s) found',
|
||||||
|
'wifi.networks.notfound': 'No networks found.',
|
||||||
|
'wifi.signal': 'Signal',
|
||||||
|
'wifi.secure': 'Secured',
|
||||||
|
'wifi.open': 'Open',
|
||||||
|
|
||||||
// Schema Editor
|
// Schema Editor
|
||||||
'schema.editor.title': 'Light Schema Editor',
|
'schema.editor.title': 'Light Schema Editor',
|
||||||
@@ -440,6 +448,10 @@ function updatePageLanguage() {
|
|||||||
if (titleEl) {
|
if (titleEl) {
|
||||||
document.title = t(titleEl.getAttribute('data-i18n'));
|
document.title = t(titleEl.getAttribute('data-i18n'));
|
||||||
}
|
}
|
||||||
|
// WLAN-Optionen dynamisch übersetzen
|
||||||
|
if (typeof updateWifiOptionsLanguage === 'function') {
|
||||||
|
updateWifiOptionsLanguage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ function switchSubTab(subTabName) {
|
|||||||
document.querySelector(`.sub-tab[onclick="switchSubTab('${subTabName}')"]`).classList.add('active');
|
document.querySelector(`.sub-tab[onclick="switchSubTab('${subTabName}')"]`).classList.add('active');
|
||||||
document.getElementById(`subtab-${subTabName}`).classList.add('active');
|
document.getElementById(`subtab-${subTabName}`).classList.add('active');
|
||||||
|
|
||||||
if (subTabName === 'schema' && schemaData.length === 0) {
|
if (subTabName === 'schema' && typeof schemaData !== 'undefined' && schemaData.length === 0) {
|
||||||
loadSchema();
|
loadSchema();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user