Added
add forced cache refresh after removing and saving Bambu credentials (Manuel Weiser) add functionality to remove Bambu credentials and update API handling (Manuel Weiser) add rfid_bambu.html and update bambu connection handling (Manuel Weiser) Fixed handle Bambu connection state by introducing bambuDisabled flag (Manuel Weiser) fe4d2d7 - Fix rfid.js-Failure with X1-Series, if you wanna send a Spool to AMS: - Uncaught TypeError: Cannot read properties of undefined (reading 'replace') at handleSpoolIn (rfid.js:493:67) at HTMLButtonElement.onclick ((Index):1:1) handleSpoolIn @ rfid.js:493 onclick @ (Index):1 (tugsi) Changed docs: update changelog and header for version v1.4.7 (Manuel Weiser) docs: update platformio.ini for version v1.4.7 (Manuel Weiser) Merge branch 'testing' (Manuel Weiser) style: update remove button for Bambu credentials with red background (Manuel Weiser) Merge pull request #28 from tugsi/main (ManuelW)
This commit is contained in:
+33
-7
@@ -27,6 +27,7 @@ const char* bambu_serialnr = nullptr;
|
||||
String g_bambu_ip = "";
|
||||
String g_bambu_accesscode = "";
|
||||
String g_bambu_serialnr = "";
|
||||
bool bambuDisabled = false;
|
||||
|
||||
bool bambu_connected = false;
|
||||
bool autoSendToBambu = false;
|
||||
@@ -37,6 +38,35 @@ int ams_count = 0;
|
||||
String amsJsonData; // Speichert das fertige JSON für WebSocket-Clients
|
||||
AMSData ams_data[MAX_AMS]; // Definition des Arrays;
|
||||
|
||||
bool removeBambuCredentials()
|
||||
{
|
||||
if (BambuMqttTask)
|
||||
{
|
||||
vTaskDelete(BambuMqttTask);
|
||||
}
|
||||
|
||||
if (!removeJsonValue("/bambu_credentials.json"))
|
||||
{
|
||||
Serial.println("Fehler beim Löschen der Bambu-Credentials.");
|
||||
return false;
|
||||
}
|
||||
// Löschen der globalen Variablen
|
||||
g_bambu_ip = "";
|
||||
g_bambu_accesscode = "";
|
||||
g_bambu_serialnr = "";
|
||||
bambu_ip = nullptr;
|
||||
bambu_accesscode = nullptr;
|
||||
bambu_serialnr = nullptr;
|
||||
autoSendToBambu = false;
|
||||
autoSetToBambuSpoolId = 0;
|
||||
ams_count = 0;
|
||||
amsJsonData = "";
|
||||
|
||||
bambuDisabled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool saveBambuCredentials(const String& ip, const String& serialnr, const String& accesscode, bool autoSend, const String& autoSendTime) {
|
||||
if (BambuMqttTask) {
|
||||
vTaskDelete(BambuMqttTask);
|
||||
@@ -706,14 +736,13 @@ bool setupMqtt() {
|
||||
bool success = loadBambuCredentials();
|
||||
|
||||
if (!success) {
|
||||
Serial.println("Failed to load Bambu credentials");
|
||||
oledShowMessage("Bambu Credentials Missing");
|
||||
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||
bambuDisabled = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (success && bambu_ip != "" && bambu_accesscode != "" && bambu_serialnr != "")
|
||||
{
|
||||
bambuDisabled = false;
|
||||
sslClient.setCACert(root_ca);
|
||||
sslClient.setInsecure();
|
||||
client.setServer(bambu_ip, 8883);
|
||||
@@ -770,10 +799,7 @@ bool setupMqtt() {
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Fehler: Keine MQTT-Daten vorhanden");
|
||||
oledShowMessage("Bambu Credentials Missing");
|
||||
oledShowTopRow();
|
||||
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||
bambuDisabled = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -30,7 +30,9 @@ extern int ams_count;
|
||||
extern AMSData ams_data[MAX_AMS];
|
||||
extern bool autoSendToBambu;
|
||||
extern int autoSetToBambuSpoolId;
|
||||
extern bool bambuDisabled;
|
||||
|
||||
bool removeBambuCredentials();
|
||||
bool loadBambuCredentials();
|
||||
bool saveBambuCredentials(const String& bambu_ip, const String& bambu_serialnr, const String& bambu_accesscode, const bool autoSend, const String& autoSendTime);
|
||||
bool setupMqtt();
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
#include "commonFS.h"
|
||||
#include <LittleFS.h>
|
||||
|
||||
bool removeJsonValue(const char *filename)
|
||||
{
|
||||
File file = LittleFS.open(filename, "r");
|
||||
if (!file)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
file.close();
|
||||
if (!LittleFS.remove(filename))
|
||||
{
|
||||
Serial.print("Fehler beim Löschen der Datei: ");
|
||||
Serial.println(filename);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool saveJsonValue(const char* filename, const JsonDocument& doc) {
|
||||
File file = LittleFS.open(filename, "w");
|
||||
if (!file) {
|
||||
|
||||
+2
-1
@@ -5,7 +5,8 @@
|
||||
#include <ArduinoJson.h>
|
||||
#include <LittleFS.h>
|
||||
|
||||
bool saveJsonValue(const char* filename, const JsonDocument& doc);
|
||||
bool removeJsonValue(const char *filename);
|
||||
bool saveJsonValue(const char *filename, const JsonDocument &doc);
|
||||
bool loadJsonValue(const char* filename, JsonDocument& doc);
|
||||
void initializeFileSystem();
|
||||
|
||||
|
||||
+5
-4
@@ -98,10 +98,11 @@ void loop() {
|
||||
|
||||
// Wenn Bambu auto set Spool aktiv
|
||||
if (autoSendToBambu && autoSetToBambuSpoolId > 0) {
|
||||
if (!bambu_connected)
|
||||
{
|
||||
bambu_restart();
|
||||
}
|
||||
if (!bambuDisabled && !bambu_connected)
|
||||
|
||||
{
|
||||
bambu_restart();
|
||||
}
|
||||
if (intervalElapsed(currentMillis, lastAutoSetBambuAmsTime, autoSetBambuAmsInterval))
|
||||
{
|
||||
if (hasReadRfidTag == 0)
|
||||
|
||||
+16
-5
@@ -29,7 +29,7 @@ void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventTyp
|
||||
if (type == WS_EVT_CONNECT) {
|
||||
Serial.println("Neuer Client verbunden!");
|
||||
// Sende die AMS-Daten an den neuen Client
|
||||
sendAmsData(client);
|
||||
if (!bambuDisabled) sendAmsData(client);
|
||||
sendNfcData(client);
|
||||
foundNfcTag(client, 0);
|
||||
sendWriteResult(client, 3);
|
||||
@@ -213,7 +213,9 @@ void setupWebserver(AsyncWebServer &server) {
|
||||
// Route für RFID
|
||||
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
Serial.println("Anfrage für /rfid erhalten");
|
||||
AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/rfid.html.gz", "text/html");
|
||||
|
||||
String page = (bambuDisabled) ? "/rfid.html.gz" : "/rfid_bambu.html.gz";
|
||||
AsyncWebServerResponse *response = request->beginResponse(LittleFS, page, "text/html");
|
||||
response->addHeader("Content-Encoding", "gzip");
|
||||
response->addHeader("Cache-Control", CACHE_CONTROL);
|
||||
request->send(response);
|
||||
@@ -311,7 +313,17 @@ void setupWebserver(AsyncWebServer &server) {
|
||||
});
|
||||
|
||||
// Route für das Überprüfen der Bambu-Instanz
|
||||
server.on("/api/bambu", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
server.on("/api/bambu", HTTP_GET, [](AsyncWebServerRequest *request)
|
||||
{
|
||||
if (request->hasParam("remove")) {
|
||||
if (removeBambuCredentials()) {
|
||||
request->send(200, "application/json", "{\"success\": true}");
|
||||
} else {
|
||||
request->send(500, "application/json", "{\"success\": false, \"error\": \"Fehler beim Löschen der Bambu-Credentials\"}");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!request->hasParam("bambu_ip") || !request->hasParam("bambu_serialnr") || !request->hasParam("bambu_accesscode")) {
|
||||
request->send(400, "application/json", "{\"success\": false, \"error\": \"Missing parameter\"}");
|
||||
return;
|
||||
@@ -335,8 +347,7 @@ void setupWebserver(AsyncWebServer &server) {
|
||||
|
||||
bool success = saveBambuCredentials(bambu_ip, bambu_serialnr, bambu_accesscode, autoSend, autoSendTime);
|
||||
|
||||
request->send(200, "application/json", "{\"healthy\": " + String(success ? "true" : "false") + "}");
|
||||
});
|
||||
request->send(200, "application/json", "{\"healthy\": " + String(success ? "true" : "false") + "}"); });
|
||||
|
||||
// Route für das Überprüfen der Spoolman-Instanz
|
||||
server.on("/reboot", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
|
||||
Reference in New Issue
Block a user