From a09fd4fda4d73bf4b4cd7f0d69c1fa3e4fb5d961 Mon Sep 17 00:00:00 2001
From: Manuel Weiser <manuel.weiser@me.com>
Date: Sun, 23 Mar 2025 11:03:51 +0100
Subject: [PATCH] fix: add WiFi connection check and restart Bambu if not
 connected

---
 src/main.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/main.cpp b/src/main.cpp
index 84e45f1..157a0b2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -92,12 +92,19 @@ void loop() {
   unsigned long currentMillis = millis();
 
   // Überprüfe regelmäßig die WLAN-Verbindung
-  if (intervalElapsed(currentMillis, lastWifiCheckTime, wifiCheckInterval)) {
+  if (intervalElapsed(currentMillis, lastWifiCheckTime, wifiCheckInterval)) 
+  {
     checkWiFiConnection();
   }
 
   // Wenn Bambu auto set Spool aktiv
-  if (autoSendToBambu && autoSetToBambuSpoolId > 0) {
+  if (autoSendToBambu && autoSetToBambuSpoolId > 0) 
+  {
+    if (!bambu_connected) 
+    {
+      bambu_restart();
+    }
+
     if (intervalElapsed(currentMillis, lastAutoSetBambuAmsTime, autoSetBambuAmsInterval)) 
     {
       if (hasReadRfidTag == 0)