firmware umbenennung für remote OTA der buttons, update button für remote update
This commit is contained in:
Binary file not shown.
@@ -208,6 +208,13 @@
|
||||
>
|
||||
🔄 Update durchführen
|
||||
</button>
|
||||
<button
|
||||
id="mqttPublishBtn"
|
||||
onclick="updateButtons()"
|
||||
class="btn btn-warning"
|
||||
>
|
||||
📡 Buttons Updaten
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -560,6 +567,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
// MQTT Message publish function
|
||||
function updateButtons() {
|
||||
if (confirm("Update Buttons?")) {
|
||||
fetch("/api/updateButtons", {
|
||||
method: "GET"
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.status === 200) {
|
||||
showMessage("Buttons führen das Update erfolgreich aus!", "success");
|
||||
} else {
|
||||
showMessage("Fehler beim Senden der MQTT Message", "error");
|
||||
}
|
||||
})
|
||||
.catch((error) => showMessage("Verbindungsfehler beim MQTT Publish", "error"));
|
||||
}
|
||||
}
|
||||
|
||||
function updateWifiButtonAccess(licenseLevel) {
|
||||
const wifiSubmitBtn = document.getElementById("wifiSubmitBtn");
|
||||
const wifiForm = document.getElementById("wifiForm");
|
||||
|
||||
@@ -225,7 +225,7 @@ void setupMqttServer() {
|
||||
}
|
||||
else if (strncmp(topic, "heartbeat/alive/", 16) == 0) {
|
||||
handleHeartbeatTopic(topic, payload);
|
||||
}
|
||||
}
|
||||
updateStatusLED(3);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
void sendMQTTMessage(const char * topic, const char * message);
|
||||
|
||||
#include "master.h"
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <AsyncWebSocket.h>
|
||||
@@ -7,9 +10,9 @@
|
||||
#include <SPIFFS.h>
|
||||
#include <esp_wifi.h>
|
||||
|
||||
|
||||
#include <buttonassigh.h>
|
||||
#include <wificlass.h>
|
||||
#include "communication.h"
|
||||
|
||||
AsyncWebServer server(80);
|
||||
AsyncWebSocket ws("/ws");
|
||||
@@ -32,13 +35,13 @@ void setupRoutes(){
|
||||
request->send(SPIFFS, "/rfid.html", "text/html");
|
||||
});
|
||||
|
||||
server.on("/button.bin", HTTP_GET, [](AsyncWebServerRequest *request) {
|
||||
if (SPIFFS.exists("/button.bin")) {
|
||||
request->send(SPIFFS, "/button.bin", "application/octet-stream");
|
||||
Serial.println("Firmware file served: /button.bin");
|
||||
server.on("/firmware.bin", HTTP_GET, [](AsyncWebServerRequest *request) {
|
||||
if (SPIFFS.exists("/firmware.bin")) {
|
||||
request->send(SPIFFS, "/firmware.bin", "application/octet-stream");
|
||||
Serial.println("Firmware file served: /firmware.bin");
|
||||
} else {
|
||||
request->send(404, "application/json", "{\"error\":\"File not found\"}");
|
||||
Serial.println("Firmware file not found: /button.bin");
|
||||
Serial.println("Firmware file not found: /firmware.bin");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -253,6 +256,16 @@ server.on("/api/set-location", HTTP_POST, [](AsyncWebServerRequest *request) {
|
||||
request->send(200, "application/json", result);
|
||||
});
|
||||
|
||||
|
||||
server.on("/api/updateButtons", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
Serial.println("/api/updateButtons called");
|
||||
|
||||
// MQTT publish on aquacross/update/flag with raw payload "1"
|
||||
sendMQTTMessage("aquacross/update/flag", "1");
|
||||
Serial.println("MQTT published: aquacross/update/flag -> 1");
|
||||
request->send(200, "application/json", "{\"success\":true}");
|
||||
});
|
||||
|
||||
|
||||
// Statische Dateien
|
||||
server.serveStatic("/", SPIFFS, "/");
|
||||
@@ -280,4 +293,4 @@ void pushUpdateToFrontend(const String &message) {
|
||||
|
||||
void loopWebSocket() {
|
||||
ws.cleanupClients(); // Clean up disconnected clients
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user