From 7e1565baa1afe29e381f00ece1d92c1224ec7ac6 Mon Sep 17 00:00:00 2001 From: SoftWareCrash Date: Tue, 27 May 2025 10:59:18 +0200 Subject: [PATCH 01/34] some smal changes --- src/blled/leds.h | 13 ++++++++-- src/blled/mqttmanager.h | 57 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/src/blled/leds.h b/src/blled/leds.h index 36ae1f8..f0e059c 100644 --- a/src/blled/leds.h +++ b/src/blled/leds.h @@ -132,7 +132,7 @@ void tweenToColor(String strTargetColor, short ww_value = 0, short cw_value = 0) tweenToColor(targetcolor.r, targetcolor.g, targetcolor.b, targetcolor.ww, targetcolor.cw); } // Example: tweenToColor(0xFFACA5) -void tweenToColor(int hexValue, short ww_value = 0, short cw_value = 0) +/* void tweenToColor(int hexValue, short ww_value = 0, short cw_value = 0) { COLOR targetcolor; targetcolor.r = ((hexValue >> 16) & 0xFF) / 255.0; @@ -141,8 +141,17 @@ void tweenToColor(int hexValue, short ww_value = 0, short cw_value = 0) targetcolor.ww = ww_value; targetcolor.cw = cw_value; tweenToColor(targetcolor.r, targetcolor.g, targetcolor.b, targetcolor.ww, targetcolor.cw); +} */ +void tweenToColor(int hexValue, short ww_value = 0, short cw_value = 0) +{ + COLOR targetcolor; + targetcolor.r = (hexValue >> 16) & 0xFF; + targetcolor.g = (hexValue >> 8) & 0xFF; + targetcolor.b = hexValue & 0xFF; + targetcolor.ww = ww_value; + targetcolor.cw = cw_value; + tweenToColor(targetcolor.r, targetcolor.g, targetcolor.b, targetcolor.ww, targetcolor.cw); } - float hue = 0.0; void RGBCycle() diff --git a/src/blled/mqttmanager.h b/src/blled/mqttmanager.h index 52659d2..f946ae5 100644 --- a/src/blled/mqttmanager.h +++ b/src/blled/mqttmanager.h @@ -26,6 +26,7 @@ unsigned long lastMQTTupdate = millis(); TaskHandle_t mqttTaskHandle = NULL; bool mqttTaskRunning = false; +volatile bool mqttConnectInProgress = false; // With a Default BLLED // Expected information when viewing MQTT status messages @@ -44,7 +45,7 @@ bool mqttTaskRunning = false; // FINISH -1 White After door interaction // FINISH -1 OFF Inactivity after 30mins -void connectMqtt() +/* void connectMqtt() { if (WiFi.status() != WL_CONNECTED || WiFi.getMode() != WIFI_MODE_STA) { @@ -88,8 +89,58 @@ void connectMqtt() } } } +} */ +void connectMqtt() +{ + if (mqttConnectInProgress) return; + + mqttConnectInProgress = true; + + if (WiFi.status() != WL_CONNECTED || WiFi.getMode() != WIFI_MODE_STA) + { + mqttConnectInProgress = false; + return; + } + + if (strlen(printerConfig.printerIP) == 0 || strlen(printerConfig.accessCode) == 0) + { + Serial.println(F("[MQTT] Abort connect: printerIP oder accessCode wrong or empty")); + mqttConnectInProgress = false; + return; + } + + if (!mqttClient.connected() && (millis() - mqttattempt) >= 3000) + { + tweenToColor(10, 10, 10, 10, 10); + Serial.println(F("Connecting to mqtt...")); + + if (mqttClient.connect(clientId.c_str(), "bblp", printerConfig.accessCode)) + { + Serial.print(F("MQTT connected, subscribing to MQTT Topic: ")); + Serial.println(report_topic); + mqttClient.subscribe(report_topic.c_str()); + printerVariables.online = true; + printerVariables.disconnectMQTTms = 0; + } + else + { + Serial.println(F("Failed to connect with error code: ")); + Serial.print(mqttClient.state()); + Serial.print(F(" ")); + ParseMQTTState(mqttClient.state()); + + if (mqttClient.state() == 5) + { + tweenToColor(127, 0, 0, 0, 0); + mqttattempt = millis() - 3000; + } + } + } + + mqttConnectInProgress = false; } + void mqttTask(void *parameter) { mqttTaskRunning = true; @@ -461,8 +512,8 @@ void setupMqtt() report_topic = device_topic + String("/report"); wifiSecureClient.setInsecure(); - wifiSecureClient.setTimeout(3); - mqttClient.setSocketTimeout(3); + wifiSecureClient.setTimeout(10); + mqttClient.setSocketTimeout(10); mqttClient.setBufferSize(1024); mqttClient.setServer(printerConfig.printerIP, 8883); mqttClient.setStream(stream); From d76505e7d930c1312f09374f11550be85652a133 Mon Sep 17 00:00:00 2001 From: softwarecrash Date: Tue, 27 May 2025 11:57:45 +0200 Subject: [PATCH 02/34] remove led state from mqtt connect --- src/blled/mqttmanager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blled/mqttmanager.h b/src/blled/mqttmanager.h index f946ae5..a6a25e4 100644 --- a/src/blled/mqttmanager.h +++ b/src/blled/mqttmanager.h @@ -111,7 +111,7 @@ void connectMqtt() if (!mqttClient.connected() && (millis() - mqttattempt) >= 3000) { - tweenToColor(10, 10, 10, 10, 10); + //tweenToColor(10, 10, 10, 10, 10); Serial.println(F("Connecting to mqtt...")); if (mqttClient.connect(clientId.c_str(), "bblp", printerConfig.accessCode)) From 3fc791ed8e66d3d7e1b5f039b777828be3a15239 Mon Sep 17 00:00:00 2001 From: SoftWareCrash Date: Tue, 27 May 2025 12:38:55 +0200 Subject: [PATCH 03/34] version bump --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index fc18a31..ad9acfd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,7 @@ [env:esp32dev] custom_project_name = BLLEDController custom_project_codename = Balder -custom_version = 1.0.0.nightly.250525.1 ; for github release name the release VX.Y.Z X=(Incerase when Modifications oder new functions Break the API/webUI) Y=(Incerase for add oder modify changes that not breake the API/webUI until X incearase) Z=(Incerase for bugfix releases until minor is incerase) +custom_version = 1.0.1.nightly.270525.1 ; for github release name the release VX.Y.Z X=(Incerase when Modifications oder new functions Break the API/webUI) Y=(Incerase for add oder modify changes that not breake the API/webUI until X incearase) Z=(Incerase for bugfix releases until minor is incerase) platform = espressif32 board = esp32dev framework = arduino From f7276312f62c6d1942aa7d75b87ecac93b54584d Mon Sep 17 00:00:00 2001 From: SoftWareCrash Date: Tue, 27 May 2025 12:39:53 +0200 Subject: [PATCH 04/34] correct button name --- src/www/setupPage.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/www/setupPage.html b/src/www/setupPage.html index 9e1273f..687496f 100644 --- a/src/www/setupPage.html +++ b/src/www/setupPage.html @@ -483,7 +483,7 @@

BLLED LED Settings

Navigation

- + From 740f38bc0d29720b08b1274260adaab3f6270f28 Mon Sep 17 00:00:00 2001 From: SoftWareCrash Date: Tue, 27 May 2025 17:29:42 +0200 Subject: [PATCH 05/34] add comments and modify debug a bit --- src/blled/leds.h | 14 ++++++++++++-- src/blled/mqttmanager.h | 8 ++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/blled/leds.h b/src/blled/leds.h index f0e059c..f9580e2 100644 --- a/src/blled/leds.h +++ b/src/blled/leds.h @@ -299,13 +299,23 @@ void updateleds() // From here the BBLP status sets the colors if (printerConfig.debuging == true) { - LogSerial.println(F("Updating LEDs")); +/* LogSerial.println(F("Updating LEDs")); LogSerial.println(printerVariables.stage); LogSerial.println(printerVariables.gcodeState); LogSerial.println(printerVariables.printerledstate); LogSerial.println(printerVariables.hmsstate); - LogSerial.println(printerVariables.parsedHMSlevel); + LogSerial.println(printerVariables.parsedHMSlevel); */ + + char ledDbgStr[128]; + snprintf(ledDbgStr, sizeof(ledDbgStr), + "[LED] Stage:%d gcodeState:%s printerLedState:%s HMSErr:%s ParsedHMS:%s", + printerVariables.stage, + printerVariables.gcodeState.c_str(), + printerVariables.printerledstate ? "true" : "false", + printerVariables.hmsstate ? "true" : "false", + printerVariables.parsedHMSlevel.c_str()); + LogSerial.println(ledDbgStr); } // Initial Boot diff --git a/src/blled/mqttmanager.h b/src/blled/mqttmanager.h index a6a25e4..59babdc 100644 --- a/src/blled/mqttmanager.h +++ b/src/blled/mqttmanager.h @@ -187,6 +187,14 @@ void ParseCallback(char *topic, byte *payload, unsigned int length) JsonDocument filter; // Rather than showing the entire message to Serial - grabbing only the pertinent bits for BLLED. // Device Status + +//sniped: implement to get layer num. for hms error, swap back to running state after layer change +/* "print": { + "3D": { + "layer_num": 0, + "total_layer_num": 191 + } */ + filter["print"]["command"] = true; filter["print"]["fail_reason"] = true; filter["print"]["gcode_state"] = true; From 8c4cbd36fd0219725c6e1c94d8984a581d8e28c5 Mon Sep 17 00:00:00 2001 From: SoftWareCrash Date: Tue, 10 Jun 2025 18:54:22 +0200 Subject: [PATCH 06/34] version bump --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index ad9acfd..5ac3649 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,7 @@ [env:esp32dev] custom_project_name = BLLEDController custom_project_codename = Balder -custom_version = 1.0.1.nightly.270525.1 ; for github release name the release VX.Y.Z X=(Incerase when Modifications oder new functions Break the API/webUI) Y=(Incerase for add oder modify changes that not breake the API/webUI until X incearase) Z=(Incerase for bugfix releases until minor is incerase) +custom_version = 1.0.1.nightly.100625.1 ; for github release name the release VX.Y.Z X=(Incerase when Modifications oder new functions Break the API/webUI) Y=(Incerase for add oder modify changes that not breake the API/webUI until X incearase) Z=(Incerase for bugfix releases until minor is incerase) platform = espressif32 board = esp32dev framework = arduino From b837032d0ca53f61f0363b2d08e817d2ed718739 Mon Sep 17 00:00:00 2001 From: SoftWareCrash Date: Tue, 10 Jun 2025 19:01:07 +0200 Subject: [PATCH 07/34] upstream to origin version --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 5ac3649..227ac65 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,7 @@ [env:esp32dev] custom_project_name = BLLEDController custom_project_codename = Balder -custom_version = 1.0.1.nightly.100625.1 ; for github release name the release VX.Y.Z X=(Incerase when Modifications oder new functions Break the API/webUI) Y=(Incerase for add oder modify changes that not breake the API/webUI until X incearase) Z=(Incerase for bugfix releases until minor is incerase) +custom_version = 2.1.1.nightly.100625.1 ; for github release name the release VX.Y.Z X=(Incerase when Modifications oder new functions Break the API/webUI) Y=(Incerase for add oder modify changes that not breake the API/webUI until X incearase) Z=(Incerase for bugfix releases until minor is incerase) platform = espressif32 board = esp32dev framework = arduino From 16ff91609e456dafc59a579c3aa313da03b8241e Mon Sep 17 00:00:00 2001 From: SoftWareCrash Date: Tue, 10 Jun 2025 19:10:45 +0200 Subject: [PATCH 08/34] incerase mqtt timeout time --- src/blled/leds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blled/leds.h b/src/blled/leds.h index f9580e2..088c893 100644 --- a/src/blled/leds.h +++ b/src/blled/leds.h @@ -458,7 +458,7 @@ void updateleds() // OFF -- OFF -- OFF -- OFF // printer offline and MQTT disconnect more than 5 seconds. - if (printerVariables.online == false && (millis() - printerVariables.disconnectMQTTms) >= 5000) + if (printerVariables.online == false && (millis() - printerVariables.disconnectMQTTms) >= 30000) { tweenToColor(0, 0, 0, 0, 0); // OFF printLogs("Printer offline", 0, 0, 0, 0, 0); From aebb801d73d0e48e1b9b864d6257014c0020d7ee Mon Sep 17 00:00:00 2001 From: SoftWareCrash Date: Wed, 11 Jun 2025 12:46:31 +0200 Subject: [PATCH 09/34] fix typo --- src/blled/wifi-manager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blled/wifi-manager.h b/src/blled/wifi-manager.h index a091f2e..a9aff8b 100644 --- a/src/blled/wifi-manager.h +++ b/src/blled/wifi-manager.h @@ -171,7 +171,7 @@ void startAPMode() { WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0)); dnsServer.start(53, "*", apIP); - Serial.println(F("[WiFiManager] AP gestartet auf IP: ")); + Serial.print(F("[WiFiManager] AP started on IP: ")); Serial.println(WiFi.softAPIP()); } From 665769b2516ac489c4e06948ab0c3d61e66a7fcd Mon Sep 17 00:00:00 2001 From: softwarecrash Date: Sun, 15 Jun 2025 14:57:54 +0200 Subject: [PATCH 10/34] add printer scan and autofill function --- src/blled/bblPrinterDiscovery.h | 153 ++++++++++++++++++++++++++++++++ src/blled/web-server.h | 19 +++- src/main.cpp | 6 ++ src/www/wifiSetup.html | 79 ++++++++++++++++- 4 files changed, 255 insertions(+), 2 deletions(-) create mode 100644 src/blled/bblPrinterDiscovery.h diff --git a/src/blled/bblPrinterDiscovery.h b/src/blled/bblPrinterDiscovery.h new file mode 100644 index 0000000..317ab3c --- /dev/null +++ b/src/blled/bblPrinterDiscovery.h @@ -0,0 +1,153 @@ +#ifndef _BBLPRINTERDISCOVERY_H +#define _BBLPRINTERDISCOVERY_H + +#include +#include +#include // for ARP lookup + +#define BBL_SSDP_PORT 2021 +#define BBL_SSDP_MCAST_IP IPAddress(239, 255, 255, 250) +#define BBL_DISCOVERY_INTERVAL 10000UL +#define BBL_MAX_PRINTERS 10 + +struct BBLPrinter { + IPAddress ip; + uint8_t mac[6]; + char usn[64]; +}; + +static WiFiUDP bblUdp; +static bool bblUdpInitialized = false; +static unsigned long bblLastDiscovery = 0; + +static BBLPrinter bblLastKnownPrinters[BBL_MAX_PRINTERS]; +static int bblKnownPrinterCount = 0; + +bool bblIsPrinterKnown(IPAddress ip) { + for (int i = 0; i < bblKnownPrinterCount; i++) { + if (bblLastKnownPrinters[i].ip == ip) return true; + } + return false; +} + +void bblPrintKnownPrinters() { + LogSerial.println("[BBLScan] Known printers:"); + if (bblKnownPrinterCount == 0) { + LogSerial.println(" (none)"); + } + for (int i = 0; i < bblKnownPrinterCount; i++) { + LogSerial.printf(" [%d] IP: %s MAC: %02X:%02X:%02X:%02X:%02X:%02X", + i + 1, + bblLastKnownPrinters[i].ip.toString().c_str(), + bblLastKnownPrinters[i].mac[0], bblLastKnownPrinters[i].mac[1], + bblLastKnownPrinters[i].mac[2], bblLastKnownPrinters[i].mac[3], + bblLastKnownPrinters[i].mac[4], bblLastKnownPrinters[i].mac[5]); + if (strlen(bblLastKnownPrinters[i].usn) > 0) { + LogSerial.printf(" [USN: %s]", bblLastKnownPrinters[i].usn); + } + LogSerial.println(); + } +} + +void bblSearchPrinters() { + unsigned long now = millis(); + if (now - bblLastDiscovery < BBL_DISCOVERY_INTERVAL) return; + bblLastDiscovery = now; + + if (!bblUdpInitialized) { + bblUdp.beginMulticast(BBL_SSDP_MCAST_IP, BBL_SSDP_PORT); + bblUdpInitialized = true; + } + + String msearch = + "M-SEARCH * HTTP/1.1\r\n" + "HOST: 239.255.255.250:2021\r\n" + "MAN: \"ssdp:discover\"\r\n" + "MX: 5\r\n" + "ST: urn:bambulab-com:device:3dprinter:1\r\n\r\n"; + + // Send twice + for (int i = 0; i < 2; i++) { + bblUdp.beginPacket(BBL_SSDP_MCAST_IP, BBL_SSDP_PORT); + bblUdp.print(msearch); + bblUdp.endPacket(); + delay(250); + } + + LogSerial.println("[BBLScan] Searching for printers..."); + + unsigned long start = millis(); + int sessionFound = 0; + IPAddress seenIPs[BBL_MAX_PRINTERS]; + int seenCount = 0; + + while (millis() - start < 5000) { + int size = bblUdp.parsePacket(); + if (size) { + IPAddress senderIP = bblUdp.remoteIP(); + + bool alreadySeen = false; + for (int i = 0; i < seenCount; i++) { + if (seenIPs[i] == senderIP) { + alreadySeen = true; + break; + } + } + if (alreadySeen) continue; + if (seenCount < BBL_MAX_PRINTERS) seenIPs[seenCount++] = senderIP; + + char buffer[512]; + int len = bblUdp.read(buffer, sizeof(buffer) - 1); + buffer[len] = 0; + + eth_addr* mac; + ip4_addr_t ip4; + ip4.addr = static_cast(senderIP); + const ip4_addr_t* dummyPtr; + bool macFound = (etharp_find_addr(netif_list, &ip4, &mac, &dummyPtr) == ERR_OK); + + String response(buffer); + String usnStr = ""; + int usnPos = response.indexOf("USN:"); + if (usnPos >= 0) { + int end = response.indexOf("\r\n", usnPos); + usnStr = response.substring(usnPos + 4, end); + usnStr.trim(); + } + + LogSerial.printf(" [%d] IP: %s", ++sessionFound, senderIP.toString().c_str()); + if (macFound) { + LogSerial.printf(" MAC: %02X:%02X:%02X:%02X:%02X:%02X", + mac->addr[0], mac->addr[1], mac->addr[2], + mac->addr[3], mac->addr[4], mac->addr[5]); + } else { + LogSerial.print(" MAC: (not found)"); + } + if (usnStr.length()) { + LogSerial.printf(" [USN: %s]", usnStr.c_str()); + } + LogSerial.println(); + + if (!bblIsPrinterKnown(senderIP) && bblKnownPrinterCount < BBL_MAX_PRINTERS) { + BBLPrinter& printer = bblLastKnownPrinters[bblKnownPrinterCount++]; + printer.ip = senderIP; + if (macFound) { + memcpy(printer.mac, mac->addr, 6); + } else { + memset(printer.mac, 0, 6); + } + strncpy(printer.usn, usnStr.c_str(), sizeof(printer.usn) - 1); + printer.usn[sizeof(printer.usn) - 1] = 0; + } + } + delay(10); + } + + if (sessionFound == 0) { + LogSerial.println("[BBLScan] No printers found."); + } + + bblPrintKnownPrinters(); +} + +#endif diff --git a/src/blled/web-server.h b/src/blled/web-server.h index df0c61c..d7711d2 100644 --- a/src/blled/web-server.h +++ b/src/blled/web-server.h @@ -441,7 +441,6 @@ void handleDownloadConfigFile(AsyncWebServerRequest *request) request->send(response); } - void handleWebSerialPage(AsyncWebServerRequest *request) { if (!isAuthorized(request)) @@ -451,6 +450,23 @@ void handleWebSerialPage(AsyncWebServerRequest *request) request->send(response); } +void handlePrinterList(AsyncWebServerRequest *request) +{ + JsonDocument doc; + JsonArray arr = doc.to(); + + for (int i = 0; i < bblKnownPrinterCount; i++) + { + JsonObject obj = arr.add(); + obj["ip"] = bblLastKnownPrinters[i].ip.toString(); + obj["usn"] = bblLastKnownPrinters[i].usn; + } + + String json; + serializeJson(doc, json); + request->send(200, "application/json", json); +} + void handleUploadConfigFileData(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final) @@ -536,6 +552,7 @@ void setupWebserver() webServer.on("/backuprestore", HTTP_GET, handleConfigPage); webServer.on("/configfile.json", HTTP_GET, handleDownloadConfigFile); webServer.on("/webserial", HTTP_GET, handleWebSerialPage); + webServer.on("/printerList", HTTP_GET, handlePrinterList); webServer.on("/configrestore", HTTP_POST, [](AsyncWebServerRequest *request) { if (!isAuthorized(request)) { diff --git a/src/main.cpp b/src/main.cpp index 4ccd435..c30164d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,6 +2,7 @@ bool shouldRestart = false; unsigned long restartRequestTime = 0; #include "./blled/logSerial.h" +#include "./blled/bblPrinterDiscovery.h" #include "./blled/web-server.h" #include "./blled/mqttmanager.h" #include "./blled/filesystem.h" @@ -11,6 +12,7 @@ unsigned long restartRequestTime = 0; #include "./blled/wifi-manager.h" #include "./blled/ssdp.h" + int wifi_reconnect_count = 0; void defaultcolors() @@ -137,6 +139,10 @@ void loop() { dnsServer.processNextRequest(); } + if(WiFi.status() == WL_CONNECTED && WiFi.getMode() != WIFI_AP) + { + bblSearchPrinters(); // gibt alle 10s IP + MAC der Drucker aus + } } if (printerConfig.rescanWiFiNetwork) { diff --git a/src/www/wifiSetup.html b/src/www/wifiSetup.html index a304d31..5d62021 100644 --- a/src/www/wifiSetup.html +++ b/src/www/wifiSetup.html @@ -26,7 +26,11 @@

BLLED WiFi Setup

- +
+ + +
@@ -49,6 +53,30 @@

BLLED WiFi Setup

â„šī¸Placeholder
+
+
+

Select Printer

+
+
+ +
+
+
From cee1a477a0b0d8314c2a0548e41f542235ad3cba Mon Sep 17 00:00:00 2001 From: softwarecrash Date: Sun, 15 Jun 2025 15:04:32 +0200 Subject: [PATCH 11/34] cleanup & version bump --- platformio.ini | 2 +- src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 227ac65..f1df2b0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,7 @@ [env:esp32dev] custom_project_name = BLLEDController custom_project_codename = Balder -custom_version = 2.1.1.nightly.100625.1 ; for github release name the release VX.Y.Z X=(Incerase when Modifications oder new functions Break the API/webUI) Y=(Incerase for add oder modify changes that not breake the API/webUI until X incearase) Z=(Incerase for bugfix releases until minor is incerase) +custom_version = 2.1.1.nightly.150625.1 ; for github release name the release VX.Y.Z X=(Incerase when Modifications oder new functions Break the API/webUI) Y=(Incerase for add oder modify changes that not breake the API/webUI until X incearase) Z=(Incerase for bugfix releases until minor is incerase) platform = espressif32 board = esp32dev framework = arduino diff --git a/src/main.cpp b/src/main.cpp index c30164d..c4fc90e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -141,7 +141,7 @@ void loop() } if(WiFi.status() == WL_CONNECTED && WiFi.getMode() != WIFI_AP) { - bblSearchPrinters(); // gibt alle 10s IP + MAC der Drucker aus + bblSearchPrinters(); } } if (printerConfig.rescanWiFiNetwork) From bd56bbe6b6d3aa1f3a827d341a30f696ac9d7cc7 Mon Sep 17 00:00:00 2001 From: softwarecrash Date: Sun, 15 Jun 2025 15:28:20 +0200 Subject: [PATCH 12/34] final implement printer discovery --- src/blled/bblPrinterDiscovery.h | 60 +++++++++++++-------------------- src/blled/filesystem.h | 2 +- src/main.cpp | 8 +++-- 3 files changed, 29 insertions(+), 41 deletions(-) diff --git a/src/blled/bblPrinterDiscovery.h b/src/blled/bblPrinterDiscovery.h index 317ab3c..81fbeae 100644 --- a/src/blled/bblPrinterDiscovery.h +++ b/src/blled/bblPrinterDiscovery.h @@ -3,7 +3,6 @@ #include #include -#include // for ARP lookup #define BBL_SSDP_PORT 2021 #define BBL_SSDP_MCAST_IP IPAddress(239, 255, 255, 250) @@ -12,7 +11,6 @@ struct BBLPrinter { IPAddress ip; - uint8_t mac[6]; char usn[64]; }; @@ -23,9 +21,12 @@ static unsigned long bblLastDiscovery = 0; static BBLPrinter bblLastKnownPrinters[BBL_MAX_PRINTERS]; static int bblKnownPrinterCount = 0; -bool bblIsPrinterKnown(IPAddress ip) { +bool bblIsPrinterKnown(IPAddress ip, int* index = nullptr) { for (int i = 0; i < bblKnownPrinterCount; i++) { - if (bblLastKnownPrinters[i].ip == ip) return true; + if (bblLastKnownPrinters[i].ip == ip) { + if (index) *index = i; + return true; + } } return false; } @@ -36,12 +37,7 @@ void bblPrintKnownPrinters() { LogSerial.println(" (none)"); } for (int i = 0; i < bblKnownPrinterCount; i++) { - LogSerial.printf(" [%d] IP: %s MAC: %02X:%02X:%02X:%02X:%02X:%02X", - i + 1, - bblLastKnownPrinters[i].ip.toString().c_str(), - bblLastKnownPrinters[i].mac[0], bblLastKnownPrinters[i].mac[1], - bblLastKnownPrinters[i].mac[2], bblLastKnownPrinters[i].mac[3], - bblLastKnownPrinters[i].mac[4], bblLastKnownPrinters[i].mac[5]); + LogSerial.printf(" [%d] IP: %s", i + 1, bblLastKnownPrinters[i].ip.toString().c_str()); if (strlen(bblLastKnownPrinters[i].usn) > 0) { LogSerial.printf(" [USN: %s]", bblLastKnownPrinters[i].usn); } @@ -66,7 +62,6 @@ void bblSearchPrinters() { "MX: 5\r\n" "ST: urn:bambulab-com:device:3dprinter:1\r\n\r\n"; - // Send twice for (int i = 0; i < 2; i++) { bblUdp.beginPacket(BBL_SSDP_MCAST_IP, BBL_SSDP_PORT); bblUdp.print(msearch); @@ -74,7 +69,9 @@ void bblSearchPrinters() { delay(250); } - LogSerial.println("[BBLScan] Searching for printers..."); + if (printerConfig.debuging) { + LogSerial.println("[BBLScan] Searching for printers..."); + } unsigned long start = millis(); int sessionFound = 0; @@ -100,12 +97,6 @@ void bblSearchPrinters() { int len = bblUdp.read(buffer, sizeof(buffer) - 1); buffer[len] = 0; - eth_addr* mac; - ip4_addr_t ip4; - ip4.addr = static_cast(senderIP); - const ip4_addr_t* dummyPtr; - bool macFound = (etharp_find_addr(netif_list, &ip4, &mac, &dummyPtr) == ERR_OK); - String response(buffer); String usnStr = ""; int usnPos = response.indexOf("USN:"); @@ -115,27 +106,20 @@ void bblSearchPrinters() { usnStr.trim(); } - LogSerial.printf(" [%d] IP: %s", ++sessionFound, senderIP.toString().c_str()); - if (macFound) { - LogSerial.printf(" MAC: %02X:%02X:%02X:%02X:%02X:%02X", - mac->addr[0], mac->addr[1], mac->addr[2], - mac->addr[3], mac->addr[4], mac->addr[5]); - } else { - LogSerial.print(" MAC: (not found)"); - } - if (usnStr.length()) { - LogSerial.printf(" [USN: %s]", usnStr.c_str()); + int existingIndex = -1; + bool isNewPrinter = !bblIsPrinterKnown(senderIP, &existingIndex); + + if (printerConfig.debuging || (printerConfig.debugingchange && isNewPrinter)) { + LogSerial.printf("[BBLScan] [%d] IP: %s", ++sessionFound, senderIP.toString().c_str()); + if (usnStr.length()) { + LogSerial.printf(" [USN: %s]", usnStr.c_str()); + } + LogSerial.println(); } - LogSerial.println(); - if (!bblIsPrinterKnown(senderIP) && bblKnownPrinterCount < BBL_MAX_PRINTERS) { + if (isNewPrinter && bblKnownPrinterCount < BBL_MAX_PRINTERS) { BBLPrinter& printer = bblLastKnownPrinters[bblKnownPrinterCount++]; printer.ip = senderIP; - if (macFound) { - memcpy(printer.mac, mac->addr, 6); - } else { - memset(printer.mac, 0, 6); - } strncpy(printer.usn, usnStr.c_str(), sizeof(printer.usn) - 1); printer.usn[sizeof(printer.usn) - 1] = 0; } @@ -143,11 +127,13 @@ void bblSearchPrinters() { delay(10); } - if (sessionFound == 0) { + if (printerConfig.debuging && sessionFound == 0) { LogSerial.println("[BBLScan] No printers found."); } - bblPrintKnownPrinters(); + if (printerConfig.debuging) { + bblPrintKnownPrinters(); + } } #endif diff --git a/src/blled/filesystem.h b/src/blled/filesystem.h index f1cf177..3f00401 100644 --- a/src/blled/filesystem.h +++ b/src/blled/filesystem.h @@ -3,7 +3,7 @@ #include #include "FS.h" - +#include #include #include #include "types.h" diff --git a/src/main.cpp b/src/main.cpp index c4fc90e..1b59bcb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,12 +2,14 @@ bool shouldRestart = false; unsigned long restartRequestTime = 0; #include "./blled/logSerial.h" +#include "./blled/leds.h" +#include "./blled/filesystem.h" +#include "./blled/types.h" #include "./blled/bblPrinterDiscovery.h" #include "./blled/web-server.h" #include "./blled/mqttmanager.h" -#include "./blled/filesystem.h" -#include "./blled/types.h" -#include "./blled/leds.h" + + #include "./blled/serialmanager.h" #include "./blled/wifi-manager.h" #include "./blled/ssdp.h" From 660310d30ef57f5565c0be75501dbb41f8898007 Mon Sep 17 00:00:00 2001 From: softwarecrash Date: Sun, 15 Jun 2025 16:33:33 +0200 Subject: [PATCH 13/34] add method to follow up a changed printer ip add debug labels --- src/blled/bblPrinterDiscovery.h | 11 +++++++++++ src/blled/filesystem.h | 32 ++++++++++++++++---------------- src/main.cpp | 2 -- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/blled/bblPrinterDiscovery.h b/src/blled/bblPrinterDiscovery.h index 81fbeae..56fca16 100644 --- a/src/blled/bblPrinterDiscovery.h +++ b/src/blled/bblPrinterDiscovery.h @@ -3,6 +3,7 @@ #include #include +#include "filesystem.h" // for saveFileSystem() #define BBL_SSDP_PORT 2021 #define BBL_SSDP_MCAST_IP IPAddress(239, 255, 255, 250) @@ -106,6 +107,16 @@ void bblSearchPrinters() { usnStr.trim(); } + // IP update check for stored USN + if (usnStr.length() > 0 && strcmp(printerConfig.serialNumber, usnStr.c_str()) == 0) { + String currentIP = senderIP.toString(); + if (String(printerConfig.printerIP) != currentIP) { + LogSerial.printf("[BBLScan] Detected matching USN with updated IP (%s → %s). Saving...\n", printerConfig.printerIP, currentIP.c_str()); + strlcpy(printerConfig.printerIP, currentIP.c_str(), sizeof(printerConfig.printerIP)); + saveFileSystem(); + } + } + int existingIndex = -1; bool isNewPrinter = !bblIsPrinterKnown(senderIP, &existingIndex); diff --git a/src/blled/filesystem.h b/src/blled/filesystem.h index 3f00401..c499ed5 100644 --- a/src/blled/filesystem.h +++ b/src/blled/filesystem.h @@ -28,7 +28,7 @@ char *generateRandomString(int length) void saveFileSystem() { - LogSerial.println(F("Saving config")); + LogSerial.println(F("[Filesystem] Saving config")); JsonDocument json; json["ssid"] = globalVariables.SSID; @@ -124,17 +124,17 @@ void saveFileSystem() File configFile = LittleFS.open(configPath, "w"); if (!configFile) { - LogSerial.println(F("Failed to save config")); + LogSerial.println(F("[Filesystem] Failed to save config")); return; } serializeJson(json, configFile); configFile.close(); - LogSerial.println(F("Config Saved")); + LogSerial.println(F("[Filesystem] Config Saved")); } void loadFileSystem() { - LogSerial.println(F("Loading config")); + LogSerial.println(F("[Filesystem] Loading config")); File configFile; int attempts = 0; @@ -146,16 +146,16 @@ void loadFileSystem() break; } attempts++; - LogSerial.println(F("Failed to open config file, retrying..")); + LogSerial.println(F("[Filesystem] Failed to open config file, retrying..")); delay(2000); } if (!configFile) { - LogSerial.print(F("Failed to open config file after ")); + LogSerial.print(F("[Filesystem] Failed to open config file after ")); LogSerial.print(attempts); LogSerial.println(F(" retries")); - LogSerial.println(F("Clearing config")); + LogSerial.println(F("[Filesystem] Clearing config")); // LittleFS.remove(configPath); saveFileSystem(); return; @@ -222,12 +222,12 @@ void loadFileSystem() printerConfig.frontCoverRGB = hex2rgb(json["frontCoverRGB"], json["frontCoverWW"], json["frontCoverCW"]); printerConfig.nozzleTempRGB = hex2rgb(json["nozzleTempRGB"], json["nozzleTempWW"], json["nozzleTempCW"]); printerConfig.bedTempRGB = hex2rgb(json["bedTempRGB"], json["bedTempWW"], json["bedTempCW"]); - LogSerial.println(F("Loaded config")); + LogSerial.println(F("[Filesystem] Loaded config")); } else { - LogSerial.println(F("Failed loading config")); - LogSerial.println(F("Clearing config")); + LogSerial.println(F("[Filesystem] Failed loading config")); + LogSerial.println(F("[Filesystem] Clearing config")); LittleFS.remove(configPath); // LogSerial.println(F("Generating new password")); @@ -240,7 +240,7 @@ void loadFileSystem() void deleteFileSystem() { - LogSerial.println(F("Deleting LittleFS")); + LogSerial.println(F("[Filesystem] Deleting LittleFS")); LittleFS.remove(configPath); } @@ -251,17 +251,17 @@ bool hasFileSystem() void setupFileSystem() { - LogSerial.println(F("Mounting LittleFS")); + LogSerial.println(F("[Filesystem] Mounting LittleFS")); if (!LittleFS.begin()) { - LogSerial.println(F("Failed to mount LittleFS")); + LogSerial.println(F("[Filesystem] Failed to mount LittleFS")); LittleFS.format(); - LogSerial.println(F("Formatting LittleFS")); - LogSerial.println(F("Restarting Device")); + LogSerial.println(F("[Filesystem] Formatting LittleFS")); + LogSerial.println(F("[Filesystem] Restarting Device")); delay(1000); ESP.restart(); } - LogSerial.println(F("Mounted LittleFS")); + LogSerial.println(F("[Filesystem] Mounted LittleFS")); }; #endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 1b59bcb..5bfe818 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,8 +8,6 @@ unsigned long restartRequestTime = 0; #include "./blled/bblPrinterDiscovery.h" #include "./blled/web-server.h" #include "./blled/mqttmanager.h" - - #include "./blled/serialmanager.h" #include "./blled/wifi-manager.h" #include "./blled/ssdp.h" From 4e740862cbdb6336941d4225b8d147eb46bde70a Mon Sep 17 00:00:00 2001 From: softwarecrash Date: Sun, 15 Jun 2025 16:46:18 +0200 Subject: [PATCH 14/34] secure filesystem read --- src/blled/bblPrinterDiscovery.h | 101 ++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 36 deletions(-) diff --git a/src/blled/bblPrinterDiscovery.h b/src/blled/bblPrinterDiscovery.h index 56fca16..b226a00 100644 --- a/src/blled/bblPrinterDiscovery.h +++ b/src/blled/bblPrinterDiscovery.h @@ -3,14 +3,15 @@ #include #include -#include "filesystem.h" // for saveFileSystem() +#include "filesystem.h" // for saveFileSystem() #define BBL_SSDP_PORT 2021 #define BBL_SSDP_MCAST_IP IPAddress(239, 255, 255, 250) #define BBL_DISCOVERY_INTERVAL 10000UL #define BBL_MAX_PRINTERS 10 -struct BBLPrinter { +struct BBLPrinter +{ IPAddress ip; char usn[64]; }; @@ -22,55 +23,68 @@ static unsigned long bblLastDiscovery = 0; static BBLPrinter bblLastKnownPrinters[BBL_MAX_PRINTERS]; static int bblKnownPrinterCount = 0; -bool bblIsPrinterKnown(IPAddress ip, int* index = nullptr) { - for (int i = 0; i < bblKnownPrinterCount; i++) { - if (bblLastKnownPrinters[i].ip == ip) { - if (index) *index = i; +bool bblIsPrinterKnown(IPAddress ip, int *index = nullptr) +{ + for (int i = 0; i < bblKnownPrinterCount; i++) + { + if (bblLastKnownPrinters[i].ip == ip) + { + if (index) + *index = i; return true; } } return false; } -void bblPrintKnownPrinters() { +void bblPrintKnownPrinters() +{ LogSerial.println("[BBLScan] Known printers:"); - if (bblKnownPrinterCount == 0) { + if (bblKnownPrinterCount == 0) + { LogSerial.println(" (none)"); } - for (int i = 0; i < bblKnownPrinterCount; i++) { + for (int i = 0; i < bblKnownPrinterCount; i++) + { LogSerial.printf(" [%d] IP: %s", i + 1, bblLastKnownPrinters[i].ip.toString().c_str()); - if (strlen(bblLastKnownPrinters[i].usn) > 0) { + if (strlen(bblLastKnownPrinters[i].usn) > 0) + { LogSerial.printf(" [USN: %s]", bblLastKnownPrinters[i].usn); } LogSerial.println(); } } -void bblSearchPrinters() { +void bblSearchPrinters() +{ unsigned long now = millis(); - if (now - bblLastDiscovery < BBL_DISCOVERY_INTERVAL) return; + if (now - bblLastDiscovery < BBL_DISCOVERY_INTERVAL) + return; bblLastDiscovery = now; - if (!bblUdpInitialized) { + if (!bblUdpInitialized) + { bblUdp.beginMulticast(BBL_SSDP_MCAST_IP, BBL_SSDP_PORT); bblUdpInitialized = true; } String msearch = - "M-SEARCH * HTTP/1.1\r\n" - "HOST: 239.255.255.250:2021\r\n" - "MAN: \"ssdp:discover\"\r\n" - "MX: 5\r\n" - "ST: urn:bambulab-com:device:3dprinter:1\r\n\r\n"; - - for (int i = 0; i < 2; i++) { + "M-SEARCH * HTTP/1.1\r\n" + "HOST: 239.255.255.250:2021\r\n" + "MAN: \"ssdp:discover\"\r\n" + "MX: 5\r\n" + "ST: urn:bambulab-com:device:3dprinter:1\r\n\r\n"; + + for (int i = 0; i < 2; i++) + { bblUdp.beginPacket(BBL_SSDP_MCAST_IP, BBL_SSDP_PORT); bblUdp.print(msearch); bblUdp.endPacket(); delay(250); } - if (printerConfig.debuging) { + if (printerConfig.debuging) + { LogSerial.println("[BBLScan] Searching for printers..."); } @@ -79,20 +93,26 @@ void bblSearchPrinters() { IPAddress seenIPs[BBL_MAX_PRINTERS]; int seenCount = 0; - while (millis() - start < 5000) { + while (millis() - start < 5000) + { int size = bblUdp.parsePacket(); - if (size) { + if (size) + { IPAddress senderIP = bblUdp.remoteIP(); bool alreadySeen = false; - for (int i = 0; i < seenCount; i++) { - if (seenIPs[i] == senderIP) { + for (int i = 0; i < seenCount; i++) + { + if (seenIPs[i] == senderIP) + { alreadySeen = true; break; } } - if (alreadySeen) continue; - if (seenCount < BBL_MAX_PRINTERS) seenIPs[seenCount++] = senderIP; + if (alreadySeen) + continue; + if (seenCount < BBL_MAX_PRINTERS) + seenIPs[seenCount++] = senderIP; char buffer[512]; int len = bblUdp.read(buffer, sizeof(buffer) - 1); @@ -101,16 +121,20 @@ void bblSearchPrinters() { String response(buffer); String usnStr = ""; int usnPos = response.indexOf("USN:"); - if (usnPos >= 0) { + if (usnPos >= 0) + { int end = response.indexOf("\r\n", usnPos); usnStr = response.substring(usnPos + 4, end); usnStr.trim(); } // IP update check for stored USN - if (usnStr.length() > 0 && strcmp(printerConfig.serialNumber, usnStr.c_str()) == 0) { + if (strlen(printerConfig.serialNumber) > 0 && usnStr.length() > 0 && + strcmp(printerConfig.serialNumber, usnStr.c_str()) == 0) + { String currentIP = senderIP.toString(); - if (String(printerConfig.printerIP) != currentIP) { + if (String(printerConfig.printerIP) != currentIP) + { LogSerial.printf("[BBLScan] Detected matching USN with updated IP (%s → %s). Saving...\n", printerConfig.printerIP, currentIP.c_str()); strlcpy(printerConfig.printerIP, currentIP.c_str(), sizeof(printerConfig.printerIP)); saveFileSystem(); @@ -120,16 +144,19 @@ void bblSearchPrinters() { int existingIndex = -1; bool isNewPrinter = !bblIsPrinterKnown(senderIP, &existingIndex); - if (printerConfig.debuging || (printerConfig.debugingchange && isNewPrinter)) { + if (printerConfig.debuging || (printerConfig.debugingchange && isNewPrinter)) + { LogSerial.printf("[BBLScan] [%d] IP: %s", ++sessionFound, senderIP.toString().c_str()); - if (usnStr.length()) { + if (usnStr.length()) + { LogSerial.printf(" [USN: %s]", usnStr.c_str()); } LogSerial.println(); } - if (isNewPrinter && bblKnownPrinterCount < BBL_MAX_PRINTERS) { - BBLPrinter& printer = bblLastKnownPrinters[bblKnownPrinterCount++]; + if (isNewPrinter && bblKnownPrinterCount < BBL_MAX_PRINTERS) + { + BBLPrinter &printer = bblLastKnownPrinters[bblKnownPrinterCount++]; printer.ip = senderIP; strncpy(printer.usn, usnStr.c_str(), sizeof(printer.usn) - 1); printer.usn[sizeof(printer.usn) - 1] = 0; @@ -138,11 +165,13 @@ void bblSearchPrinters() { delay(10); } - if (printerConfig.debuging && sessionFound == 0) { + if (printerConfig.debuging && sessionFound == 0) + { LogSerial.println("[BBLScan] No printers found."); } - if (printerConfig.debuging) { + if (printerConfig.debuging) + { bblPrintKnownPrinters(); } } From cd43e2c556d95595fd2d4bdacc4ef5d31f08da37 Mon Sep 17 00:00:00 2001 From: SoftWareCrash Date: Mon, 16 Jun 2025 15:58:15 +0200 Subject: [PATCH 15/34] add search button control --- src/blled/web-server.h | 3 ++- src/www/wifiSetup.html | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/blled/web-server.h b/src/blled/web-server.h index d7711d2..0390b72 100644 --- a/src/blled/web-server.h +++ b/src/blled/web-server.h @@ -199,6 +199,7 @@ void handlePrinterConfigJson(AsyncWebServerRequest *request) doc["accessCode"] = printerConfig.accessCode; doc["webUser"] = securityVariables.HTTPUser; doc["webPass"] = securityVariables.HTTPPass; + doc["isAPMode"] = (WiFi.getMode() & WIFI_AP); String json; serializeJson(doc, json); @@ -290,11 +291,11 @@ void sendJsonToAll(JsonDocument &doc) ws.textAll(jsonString); } + void handleWiFiScan(AsyncWebServerRequest *request) { JsonDocument doc; JsonArray networks = doc["networks"].to(); - int n = WiFi.scanNetworks(); for (int i = 0; i < n; ++i) { diff --git a/src/www/wifiSetup.html b/src/www/wifiSetup.html index 5d62021..8dac118 100644 --- a/src/www/wifiSetup.html +++ b/src/www/wifiSetup.html @@ -29,7 +29,7 @@

BLLED WiFi Setup

+ style="width: 28px; height: 28px; padding: 0; font-size: 16px; margin-bottom: 8px; background: #eee; cursor: pointer; display: none;">🔍
@@ -198,6 +198,11 @@

Select Printer

document.getElementById("password").value = config.pass || ""; document.getElementById("printerIP").value = config.printerIP || ""; document.getElementById("printerSerial").value = config.printerSerial || ""; + if (config.isAPMode) { + document.getElementById("openPrinterList").style.display = "none"; + } else { + document.getElementById("openPrinterList").style.display = "inline-block"; + } document.getElementById("accessCode").value = config.accessCode || ""; document.getElementById("webUser").value = config.webUser || ""; document.getElementById("webPass").value = config.webPass || ""; From 2b37face4d12c0f52b7e20588800a15af559e46d Mon Sep 17 00:00:00 2001 From: softwarecrash Date: Mon, 16 Jun 2025 20:30:49 +0200 Subject: [PATCH 16/34] cleanup add mqtt tags version bump --- platformio.ini | 2 +- src/blled/mqttmanager.h | 24 ++++++++++++------------ src/blled/web-server.h | 2 -- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/platformio.ini b/platformio.ini index f1df2b0..5bd02c2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,7 @@ [env:esp32dev] custom_project_name = BLLEDController custom_project_codename = Balder -custom_version = 2.1.1.nightly.150625.1 ; for github release name the release VX.Y.Z X=(Incerase when Modifications oder new functions Break the API/webUI) Y=(Incerase for add oder modify changes that not breake the API/webUI until X incearase) Z=(Incerase for bugfix releases until minor is incerase) +custom_version = 2.1.1.nightly.160625.1 #BLLC_[Major].[Minor].[Patch] platform = espressif32 board = esp32dev framework = arduino diff --git a/src/blled/mqttmanager.h b/src/blled/mqttmanager.h index 59babdc..c3f82fe 100644 --- a/src/blled/mqttmanager.h +++ b/src/blled/mqttmanager.h @@ -63,7 +63,7 @@ volatile bool mqttConnectInProgress = false; LogSerial.println(F("Connecting to mqtt...")); if (mqttClient.connect(clientId.c_str(), "bblp", printerConfig.accessCode)) { - LogSerial.print(F("MQTT connected, subscribing to MQTT Topic: ")); + LogSerial.print(F("[MQTT] connected, subscribing to MQTT Topic: ")); LogSerial.println(report_topic); mqttClient.subscribe(report_topic.c_str()); printerVariables.online = true; @@ -116,7 +116,7 @@ void connectMqtt() if (mqttClient.connect(clientId.c_str(), "bblp", printerConfig.accessCode)) { - Serial.print(F("MQTT connected, subscribing to MQTT Topic: ")); + Serial.print(F("[MQTT] connected, subscribing to MQTT Topic: ")); Serial.println(report_topic); mqttClient.subscribe(report_topic.c_str()); printerVariables.online = true; @@ -253,7 +253,7 @@ void ParseCallback(char *topic, byte *payload, unsigned int length) if (printerConfig.mqttdebug && (printerConfig.maintMode || printerConfig.testcolorEnabled || printerConfig.discoMode || printerConfig.debugwifi)) { - LogSerial.print(F("MQTT Message Ignored while in ")); + LogSerial.print(F("[MQTT] Message Ignored while in ")); if (printerConfig.maintMode) LogSerial.print(F("Maintenance")); if (printerConfig.testcolorEnabled) @@ -281,7 +281,7 @@ void ParseCallback(char *topic, byte *payload, unsigned int length) printerVariables.doorOpen = doorState; if (printerConfig.debugingchange) - LogSerial.print(F("MQTT Door ")); + LogSerial.print(F("[MQTT] Door ")); if (printerVariables.doorOpen) { printerVariables.lastdoorOpenms = millis(); @@ -311,7 +311,7 @@ void ParseCallback(char *topic, byte *payload, unsigned int length) if (printerConfig.debugingchange || printerConfig.debuging) { - LogSerial.print(F("MQTT update - stg_cur now: ")); + LogSerial.print(F("[MQTT] update - stg_cur now: ")); LogSerial.println(printerVariables.stage); } Changed = true; @@ -343,7 +343,7 @@ void ParseCallback(char *topic, byte *payload, unsigned int length) if (printerConfig.debugingchange || printerConfig.debuging) { - LogSerial.print(F("MQTT update - gcode_state now: ")); + LogSerial.print(F("[MQTT] update - gcode_state now: ")); LogSerial.println(printerVariables.gcodeState); } Changed = true; @@ -356,7 +356,7 @@ void ParseCallback(char *topic, byte *payload, unsigned int length) if (messageobject["print"]["command"] == "pause") { lastMQTTupdate = millis(); - LogSerial.println(F("MQTT update - manual PAUSE")); + LogSerial.println(F("[MQTT] update - manual PAUSE")); printerVariables.gcodeState = "PAUSE"; Changed = true; } @@ -377,7 +377,7 @@ void ParseCallback(char *topic, byte *payload, unsigned int length) printerConfig.replicate_update = true; if (printerConfig.debugingchange || printerConfig.debuging) { - LogSerial.print(F("MQTT chamber_light now: ")); + LogSerial.print(F("[MQTT] chamber_light now: ")); LogSerial.println(printerVariables.printerledstate); } if (printerVariables.waitingForDoor && printerConfig.finish_check) @@ -403,7 +403,7 @@ void ParseCallback(char *topic, byte *payload, unsigned int length) lastMQTTupdate = millis(); if (printerConfig.debugingchange || printerConfig.debuging) { - LogSerial.print(F("MQTT led_mode now: ")); + LogSerial.print(F("[MQTT] led_mode now: ")); LogSerial.println(printerVariables.printerledstate); } if (printerVariables.waitingForDoor && printerConfig.finish_check) @@ -449,7 +449,7 @@ void ParseCallback(char *topic, byte *payload, unsigned int length) if (printerConfig.debuging || printerConfig.debugingchange) { - LogSerial.print(F("MQTT update - parsedHMSlevel now: ")); + LogSerial.print(F("[MQTT] update - parsedHMSlevel now: ")); if (printerVariables.parsedHMSlevel.length() > 0) { LogSerial.print(printerVariables.parsedHMSlevel); @@ -556,7 +556,7 @@ void setupMqtt() if (result == pdPASS) { - LogSerial.println(F("MQTT task successfully started")); + LogSerial.println(F("[MQTT] task successfully started")); } else { @@ -581,7 +581,7 @@ void mqttloop() { printerVariables.disconnectMQTTms = millis(); // Record last time MQTT dropped connection - LogSerial.println(F("MQTT dropped during mqttloop")); + LogSerial.println(F("[MQTT] dropped during mqttloop")); ParseMQTTState(mqttClient.state()); } //delay(500); diff --git a/src/blled/web-server.h b/src/blled/web-server.h index 0390b72..77471f4 100644 --- a/src/blled/web-server.h +++ b/src/blled/web-server.h @@ -291,7 +291,6 @@ void sendJsonToAll(JsonDocument &doc) ws.textAll(jsonString); } - void handleWiFiScan(AsyncWebServerRequest *request) { JsonDocument doc; @@ -468,7 +467,6 @@ void handlePrinterList(AsyncWebServerRequest *request) request->send(200, "application/json", json); } - void handleUploadConfigFileData(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final) { From c649f04bd555852b9168ca4a19d6ce5bbf83de08 Mon Sep 17 00:00:00 2001 From: softwarecrash Date: Mon, 16 Jun 2025 21:48:40 +0200 Subject: [PATCH 17/34] fix Typo stop log spamming --- src/blled/leds.h | 37 +++++++++++++++++++++++++++++++++- src/blled/mqttparsingutility.h | 20 +++++++++--------- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/src/blled/leds.h b/src/blled/leds.h index 088c893..871140f 100644 --- a/src/blled/leds.h +++ b/src/blled/leds.h @@ -204,7 +204,7 @@ void RGBCycle() ledcWrite(coldChannel, currentCold); } -void printLogs(String Desc, COLOR thisColor) +/* void printLogs(String Desc, COLOR thisColor) { if (printerConfig.debuging || printerConfig.debugingchange) { @@ -228,7 +228,42 @@ void printLogs(String Desc, COLOR thisColor) LogSerial.print(F(" Brightness: ")); LogSerial.println(printerConfig.brightness); }; +} */ +void printLogs(String Desc, COLOR thisColor) +{ + static COLOR lastColor = {-1, -1, -1, -1, -1}; + static String lastDesc = ""; + static unsigned long lastPrintTime = 0; + + // Skip if same state and printed less than 3 seconds ago + if (Desc == lastDesc && + memcmp(&thisColor, &lastColor, sizeof(COLOR)) == 0 && + millis() - lastPrintTime < 3000) + { + return; + } + + if (printerConfig.debuging || printerConfig.debugingchange) + { + LogSerial.printf("%s - Turning LEDs to:", Desc.c_str()); + if ((thisColor.r + thisColor.g + thisColor.b + thisColor.ww + thisColor.cw) == 0) + { + LogSerial.println(" OFF"); + } + else + { + LogSerial.printf(" r:%d g:%d b:%d ww:%d cw:%d Brightness: %d\n", + thisColor.r, thisColor.g, thisColor.b, + thisColor.ww, thisColor.cw, printerConfig.brightness); + } + } + + lastColor = thisColor; + lastDesc = Desc; + lastPrintTime = millis(); } + + void printLogs(String Desc, short r, short g, short b, short ww, short cw) { COLOR tempColor; diff --git a/src/blled/mqttparsingutility.h b/src/blled/mqttparsingutility.h index ebc7d05..7e24c92 100644 --- a/src/blled/mqttparsingutility.h +++ b/src/blled/mqttparsingutility.h @@ -23,34 +23,34 @@ void ParseMQTTState(int code){ switch (code) { case -4: // MQTT_CONNECTION_TIMEOUT - LogSerial.println(F("MQTT TIMEOUT")); + LogSerial.println(F("[MQTT] Timeout (-4)")); break; case -3: // MQTT_CONNECTION_LOST - LogSerial.println(F("MQTT CONNECTION_LOST")); + LogSerial.println(F("[MQTT] Connection Lost (-3)")); break; case -2: // MQTT_CONNECT_FAILED - LogSerial.println(F("MQTT CONNECT_FAILED")); + LogSerial.println(F("[MQTT] Connection Failed (-2)")); break; case -1: // MQTT_DISCONNECTED - LogSerial.println(F("MQTT DISCONNECTED")); + LogSerial.println(F("[MQTT] Disconnected (-1)")); break; case 0: // MQTT_CONNECTED - LogSerial.println(F("MQTT CONNECTED")); + LogSerial.println(F("[MQTT] Connected (0)")); break; case 1: // MQTT_CONNECT_BAD_PROTOCOL - LogSerial.println(F("MQTT BAD PROTOCOL")); + LogSerial.println(F("[MQTT] Bad protocol (1)")); break; case 2: // MQTT_CONNECT_BAD_CLIENT_ID - LogSerial.println(F("MQTT BAD CLIENT ID")); + LogSerial.println(F("[MQTT] Bad Client ID (2)")); break; case 3: // MQTT_CONNECT_UNAVAILABLE - LogSerial.println(F("MQTT UNAVAILABLE")); + LogSerial.println(F("[MQTT] Unavailable (3)")); break; case 4: // MQTT_CONNECT_BAD_CREDENTIALS - LogSerial.println(F("MQTT BAD CREDENTIALS")); + LogSerial.println(F("[MQTT] Bad Credentials (4)")); break; case 5: // MQTT UNAUTHORIZED - LogSerial.println(F("MQTT UNAUTHORIZED")); + LogSerial.println(F("[MQTT] Unauthorized (5)")); break; } } From 3d2c00896d663b6a3edb8a0ed58f28c334396f89 Mon Sep 17 00:00:00 2001 From: Rocky <44615614+softwarecrash@users.noreply.github.com> Date: Mon, 16 Jun 2025 22:00:47 +0200 Subject: [PATCH 18/34] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index de5922f..30ff0b5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## BL Led Controller -The BL Led Controller is an ESP8266 / ESP32 based device that connects to your Bambulab X1,X1C,P1P Or P1S and controls the LED strip based on the state of the printer. +The BL Led Controller is an ESP32 based device that connects to your Bambulab X1,X1C,P1P Or P1S and controls the LED strip based on the state of the printer. ### Flashing and Setup 1. go to the [Web Flasher](https://softwarecrash.github.io/BLLED-Flasher/) From 7329ca51de13bbc804506b1d03d2e862d28ae979 Mon Sep 17 00:00:00 2001 From: softwarecrash Date: Thu, 19 Jun 2025 20:01:11 +0200 Subject: [PATCH 19/34] add hms ignore list --- platformio.ini | 2 +- src/blled/filesystem.h | 5 ++ src/blled/mqttmanager.h | 114 +++++++++++++++++++++++++++------------- src/blled/types.h | 3 +- src/blled/web-server.h | 5 ++ src/www/setupPage.html | 20 ++++--- 6 files changed, 103 insertions(+), 46 deletions(-) diff --git a/platformio.ini b/platformio.ini index 5bd02c2..0cdc782 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,7 @@ [env:esp32dev] custom_project_name = BLLEDController custom_project_codename = Balder -custom_version = 2.1.1.nightly.160625.1 #BLLC_[Major].[Minor].[Patch] +custom_version = 2.2.0.nightly.190625.1 #BLLC_[Major].[Minor].[Patch] platform = espressif32 board = esp32dev framework = arduino diff --git a/src/blled/filesystem.h b/src/blled/filesystem.h index c499ed5..c8b14f9 100644 --- a/src/blled/filesystem.h +++ b/src/blled/filesystem.h @@ -120,6 +120,8 @@ void saveFileSystem() json["bedTempRGB"] = printerConfig.bedTempRGB.RGBhex; json["bedTempWW"] = printerConfig.bedTempRGB.ww; json["bedTempCW"] = printerConfig.bedTempRGB.cw; + //HMS Error handling + json["hmsIgnoreList"] = printerConfig.hmsIgnoreList; File configFile = LittleFS.open(configPath, "w"); if (!configFile) @@ -222,6 +224,9 @@ void loadFileSystem() printerConfig.frontCoverRGB = hex2rgb(json["frontCoverRGB"], json["frontCoverWW"], json["frontCoverCW"]); printerConfig.nozzleTempRGB = hex2rgb(json["nozzleTempRGB"], json["nozzleTempWW"], json["nozzleTempCW"]); printerConfig.bedTempRGB = hex2rgb(json["bedTempRGB"], json["bedTempWW"], json["bedTempCW"]); + // HMS Error handling + printerConfig.hmsIgnoreList = json["hmsIgnoreList"] | ""; + LogSerial.println(F("[Filesystem] Loaded config")); } else diff --git a/src/blled/mqttmanager.h b/src/blled/mqttmanager.h index c3f82fe..fb92113 100644 --- a/src/blled/mqttmanager.h +++ b/src/blled/mqttmanager.h @@ -92,7 +92,8 @@ volatile bool mqttConnectInProgress = false; } */ void connectMqtt() { - if (mqttConnectInProgress) return; + if (mqttConnectInProgress) + return; mqttConnectInProgress = true; @@ -111,7 +112,7 @@ void connectMqtt() if (!mqttClient.connected() && (millis() - mqttattempt) >= 3000) { - //tweenToColor(10, 10, 10, 10, 10); + // tweenToColor(10, 10, 10, 10, 10); Serial.println(F("Connecting to mqtt...")); if (mqttClient.connect(clientId.c_str(), "bblp", printerConfig.accessCode)) @@ -140,7 +141,6 @@ void connectMqtt() mqttConnectInProgress = false; } - void mqttTask(void *parameter) { mqttTaskRunning = true; @@ -188,12 +188,12 @@ void ParseCallback(char *topic, byte *payload, unsigned int length) // Rather than showing the entire message to Serial - grabbing only the pertinent bits for BLLED. // Device Status -//sniped: implement to get layer num. for hms error, swap back to running state after layer change -/* "print": { - "3D": { - "layer_num": 0, - "total_layer_num": 191 - } */ + // sniped: implement to get layer num. for hms error, swap back to running state after layer change + /* "print": { + "3D": { + "layer_num": 0, + "total_layer_num": 191 + } */ filter["print"]["command"] = true; filter["print"]["fail_reason"] = true; @@ -229,8 +229,7 @@ void ParseCallback(char *topic, byte *payload, unsigned int length) || messageobject["print"]["command"] == "clean_print_error" // During error (no info) || messageobject["print"]["command"] == "resume" // After error or pause || messageobject["print"]["command"] == "get_accessories" // After error or pause - || messageobject["print"]["command"] == "prepare" - || messageobject["print"]["command"] == "extrusion_cali_get") + || messageobject["print"]["command"] == "prepare" || messageobject["print"]["command"] == "extrusion_cali_get") { // 1 message per print return; } @@ -424,18 +423,63 @@ void ParseCallback(char *topic, byte *payload, unsigned int length) printerVariables.hmsstate = false; printerVariables.parsedHMSlevel = ""; + /* for (const auto &hms : messageobject["print"]["hms"].as()) + { + if (ParseHMSSeverity(hms["code"]) != "") + { + printerVariables.hmsstate = true; + printerVariables.parsedHMSlevel = ParseHMSSeverity(hms["code"]); + printerVariables.parsedHMScode = ((uint64_t)hms["attr"] << 32) + (uint64_t)hms["code"]; + } + } */ for (const auto &hms : messageobject["print"]["hms"].as()) { + uint64_t code = ((uint64_t)hms["attr"] << 32) + (uint64_t)hms["code"]; + + int chunk1 = (code >> 48); + int chunk2 = (code >> 32) & 0xFFFF; + int chunk3 = (code >> 16) & 0xFFFF; + int chunk4 = code & 0xFFFF; + + char strHMScode[32]; + sprintf(strHMScode, "HMS_%04X_%04X_%04X_%04X", chunk1, chunk2, chunk3, chunk4); + + // Normalize input string (replace '-' with '_', remove whitespace) + String normalizedIgnoreList = printerConfig.hmsIgnoreList; + normalizedIgnoreList.replace("-", "_"); + normalizedIgnoreList.replace(" ", ""); + normalizedIgnoreList.replace("\r", ""); + normalizedIgnoreList.replace("\n", ","); + + // Check if code is in ignore list + if (("," + normalizedIgnoreList + ",").indexOf("," + String(strHMScode) + ",") >= 0) + { + LogSerial.print(F("[MQTT] Ignored HMS Code: ")); + LogSerial.println(strHMScode); + continue; + } + + // Ignore if present in ignore list + if (printerConfig.hmsIgnoreList.indexOf(strHMScode) >= 0) + { + LogSerial.print(F("[MQTT] HMS code ignored: ")); + LogSerial.println(strHMScode); + continue; + } + if (ParseHMSSeverity(hms["code"]) != "") { printerVariables.hmsstate = true; printerVariables.parsedHMSlevel = ParseHMSSeverity(hms["code"]); - printerVariables.parsedHMScode = ((uint64_t)hms["attr"] << 32) + (uint64_t)hms["code"]; + printerVariables.parsedHMScode = code; } } + if (oldHMSlevel != printerVariables.parsedHMSlevel) { - + // example, cap fall off + // Error Code: 0300_1200_0002_0001 ** + //"hms":[{"attr":50336256,"code":131073}] if (printerVariables.parsedHMScode == 0x0C0003000003000B) printerVariables.overridestage = 10; if (printerVariables.parsedHMScode == 0x0300120000020001) @@ -453,7 +497,7 @@ void ParseCallback(char *topic, byte *payload, unsigned int length) if (printerVariables.parsedHMSlevel.length() > 0) { LogSerial.print(printerVariables.parsedHMSlevel); - LogSerial.print(F(" Error Code: ")); + LogSerial.print(F(" Error Code: HMS_")); // LogSerial.println(F("https://wiki.bambulab.com/en/x1/troubleshooting/how-to-enter-the-specific-code-page")); int chunk1 = (printerVariables.parsedHMScode >> 48); int chunk2 = (printerVariables.parsedHMScode >> 32) & 0xFFFF; @@ -533,26 +577,25 @@ void setupMqtt() { BaseType_t result; - #if CONFIG_FREERTOS_UNICORE - result = xTaskCreate( - mqttTask, - "mqttTask", - 6144, - NULL, - 1, - &mqttTaskHandle - ); - #else - result = xTaskCreatePinnedToCore( - mqttTask, - "mqttTask", - 6144, - NULL, - 1, - &mqttTaskHandle, - 1 // Core 1 (App Core) - ); - #endif +#if CONFIG_FREERTOS_UNICORE + result = xTaskCreate( + mqttTask, + "mqttTask", + 6144, + NULL, + 1, + &mqttTaskHandle); +#else + result = xTaskCreatePinnedToCore( + mqttTask, + "mqttTask", + 6144, + NULL, + 1, + &mqttTaskHandle, + 1 // Core 1 (App Core) + ); +#endif if (result == pdPASS) { @@ -565,7 +608,6 @@ void setupMqtt() } } - void mqttloop() { if (WiFi.status() != WL_CONNECTED || WiFi.getMode() != WIFI_MODE_STA) @@ -584,7 +626,7 @@ void mqttloop() LogSerial.println(F("[MQTT] dropped during mqttloop")); ParseMQTTState(mqttClient.state()); } - //delay(500); + // delay(500); connectMqtt(); delay(32); return; diff --git a/src/blled/types.h b/src/blled/types.h index ec4bd72..9547ade 100644 --- a/src/blled/types.h +++ b/src/blled/types.h @@ -118,8 +118,9 @@ extern "C" COLOR frontCoverRGB; COLOR nozzleTempRGB; COLOR bedTempRGB; + // HMS Error Handling + String hmsIgnoreList; // comma-separated list of HMS_XXXX_XXXX_XXXX_XXXX codes to ignore - //char webpagePassword[8]; } PrinterConfig; PrinterConfig printerConfig; diff --git a/src/blled/web-server.h b/src/blled/web-server.h index 77471f4..bb8d330 100644 --- a/src/blled/web-server.h +++ b/src/blled/web-server.h @@ -179,6 +179,9 @@ void handleGetConfig(AsyncWebServerRequest *request) doc["bedTempRGB"] = printerConfig.bedTempRGB.RGBhex; doc["bedTempWW"] = printerConfig.bedTempRGB.ww; doc["bedTempCW"] = printerConfig.bedTempRGB.cw; + //HMS Error Handling + doc["hmsIgnoreList"] = printerConfig.hmsIgnoreList; + String jsonString; serializeJson(doc, jsonString); @@ -271,6 +274,8 @@ void handleSubmitConfig(AsyncWebServerRequest *request) printerConfig.frontCoverRGB = hex2rgb(getSafeParamValue(request, "frontCoverRGB").c_str(), getSafeParamInt(request, "frontCoverWW"), getSafeParamInt(request, "frontCoverCW")); printerConfig.nozzleTempRGB = hex2rgb(getSafeParamValue(request, "nozzleTempRGB").c_str(), getSafeParamInt(request, "nozzleTempWW"), getSafeParamInt(request, "nozzleTempCW")); printerConfig.bedTempRGB = hex2rgb(getSafeParamValue(request, "bedTempRGB").c_str(), getSafeParamInt(request, "bedTempWW"), getSafeParamInt(request, "bedTempCW")); + //HMS Error handling + printerConfig.hmsIgnoreList = getSafeParamValue(request, "hmsIgnoreList"); saveFileSystem(); LogSerial.println(F("Packet received from setuppage")); diff --git a/src/www/setupPage.html b/src/www/setupPage.html index 687496f..7e8e5d4 100644 --- a/src/www/setupPage.html +++ b/src/www/setupPage.html @@ -122,8 +122,7 @@

BLLED LED Settings

Replicate State -
+
BLLED LED Settings Color Test (Always On) -
+
@@ -170,8 +168,7 @@

BLLED LED Settings

Finish Indication -
+
BLLED LED Settings Inactivity Timeout (Minutes) -
+
@@ -444,6 +440,12 @@

BLLED LED Settings

step="1">
+
+ Ignore HMS Codes (one per line) + +
@@ -835,6 +837,8 @@

Firmware version: ??.??.??

document.getElementById('bedTempRGB').value = configData.bedTempRGB || ''; document.getElementById('bedTempWW').value = configData.bedTempWW || 0; document.getElementById('bedTempCW').value = configData.bedTempCW || 0; + //HMS Error handling + document.getElementById('hmsIgnoreList').value = configData.hmsIgnoreList || ''; updateIdle(); showhideOptions(); From c9ecbe97aa3d1b8203d01c6ac18ebd6e2db96d03 Mon Sep 17 00:00:00 2001 From: softwarecrash Date: Thu, 19 Jun 2025 20:53:46 +0200 Subject: [PATCH 20/34] add routine to check led updates without triggers --- src/blled/leds.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/blled/leds.h b/src/blled/leds.h index 871140f..cc19617 100644 --- a/src/blled/leds.h +++ b/src/blled/leds.h @@ -718,7 +718,12 @@ void ledsloop() // Opening or Closing the Door will turn LEDs back on and restart the timer. updateleds(); } - + // Periodic fallback update to ensure MQTT timeout or other updates are evaluated + static unsigned long lastPeriodicUpdate = 0; + if (millis() - lastPeriodicUpdate > 10000) { // every 10 seconds + updateleds(); + lastPeriodicUpdate = millis(); + } delay(10); } From 266056d071e7a6c84950e739af2039aa60d078b0 Mon Sep 17 00:00:00 2001 From: softwarecrash Date: Thu, 19 Jun 2025 20:54:18 +0200 Subject: [PATCH 21/34] disable led update... future use --- src/blled/leds.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/blled/leds.h b/src/blled/leds.h index cc19617..5bfa55a 100644 --- a/src/blled/leds.h +++ b/src/blled/leds.h @@ -718,12 +718,12 @@ void ledsloop() // Opening or Closing the Door will turn LEDs back on and restart the timer. updateleds(); } - // Periodic fallback update to ensure MQTT timeout or other updates are evaluated +/* // Periodic fallback update to ensure MQTT timeout or other updates are evaluated static unsigned long lastPeriodicUpdate = 0; if (millis() - lastPeriodicUpdate > 10000) { // every 10 seconds updateleds(); lastPeriodicUpdate = millis(); - } + } */ delay(10); } From 5fe3ee1b9912e6804531328cce34bf0286739ebd Mon Sep 17 00:00:00 2001 From: softwarecrash Date: Thu, 19 Jun 2025 20:54:43 +0200 Subject: [PATCH 22/34] add comment --- src/blled/leds.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/blled/leds.h b/src/blled/leds.h index 5bfa55a..b9366a0 100644 --- a/src/blled/leds.h +++ b/src/blled/leds.h @@ -718,6 +718,7 @@ void ledsloop() // Opening or Closing the Door will turn LEDs back on and restart the timer. updateleds(); } + //disabled, need testing for future use /* // Periodic fallback update to ensure MQTT timeout or other updates are evaluated static unsigned long lastPeriodicUpdate = 0; if (millis() - lastPeriodicUpdate > 10000) { // every 10 seconds From 855ddf17ea49c0960593c72fba560f6857fb2507 Mon Sep 17 00:00:00 2001 From: SoftWareCrash Date: Fri, 20 Jun 2025 15:24:12 +0200 Subject: [PATCH 23/34] add chamber light control add factory reset method --- docs/manual.md | 36 +++++++++++++++++++++++++ platformio.ini | 2 +- src/blled/filesystem.h | 2 ++ src/blled/leds.h | 60 ++++++++++++++++++++++++++++++++++++++++- src/blled/mqttmanager.h | 45 +++++++++++++++++++++++++++++++ src/blled/types.h | 1 + src/blled/web-server.h | 19 +++++++++++++ src/www/setupPage.html | 8 ++++++ 8 files changed, 171 insertions(+), 2 deletions(-) create mode 100644 docs/manual.md diff --git a/docs/manual.md b/docs/manual.md new file mode 100644 index 0000000..c61fa29 --- /dev/null +++ b/docs/manual.md @@ -0,0 +1,36 @@ +### đŸ”Ļ Control Chamber Light + +When enabled, the BLLED Controller will automatically control the printer's internal chamber light via MQTT: + +- ✅ Turns the chamber light **on** when a print starts +- ❌ Turns it **off** after the print finishes (based on timeout or door interaction) +- 🔁 Toggles the chamber light together with the LEDs when using the **door double-close gesture** + +> This feature requires a working MQTT connection to your Bambu printer. +> It will not interfere with manual light control or other automations. + + +### 💾 Backup & Restore Configuration + +Use these options to save or restore your current BLLED configuration: + +- ✅ **Backup**: Downloads the current configuration (`blledconfig.json`) to your computer +- 🔁 **Restore**: Uploads a previously saved configuration to restore all LED and printer settings +- 🔒 Includes printer IP, access code, and all LED behaviors + +> Useful for transferring settings between devices or keeping a safety copy before updates. + +--- + +### â™ģī¸ Factory Reset + +Performs a full reset of the BLLED controller: + +- ❌ Deletes all saved configuration and WiFi credentials from internal storage +- 🔄 Automatically restarts the device into Access Point (setup) mode +- 🌐 You’ll need to reconnect and reconfigure via the setup page + +**How to trigger:** +Open your browser and navigate to: http://[device-ip]/factoryreset + + diff --git a/platformio.ini b/platformio.ini index 0cdc782..67d703f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,7 @@ [env:esp32dev] custom_project_name = BLLEDController custom_project_codename = Balder -custom_version = 2.2.0.nightly.190625.1 #BLLC_[Major].[Minor].[Patch] +custom_version = 2.2.0.nightly.200625.1 #BLLC_[Major].[Minor].[Patch] platform = espressif32 board = esp32dev framework = arduino diff --git a/src/blled/filesystem.h b/src/blled/filesystem.h index c8b14f9..03b7ab4 100644 --- a/src/blled/filesystem.h +++ b/src/blled/filesystem.h @@ -65,6 +65,7 @@ void saveFileSystem() json["finishTimerMins"] = printerConfig.finishTimeOut; json["inactivityEnabled"] = printerConfig.inactivityEnabled; json["inactivityTimeOut"] = printerConfig.inactivityTimeOut; + json["controlChamberLight"] = printerConfig.controlChamberLight; //control chamber light // Debugging json["debuging"] = printerConfig.debuging; json["debugingchange"] = printerConfig.debugingchange; @@ -199,6 +200,7 @@ void loadFileSystem() printerConfig.finish_check = json["finish_check"]; printerConfig.inactivityEnabled = json["inactivityEnabled"]; printerConfig.inactivityTimeOut = json["inactivityTimeOut"]; + printerConfig.controlChamberLight = json["controlChamberLight"]; //control chamber light // Debugging printerConfig.debuging = json["debuging"]; printerConfig.debugingchange = json["debugingchange"]; diff --git a/src/blled/leds.h b/src/blled/leds.h index b9366a0..49767d1 100644 --- a/src/blled/leds.h +++ b/src/blled/leds.h @@ -3,6 +3,7 @@ #include #include "mqttparsingutility.h" +void controlChamberLight(bool on); // Forward declaration const int redPin = 19; const int greenPin = 18; @@ -374,7 +375,7 @@ void updateleds() // TOGGLE LIGHTS via DOOR // If door is closed twice in 6 seconds, it will flip the state of the lights - if (printerVariables.doorSwitchTriggered == true) +/* if (printerVariables.doorSwitchTriggered == true) { if (printerConfig.debugingchange) { @@ -402,8 +403,63 @@ void updateleds() } printerVariables.doorSwitchTriggered = false; return; + } */ + if (printerVariables.doorSwitchTriggered == true) +{ + bool ledsAreOff = (currentWarm == 0 && currentCold == 0); + bool chamberLightIsOff = (printerVariables.printerledstate == false); + + if (printerConfig.debugingchange) + { + LogSerial.print(F("Door closed twice within 6 seconds - ")); + + if (ledsAreOff) + LogSerial.print(F("Turning LEDs ON")); + else + LogSerial.print(F("Turning LEDs OFF")); + + if (printerConfig.controlChamberLight) + { + if (ledsAreOff && chamberLightIsOff) + LogSerial.println(F(" + Chamber Light ON")); + else if (!ledsAreOff) + LogSerial.println(F(" + Chamber Light OFF")); + else + LogSerial.println(); + } + else + { + LogSerial.println(); + } } + if (ledsAreOff) + { + tweenToColor(0, 0, 0, 255, 255); // WHITE + printerConfig.isIdleOFFActive = false; + + if (printerConfig.controlChamberLight && chamberLightIsOff) + { + controlChamberLight(true); // Turn ON chamber light only if off + } + } + else + { + tweenToColor(0, 0, 0, 0, 0); // OFF + printerConfig.isIdleOFFActive = true; + printerConfig.inactivityStartms = millis() - printerConfig.inactivityTimeOut; + + if (printerConfig.controlChamberLight) + { + controlChamberLight(false); // Always OFF on manual off + } + } + + printerVariables.doorSwitchTriggered = false; + return; +} + + // RED -- RED -- RED -- RED // allow errordetection to turn ledstrip red @@ -697,6 +753,7 @@ void ledsloop() printerConfig.inactivityStartms = millis(); printerConfig.isIdleOFFActive = false; updateleds(); + controlChamberLight(false); // Turn off chamber light via MQTT } if ((printerConfig.finish_check && printerConfig.finishindication && printerConfig.finishExit == false && ((millis() - printerConfig.finishStartms) > printerConfig.finishTimeOut))) @@ -709,6 +766,7 @@ void ledsloop() printerConfig.inactivityStartms = millis(); printerConfig.isIdleOFFActive = false; updateleds(); + controlChamberLight(false); // Turn off chamber light via MQTT } // Need an trigger action to run updateleds() so lights turn off diff --git a/src/blled/mqttmanager.h b/src/blled/mqttmanager.h index fb92113..249638e 100644 --- a/src/blled/mqttmanager.h +++ b/src/blled/mqttmanager.h @@ -90,6 +90,7 @@ volatile bool mqttConnectInProgress = false; } } } */ + void connectMqtt() { if (mqttConnectInProgress) @@ -327,6 +328,11 @@ void ParseCallback(char *topic, byte *payload, unsigned int length) // Never turn off light (due to idle timer) while in this state printerConfig.inactivityStartms = millis(); } + if (mqttgcodeState == "RUNNING" && printerConfig.controlChamberLight && printerVariables.printerledstate == false) + { + controlChamberLight(true); // Turn chamber light ON at print start + LogSerial.println(F("[MQTT] Print started – Chamber Light ON requested")); + } // Onchange of gcodeState... if (printerVariables.gcodeState != mqttgcodeState) @@ -554,6 +560,45 @@ void mqttCallback(char *topic, byte *payload, unsigned int length) stream.flush(); } +void controlChamberLight(bool on) +{ + static bool lastState = false; + if (lastState == on) + return; // Skip sending if state hasn't changed + lastState = on; + + if (!printerConfig.controlChamberLight) + return; + + if (!mqttClient.connected()) + { + LogSerial.println(F("[MQTT] Skipped chamber_light control – MQTT not connected")); + return; + } + + JsonDocument doc; + JsonObject system = doc["system"].to(); + system["command"] = "ledctrl"; + system["sequence_id"] = "blled_auto"; + system["led_node"] = "chamber_light"; + system["led_mode"] = on ? "on" : "off"; + system["led_on_time"] = 500; + system["led_off_time"] = 500; + system["loop_times"] = 0; + system["interval_time"] = 1000; + + String payload; + serializeJson(doc, payload); + + String topic = String("device/") + printerConfig.serialNumber + "/request"; + mqttClient.publish(topic.c_str(), payload.c_str()); + + LogSerial.print(F("[MQTT] Chamber Light ")); + LogSerial.print(on ? F("ON") : F("OFF")); + LogSerial.print(F(" sent to topic: ")); + LogSerial.println(topic); +} + void setupMqtt() { clientId += String(random(0xffff), HEX); diff --git a/src/blled/types.h b/src/blled/types.h index 9547ade..8f5b85e 100644 --- a/src/blled/types.h +++ b/src/blled/types.h @@ -90,6 +90,7 @@ extern "C" bool finish_check = false; //When updateleds() is run, should the TEST LEDS be set? unsigned long finishStartms = 0; // Time the finish countdown is measured from int finishTimeOut = 600000; //300000 = 5 mins + bool controlChamberLight = false; //control chamber light //Inactivity Timout bool inactivityEnabled = true; diff --git a/src/blled/web-server.h b/src/blled/web-server.h index bb8d330..29bd658 100644 --- a/src/blled/web-server.h +++ b/src/blled/web-server.h @@ -181,6 +181,8 @@ void handleGetConfig(AsyncWebServerRequest *request) doc["bedTempCW"] = printerConfig.bedTempRGB.cw; //HMS Error Handling doc["hmsIgnoreList"] = printerConfig.hmsIgnoreList; + //control chamber light + doc["controlChamberLight"] = printerConfig.controlChamberLight; String jsonString; @@ -276,6 +278,8 @@ void handleSubmitConfig(AsyncWebServerRequest *request) printerConfig.bedTempRGB = hex2rgb(getSafeParamValue(request, "bedTempRGB").c_str(), getSafeParamInt(request, "bedTempWW"), getSafeParamInt(request, "bedTempCW")); //HMS Error handling printerConfig.hmsIgnoreList = getSafeParamValue(request, "hmsIgnoreList"); + //Control Chamber Light + printerConfig.controlChamberLight = request->hasParam("controlChamberLight", true); saveFileSystem(); LogSerial.println(F("Packet received from setuppage")); @@ -472,6 +476,20 @@ void handlePrinterList(AsyncWebServerRequest *request) request->send(200, "application/json", json); } +void handleFactoryReset(AsyncWebServerRequest *request) +{ + if (!isAuthorized(request)) + return request->requestAuthentication(); + + LogSerial.println(F("[FactoryReset] Performing full reset...")); + + deleteFileSystem(); // delete LittleFS config + request->send(200, "text/plain", "Factory reset complete. Restarting..."); + + shouldRestart = true; + restartRequestTime = millis(); +} + void handleUploadConfigFileData(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final) { @@ -557,6 +575,7 @@ void setupWebserver() webServer.on("/configfile.json", HTTP_GET, handleDownloadConfigFile); webServer.on("/webserial", HTTP_GET, handleWebSerialPage); webServer.on("/printerList", HTTP_GET, handlePrinterList); + webServer.on("/factoryreset", HTTP_GET, handleFactoryReset); webServer.on("/configrestore", HTTP_POST, [](AsyncWebServerRequest *request) { if (!isAuthorized(request)) { diff --git a/src/www/setupPage.html b/src/www/setupPage.html index 7e8e5d4..7a97d57 100644 --- a/src/www/setupPage.html +++ b/src/www/setupPage.html @@ -218,6 +218,14 @@

BLLED LED Settings

size='3'>
+ +
+ + Control Chamber Light +
From fce024a4f3b77bb2258fb8b13d5624997557bb9c Mon Sep 17 00:00:00 2001 From: SoftWareCrash Date: Fri, 20 Jun 2025 16:18:27 +0200 Subject: [PATCH 24/34] add doc --- docs/manual.md | 147 +++++++++++-- docs/manual_old.md | 537 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 664 insertions(+), 20 deletions(-) create mode 100644 docs/manual_old.md diff --git a/docs/manual.md b/docs/manual.md index c61fa29..3ebee72 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -1,36 +1,143 @@ -### đŸ”Ļ Control Chamber Light -When enabled, the BLLED Controller will automatically control the printer's internal chamber light via MQTT: +# 📘 BLLED Controller Manual -- ✅ Turns the chamber light **on** when a print starts -- ❌ Turns it **off** after the print finishes (based on timeout or door interaction) -- 🔁 Toggles the chamber light together with the LEDs when using the **door double-close gesture** +This document describes all configuration options and web interfaces provided by the BLLED firmware. -> This feature requires a working MQTT connection to your Bambu printer. -> It will not interfere with manual light control or other automations. +--- + +## âš™ī¸ Setup Page + +This is the main configuration page of the controller. + +### 🔆 Brightness +**ID:** `brightnessslider` +Adjusts the global brightness of the LED output (0–100%). + +### đŸ§Ē Maintenance Mode +**ID:** `maintMode` +Keeps LEDs permanently on (white), overrides other states. + +### 🌈 RGB Cycle Mode +**ID:** `discoMode` +Cycles through colors continuously for timelapse or decoration. + +### 🔁 Replicate State +**ID:** `replicateLedState` +Copies the printer’s internal chamber light status to the LEDs. + +#### Running Color Parameters +- `runningRGB`, `runningWW`, `runningCW` + +### đŸ§Ē Color Test Mode +**ID:** `showtestcolor` +Forces LEDs to show test color values. + +#### Test Color Parameters +- `testRGB`, `testWW`, `testCW` + +### đŸ“ļ WiFi Strength via LEDs +**ID:** `debugwifi` +Displays signal strength using LED colors. + +### đŸŽŦ Finish Indication +**ID:** `finishIndication` +Shows a color when print completes. + +#### Finish Color & Exit Behavior +- `finishColor`, `finishWW`, `finishCW` +- `finishEndDoor`, `finishEndTimer`, `finishTimerMins` + +### 🔕 Inactivity Timeout +**ID:** `inactivityEnabled` +Turns off LEDs after period of inactivity. + +- `inactivityMins`: Timeout duration + +### đŸ”Ļ Control Chamber Light (via MQTT) +**ID:** `controlChamberLight` +Synchronizes printer’s internal light with LED behavior. + +### đŸ–¨ī¸ Printer Type: P1 Compatibility +**ID:** `p1Printer` +Adjusts logic for P1 printers (no door sensor). + +### 🔧 Door Switch Support +**ID:** `doorSwitch` +Enables toggling LEDs via door open/close gesture. + +### đŸ› ī¸ Stage-Specific LED Colors +Assign LED colors to internal printer stages: +- `stage1RGB`, `stage8RGB`, `stage9RGB`, etc. +### ❗ Error Detection +**ID:** `errorDetection` +Uses LED colors to signal HMS or print errors. -### 💾 Backup & Restore Configuration +### 🎨 Custom Error Colors +- `wifiRGB`, `pauseRGB`, `firstlayerRGB`, etc. -Use these options to save or restore your current BLLED configuration: +### đŸšĢ Ignore HMS Codes +**ID:** `hmsIgnoreList` +List HMS codes (one per line) to suppress. -- ✅ **Backup**: Downloads the current configuration (`blledconfig.json`) to your computer -- 🔁 **Restore**: Uploads a previously saved configuration to restore all LED and printer settings -- 🔒 Includes printer IP, access code, and all LED behaviors +### 🐞 Debug Options +- `debuging`, `debugingchange`, `mqttdebug` -> Useful for transferring settings between devices or keeping a safety copy before updates. +### 🧭 Navigation +| Page | URL | +|------------------|--------------------| +| WiFi Setup | `/wifi` | +| Firmware Update | `/fwupdate` | +| Backup & Restore | `/backuprestore` | +| Web Log Console | `/webserial` | --- -### â™ģī¸ Factory Reset +## 📡 WiFi & Printer Setup (`/wifi`) -Performs a full reset of the BLLED controller: +Configure WiFi and printer link: -- ❌ Deletes all saved configuration and WiFi credentials from internal storage -- 🔄 Automatically restarts the device into Access Point (setup) mode -- 🌐 You’ll need to reconnect and reconfigure via the setup page +- `ssid`, `password`: WiFi credentials +- `printerIP`, `printerSerial`, `accessCode`: Bambu printer link +- `username`, `userpassword`: WebUI access login +- `Test Printer Connection` button -**How to trigger:** -Open your browser and navigate to: http://[device-ip]/factoryreset +--- + +## 💾 Backup & Restore (`/backuprestore`) + +- **Backup** → Download current `blledconfig.json` +- **Restore** → Upload config and restart device + +--- + +## 🔧 Firmware Update (`/fwupdate`) + +Upload a `.bin` firmware file. +Device reboots automatically. + +--- + +## đŸ–Ĩī¸ Web Serial Console (`/webserial`) +Live view of serial log messages. + +- Log area with auto-scroll +- Buttons: Clear, Copy, Pause +- Command input + +--- + +## â™ģī¸ Factory Reset + +Triggers full reset via: + +``` +http://[device-ip]/factoryreset +``` + +- Deletes all config and WiFi credentials +- Reboots into AP mode + +--- diff --git a/docs/manual_old.md b/docs/manual_old.md new file mode 100644 index 0000000..a09206e --- /dev/null +++ b/docs/manual_old.md @@ -0,0 +1,537 @@ +## âš™ī¸ BLLED Web Setup – Configuration Guide + +This document describes each setting available in the BLLED Controller setup interface. + +--- + +### 🔆 Brightness + +**ID:** `brightnessslider` +**Type:** Range (0–100) + +Adjusts the global brightness level of the LED output. +Value is in percent. + +- `0` → LEDs off +- `100` → full brightness (default: `100`) + +--- + +### đŸ§Ē Maintenance Mode + +**ID:** `maintMode` +**Type:** Checkbox +**Group:** `LEDBehavior` + +When enabled, LEDs stay **permanently on** in white color, regardless of printer state or WiFi/MQTT connection. + +- Always on (white) +- Overrides all other LED modes + +--- + +### 🌈 RGB Cycle Mode + +**ID:** `discoMode` +**Type:** Checkbox +**Group:** `LEDBehavior` + +Activates a continuous RGB color transition cycle for decorative purposes. + +- LED color cycles smoothly through red/green/blue +- Used for visual effects or time-lapse printing + +--- + +### 🔁 Replicate State + +**ID:** `replicateLedState` +**Type:** Checkbox +**Group:** `LEDBehavior` + +Replicates the printer’s internal **chamber light state** on the external LEDs. + +- When the printer turns its own light on/off, BLLED will follow +- Must be connected via MQTT + +#### 🔧 Running Color + +- `runningRGB`: LED color (HEX) +- `runningWW`: Warm white value (0–255) +- `runningCW`: Cold white value (0–255) + +These are used while the replicate mode is active and printer light is on. + +--- + +MÃļchtest du, dass ich weitermache mit: +- đŸ§Ē Test Color Mode +- đŸ“ļ Wifi Strength Display +- đŸŽŦ Finish Indication + +### đŸ§Ē Color Test Mode + +**ID:** `showtestcolor` +**Type:** Checkbox +**Group:** `LEDBehavior` + +Forces the LEDs to show a fixed test color at all times, regardless of printer state. +Useful for hardware tests and verifying PWM color output. + +#### 🔧 Test Color Parameters + +- `testRGB`: HEX color value (e.g., `#3F3CFB`) +- `testWW`: Warm white value (0–255) +- `testCW`: Cold white value (0–255) + +--- + +### đŸ“ļ Show WiFi Strength via LEDs + +**ID:** `debugwifi` +**Type:** Checkbox +**Group:** `LEDBehavior` + +LEDs display WiFi signal strength as color: + +- Green: excellent signal +- Yellow/orange: medium +- Red: poor signal + +This helps determine ESP placement for optimal reception. + +--- + +### đŸŽŦ Finish Indication + +**ID:** `finishIndication` +**Type:** Checkbox + +When a print completes, LEDs change to a dedicated **"Finish" color** for visual feedback. + +#### 🔧 Finish Color Parameters + +- `finishColor`: HEX color (e.g., green) +- `finishWW`: Warm white level +- `finishCW`: Cold white level + +#### ⏱ Finish Exit Behavior + +You can configure how and when to leave the "finished" state: + +--- + +### đŸšĒ Exit after Door Action + +**ID:** `finishEndDoor` +**Type:** Checkbox +**Group:** `finishOption` + +Leaves the finish state after the door is opened and closed once (or vice versa). + +--- + +### â˛ī¸ Exit after Timeout + +**ID:** `finishEndTimer` +**Type:** Checkbox +**Group:** `finishOption` + +Leaves the finish state after a user-defined number of minutes. + +- `finishTimerMins`: Duration in minutes (e.g., `1` = 1 min) + +### 🔕 Inactivity Timeout + +**ID:** `inactivityEnabled` +**Type:** Checkbox + +Automatically turns off the LEDs after a period of printer inactivity. + +#### 🔧 Timeout Duration + +- `inactivityMins`: Number of minutes without activity before LEDs turn off + *(e.g., `30` = 30 minutes)* + +If the door is opened or a new print starts, the LEDs turn back on automatically. + +--- + +### đŸ”Ļ Control Chamber Light + +**ID:** `controlChamberLight` +**Type:** Checkbox + +When enabled, the BLLED controller will also send MQTT commands to toggle the printer's internal **chamber light** in sync with: + +- đŸšĒ Door-based LED toggling (on/off) +- ✅ Print start → turns chamber light on +- ⏱ Print finish → turns chamber light off after timeout or door interaction + +> Requires an active MQTT connection to your Bambu printer. + +--- + +### đŸ–¨ī¸ Printer Type: P1 Compatibility + +**ID:** `p1Printer` +**Type:** Checkbox +**Group:** `PrinterOptions` + +If checked, adjusts behavior for P1 printers: + +- Disables door switch-related features (P1 has no door sensor) +- Automatically sets all LIDAR-related stage colors to full white (255/255) + +--- + +### 🔧 Door Switch Support + +**ID:** `doorSwitch` +**Type:** Checkbox +**Group:** `PrinterOptions` + +Enable this if your printer has a door sensor and you want to use: + +- Double-close gesture to toggle LEDs +- Finish indication reset by door interaction + +> Automatically disabled when `p1Printer` is active. + +--- + +### đŸ› ī¸ Stage-Specific LED Colors + +For advanced customization, you can assign LED colors to specific printer stages: + +- `stage14RGB`, `stage14WW`, `stage14CW` → Cleaning Nozzle +- `stage1RGB`, `stage1WW`, `stage1CW` → Bed Leveling +- `stage8RGB`, `stage8WW`, `stage8CW` → Calibrating Extrusion +- `stage9RGB`, `stage9WW`, `stage9CW` → Scanning Bed Surface +- `stage10RGB`, `stage10WW`, `stage10CW` → First Layer Inspection + +Default values are OFF or white depending on printer type. + +### ❗ Error Detection + +**ID:** `errorDetection` +**Type:** Checkbox +**Group:** `PrinterOptions` + +When enabled, BLLED reacts to known printer errors or HMS codes by switching to predefined **alert colors**. + +--- + +### 🎨 Custom Error Colors + +You can assign LED colors for specific error conditions: + +| Condition | ID Prefix | Description | +|------------------------------|----------------|--------------------------------------------| +| WiFi Scan / Setup | `wifiRGB` | Orange by default | +| Pause (User or Gcode) | `pauseRGB` | Blue | +| First Layer Error | `firstlayerRGB`| Blue | +| Nozzle Clog | `nozzleclogRGB`| Blue | +| HMS Serious Severity | `hmsSeriousRGB`| Red | +| HMS Fatal Severity | `hmsFatalRGB` | Red | +| Filament Runout | `filamentRunoutRGB` | Red | +| Front Cover Removed | `frontCoverRGB`| Red | +| Nozzle Temperature Fail | `nozzleTempRGB`| Red | +| Bed Temperature Fail | `bedTempRGB` | Red | + +Each has associated warm/cold white (`WW`/`CW`) sliders to fine-tune tone and intensity. + +--- + +### đŸšĢ Ignore Specific HMS Codes + +**ID:** `hmsIgnoreList` +**Type:** Textarea (multiline) + +Enter one or more HMS codes (one per line or comma-separated) to suppress LED error response for those codes. + +Example: +HMS_0300_1200_0002_0001 +HMS_0700_2000_0003_0001 + + +--- + +### 🐞 Debug Options + +These options help track behavior for diagnostics: + +| ID | Description | +|------------------|-----------------------------------------------| +| `debuging` | Global debug log output | +| `debugingchange` | Logs only when a value or state changes | +| `mqttdebug` | Logs all MQTT messages to WebSerial/Console | + +--- + +### 🧭 Navigation Buttons + +Located at the bottom of the config page: + +| Button | Target Page | Description | +|---------------------|------------------------|------------------------------------------| +| **WiFi & Printer Setup** | `/wifi` | Configure network and printer credentials | +| **Firmware Update** | `/fwupdate` | Upload new firmware | +| **Backup & Restore** | `/backuprestore` | Save or restore full configuration | +| **Web Serial Log** | `/webserial` | Open debug log console | + + + + + + +## 💾 Backup & Restore Configuration + +Access this page at: http://[device-ip]/backuprestore + +Allows you to download or upload the full BLLED configuration (`blledconfig.json`). + +--- + +### đŸ“Ĩ Backup Current Config + +**Button Label:** `Download Config File` +**Action:** Initiates download of the current `blledconfig.json` file from internal storage. + +- Includes: WiFi, printer IP, serial number, LED settings, HMS ignores, etc. +- Format: JSON file, pretty-formatted + +--- + +### 📤 Restore Config File + +**Form Upload (Drag & Drop or File Picker)** +**Action URL:** `/configrestore` +**Method:** POST + +Uploads a `blledconfig.json` backup file and replaces the current configuration. + +- âš ī¸ Device will **restart automatically** after upload +- File is validated for structure and required fields +- No merge – existing settings will be fully replaced + +--- + +## 📡 WiFi & Printer Setup + +Access this page at: http://[device-ip]/wifi + + +Use this page to configure the device’s WiFi connection and printer link. + +--- + +### đŸ“ļ WiFi Network + +#### đŸ“Ĩ SSID + +**ID:** `ssid` +**Type:** Text (required) +**Description:** +Name of the WiFi network the device should connect to. + +#### 🔒 Password + +**ID:** `password` +**Type:** Password (required) +**Description:** +WiFi password. Will be stored encrypted in the local config. + +> You can view available networks via the 🔍 Scan button. + +--- + +### đŸ–¨ī¸ Printer Connection + +#### 🌐 Printer IP + +**ID:** `printerIP` +**Type:** Text +**Placeholder:** `e.g. 192.168.1.100` +**Description:** +IP address of the Bambu printer to receive MQTT status from. Must be reachable on the local network. + +#### đŸ”ĸ Serial Number + +**ID:** `printerSerial` +**Type:** Text +**Placeholder:** `e.g. BL123456789` +**Description:** +The unique serial number (USN) of your printer, used in MQTT topic handling. + +#### 🔑 Access Code + +**ID:** `accessCode` +**Type:** Text +**Placeholder:** `e.g. Access123` +**Description:** +Used for MQTT authentication with your printer. Obtain this from the Bambu app or device. + +--- + +### 👤 Web Login (Optional) + +#### đŸ‘Ĩ Username + +**ID:** `username` +**Type:** Text +Default is blank. If set, it will enable HTTP Basic Auth for accessing the web interface. + +#### 🔑 Password + +**ID:** `userpassword` +**Type:** Password +Used with the above username for securing access to all pages. + +--- + +### đŸ§Ē Test Connection + +Button: `Test Printer Connection` +Tests MQTT reachability of the printer with the current IP/serial. + +--- + +## 🔧 Firmware Update + +Access this page at: http://[device-ip]/fwupdate + + +Allows you to upload and install a new firmware binary file (`.bin`) directly to the controller. + +--- + +### 📤 Firmware Upload + +#### 📄 File Input + +**Type:** File upload +**Accepted File:** `.bin` (firmware binary) +**Form Target:** `/update` (POST) + +- Uploads a new firmware image to flash memory +- File is verified and written immediately +- Progress and status are displayed below + +> âš ī¸ The device will reboot automatically after a successful update. + +--- + +### ⏚ Cancel Button + +Cancels the upload process if not yet started. + +--- + +### 💡 Tip + +Ensure that your binary is built for the correct chip (e.g., ESP32) and compatible with the current hardware revision. + + +## đŸ–Ĩī¸ Web Serial Debug Log + +Access this page at: http://[device-ip]/webserial + + +This live interface displays system logs and debug messages from the controller in real time – without using a physical USB connection. + +--- + +### đŸĒĩ Log Output Console + +**Element:** `textarea` (read-only) +**Function:** Displays all serial output from the controller, including: + +- MQTT messages +- LED state changes +- Door sensor triggers +- WiFi and printer status +- HMS error parsing results + +Output scrolls live as messages are received. + +--- + +### 🔧 Controls + +| Button | Function | +|-----------------------|------------------------------------------| +| `Clear Console` | Clears the current log view | +| `Copy` | Copies all visible log contents | +| `Pause Log` | Temporarily pauses real-time updates | +| `Send Command` (input + button) | Sends a command string to the controller via WebSerial (if supported) | + +> Useful for debugging MQTT, LEDs, and print events in real time. + +--- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +### đŸ”Ļ Control Chamber Light + +When enabled, the BLLED Controller will automatically control the printer's internal chamber light via MQTT: + +- ✅ Turns the chamber light **on** when a print starts +- ❌ Turns it **off** after the print finishes (based on timeout or door interaction) +- 🔁 Toggles the chamber light together with the LEDs when using the **door double-close gesture** + +> This feature requires a working MQTT connection to your Bambu printer. +> It will not interfere with manual light control or other automations. + + +### 💾 Backup & Restore Configuration + +Use these options to save or restore your current BLLED configuration: + +- ✅ **Backup**: Downloads the current configuration (`blledconfig.json`) to your computer +- 🔁 **Restore**: Uploads a previously saved configuration to restore all LED and printer settings +- 🔒 Includes printer IP, access code, and all LED behaviors + +> Useful for transferring settings between devices or keeping a safety copy before updates. + +--- + +### â™ģī¸ Factory Reset + +Performs a full reset of the BLLED controller: + +- ❌ Deletes all saved configuration and WiFi credentials from internal storage +- 🔄 Automatically restarts the device into Access Point (setup) mode +- 🌐 You’ll need to reconnect and reconfigure via the setup page + +**How to trigger:** +Open your browser and navigate to: http://[device-ip]/factoryreset + + From c35b433901c45ffc803a1e991b6f6689006e3baa Mon Sep 17 00:00:00 2001 From: SoftWareCrash Date: Fri, 20 Jun 2025 16:19:48 +0200 Subject: [PATCH 25/34] correct manual --- docs/manual.md | 526 ++++++++++++++++++++++++++++++++++++++------ docs/manual_old.md | 537 --------------------------------------------- 2 files changed, 460 insertions(+), 603 deletions(-) delete mode 100644 docs/manual_old.md diff --git a/docs/manual.md b/docs/manual.md index 3ebee72..a09206e 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -1,143 +1,537 @@ +## âš™ī¸ BLLED Web Setup – Configuration Guide -# 📘 BLLED Controller Manual - -This document describes all configuration options and web interfaces provided by the BLLED firmware. +This document describes each setting available in the BLLED Controller setup interface. --- -## âš™ī¸ Setup Page - -This is the main configuration page of the controller. - ### 🔆 Brightness + **ID:** `brightnessslider` -Adjusts the global brightness of the LED output (0–100%). +**Type:** Range (0–100) + +Adjusts the global brightness level of the LED output. +Value is in percent. + +- `0` → LEDs off +- `100` → full brightness (default: `100`) + +--- ### đŸ§Ē Maintenance Mode + **ID:** `maintMode` -Keeps LEDs permanently on (white), overrides other states. +**Type:** Checkbox +**Group:** `LEDBehavior` + +When enabled, LEDs stay **permanently on** in white color, regardless of printer state or WiFi/MQTT connection. + +- Always on (white) +- Overrides all other LED modes + +--- ### 🌈 RGB Cycle Mode + **ID:** `discoMode` -Cycles through colors continuously for timelapse or decoration. +**Type:** Checkbox +**Group:** `LEDBehavior` + +Activates a continuous RGB color transition cycle for decorative purposes. + +- LED color cycles smoothly through red/green/blue +- Used for visual effects or time-lapse printing + +--- ### 🔁 Replicate State + **ID:** `replicateLedState` -Copies the printer’s internal chamber light status to the LEDs. +**Type:** Checkbox +**Group:** `LEDBehavior` + +Replicates the printer’s internal **chamber light state** on the external LEDs. + +- When the printer turns its own light on/off, BLLED will follow +- Must be connected via MQTT -#### Running Color Parameters -- `runningRGB`, `runningWW`, `runningCW` +#### 🔧 Running Color + +- `runningRGB`: LED color (HEX) +- `runningWW`: Warm white value (0–255) +- `runningCW`: Cold white value (0–255) + +These are used while the replicate mode is active and printer light is on. + +--- + +MÃļchtest du, dass ich weitermache mit: +- đŸ§Ē Test Color Mode +- đŸ“ļ Wifi Strength Display +- đŸŽŦ Finish Indication ### đŸ§Ē Color Test Mode + **ID:** `showtestcolor` -Forces LEDs to show test color values. +**Type:** Checkbox +**Group:** `LEDBehavior` -#### Test Color Parameters -- `testRGB`, `testWW`, `testCW` +Forces the LEDs to show a fixed test color at all times, regardless of printer state. +Useful for hardware tests and verifying PWM color output. + +#### 🔧 Test Color Parameters + +- `testRGB`: HEX color value (e.g., `#3F3CFB`) +- `testWW`: Warm white value (0–255) +- `testCW`: Cold white value (0–255) + +--- + +### đŸ“ļ Show WiFi Strength via LEDs -### đŸ“ļ WiFi Strength via LEDs **ID:** `debugwifi` -Displays signal strength using LED colors. +**Type:** Checkbox +**Group:** `LEDBehavior` + +LEDs display WiFi signal strength as color: + +- Green: excellent signal +- Yellow/orange: medium +- Red: poor signal + +This helps determine ESP placement for optimal reception. + +--- ### đŸŽŦ Finish Indication + **ID:** `finishIndication` -Shows a color when print completes. +**Type:** Checkbox + +When a print completes, LEDs change to a dedicated **"Finish" color** for visual feedback. + +#### 🔧 Finish Color Parameters + +- `finishColor`: HEX color (e.g., green) +- `finishWW`: Warm white level +- `finishCW`: Cold white level + +#### ⏱ Finish Exit Behavior + +You can configure how and when to leave the "finished" state: + +--- + +### đŸšĒ Exit after Door Action + +**ID:** `finishEndDoor` +**Type:** Checkbox +**Group:** `finishOption` + +Leaves the finish state after the door is opened and closed once (or vice versa). + +--- + +### â˛ī¸ Exit after Timeout + +**ID:** `finishEndTimer` +**Type:** Checkbox +**Group:** `finishOption` + +Leaves the finish state after a user-defined number of minutes. -#### Finish Color & Exit Behavior -- `finishColor`, `finishWW`, `finishCW` -- `finishEndDoor`, `finishEndTimer`, `finishTimerMins` +- `finishTimerMins`: Duration in minutes (e.g., `1` = 1 min) ### 🔕 Inactivity Timeout + **ID:** `inactivityEnabled` -Turns off LEDs after period of inactivity. +**Type:** Checkbox + +Automatically turns off the LEDs after a period of printer inactivity. + +#### 🔧 Timeout Duration + +- `inactivityMins`: Number of minutes without activity before LEDs turn off + *(e.g., `30` = 30 minutes)* + +If the door is opened or a new print starts, the LEDs turn back on automatically. + +--- -- `inactivityMins`: Timeout duration +### đŸ”Ļ Control Chamber Light -### đŸ”Ļ Control Chamber Light (via MQTT) **ID:** `controlChamberLight` -Synchronizes printer’s internal light with LED behavior. +**Type:** Checkbox + +When enabled, the BLLED controller will also send MQTT commands to toggle the printer's internal **chamber light** in sync with: + +- đŸšĒ Door-based LED toggling (on/off) +- ✅ Print start → turns chamber light on +- ⏱ Print finish → turns chamber light off after timeout or door interaction + +> Requires an active MQTT connection to your Bambu printer. + +--- ### đŸ–¨ī¸ Printer Type: P1 Compatibility + **ID:** `p1Printer` -Adjusts logic for P1 printers (no door sensor). +**Type:** Checkbox +**Group:** `PrinterOptions` + +If checked, adjusts behavior for P1 printers: + +- Disables door switch-related features (P1 has no door sensor) +- Automatically sets all LIDAR-related stage colors to full white (255/255) + +--- ### 🔧 Door Switch Support + **ID:** `doorSwitch` -Enables toggling LEDs via door open/close gesture. +**Type:** Checkbox +**Group:** `PrinterOptions` + +Enable this if your printer has a door sensor and you want to use: + +- Double-close gesture to toggle LEDs +- Finish indication reset by door interaction + +> Automatically disabled when `p1Printer` is active. + +--- ### đŸ› ī¸ Stage-Specific LED Colors -Assign LED colors to internal printer stages: -- `stage1RGB`, `stage8RGB`, `stage9RGB`, etc. + +For advanced customization, you can assign LED colors to specific printer stages: + +- `stage14RGB`, `stage14WW`, `stage14CW` → Cleaning Nozzle +- `stage1RGB`, `stage1WW`, `stage1CW` → Bed Leveling +- `stage8RGB`, `stage8WW`, `stage8CW` → Calibrating Extrusion +- `stage9RGB`, `stage9WW`, `stage9CW` → Scanning Bed Surface +- `stage10RGB`, `stage10WW`, `stage10CW` → First Layer Inspection + +Default values are OFF or white depending on printer type. ### ❗ Error Detection + **ID:** `errorDetection` -Uses LED colors to signal HMS or print errors. +**Type:** Checkbox +**Group:** `PrinterOptions` + +When enabled, BLLED reacts to known printer errors or HMS codes by switching to predefined **alert colors**. + +--- ### 🎨 Custom Error Colors -- `wifiRGB`, `pauseRGB`, `firstlayerRGB`, etc. -### đŸšĢ Ignore HMS Codes +You can assign LED colors for specific error conditions: + +| Condition | ID Prefix | Description | +|------------------------------|----------------|--------------------------------------------| +| WiFi Scan / Setup | `wifiRGB` | Orange by default | +| Pause (User or Gcode) | `pauseRGB` | Blue | +| First Layer Error | `firstlayerRGB`| Blue | +| Nozzle Clog | `nozzleclogRGB`| Blue | +| HMS Serious Severity | `hmsSeriousRGB`| Red | +| HMS Fatal Severity | `hmsFatalRGB` | Red | +| Filament Runout | `filamentRunoutRGB` | Red | +| Front Cover Removed | `frontCoverRGB`| Red | +| Nozzle Temperature Fail | `nozzleTempRGB`| Red | +| Bed Temperature Fail | `bedTempRGB` | Red | + +Each has associated warm/cold white (`WW`/`CW`) sliders to fine-tune tone and intensity. + +--- + +### đŸšĢ Ignore Specific HMS Codes + **ID:** `hmsIgnoreList` -List HMS codes (one per line) to suppress. +**Type:** Textarea (multiline) + +Enter one or more HMS codes (one per line or comma-separated) to suppress LED error response for those codes. + +Example: +HMS_0300_1200_0002_0001 +HMS_0700_2000_0003_0001 + + +--- ### 🐞 Debug Options -- `debuging`, `debugingchange`, `mqttdebug` -### 🧭 Navigation -| Page | URL | -|------------------|--------------------| -| WiFi Setup | `/wifi` | -| Firmware Update | `/fwupdate` | -| Backup & Restore | `/backuprestore` | -| Web Log Console | `/webserial` | +These options help track behavior for diagnostics: + +| ID | Description | +|------------------|-----------------------------------------------| +| `debuging` | Global debug log output | +| `debugingchange` | Logs only when a value or state changes | +| `mqttdebug` | Logs all MQTT messages to WebSerial/Console | --- -## 📡 WiFi & Printer Setup (`/wifi`) +### 🧭 Navigation Buttons + +Located at the bottom of the config page: + +| Button | Target Page | Description | +|---------------------|------------------------|------------------------------------------| +| **WiFi & Printer Setup** | `/wifi` | Configure network and printer credentials | +| **Firmware Update** | `/fwupdate` | Upload new firmware | +| **Backup & Restore** | `/backuprestore` | Save or restore full configuration | +| **Web Serial Log** | `/webserial` | Open debug log console | + + + -Configure WiFi and printer link: -- `ssid`, `password`: WiFi credentials -- `printerIP`, `printerSerial`, `accessCode`: Bambu printer link -- `username`, `userpassword`: WebUI access login -- `Test Printer Connection` button + +## 💾 Backup & Restore Configuration + +Access this page at: http://[device-ip]/backuprestore + +Allows you to download or upload the full BLLED configuration (`blledconfig.json`). --- -## 💾 Backup & Restore (`/backuprestore`) +### đŸ“Ĩ Backup Current Config -- **Backup** → Download current `blledconfig.json` -- **Restore** → Upload config and restart device +**Button Label:** `Download Config File` +**Action:** Initiates download of the current `blledconfig.json` file from internal storage. + +- Includes: WiFi, printer IP, serial number, LED settings, HMS ignores, etc. +- Format: JSON file, pretty-formatted --- -## 🔧 Firmware Update (`/fwupdate`) +### 📤 Restore Config File + +**Form Upload (Drag & Drop or File Picker)** +**Action URL:** `/configrestore` +**Method:** POST + +Uploads a `blledconfig.json` backup file and replaces the current configuration. -Upload a `.bin` firmware file. -Device reboots automatically. +- âš ī¸ Device will **restart automatically** after upload +- File is validated for structure and required fields +- No merge – existing settings will be fully replaced --- -## đŸ–Ĩī¸ Web Serial Console (`/webserial`) +## 📡 WiFi & Printer Setup -Live view of serial log messages. +Access this page at: http://[device-ip]/wifi -- Log area with auto-scroll -- Buttons: Clear, Copy, Pause -- Command input + +Use this page to configure the device’s WiFi connection and printer link. + +--- + +### đŸ“ļ WiFi Network + +#### đŸ“Ĩ SSID + +**ID:** `ssid` +**Type:** Text (required) +**Description:** +Name of the WiFi network the device should connect to. + +#### 🔒 Password + +**ID:** `password` +**Type:** Password (required) +**Description:** +WiFi password. Will be stored encrypted in the local config. + +> You can view available networks via the 🔍 Scan button. --- -## â™ģī¸ Factory Reset +### đŸ–¨ī¸ Printer Connection + +#### 🌐 Printer IP + +**ID:** `printerIP` +**Type:** Text +**Placeholder:** `e.g. 192.168.1.100` +**Description:** +IP address of the Bambu printer to receive MQTT status from. Must be reachable on the local network. -Triggers full reset via: +#### đŸ”ĸ Serial Number -``` -http://[device-ip]/factoryreset -``` +**ID:** `printerSerial` +**Type:** Text +**Placeholder:** `e.g. BL123456789` +**Description:** +The unique serial number (USN) of your printer, used in MQTT topic handling. -- Deletes all config and WiFi credentials -- Reboots into AP mode +#### 🔑 Access Code + +**ID:** `accessCode` +**Type:** Text +**Placeholder:** `e.g. Access123` +**Description:** +Used for MQTT authentication with your printer. Obtain this from the Bambu app or device. --- +### 👤 Web Login (Optional) + +#### đŸ‘Ĩ Username + +**ID:** `username` +**Type:** Text +Default is blank. If set, it will enable HTTP Basic Auth for accessing the web interface. + +#### 🔑 Password + +**ID:** `userpassword` +**Type:** Password +Used with the above username for securing access to all pages. + +--- + +### đŸ§Ē Test Connection + +Button: `Test Printer Connection` +Tests MQTT reachability of the printer with the current IP/serial. + +--- + +## 🔧 Firmware Update + +Access this page at: http://[device-ip]/fwupdate + + +Allows you to upload and install a new firmware binary file (`.bin`) directly to the controller. + +--- + +### 📤 Firmware Upload + +#### 📄 File Input + +**Type:** File upload +**Accepted File:** `.bin` (firmware binary) +**Form Target:** `/update` (POST) + +- Uploads a new firmware image to flash memory +- File is verified and written immediately +- Progress and status are displayed below + +> âš ī¸ The device will reboot automatically after a successful update. + +--- + +### ⏚ Cancel Button + +Cancels the upload process if not yet started. + +--- + +### 💡 Tip + +Ensure that your binary is built for the correct chip (e.g., ESP32) and compatible with the current hardware revision. + + +## đŸ–Ĩī¸ Web Serial Debug Log + +Access this page at: http://[device-ip]/webserial + + +This live interface displays system logs and debug messages from the controller in real time – without using a physical USB connection. + +--- + +### đŸĒĩ Log Output Console + +**Element:** `textarea` (read-only) +**Function:** Displays all serial output from the controller, including: + +- MQTT messages +- LED state changes +- Door sensor triggers +- WiFi and printer status +- HMS error parsing results + +Output scrolls live as messages are received. + +--- + +### 🔧 Controls + +| Button | Function | +|-----------------------|------------------------------------------| +| `Clear Console` | Clears the current log view | +| `Copy` | Copies all visible log contents | +| `Pause Log` | Temporarily pauses real-time updates | +| `Send Command` (input + button) | Sends a command string to the controller via WebSerial (if supported) | + +> Useful for debugging MQTT, LEDs, and print events in real time. + +--- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +### đŸ”Ļ Control Chamber Light + +When enabled, the BLLED Controller will automatically control the printer's internal chamber light via MQTT: + +- ✅ Turns the chamber light **on** when a print starts +- ❌ Turns it **off** after the print finishes (based on timeout or door interaction) +- 🔁 Toggles the chamber light together with the LEDs when using the **door double-close gesture** + +> This feature requires a working MQTT connection to your Bambu printer. +> It will not interfere with manual light control or other automations. + + +### 💾 Backup & Restore Configuration + +Use these options to save or restore your current BLLED configuration: + +- ✅ **Backup**: Downloads the current configuration (`blledconfig.json`) to your computer +- 🔁 **Restore**: Uploads a previously saved configuration to restore all LED and printer settings +- 🔒 Includes printer IP, access code, and all LED behaviors + +> Useful for transferring settings between devices or keeping a safety copy before updates. + +--- + +### â™ģī¸ Factory Reset + +Performs a full reset of the BLLED controller: + +- ❌ Deletes all saved configuration and WiFi credentials from internal storage +- 🔄 Automatically restarts the device into Access Point (setup) mode +- 🌐 You’ll need to reconnect and reconfigure via the setup page + +**How to trigger:** +Open your browser and navigate to: http://[device-ip]/factoryreset + + diff --git a/docs/manual_old.md b/docs/manual_old.md deleted file mode 100644 index a09206e..0000000 --- a/docs/manual_old.md +++ /dev/null @@ -1,537 +0,0 @@ -## âš™ī¸ BLLED Web Setup – Configuration Guide - -This document describes each setting available in the BLLED Controller setup interface. - ---- - -### 🔆 Brightness - -**ID:** `brightnessslider` -**Type:** Range (0–100) - -Adjusts the global brightness level of the LED output. -Value is in percent. - -- `0` → LEDs off -- `100` → full brightness (default: `100`) - ---- - -### đŸ§Ē Maintenance Mode - -**ID:** `maintMode` -**Type:** Checkbox -**Group:** `LEDBehavior` - -When enabled, LEDs stay **permanently on** in white color, regardless of printer state or WiFi/MQTT connection. - -- Always on (white) -- Overrides all other LED modes - ---- - -### 🌈 RGB Cycle Mode - -**ID:** `discoMode` -**Type:** Checkbox -**Group:** `LEDBehavior` - -Activates a continuous RGB color transition cycle for decorative purposes. - -- LED color cycles smoothly through red/green/blue -- Used for visual effects or time-lapse printing - ---- - -### 🔁 Replicate State - -**ID:** `replicateLedState` -**Type:** Checkbox -**Group:** `LEDBehavior` - -Replicates the printer’s internal **chamber light state** on the external LEDs. - -- When the printer turns its own light on/off, BLLED will follow -- Must be connected via MQTT - -#### 🔧 Running Color - -- `runningRGB`: LED color (HEX) -- `runningWW`: Warm white value (0–255) -- `runningCW`: Cold white value (0–255) - -These are used while the replicate mode is active and printer light is on. - ---- - -MÃļchtest du, dass ich weitermache mit: -- đŸ§Ē Test Color Mode -- đŸ“ļ Wifi Strength Display -- đŸŽŦ Finish Indication - -### đŸ§Ē Color Test Mode - -**ID:** `showtestcolor` -**Type:** Checkbox -**Group:** `LEDBehavior` - -Forces the LEDs to show a fixed test color at all times, regardless of printer state. -Useful for hardware tests and verifying PWM color output. - -#### 🔧 Test Color Parameters - -- `testRGB`: HEX color value (e.g., `#3F3CFB`) -- `testWW`: Warm white value (0–255) -- `testCW`: Cold white value (0–255) - ---- - -### đŸ“ļ Show WiFi Strength via LEDs - -**ID:** `debugwifi` -**Type:** Checkbox -**Group:** `LEDBehavior` - -LEDs display WiFi signal strength as color: - -- Green: excellent signal -- Yellow/orange: medium -- Red: poor signal - -This helps determine ESP placement for optimal reception. - ---- - -### đŸŽŦ Finish Indication - -**ID:** `finishIndication` -**Type:** Checkbox - -When a print completes, LEDs change to a dedicated **"Finish" color** for visual feedback. - -#### 🔧 Finish Color Parameters - -- `finishColor`: HEX color (e.g., green) -- `finishWW`: Warm white level -- `finishCW`: Cold white level - -#### ⏱ Finish Exit Behavior - -You can configure how and when to leave the "finished" state: - ---- - -### đŸšĒ Exit after Door Action - -**ID:** `finishEndDoor` -**Type:** Checkbox -**Group:** `finishOption` - -Leaves the finish state after the door is opened and closed once (or vice versa). - ---- - -### â˛ī¸ Exit after Timeout - -**ID:** `finishEndTimer` -**Type:** Checkbox -**Group:** `finishOption` - -Leaves the finish state after a user-defined number of minutes. - -- `finishTimerMins`: Duration in minutes (e.g., `1` = 1 min) - -### 🔕 Inactivity Timeout - -**ID:** `inactivityEnabled` -**Type:** Checkbox - -Automatically turns off the LEDs after a period of printer inactivity. - -#### 🔧 Timeout Duration - -- `inactivityMins`: Number of minutes without activity before LEDs turn off - *(e.g., `30` = 30 minutes)* - -If the door is opened or a new print starts, the LEDs turn back on automatically. - ---- - -### đŸ”Ļ Control Chamber Light - -**ID:** `controlChamberLight` -**Type:** Checkbox - -When enabled, the BLLED controller will also send MQTT commands to toggle the printer's internal **chamber light** in sync with: - -- đŸšĒ Door-based LED toggling (on/off) -- ✅ Print start → turns chamber light on -- ⏱ Print finish → turns chamber light off after timeout or door interaction - -> Requires an active MQTT connection to your Bambu printer. - ---- - -### đŸ–¨ī¸ Printer Type: P1 Compatibility - -**ID:** `p1Printer` -**Type:** Checkbox -**Group:** `PrinterOptions` - -If checked, adjusts behavior for P1 printers: - -- Disables door switch-related features (P1 has no door sensor) -- Automatically sets all LIDAR-related stage colors to full white (255/255) - ---- - -### 🔧 Door Switch Support - -**ID:** `doorSwitch` -**Type:** Checkbox -**Group:** `PrinterOptions` - -Enable this if your printer has a door sensor and you want to use: - -- Double-close gesture to toggle LEDs -- Finish indication reset by door interaction - -> Automatically disabled when `p1Printer` is active. - ---- - -### đŸ› ī¸ Stage-Specific LED Colors - -For advanced customization, you can assign LED colors to specific printer stages: - -- `stage14RGB`, `stage14WW`, `stage14CW` → Cleaning Nozzle -- `stage1RGB`, `stage1WW`, `stage1CW` → Bed Leveling -- `stage8RGB`, `stage8WW`, `stage8CW` → Calibrating Extrusion -- `stage9RGB`, `stage9WW`, `stage9CW` → Scanning Bed Surface -- `stage10RGB`, `stage10WW`, `stage10CW` → First Layer Inspection - -Default values are OFF or white depending on printer type. - -### ❗ Error Detection - -**ID:** `errorDetection` -**Type:** Checkbox -**Group:** `PrinterOptions` - -When enabled, BLLED reacts to known printer errors or HMS codes by switching to predefined **alert colors**. - ---- - -### 🎨 Custom Error Colors - -You can assign LED colors for specific error conditions: - -| Condition | ID Prefix | Description | -|------------------------------|----------------|--------------------------------------------| -| WiFi Scan / Setup | `wifiRGB` | Orange by default | -| Pause (User or Gcode) | `pauseRGB` | Blue | -| First Layer Error | `firstlayerRGB`| Blue | -| Nozzle Clog | `nozzleclogRGB`| Blue | -| HMS Serious Severity | `hmsSeriousRGB`| Red | -| HMS Fatal Severity | `hmsFatalRGB` | Red | -| Filament Runout | `filamentRunoutRGB` | Red | -| Front Cover Removed | `frontCoverRGB`| Red | -| Nozzle Temperature Fail | `nozzleTempRGB`| Red | -| Bed Temperature Fail | `bedTempRGB` | Red | - -Each has associated warm/cold white (`WW`/`CW`) sliders to fine-tune tone and intensity. - ---- - -### đŸšĢ Ignore Specific HMS Codes - -**ID:** `hmsIgnoreList` -**Type:** Textarea (multiline) - -Enter one or more HMS codes (one per line or comma-separated) to suppress LED error response for those codes. - -Example: -HMS_0300_1200_0002_0001 -HMS_0700_2000_0003_0001 - - ---- - -### 🐞 Debug Options - -These options help track behavior for diagnostics: - -| ID | Description | -|------------------|-----------------------------------------------| -| `debuging` | Global debug log output | -| `debugingchange` | Logs only when a value or state changes | -| `mqttdebug` | Logs all MQTT messages to WebSerial/Console | - ---- - -### 🧭 Navigation Buttons - -Located at the bottom of the config page: - -| Button | Target Page | Description | -|---------------------|------------------------|------------------------------------------| -| **WiFi & Printer Setup** | `/wifi` | Configure network and printer credentials | -| **Firmware Update** | `/fwupdate` | Upload new firmware | -| **Backup & Restore** | `/backuprestore` | Save or restore full configuration | -| **Web Serial Log** | `/webserial` | Open debug log console | - - - - - - -## 💾 Backup & Restore Configuration - -Access this page at: http://[device-ip]/backuprestore - -Allows you to download or upload the full BLLED configuration (`blledconfig.json`). - ---- - -### đŸ“Ĩ Backup Current Config - -**Button Label:** `Download Config File` -**Action:** Initiates download of the current `blledconfig.json` file from internal storage. - -- Includes: WiFi, printer IP, serial number, LED settings, HMS ignores, etc. -- Format: JSON file, pretty-formatted - ---- - -### 📤 Restore Config File - -**Form Upload (Drag & Drop or File Picker)** -**Action URL:** `/configrestore` -**Method:** POST - -Uploads a `blledconfig.json` backup file and replaces the current configuration. - -- âš ī¸ Device will **restart automatically** after upload -- File is validated for structure and required fields -- No merge – existing settings will be fully replaced - ---- - -## 📡 WiFi & Printer Setup - -Access this page at: http://[device-ip]/wifi - - -Use this page to configure the device’s WiFi connection and printer link. - ---- - -### đŸ“ļ WiFi Network - -#### đŸ“Ĩ SSID - -**ID:** `ssid` -**Type:** Text (required) -**Description:** -Name of the WiFi network the device should connect to. - -#### 🔒 Password - -**ID:** `password` -**Type:** Password (required) -**Description:** -WiFi password. Will be stored encrypted in the local config. - -> You can view available networks via the 🔍 Scan button. - ---- - -### đŸ–¨ī¸ Printer Connection - -#### 🌐 Printer IP - -**ID:** `printerIP` -**Type:** Text -**Placeholder:** `e.g. 192.168.1.100` -**Description:** -IP address of the Bambu printer to receive MQTT status from. Must be reachable on the local network. - -#### đŸ”ĸ Serial Number - -**ID:** `printerSerial` -**Type:** Text -**Placeholder:** `e.g. BL123456789` -**Description:** -The unique serial number (USN) of your printer, used in MQTT topic handling. - -#### 🔑 Access Code - -**ID:** `accessCode` -**Type:** Text -**Placeholder:** `e.g. Access123` -**Description:** -Used for MQTT authentication with your printer. Obtain this from the Bambu app or device. - ---- - -### 👤 Web Login (Optional) - -#### đŸ‘Ĩ Username - -**ID:** `username` -**Type:** Text -Default is blank. If set, it will enable HTTP Basic Auth for accessing the web interface. - -#### 🔑 Password - -**ID:** `userpassword` -**Type:** Password -Used with the above username for securing access to all pages. - ---- - -### đŸ§Ē Test Connection - -Button: `Test Printer Connection` -Tests MQTT reachability of the printer with the current IP/serial. - ---- - -## 🔧 Firmware Update - -Access this page at: http://[device-ip]/fwupdate - - -Allows you to upload and install a new firmware binary file (`.bin`) directly to the controller. - ---- - -### 📤 Firmware Upload - -#### 📄 File Input - -**Type:** File upload -**Accepted File:** `.bin` (firmware binary) -**Form Target:** `/update` (POST) - -- Uploads a new firmware image to flash memory -- File is verified and written immediately -- Progress and status are displayed below - -> âš ī¸ The device will reboot automatically after a successful update. - ---- - -### ⏚ Cancel Button - -Cancels the upload process if not yet started. - ---- - -### 💡 Tip - -Ensure that your binary is built for the correct chip (e.g., ESP32) and compatible with the current hardware revision. - - -## đŸ–Ĩī¸ Web Serial Debug Log - -Access this page at: http://[device-ip]/webserial - - -This live interface displays system logs and debug messages from the controller in real time – without using a physical USB connection. - ---- - -### đŸĒĩ Log Output Console - -**Element:** `textarea` (read-only) -**Function:** Displays all serial output from the controller, including: - -- MQTT messages -- LED state changes -- Door sensor triggers -- WiFi and printer status -- HMS error parsing results - -Output scrolls live as messages are received. - ---- - -### 🔧 Controls - -| Button | Function | -|-----------------------|------------------------------------------| -| `Clear Console` | Clears the current log view | -| `Copy` | Copies all visible log contents | -| `Pause Log` | Temporarily pauses real-time updates | -| `Send Command` (input + button) | Sends a command string to the controller via WebSerial (if supported) | - -> Useful for debugging MQTT, LEDs, and print events in real time. - ---- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -### đŸ”Ļ Control Chamber Light - -When enabled, the BLLED Controller will automatically control the printer's internal chamber light via MQTT: - -- ✅ Turns the chamber light **on** when a print starts -- ❌ Turns it **off** after the print finishes (based on timeout or door interaction) -- 🔁 Toggles the chamber light together with the LEDs when using the **door double-close gesture** - -> This feature requires a working MQTT connection to your Bambu printer. -> It will not interfere with manual light control or other automations. - - -### 💾 Backup & Restore Configuration - -Use these options to save or restore your current BLLED configuration: - -- ✅ **Backup**: Downloads the current configuration (`blledconfig.json`) to your computer -- 🔁 **Restore**: Uploads a previously saved configuration to restore all LED and printer settings -- 🔒 Includes printer IP, access code, and all LED behaviors - -> Useful for transferring settings between devices or keeping a safety copy before updates. - ---- - -### â™ģī¸ Factory Reset - -Performs a full reset of the BLLED controller: - -- ❌ Deletes all saved configuration and WiFi credentials from internal storage -- 🔄 Automatically restarts the device into Access Point (setup) mode -- 🌐 You’ll need to reconnect and reconfigure via the setup page - -**How to trigger:** -Open your browser and navigate to: http://[device-ip]/factoryreset - - From b0b586c5493e60c5c04f308ce052c8f9f50e1103 Mon Sep 17 00:00:00 2001 From: softwarecrash Date: Sat, 21 Jun 2025 10:39:55 +0200 Subject: [PATCH 26/34] fix chamber loght control --- platformio.ini | 2 +- src/blled/leds.h | 1 + src/blled/mqttmanager.h | 6 +----- src/www/setupPage.html | 1 + 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/platformio.ini b/platformio.ini index 67d703f..22f39ce 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,7 @@ [env:esp32dev] custom_project_name = BLLEDController custom_project_codename = Balder -custom_version = 2.2.0.nightly.200625.1 #BLLC_[Major].[Minor].[Patch] +custom_version = 2.2.0.nightly.210625.1 #BLLC_[Major].[Minor].[Patch] platform = espressif32 board = esp32dev framework = arduino diff --git a/src/blled/leds.h b/src/blled/leds.h index 49767d1..6382c16 100644 --- a/src/blled/leds.h +++ b/src/blled/leds.h @@ -617,6 +617,7 @@ void updateleds() if ((printerVariables.stage == -1 || printerVariables.stage == 255) && !((printerConfig.finishExit && printerVariables.waitingForDoor) || (printerConfig.finishExit == false && ((millis() - printerConfig.finishStartms) < printerConfig.finishTimeOut))) && (millis() - printerConfig.inactivityStartms) > printerConfig.inactivityTimeOut && printerConfig.isIdleOFFActive == false && printerConfig.inactivityEnabled) { tweenToColor(0, 0, 0, 0, 0); // OFF + controlChamberLight(false); // Turn off chamber light via MQTT printerConfig.isIdleOFFActive = true; if (printerConfig.debuging || printerConfig.debugingchange) { diff --git a/src/blled/mqttmanager.h b/src/blled/mqttmanager.h index 249638e..987749f 100644 --- a/src/blled/mqttmanager.h +++ b/src/blled/mqttmanager.h @@ -562,11 +562,7 @@ void mqttCallback(char *topic, byte *payload, unsigned int length) void controlChamberLight(bool on) { - static bool lastState = false; - if (lastState == on) - return; // Skip sending if state hasn't changed - lastState = on; - + LogSerial.printf("[DEBUG] controlChamberLight called with: %s\n", on ? "true" : "false"); if (!printerConfig.controlChamberLight) return; diff --git a/src/www/setupPage.html b/src/www/setupPage.html index 7a97d57..95a0fcb 100644 --- a/src/www/setupPage.html +++ b/src/www/setupPage.html @@ -794,6 +794,7 @@

Firmware version: ??.??.??

document.getElementById('finishTimerMins').value = configData.finishTimerMins || 10; document.getElementById('inactivityEnabled').checked = configData.inactivityEnabled || false; document.getElementById('inactivityMins').value = configData.inactivityMins || 30; + document.getElementById('controlChamberLight').checked = configData.controlChamberLight || false; document.getElementById('debuging').checked = configData.debuging || false; document.getElementById('debugingchange').checked = configData.debugingchange || false; document.getElementById('mqttdebug').checked = configData.mqttdebug || false; From de2406dae0dbb229cf572a01be8b2e2b6976ffb8 Mon Sep 17 00:00:00 2001 From: softwarecrash Date: Sat, 21 Jun 2025 10:48:23 +0200 Subject: [PATCH 27/34] correct something --- docs/manual.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/manual.md b/docs/manual.md index a09206e..9cefb46 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -64,11 +64,6 @@ These are used while the replicate mode is active and printer light is on. --- -MÃļchtest du, dass ich weitermache mit: -- đŸ§Ē Test Color Mode -- đŸ“ļ Wifi Strength Display -- đŸŽŦ Finish Indication - ### đŸ§Ē Color Test Mode **ID:** `showtestcolor` From 7c4c742a17f6200e386aa0b5b4d3c35423b9d15d Mon Sep 17 00:00:00 2001 From: softwarecrash Date: Sun, 22 Jun 2025 12:29:42 +0200 Subject: [PATCH 28/34] fix lost bssid fix chamberr light control --- platformio.ini | 2 +- src/blled/leds.h | 1 - src/blled/web-server.h | 18 +++++++++++------- src/www/wifiSetup.html | 22 +++++++++++++++++----- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/platformio.ini b/platformio.ini index 22f39ce..136de49 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,7 @@ [env:esp32dev] custom_project_name = BLLEDController custom_project_codename = Balder -custom_version = 2.2.0.nightly.210625.1 #BLLC_[Major].[Minor].[Patch] +custom_version = 2.2.0.nightly.220625.1 #BLLC_[Major].[Minor].[Patch] platform = espressif32 board = esp32dev framework = arduino diff --git a/src/blled/leds.h b/src/blled/leds.h index 6382c16..1d7172a 100644 --- a/src/blled/leds.h +++ b/src/blled/leds.h @@ -754,7 +754,6 @@ void ledsloop() printerConfig.inactivityStartms = millis(); printerConfig.isIdleOFFActive = false; updateleds(); - controlChamberLight(false); // Turn off chamber light via MQTT } if ((printerConfig.finish_check && printerConfig.finishindication && printerConfig.finishExit == false && ((millis() - printerConfig.finishStartms) > printerConfig.finishTimeOut))) diff --git a/src/blled/web-server.h b/src/blled/web-server.h index 29bd658..63f932f 100644 --- a/src/blled/web-server.h +++ b/src/blled/web-server.h @@ -179,12 +179,11 @@ void handleGetConfig(AsyncWebServerRequest *request) doc["bedTempRGB"] = printerConfig.bedTempRGB.RGBhex; doc["bedTempWW"] = printerConfig.bedTempRGB.ww; doc["bedTempCW"] = printerConfig.bedTempRGB.cw; - //HMS Error Handling + // HMS Error Handling doc["hmsIgnoreList"] = printerConfig.hmsIgnoreList; - //control chamber light + // control chamber light doc["controlChamberLight"] = printerConfig.controlChamberLight; - String jsonString; serializeJson(doc, jsonString); request->send(200, "application/json", jsonString); @@ -276,9 +275,9 @@ void handleSubmitConfig(AsyncWebServerRequest *request) printerConfig.frontCoverRGB = hex2rgb(getSafeParamValue(request, "frontCoverRGB").c_str(), getSafeParamInt(request, "frontCoverWW"), getSafeParamInt(request, "frontCoverCW")); printerConfig.nozzleTempRGB = hex2rgb(getSafeParamValue(request, "nozzleTempRGB").c_str(), getSafeParamInt(request, "nozzleTempWW"), getSafeParamInt(request, "nozzleTempCW")); printerConfig.bedTempRGB = hex2rgb(getSafeParamValue(request, "bedTempRGB").c_str(), getSafeParamInt(request, "bedTempWW"), getSafeParamInt(request, "bedTempCW")); - //HMS Error handling + // HMS Error handling printerConfig.hmsIgnoreList = getSafeParamValue(request, "hmsIgnoreList"); - //Control Chamber Light + // Control Chamber Light printerConfig.controlChamberLight = request->hasParam("controlChamberLight", true); saveFileSystem(); @@ -309,6 +308,7 @@ void handleWiFiScan(AsyncWebServerRequest *request) { JsonObject net = networks.add(); net["ssid"] = WiFi.SSID(i); + net["bssid"] = WiFi.BSSIDstr(i); net["rssi"] = WiFi.RSSI(i); net["enc"] = (WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? false : true; } @@ -335,6 +335,10 @@ void handleSubmitWiFi(AsyncWebServerRequest *request) { String ssid = request->getParam("ssid", true)->value(); String pass = request->getParam("pass", true)->value(); + String bssid = request->hasParam("bssid", true) ? request->getParam("bssid", true)->value() : ""; + if (bssid.length() > 0) + strlcpy(printerConfig.BSSID, bssid.c_str(), sizeof(printerConfig.BSSID)); + ssid.trim(); pass.trim(); @@ -483,9 +487,9 @@ void handleFactoryReset(AsyncWebServerRequest *request) LogSerial.println(F("[FactoryReset] Performing full reset...")); - deleteFileSystem(); // delete LittleFS config + deleteFileSystem(); // delete LittleFS config request->send(200, "text/plain", "Factory reset complete. Restarting..."); - + shouldRestart = true; restartRequestTime = millis(); } diff --git a/src/www/wifiSetup.html b/src/www/wifiSetup.html index 8dac118..dba00e4 100644 --- a/src/www/wifiSetup.html +++ b/src/www/wifiSetup.html @@ -21,7 +21,7 @@

BLLED WiFi Setup

- + @@ -145,15 +145,24 @@

Select Printer

const data = await res.json(); const container = document.getElementById("networks"); container.innerHTML = ""; + data.networks.forEach(net => { + net.bssid = net.bssid || ""; + const div = document.createElement("div"); div.className = "network"; div.innerHTML = ` - ${getSignalSVG(net.rssi)} ${getSignalPercent(net.rssi)} ${net.ssid} ${getLockIcon(net.enc)} - `; + ${getSignalSVG(net.rssi)} ${getSignalPercent(net.rssi)} ${net.ssid} (${net.bssid}) ${getLockIcon(net.enc)} + `; + div.style.cursor = "pointer"; + div.style.padding = "4px 8px"; + div.style.borderBottom = "1px solid #ddd"; + div.addEventListener("click", () => { document.getElementById("ssid").value = net.ssid; + document.getElementById("bssid").value = net.bssid; // ← BSSID Ãŧbernehmen }); + container.appendChild(div); }); } catch (err) { @@ -163,21 +172,24 @@

Select Printer

} } + document.getElementById("wifiForm").addEventListener("submit", async (e) => { e.preventDefault(); const ssid = document.getElementById("ssid").value; const pass = document.getElementById("password").value; + const bssid = document.getElementById("bssid").value; const printerIP = document.getElementById("printerIP").value; const printerSerial = document.getElementById("printerSerial").value; const accessCode = document.getElementById("accessCode").value; const webUser = document.getElementById("webUser").value; const webPass = document.getElementById("webPass").value; - + try { const res = await fetch("/submitWiFi", { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, - body: `ssid=${encodeURIComponent(ssid)}&pass=${encodeURIComponent(pass)}&printerIP=${encodeURIComponent(printerIP)}&printerSerial=${encodeURIComponent(printerSerial)}&accessCode=${encodeURIComponent(accessCode)}&webUser=${encodeURIComponent(webUser)}&webPass=${encodeURIComponent(webPass)}` + body: `ssid=${encodeURIComponent(ssid)}&pass=${encodeURIComponent(pass)}&bssid=${encodeURIComponent(bssid)}&printerIP=${encodeURIComponent(printerIP)}&printerSerial=${encodeURIComponent(printerSerial)}&accessCode=${encodeURIComponent(accessCode)}&webUser=${encodeURIComponent(webUser)}&webPass=${encodeURIComponent(webPass)}` + }); if (res.ok) { From 5f7d576b7d6e6468147932fe88aebdb820c0213a Mon Sep 17 00:00:00 2001 From: SoftWareCrash Date: Sun, 22 Jun 2025 16:19:26 +0200 Subject: [PATCH 29/34] cleanup and compress --- platformio.ini | 2 +- src/blled/web-server.h | 13 - src/www/blled.svg | 43 +- src/www/colorpicker.html.unused | 147 ----- src/www/favicon.png | Bin 4359 -> 1851 bytes src/www/setupPageOld.html | 1078 ------------------------------- 6 files changed, 2 insertions(+), 1281 deletions(-) delete mode 100644 src/www/colorpicker.html.unused delete mode 100644 src/www/setupPageOld.html diff --git a/platformio.ini b/platformio.ini index 136de49..d222a9e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -25,7 +25,7 @@ extra_scripts = pre:pre_build.py merge_firmware.py lib_deps = - bblanchon/ArduinoJson@7.4.1 + bblanchon/ArduinoJson@7.4.2 knolleary/pubsubclient@2.8.0 luc-github/ESP32SSDP@1.2.1 ESP32Async/AsyncTCP diff --git a/src/blled/web-server.h b/src/blled/web-server.h index 63f932f..9ba60a6 100644 --- a/src/blled/web-server.h +++ b/src/blled/web-server.h @@ -38,17 +38,6 @@ void handleSetup(AsyncWebServerRequest *request) request->send(response); } -void handleOldSetup(AsyncWebServerRequest *request) -{ - if (!isAuthorized(request)) - { - return request->requestAuthentication(); - } - AsyncWebServerResponse *response = request->beginResponse(200, setupPageOld_html_gz_mime, setupPageOld_html_gz, setupPageOld_html_gz_len); - response->addHeader("Content-Encoding", "gzip"); - request->send(response); -} - void handleUpdatePage(AsyncWebServerRequest *request) { if (!isAuthorized(request)) @@ -561,9 +550,7 @@ void setupWebserver() request->redirect("/wifi"); } else { handleSetup(request); - //handleOldSetup(request); } }); - webServer.on("/old", HTTP_GET, handleOldSetup); webServer.on("/fwupdate", HTTP_GET, handleUpdatePage); webServer.on("/getConfig", HTTP_GET, handleGetConfig); webServer.on("/submitConfig", HTTP_POST, handleSubmitConfig); diff --git a/src/www/blled.svg b/src/www/blled.svg index 05b1a9a..7c5e9e2 100644 --- a/src/www/blled.svg +++ b/src/www/blled.svg @@ -1,42 +1 @@ - - - - + \ No newline at end of file diff --git a/src/www/colorpicker.html.unused b/src/www/colorpicker.html.unused deleted file mode 100644 index 674d0ee..0000000 --- a/src/www/colorpicker.html.unused +++ /dev/null @@ -1,147 +0,0 @@ - - - - - BLLED Custom Colorpicker - - - - -

LED Farbe wählen

-
- -
- - -

-
-
-
-
-
diff --git a/src/www/favicon.png b/src/www/favicon.png
index 753583c07bf48338bececa38bc347e65c0d1d657..bb00bdf25010f03d3c5b5c0c5c443de8f5e28c68 100644
GIT binary patch
literal 1851
zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD3?#3*wF4!X83KGlT!CDMWqu6H{TY_|f*3%w
z&4XdK7nBX;HZ(B&XJBY>U}#`qn3cjX)0p8*8pHnvhE)sWME^QAh|k`RqcS*Zh5UIOBq}k
z&&E#Xw9r_c;&R4-anBbG^Q;pxqFa2K+xT{c9ZuTWs@AZp)O+z}_PckAnHF>eJS>_l
zZW=ND*ac<&mM_h&=CfZdbZZm7u#7Qy^PA_)qJCK^ELvUt4G)jCTrbm%F*|*F3-^Qm
zls9*cZk>=}c*D$7_VM0~s~6t!9I%j0z5Yt)z!JAOUDt{15?6Q3rTOG$rcSshBUq43jOlP1ydY
z=I8WnQyHF|`%ujIdGFk}l9TVg>H7LYfL*3S>BoYU!h0pQEwA3OcbsP|KVY|I_pGjD
zec!XyjO_7^Z?~;zW32hI^L@ee$!|X%-?zxNVN&hUTONuG_qobM@1F8tY`BnmTi_?>
zfpt%6W%V_DF>Z&s!v*z9(9=)tE(kqYnzfZhccPe^UL#Ket}`
UD|f};t)RT(>FVdQ&MBb@0H|n>lK=n!

literal 4359
zcmV+i5%}(jP)Px_!AV3xRCr$PoqLcR#eK&=znR_J)7|NX5O3QU5Fub71pFWsY!L%N!qS1@4lFE?
z9Y+`(2$aF5B1|rhaqKd-%V1ZGQUMH-pzg{NIw1riWhqo*5n*8)EEN_;6~-SmGTzd(5+jXpI4Y+3`=znTA>)0q(@&
ze3S_YG0d~vmJfgfiJL+1!=ojuyV>f{D6v0I~4Eh3|{u52jzoxUNzn-j6KLC6=KkI1R
z_#9NefiMjvR*)EGrbpE2SOC%@NNMrArdO6v1q+TSdlc@)>0il$b#>#0`T)>1GscY8
z_apYVP??S8%kA)UDI|h|I3TG%l0YUEazDyiV%}YB?b|`u2B+5C5Ps27&8)kliJ_s>
zu=p{^xg&DhDA>>~MZba~NR*ahc4syt`G^c7`ZDS*B=*L3I=33dU9(nO0F1eKO!Evp
zuN(N2QLCoZRq<6m1gK$RK#7|0*Et;!@GjzZx
zjmK{HBO+)l5FVnh;&3g8-`dVin}mVvZ}n^s`2qGo8|+d&<~oE5kcd;ha^Za5g!y^`nE
z1z`Qm7&|AP2G&z4rCZ5dGvBQ)0RESBJLp{c-riPCeNasRgk@JuL1MQ9i$_nlC5W1W
zXhm%W`POJkKOeDSjXwAu@uq*Fqi1im+!oaX;OC3tyuRyPRGtN8(f6S*HI>=j$5U3+t?5719vvD37e~BnpO{hWmil^VqXTnj9`tr5i%EKL>1R_w%5
zI(s6wh^hm?BeRbq5nlq#$s~TM@u(s+8p{FskTMRwC37Y)NsQa$bHGKYybqxj&E^Ub
zP%Us!7F~<&e2&g%b_Fqisn4Saz!yJ*XMwCA2^Jnz>V!h|&$WUK-PX^vnRvSJ^b(gY
z#vY!`y!xFf#NAn+?G%b1n9$DB-^IpUHKSoJpttpJs
z4JR71Lz3pav1{`AxEe!a+nF-FpZ?~-0>l!!JK}iG$$0K9Ab*8$63~(geI~=6nN1kP
z(*+D2Sj}fQn8;dWEqVaDJ0{}}-vN4WfpB8wN}y0o82u{fA3+`j@27aq+cdQeu(ij@
z%N0gMJv_IK7A{7)9ehz`xFUgIkIvr@YwBXW;UDsuwI;?KS&JTk$F4etxcdWCI#PN!
zTl9z7;X%s_iU}v3YJI5wlo;Q~ML$zy_xW+iAx)<
zcogyOV*cuPf~Hr>^XLIsI`1SbXC=r5ffGrCk@~j~He>!?EGxpqgpZ7C@*|8}c_-+D
zIJ$!7=H2YwKFFfYPQlZyZ^bo#WF%O#ScEgxSWwE(@azRFSg|v3T_tpg9)KsVJQ;L7
z%E@^xpj>Je;fR8O2wSvJT1rk(K4T06#z8E337mgssQ*<4PCdZR6GoJF0gq?Wpg7vM
zpoEVyY%k)5m47UOzJXn%2cUb-2XU>9D90B2dPS0`QeTj$iT%EfvJA17V8{R9=MZ)D
zcm=t_MDzB1bU14Fbo2l$yW$kYei3AP9%~{?0apM*a8^X%-W%<35agG5?zeCcZ)Czz
z`{?X3W^7GT8lwjwg9GvsIEd;&&y$+HaAsVwyr9CM7<kc}42CC%+
zO;06y0G7@B0G7KUO9vEKcs^PO(my%liU2714d2`}J70~<;T2yzske^4xAs&kCJ;RU
zz7^z}0L=N}r9jA@NdgUE=}TC{*U-6kxBsTe4GohS7xFWyZblzCC_50I$8mqeH1{=T
zuN^FHnBu*o2f&;IV&0E{t1{UvOP~gB^PEW=rK#)%*5m2pzO26CqLCm;%6f?qfIL%6
zC;C24tm#fVdyHE;vKBo6<|OP4-Hq^-P}y#U!7y_95Xx^sm*dH^c>UXX-_Rg4H@I1{
zIUfL}f?U*OGj2NWrG@X)-rE-$^~?5=7n?zM#{`_gPDGZZJdUI1qL33GMtKL(bqFi4
zhd0v30X7ve0W;InQ%X1#{ZsC7Gp_)XX8`0zrVOrXd=X@FfKH$KVepm;OWBRv{`M$64Tl5?&PM`CViw@
zN;qTcY9f0JnBQv-Y>~EV002v8O~Q`ffy%um3odiBiQuYo0FhTvZw;2SibJuToN}O_
ziwk5Yn;m}8J{C9j3Gl8&Wjd~X?WkX-QYD;rlcy${#T>>G^7Ib&9e9*4MxP^89RN&7
zux;0c2&)B|m(Q_-pLMD^Uky%m=CifU#d5ziK)$_umjM1lfYiO|(?pL{ri~8f
z=j!zTDaz6GyRZ1Nz1VIyfe?4-EZ}mKs}YX#cYFRiv9gkLgBF^{a@vP#JMqMe@4dVr
zUm15KcWl0@#B{*CO;1Ej?7%WX^K%d;`nx?D1S!-i2Ou~+YR(!DV-MU-$8+z&%((od
z6CPR=Bfet_O|et4t*cR;2V#8gCUG}^ao*UiSv~-v4hSHkZ>i&5!Qq`-tK|o(o({+*
zzA+!q>}Y|(<8a0Ji2fesR6qVIG=(}bXO3CCPS^z3%W9+8nCxibW`_EI!VT*Vl{Hw%
zm#U+Lb3bnMfirvyc()2NU6ocpU9r$^OwTHZkQv=0%Z|=5IZbkq301B{^_Kr1^#KM9
z-z5niT5Q4gkL}`;tjGEsH@+%|KSpXc)O&R0M@R2NV{2hw=1p
zh$mLnvUc!67bPP`HIgqn64}zhLlXRy_gYucDproF05m`Yqi@5Ts{nZXb
zX4?~$2!e9nH3?8}PdOLy9b8k(8Nv@qmUCA`p^phWKt7Hg-%$;BL$Nj1mIKl=NyZGi
zK)zJ;VvfRW5s3~+4L^kNS!NvD!v#xfQX5=f4)8^hITy@61}DC8B<1f&0#{geC?bM#
zuPP{rVX`L7m_3^rluKDyThWs#1;Z{o+I}W*bK0cOW6Og@Z%N5#HU{N}hMuVoAl9e&
z&7ZB0I^inp6zU^_%#a$WE0T3S704}W2KrCR-xX)K#YJdf`$feXsF
zf_xCf`1!YDANor=|08+xVx3z3L{NIcrn>QoUp$1cFi02puOxSIQ2>I^6f%r@_i=si
z*Mbuws*6nh0Wj-ZcIEkq_n$@YlE|iNB^+R~>-M3}1zf*odv(bhJbGgQkPPC#fXasg
z?-5GQ*yM)J9&>G_x#1*P)iSmnIYpc5nV0DEE*Z_L2&PljdNc+A{b^6njjh
zI_;JoC8EB8?fmU%*{JXC?!O-F+mHfC8
z-e+RGosTnrmASjFAzI@AV92q&{Q-oV(rN9HQ^;I7pxn>=Rrf?bc9{b<764Doy$8hn
z20->56B&z3dJ+Q8uLYh93@Eyo`MuvQlU|X()@T5H0hO2oUlU*z=vCO3!>)-X5Ebl~JW>o%!s+ApG{)~h!
zqk6l_AED@*Bja}YycEPMRr>zeVH=ABYPRgg`A}m4uzb#02p
ze_zh))p)1D0BFBy1uIpVX>7x<;&_gcW`mnW~
zYkSS5vJKH13xMTwP4$e44VyZ$Q+#tY%$Co&lR8K78Vl82w)(#)FVbw?#k`g8HU#yn
zR;XR>>P-E>>6^`U$HyY}BdD6YCW3y}Fz9P8=zn3kH{)5mYf<+VG@;Drjl}`!nVFih
ziGTP<&@Tzn9PW@+VA*1REzkQV+xosyjqB%2A$GpLjR}C6>C*PIv3M?3)R%SPhrf_~
zqAC5i(P#dB=)16-%eZdMuPY^1HQsMr08CNeMC(qJucUrqbqvu1-4On-A?bH$({C~-
zb+t`3s93?6jSGO!1@lhAb|3Jw;4&3*A;p~i_aQKMM|(HX**MO(T&x-!0Kcg3DVW&Hpv_C~FX?!pkg@vWeIt5`L6B7K~L#Z`!0?O%g)#6&eWo9snd
zjj|G)&CFl3ubzb$VS#9T4#-?d`ih%Y=P2x^58~-@s3>vWNi6m|4jtUff_3JijfyPS
zu*8d^-+K#yC|2BHV~hh(XF$dQ7zd!v6sYs({|~o-7RuQtT*m+a002ovPDHLkV1nGG
BL{tC(

diff --git a/src/www/setupPageOld.html b/src/www/setupPageOld.html
deleted file mode 100644
index 9031f9b..0000000
--- a/src/www/setupPageOld.html
+++ /dev/null
@@ -1,1078 +0,0 @@
-
-
-
-
-    
-    
-    
-    BLLED Setup
-    
-
-
-
-    
-
-    
-
- - BLLED Controller - - WiFi-Signal - - - - - - - -
-
-

BLLED LED Settings

-

Firmware version: ??.??.??

-

This page allows you to change the LED behavior.

- -
- - - - - - - - - - - - - -
- - -

LED - Behaviour (Choose One)

-
- -    Maintenance Mode (Always On) -
-
- -    RGB Color Cycle Mode (Always On) -
-
- -    Replicate LED State -
- -  WW  -  CW  -
-
- -
- - -    Test LED Colors (Always On) -
- -  WW  -  CW  -
-
- - - - - - -
-
- -    Show Wifi Strength via - LEDs -
-
- -

Options

- - - - - - - - - - -
-
- -    Finish Indication -
-
-
- -  WW  -  CW  -
-
- - - -
-
- -    Inactivity Timeout (Minutes) - -
-
- -    Debugging -
-
- -    Debugging OnChange Events -
-
- -    MQTT Logging -
-
-

Printer - Dependant

-
- -    Connecting to a P1 Printer? (No Door - Switch, No Lidar) -
-
- -    Door Switch used for actions (P1 has no - switch) -
- - - - - - -
-

- Stages with Lidar in use (if installed)

-
- -  WW  -  CW  -    Cleaning Nozzle
- - -  WW  -  CW  -    Bed Leveling
- - -  WW  -  CW  -    Calibrating Extrusion
- - -  WW  -  CW  -    Scanning Bed Surface
- - -  WW  -  CW  -    First Layer Inspection
- - -

Customise - Colors

-
- -    Error Detection -
-
- - -  WW  -  CW  -    WiFi Setup / Scanning
- - - -  WW  -  CW  -    Pause (Gcode or User)
- - -  WW  -  CW  -    First Layer Error (Pause for - user)
- - -  WW  -  CW  -    Nozzle Clog (Pause for user)
- - -  WW  -  CW  -    HMS Severity, SERIOUS
- - -  WW  -  CW  -    HMS Severity, FATAL
- - -  WW  -  CW  -    Filament Runout
- - -  WW  -  CW  -    Front Cover Removed
- - -  WW  -  CW  -    Nozzle Temp Fail
- - -  WW  -  CW  -    Bed Temp Fail
-
-
- -
- - - -
- - -
-
- - - - - - - - - - - \ No newline at end of file From c93e6c66aa94fadda9b234a1d188b90be134cb94 Mon Sep 17 00:00:00 2001 From: SoftWareCrash Date: Mon, 23 Jun 2025 09:58:16 +0200 Subject: [PATCH 30/34] version bump --- compress_html.py | 2 +- platformio.ini | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/compress_html.py b/compress_html.py index 2f288e3..b808140 100644 --- a/compress_html.py +++ b/compress_html.py @@ -38,7 +38,7 @@ def compress_and_append_file(input_file, f): compressed_file = input_file + ".gz" with open(input_file, "rb") as infile: - with gzip.open(compressed_file, "wb", compresslevel=6) as outfile: + with gzip.open(compressed_file, "wb", compresslevel=9) as outfile: outfile.write(infile.read()) with open(compressed_file, "rb") as cf: diff --git a/platformio.ini b/platformio.ini index d222a9e..821c723 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,7 @@ [env:esp32dev] custom_project_name = BLLEDController custom_project_codename = Balder -custom_version = 2.2.0.nightly.220625.1 #BLLC_[Major].[Minor].[Patch] +custom_version = 2.2.0.nightly.230625.1 #BLLC_[Major].[Minor].[Patch] platform = espressif32 board = esp32dev framework = arduino @@ -21,6 +21,7 @@ board_build.filesystem = littlefs build_flags = -DVERSION=${this.custom_version} -DSTRVERSION=\""${this.custom_version}"\" + -DCONFIG_ASYNC_TCP_STACK_SIZE=4096 extra_scripts = pre:pre_build.py merge_firmware.py From 64a42b6d8aaa8e172b73e615133dcde2c5061f10 Mon Sep 17 00:00:00 2001 From: softwarecrash Date: Mon, 23 Jun 2025 19:26:24 +0200 Subject: [PATCH 31/34] version bump --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 821c723..3f16fbd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,7 @@ [env:esp32dev] custom_project_name = BLLEDController custom_project_codename = Balder -custom_version = 2.2.0.nightly.230625.1 #BLLC_[Major].[Minor].[Patch] +custom_version = 2.2.0 #BLLC_[Major].[Minor].[Patch] platform = espressif32 board = esp32dev framework = arduino From 13f32175882e72e50942942ba021001f21bfbfd9 Mon Sep 17 00:00:00 2001 From: Rocky <44615614+softwarecrash@users.noreply.github.com> Date: Mon, 23 Jun 2025 19:30:58 +0200 Subject: [PATCH 32/34] Update README.md add pictures --- README.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 30ff0b5..51981dc 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,20 @@ The BL Led Controller is an ESP32 based device that connects to your Bambulab X1 7. Select your WiFi and Enter passwort, Optional enter all the Printer informations 8. enjoy :) -### Features -WiFi Setup: -![1000063279](https://github.com/user-attachments/assets/1cbe01fd-ce1f-4664-909e-7f6f50f6d80a) +![main setup_LED](https://github.com/user-attachments/assets/52778d28-98cd-496e-bfce-aca49cd4de89) +![main_setup_printer](https://github.com/user-attachments/assets/1969e4bd-0887-4a0c-a965-8ec575e23396) +![main_setup_error](https://github.com/user-attachments/assets/b026260c-5c33-4f5c-922a-fcc601cb9be1) +![main_setup_debug](https://github.com/user-attachments/assets/6d5a6e48-b052-4305-99f5-5d9c906eb8c1) +![main_setup_navigation](https://github.com/user-attachments/assets/78041d10-2edb-42e2-b600-6cde735d2d1f) +![setup_wifi](https://github.com/user-attachments/assets/4ef7631c-38f9-4424-ad88-72a335286c27) +![setup_wifi_printer](https://github.com/user-attachments/assets/da354544-710d-4e10-9dff-fc2cc1951857) +![ota](https://github.com/user-attachments/assets/7f223361-f811-4ff4-b3fc-45b2a1222c07) +![backup_restore](https://github.com/user-attachments/assets/b21899ba-c97f-48b6-8bc3-a87797029d14) +![navigation](https://github.com/user-attachments/assets/027fe724-ffc6-453b-ba73-c82c1ddb012e) + + + -OTA Firmware Update: -![1000063277](https://github.com/user-attachments/assets/853fa8cd-def6-47e9-8b23-4a4289651510) - Connects to Bambulab X1,X1C,P1P Or P1S - Controls LED strip based on printer state From abbb54a425acd7648493889531356cc9620b51d5 Mon Sep 17 00:00:00 2001 From: Rocky <44615614+softwarecrash@users.noreply.github.com> Date: Mon, 23 Jun 2025 20:00:02 +0200 Subject: [PATCH 33/34] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 51981dc..346ca04 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ The BL Led Controller is an ESP32 based device that connects to your Bambulab X1 7. Select your WiFi and Enter passwort, Optional enter all the Printer informations 8. enjoy :) +Questions? Read the [Docs](https://github.com/softwarecrash/BLLEDController-NG/blob/main/docs/manual.md) + ![main setup_LED](https://github.com/user-attachments/assets/52778d28-98cd-496e-bfce-aca49cd4de89) ![main_setup_printer](https://github.com/user-attachments/assets/1969e4bd-0887-4a0c-a965-8ec575e23396) ![main_setup_error](https://github.com/user-attachments/assets/b026260c-5c33-4f5c-922a-fcc601cb9be1) From b8a314e3dcbb72547a8f2761bca5280aff17654d Mon Sep 17 00:00:00 2001 From: Rocky <44615614+softwarecrash@users.noreply.github.com> Date: Mon, 23 Jun 2025 20:00:34 +0200 Subject: [PATCH 34/34] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 346ca04..51981dc 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,6 @@ The BL Led Controller is an ESP32 based device that connects to your Bambulab X1 7. Select your WiFi and Enter passwort, Optional enter all the Printer informations 8. enjoy :) -Questions? Read the [Docs](https://github.com/softwarecrash/BLLEDController-NG/blob/main/docs/manual.md) - ![main setup_LED](https://github.com/user-attachments/assets/52778d28-98cd-496e-bfce-aca49cd4de89) ![main_setup_printer](https://github.com/user-attachments/assets/1969e4bd-0887-4a0c-a965-8ec575e23396) ![main_setup_error](https://github.com/user-attachments/assets/b026260c-5c33-4f5c-922a-fcc601cb9be1)