firmware umbenennung für remote OTA der buttons, update button für remote update

This commit is contained in:
Carsten Graf
2025-07-06 03:24:23 +02:00
parent 31e548daa6
commit 393a0b718b
4 changed files with 45 additions and 8 deletions

Binary file not shown.

View File

@@ -208,6 +208,13 @@
> >
🔄 Update durchführen 🔄 Update durchführen
</button> </button>
<button
id="mqttPublishBtn"
onclick="updateButtons()"
class="btn btn-warning"
>
📡 Buttons Updaten
</button>
</div> </div>
</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) { function updateWifiButtonAccess(licenseLevel) {
const wifiSubmitBtn = document.getElementById("wifiSubmitBtn"); const wifiSubmitBtn = document.getElementById("wifiSubmitBtn");
const wifiForm = document.getElementById("wifiForm"); const wifiForm = document.getElementById("wifiForm");

View File

@@ -225,7 +225,7 @@ void setupMqttServer() {
} }
else if (strncmp(topic, "heartbeat/alive/", 16) == 0) { else if (strncmp(topic, "heartbeat/alive/", 16) == 0) {
handleHeartbeatTopic(topic, payload); handleHeartbeatTopic(topic, payload);
} }
updateStatusLED(3); updateStatusLED(3);
}); });

View File

@@ -1,5 +1,8 @@
#pragma once #pragma once
#include <Arduino.h> #include <Arduino.h>
void sendMQTTMessage(const char * topic, const char * message);
#include "master.h" #include "master.h"
#include <ESPAsyncWebServer.h> #include <ESPAsyncWebServer.h>
#include <AsyncWebSocket.h> #include <AsyncWebSocket.h>
@@ -7,9 +10,9 @@
#include <SPIFFS.h> #include <SPIFFS.h>
#include <esp_wifi.h> #include <esp_wifi.h>
#include <buttonassigh.h> #include <buttonassigh.h>
#include <wificlass.h> #include <wificlass.h>
#include "communication.h"
AsyncWebServer server(80); AsyncWebServer server(80);
AsyncWebSocket ws("/ws"); AsyncWebSocket ws("/ws");
@@ -32,13 +35,13 @@ void setupRoutes(){
request->send(SPIFFS, "/rfid.html", "text/html"); request->send(SPIFFS, "/rfid.html", "text/html");
}); });
server.on("/button.bin", HTTP_GET, [](AsyncWebServerRequest *request) { server.on("/firmware.bin", HTTP_GET, [](AsyncWebServerRequest *request) {
if (SPIFFS.exists("/button.bin")) { if (SPIFFS.exists("/firmware.bin")) {
request->send(SPIFFS, "/button.bin", "application/octet-stream"); request->send(SPIFFS, "/firmware.bin", "application/octet-stream");
Serial.println("Firmware file served: /button.bin"); Serial.println("Firmware file served: /firmware.bin");
} else { } else {
request->send(404, "application/json", "{\"error\":\"File not found\"}"); 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");
} }
}); });
@@ -254,6 +257,16 @@ server.on("/api/set-location", HTTP_POST, [](AsyncWebServerRequest *request) {
}); });
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 // Statische Dateien
server.serveStatic("/", SPIFFS, "/"); server.serveStatic("/", SPIFFS, "/");
server.begin(); server.begin();