From 72e885d2b25e7470161e88b1455255fab408bdd2 Mon Sep 17 00:00:00 2001 From: szenglein Date: Thu, 18 May 2023 15:45:11 +0200 Subject: [PATCH 1/9] Add support for saving multiple wifi networks * The new code scans available networks * Tries connecting to each known network, starting at the strongest one * Up to 10 SSIDs are saved in NVS * SSIDs can be added and removed TODO: Web-frontend for listing and deleting networks fix AP never start AP after once successful connect re-add hostname and static IP Try last ssid first and more Web API functions fix for accesspoint wifi POST add POST handlers for network settings to AP server set hostname before every connect simplify nvs key handling clean up wifi logging fix swapped log msg clean up prints from web fix some compiler warnings only print connection fail once update wifi management webinterface smaller formatting changes --- html/accesspoint.html | 15 +- html/locales/de.json | 2 + html/locales/en.json | 2 + html/management.html | 167 ++++++++++-- src/LogMessages_DE.cpp | 20 +- src/LogMessages_EN.cpp | 17 +- src/Web.cpp | 180 +++++++++++-- src/Wlan.cpp | 579 +++++++++++++++++++++++++++++++---------- src/Wlan.h | 10 +- src/logmessages.h | 14 +- 10 files changed, 805 insertions(+), 201 deletions(-) diff --git a/html/accesspoint.html b/html/accesspoint.html index eb9fb09b..618ab74e 100644 --- a/html/accesspoint.html +++ b/html/accesspoint.html @@ -45,7 +45,7 @@ -
+

WiFi-configuration

:

@@ -71,6 +71,19 @@

Ready to go?

localize = locI18next.init(i18next); localize('body'); }); + + async function wifiConfig() { + var myObj = { + ssid: document.getElementById('ssid').value, + pwd: document.getElementById('pwd').value + }; + + await fetch("/savedSSIDs", { + method: "POST", + headers: {"Content-Type": "application/json"}, + body: JSON.stringify(myObj) + }); + } \ No newline at end of file diff --git a/html/locales/de.json b/html/locales/de.json index 2742c8b9..a37773b0 100644 --- a/html/locales/de.json +++ b/html/locales/de.json @@ -24,6 +24,8 @@ }, "wifi": { "title": "WLAN-Einstellungen", + "networks": "Netzwerke", + "savedNetworks": "Gespeicherte Netzwerke", "ssid": { "title": "WLAN-Name (SSID)", "placeholder": "SSID", diff --git a/html/locales/en.json b/html/locales/en.json index 4c7b117b..5086ce2b 100644 --- a/html/locales/en.json +++ b/html/locales/en.json @@ -24,6 +24,8 @@ }, "wifi": { "title": "WiFi-configuration", + "networks": "Networks", + "savedNetworks": "Saved Networks", "ssid": { "title": "WiFi-name (SSID)", "placeholder": "SSID", diff --git a/html/management.html b/html/management.html index 6867ef19..86146487 100644 --- a/html/management.html +++ b/html/management.html @@ -175,24 +175,42 @@