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

View File

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

View File

@@ -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
}
}