From effb54d5a4260b9a9238973ea7b74e515407485c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Schl=C3=B6sser?= Date: Fri, 27 Sep 2024 14:17:28 +0200 Subject: [PATCH] Maintain connection info, better debug output --- .clang-format | 1 - library.json | 2 +- library.properties | 2 +- net.h | 20 ++++++++++++-------- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.clang-format b/.clang-format index 61f7931..fcf3a96 100644 --- a/.clang-format +++ b/.clang-format @@ -1,5 +1,4 @@ --- -Language: JavaScript Language: Cpp # BasedOnStyle: LLVM AccessModifierOffset: -2 diff --git a/library.json b/library.json index e33a017..de2c5e4 100644 --- a/library.json +++ b/library.json @@ -30,7 +30,7 @@ "frameworks": "arduino" } ], - "version": "0.4.1", + "version": "0.4.2", "frameworks": "arduino", "platforms": "*" } \ No newline at end of file diff --git a/library.properties b/library.properties index bf424e2..dfeceaa 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=munet -version=0.4.1 +version=0.4.2 author=Dominik Schlösser, Leo Moll maintainer=Dominik Schlösser, sentence=Modules for Wifi connectivity, NTP, OTA, MQTT on ESP32/ESP8266 compatible with muwerk scheduler, serial link for other platforms diff --git a/net.h b/net.h index 6d68283..8336ad2 100644 --- a/net.h +++ b/net.h @@ -97,6 +97,11 @@ class Net { String macAddress; String deviceID; + // Credentials + String SSID; + String password; + String hostname; + // runtime control - state management Netmode mode; Netstate curState; @@ -280,7 +285,7 @@ class Net { return; } if (connectTimeout.test()) { - DBG("Timout connecting to WiFi " + WiFi.SSID()); + DBG("Timout connecting to WiFi " + SSID + ", status: " + WiFi.status()); if (bOnceConnected) { if (bRebootOnContinuedFailure) { --deathCounter; @@ -295,7 +300,6 @@ class Net { WiFi.reconnect(); connectTimeout.reset(); } else { - DBG("Retrying to connect..."); if (initialCounter > 0) { if (bRebootOnContinuedFailure) { --initialCounter; @@ -545,7 +549,7 @@ class Net { bool startAP() { // configure hostname - String hostname = replaceVars(config.readString("net/hostname", "muwerk-${macls}")); + hostname = replaceVars(config.readString("net/hostname", "muwerk-${macls}")); wifiAPSetHostname(hostname); // configure network @@ -557,11 +561,11 @@ class Net { } // configure AP - String SSID = replaceVars(config.readString("net/ap/SSID", "muwerk-${macls}")); + SSID = replaceVars(config.readString("net/ap/SSID", "muwerk-${macls}")); if (!SSID.length()) { SSID = replaceVars("muwerk-${macls}"); } - String password = config.readString("net/ap/password"); + password = config.readString("net/ap/password"); unsigned int channel = config.readLong("net/ap/channel", 1, 13, 1); bool hidden = config.readBool("net/ap/hidden", false); unsigned int maxConnections = config.readLong("net/ap/maxConnections", 1, 8, 4); @@ -580,9 +584,9 @@ class Net { bool startSTATION() { // get connection parameters - String hostname = replaceVars(config.readString("net/hostname")); - String SSID = config.readString("net/station/SSID"); - String password = config.readString("net/station/password"); + hostname = replaceVars(config.readString("net/hostname")); + SSID = config.readString("net/station/SSID"); + password = config.readString("net/station/password"); // get network parameter ustd::array dns;