Skip to content

Commit

Permalink
Maintain connection info, better debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
domschl committed Sep 27, 2024
1 parent 323a012 commit effb54d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
Language: JavaScript
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"frameworks": "arduino"
}
],
"version": "0.4.1",
"version": "0.4.2",
"frameworks": "arduino",
"platforms": "*"
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=munet
version=0.4.1
version=0.4.2
author=Dominik Schlösser, Leo Moll
maintainer=Dominik Schlösser, <dsc@dosc.net>
sentence=Modules for Wifi connectivity, NTP, OTA, MQTT on ESP32/ESP8266 compatible with muwerk scheduler, serial link for other platforms
Expand Down
20 changes: 12 additions & 8 deletions net.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -295,7 +300,6 @@ class Net {
WiFi.reconnect();
connectTimeout.reset();
} else {
DBG("Retrying to connect...");
if (initialCounter > 0) {
if (bRebootOnContinuedFailure) {
--initialCounter;
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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<String> dns;
Expand Down

0 comments on commit effb54d

Please sign in to comment.