From dcee1350d79d548fee68f66f256b358947e4a671 Mon Sep 17 00:00:00 2001 From: Adam Douglas Date: Sat, 6 Apr 2024 08:19:10 +1100 Subject: [PATCH 1/3] Changed initial LED update --- src/main.cpp | 3 ++- src/mqttmanager.h | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 52e1ab9..b68ce48 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -86,7 +86,8 @@ void setup(){ Serial.println(F(" **")); Serial.println(); globalVariables.started = true; - + Serial.println(F("Updating LEDs from Setup")); + updateleds(); } void loop(){ diff --git a/src/mqttmanager.h b/src/mqttmanager.h index 1e162ee..1ebca38 100644 --- a/src/mqttmanager.h +++ b/src/mqttmanager.h @@ -55,8 +55,8 @@ void connectMqtt(){ mqttClient.subscribe(report_topic.c_str()); printerVariables.online = true; printerVariables.disconnectMQTTms = 0; - Serial.println(F("Updating LEDs from MQTT connect")); - updateleds(); + //Serial.println(F("Updating LEDs from MQTT connect")); + //updateleds(); }else{ Serial.println(F("Failed to connect with error code: ")); Serial.print(mqttClient.state()); @@ -93,7 +93,7 @@ void ParseCallback(char *topic, byte *payload, unsigned int length){ auto deserializeError = deserializeJson(messageobject, payload, length, DeserializationOption::Filter(filter)); if (!deserializeError){ if (printerConfig.debuging){ - Serial.print(F("Mqtt message received, ")); + Serial.println(F("Mqtt message received.")); Serial.print(F("FreeHeap: ")); Serial.println(ESP.getFreeHeap()); } @@ -106,6 +106,7 @@ void ParseCallback(char *topic, byte *payload, unsigned int length){ || messageobject["print"]["command"] == "project_file" //1 message per print || 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"){ //1 message per print return; } From 14fd39fa66690960ea9d7079f44c93e05b58dae8 Mon Sep 17 00:00:00 2001 From: Adam Douglas Date: Sat, 20 Apr 2024 11:53:59 +1000 Subject: [PATCH 2/3] AddingWifi rescan on repeat failure --- src/main.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b68ce48..c1cd376 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,7 +7,7 @@ #include "serialmanager.h" #include "wifi-manager.h" - +int wifi_reconnect_count = 0; void defaultcolors(){ Serial.println(F("Setting default customisable colors")); printerConfig.runningColor = hex2rgb("#000000",255,255);//WHITE Running @@ -98,12 +98,22 @@ void loop(){ ledsloop(); if (WiFi.status() != WL_CONNECTED){ - if (WiFi.status() == WL_DISCONNECTED) Serial.print(F("Wifi connection Disconnected. ")); - + Serial.print(F("Wifi connection dropped. ")); + Serial.print(F("Wifi Status: ")); + Serial.println(wl_status_to_string(status)); Serial.println(F("Attempting to reconnect to WiFi...")); - WiFi.disconnect(); - delay(10); - WiFi.reconnect(); + wifi_reconnect_count += 1; + if(wifi_reconnect_count <= 2){ + WiFi.disconnect(); + delay(100); + WiFi.reconnect(); + } else { + //Not connecting after 10 simple disconnect / reconnects + //Do something more drastic in case needing to switch to new AP + scanNetwork(); + connectToWifi(); + wifi_reconnect_count = 0; + } } } if(printerConfig.rescanWiFiNetwork) From b418816e1fd82a0201c445980faecb910662ee83 Mon Sep 17 00:00:00 2001 From: Adam Douglas Date: Sat, 20 Apr 2024 11:57:15 +1000 Subject: [PATCH 3/3] Status update --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c1cd376..6a5954f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -100,7 +100,7 @@ void loop(){ if (WiFi.status() != WL_CONNECTED){ Serial.print(F("Wifi connection dropped. ")); Serial.print(F("Wifi Status: ")); - Serial.println(wl_status_to_string(status)); + Serial.println(wl_status_to_string(WiFi.status())); Serial.println(F("Attempting to reconnect to WiFi...")); wifi_reconnect_count += 1; if(wifi_reconnect_count <= 2){