From 1aa495bc3e8c2c5429481b979920182af7020944 Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Thu, 19 Feb 2026 10:24:24 +0100 Subject: [PATCH] upstream sync --- include/NTPupdate.h | 6 +- include/constants.h | 2 +- include/core.h | 1 - include/globals.h | 3 +- include/language.h | 486 ++++++++++++++++++- lib/WiFiConnect/LICENSE | 674 --------------------------- lib/WiFiConnect/WC_AP_HTML.h | 64 --- lib/WiFiConnect/WiFiConnect.cpp | 667 -------------------------- lib/WiFiConnect/WiFiConnect.h | 87 ---- lib/WiFiConnect/WiFiConnectParam.cpp | 55 --- lib/WiFiConnect/WiFiConnectParam.h | 31 -- lib/WiFiConnect/library.json | 15 - src/WifiConnect.cpp | 612 ++++++++++++++++++++++++ src/WifiConnect.h | 81 ++++ src/comms.cpp | 1 + src/core.cpp | 1 + src/gui.cpp | 3 +- src/main.cpp | 1 + src/rds.cpp | 1 + 19 files changed, 1167 insertions(+), 1624 deletions(-) delete mode 100644 lib/WiFiConnect/LICENSE delete mode 100644 lib/WiFiConnect/WC_AP_HTML.h delete mode 100644 lib/WiFiConnect/WiFiConnect.cpp delete mode 100644 lib/WiFiConnect/WiFiConnect.h delete mode 100644 lib/WiFiConnect/WiFiConnectParam.cpp delete mode 100644 lib/WiFiConnect/WiFiConnectParam.h delete mode 100644 lib/WiFiConnect/library.json create mode 100644 src/WifiConnect.cpp create mode 100644 src/WifiConnect.h diff --git a/include/NTPupdate.h b/include/NTPupdate.h index 6f0582e..753152c 100644 --- a/include/NTPupdate.h +++ b/include/NTPupdate.h @@ -2,9 +2,9 @@ #include "globals.h" #include "rtc.hpp" -static const char ntpServerName[] = "0.pool.ntp.org"; -static const int localPort = 8944; -const int NTP_PACKET_SIZE = 48; +static constexpr char ntpServerName[] = "0.pool.ntp.org"; +static constexpr int localPort = 8944; +constexpr int NTP_PACKET_SIZE = 48; void sendNTPpacket(IPAddress &address); void NTPupdate(); diff --git a/include/constants.h b/include/constants.h index ee108b4..7dc3630 100644 --- a/include/constants.h +++ b/include/constants.h @@ -2,7 +2,7 @@ #include -#define VERSION "v2.20.6c" +#define VERSION "v2.20.7b" #define ROTARY_PIN_A 34 #define ROTARY_PIN_B 36 diff --git a/include/core.h b/include/core.h index 1373ee7..3df3a52 100644 --- a/include/core.h +++ b/include/core.h @@ -1,7 +1,6 @@ #pragma once #include #include -#include "graphics.h" const char* textUI(uint16_t number); uint8_t doAutoMemory(uint16_t startfreq, uint16_t stopfreq, uint8_t startmem, uint8_t stopmem, bool rdsonly, uint8_t doublepi); diff --git a/include/globals.h b/include/globals.h index a214caa..6e06fdb 100644 --- a/include/globals.h +++ b/include/globals.h @@ -11,10 +11,9 @@ #include #include #include -#include -#include #include "scrolling_text.h" #include "rtc.hpp" +#include "WiFiConnect.h" extern bool RDSstatus; extern bool RDSstatusold; diff --git a/include/language.h b/include/language.h index 6ed7c75..1a822e0 100644 --- a/include/language.h +++ b/include/language.h @@ -24,7 +24,7 @@ Process: } */ -static const char* const Languages[22][297] PROGMEM = { +static const char* const Languages[22][317] PROGMEM = { { "English", // English "Rotary direction changed", // 1 "Please release button", // 2 @@ -321,7 +321,27 @@ static const char* const Languages[22][297] PROGMEM = { "Auto DST on NTP time", // 293 "Set time zone", // 294 "The logbook contains over 130 entries, which the viewer cannot process. Please download the CSV file to process it.", // 295 - "Canada" // 296 + "Canada", // 296 + "Connect this device to a WiFi network to enable remote features.", // 297 + "Configure WiFi", // 298 + "Hidden network", // 299 + "WiFi Network Name", // 300 + "Enter SSID or tap a network above", // 301 + "Password", // 302 + "Enter password", // 303 + "Save and Connect", // 304 + "Scan again", // 305 + "Connecting to", // 306 + "Connected to", // 307 + "You may now close this page.", // 308 + "Could not connect to", // 309 + "Click here to try again", // 310 + "Options", // 311 + "Select WiFi", // 312 + "No networks found. Refresh to scan again.", // 313 + "Credentials Saved", // 314 + "Set XDRGTK password (max 8 characters)", // 315 + "ID" // 316 }, { "Nederlands", // Dutch @@ -620,7 +640,27 @@ static const char* const Languages[22][297] PROGMEM = { "Auto zomertijd\nop NTP tijd", // 293 "Tijdzone", // 294 "Het logboek bevat meer dan 130 items, die de viewer niet kan verwerken. Download alstublieft het CSV-bestand om het te bekijken.", // 295 - "Canada" // 296 + "Canada", // 296 + "Configureer de verbinding met een WiFi netwerk.
Hierna zal de radio automatisch proberen verbinding te maken.", // 297 + "WiFi configureren", // 298 + "Verborgen netwerk", // 299 + "WiFi netwerknaam", // 300 + "Voer SSID in of klik op een netwerk", // 301 + "Wachtwoord", // 302 + "Voer wachtwoord in", // 303 + "Opslaan en verbinden", // 304 + "Opnieuw zoeken", // 305 + "Verbinden met", // 306 + "Verbonden met", // 307 + "Je kunt deze pagina sluiten.", // 308 + "Kan niet verbinden met", // 309 + "Klik hier om opnieuw te proberen", // 310 + "Opties", // 311 + "Selecteer WiFi", // 312 + "Geen netwerken gevonden. Ververs om opnieuw te zoeken.", // 313 + "Gegevens opgeslagen", // 314 + "Voer XDRGTK wachtwoord (max 8 karakters) in", // 315 + "ID" // 316 }, { "Polski", // Polish @@ -919,7 +959,27 @@ static const char* const Languages[22][297] PROGMEM = { "Auto czas letni wg NTP", // 293 "Strefa czasowa", // 294 "Wykaz zawiera ponad 130 wpisów, których przeglądarka nie może pokazać. Pobierz plik CSV, aby je przetworzyć.", // 295 - "Kanada" // 296 + "Kanada", // 296 + "Połącz to urządzenie z siecią WiFi, aby włączyć funkcje zdalne.", // 297 + "Konfiguruj WiFi", // 298 + "Ukryta sieć", // 299 + "Nazwa sieci WiFi", // 300 + "Wpisz SSID lub wybierz sieć powyżej", // 301 + "Hasło", // 302 + "Wpisz hasło", // 303 + "Zapisz i połącz", // 304 + "Skanuj ponownie", // 305 + "Łączenie z", // 306 + "Połączono z", // 307 + "Możesz teraz zamknąć tę stronę.", // 308 + "Nie można połączyć z", // 309 + "Kliknij tutaj, aby spróbować ponownie", // 310 + "Opcje", // 311 + "Wybierz WiFi", // 312 + "Nie znaleziono sieci. Odśwież, aby skanować ponownie.", // 313 + "Dane zapisane", // 314 + "Ustaw hasło XDRGTK (maks. 8 znaków)", // 315 + "ID" // 316 }, { "Hrvatski", // Croatian @@ -1218,7 +1278,27 @@ static const char* const Languages[22][297] PROGMEM = { "Auto DST na NTP vremenu", // 293 "postaviti pomak vremenske zone", // 294 "Dnevnik sadrži preko 130 unosa, koje preglednik ne može obraditi. Preuzmite CSV datoteku za obradu.", // 295 - "Canada" // 296 + "Canada", // 296 + "Povežite ovaj uređaj na WiFi mrežu za omogućavanje daljinskih funkcija.", // 297 + "Konfiguriraj WiFi", // 298 + "Skrivena mreža", // 299 + "Naziv WiFi mreže", // 300 + "Unesite SSID ili odaberite mrežu iznad", // 301 + "Lozinka", // 302 + "Unesite lozinku", // 303 + "Spremi i poveži", // 304 + "Skeniraj ponovo", // 305 + "Povezivanje na", // 306 + "Povezano na", // 307 + "Sada možete zatvoriti ovu stranicu.", // 308 + "Nije moguće povezati se na", // 309 + "Kliknite ovdje za ponovni pokušaj", // 310 + "Opcije", // 311 + "Odaberi WiFi", // 312 + "Mreže nisu pronađene. Osvježite za ponovno skeniranje.", // 313 + "Podaci spremljeni", // 314 + "Postavi XDRGTK lozinku (maks. 8 znakova)", // 315 + "ID" // 316 }, { "Ελληνικά", // Greek @@ -1517,7 +1597,27 @@ static const char* const Languages[22][297] PROGMEM = { "Αυτόματο DST\nσε ώρα NTP", // 293 "Ορισμός ζώνης ώρας", // 294 "Το βιβλίο περιέχει πάνω από 130 καταγραφές, και είναι αδύνατη η επεξεργασία τους από το χρήστη. Κάντε λήψη του αρχείου CSV για να το επεξεργαστείτε.", // 295 - "Καναδάς" // 296 + "Καναδάς", // 296 + "Συνδέστε αυτή τη συσκευή σε δίκτυο WiFi για ενεργοποίηση λειτουργιών.", // 297 + "Ρύθμιση WiFi", // 298 + "Κρυφό δίκτυο", // 299 + "Όνομα δικτύου WiFi", // 300 + "Εισάγετε SSID ή επιλέξτε δίκτυο", // 301 + "Κωδικός πρόσβασης", // 302 + "Εισάγετε κωδικό", // 303 + "Αποθήκευση και σύνδεση", // 304 + "Σάρωση ξανά", // 305 + "Σύνδεση με", // 306 + "Συνδεδεμένο με", // 307 + "Μπορείτε να κλείσετε αυτή τη σελίδα.", // 308 + "Αδύνατη η σύνδεση με", // 309 + "Κάντε κλικ εδώ για να ξαναδοκιμάσετε", // 310 + "Επιλογές", // 311 + "Επιλογή WiFi", // 312 + "Δεν βρέθηκαν δίκτυα. Ανανεώστε για σάρωση.", // 313 + "Στοιχεία αποθηκεύτηκαν", // 314 + "Ορισμός κωδικού XDRGTK (μέγ. 8 χαρακτήρες)", // 315 + "ID" // 316 }, { "Română", // Romanian @@ -1816,7 +1916,27 @@ static const char* const Languages[22][297] PROGMEM = { "Auto DST pe ora NTP", // 293 "Setați fusul orar", // 294 "Jurnalul conține peste 130 de intrări, pe care vizualizatorul nu le poate procesa. Te rog descarcă fișierul CSV pentru a le procesa.", // 295 - "Canada" // 296 + "Canada", // 296 + "Conectați acest dispozitiv la o rețea WiFi pentru a activa funcțiile la distanță.", // 297 + "Configurare WiFi", // 298 + "Rețea ascunsă", // 299 + "Numele rețelei WiFi", // 300 + "Introduceți SSID sau selectați o rețea", // 301 + "Parolă", // 302 + "Introduceți parola", // 303 + "Salvează și conectează", // 304 + "Scanează din nou", // 305 + "Conectare la", // 306 + "Conectat la", // 307 + "Puteți închide această pagină.", // 308 + "Nu s-a putut conecta la", // 309 + "Apăsați aici pentru a încerca din nou", // 310 + "Opțiuni", // 311 + "Selectați WiFi", // 312 + "Nu s-au găsit rețele. Reîmprospătați pentru a scana din nou.", // 313 + "Date salvate", // 314 + "Setați parola XDRGTK (max. 8 caractere)", // 315 + "ID" // 316 }, { "Deutsch", // German @@ -2115,7 +2235,27 @@ static const char* const Languages[22][297] PROGMEM = { "Auto-Sommerzeit\nüber NTP", // 293 "Zeitzone einstellen", // 294 "Das Logbuch enthält mehr als 130 Einträge, was das Anzeigeprogramm nicht verarbeiten kann. Bitte lade die CSV-Datei zum Verarbeiten herunter.", // 295 - "Kanada" // 296 + "Kanada", // 296 + "Verbinden Sie dieses Gerät mit einem WiFi-Netzwerk, um Fernfunktionen zu aktivieren.", // 297 + "WiFi konfigurieren", // 298 + "Verstecktes Netzwerk", // 299 + "WiFi-Netzwerkname", // 300 + "SSID eingeben oder Netzwerk oben wählen", // 301 + "Passwort", // 302 + "Passwort eingeben", // 303 + "Speichern und verbinden", // 304 + "Erneut scannen", // 305 + "Verbinde mit", // 306 + "Verbunden mit", // 307 + "Sie können diese Seite jetzt schließen.", // 308 + "Verbindung fehlgeschlagen mit", // 309 + "Hier klicken, um es erneut zu versuchen", // 310 + "Optionen", // 311 + "WiFi auswählen", // 312 + "Keine Netzwerke gefunden. Aktualisieren zum erneuten Scannen.", // 313 + "Zugangsdaten gespeichert", // 314 + "XDRGTK-Passwort festlegen (max. 8 Zeichen)", // 315 + "ID" // 316 }, { "Čeština", // Czech @@ -2414,7 +2554,27 @@ static const char* const Languages[22][297] PROGMEM = { "Auto DST u NTP času", // 293 "Nastavit časové pásmo", // 294 "Logbook obsahuje více než 130 položek, které prohlížeč nedokáže zpracovat. Pro zpracování všech položek si stáhněte CSV soubor.", // 295 - "Canada" // 296 + "Canada", // 296 + "Připojte toto zařízení k WiFi síti pro povolení vzdálených funkcí.", // 297 + "Konfigurace WiFi", // 298 + "Skrytá síť", // 299 + "Název WiFi sítě", // 300 + "Zadejte SSID nebo vyberte síť výše", // 301 + "Heslo", // 302 + "Zadejte heslo", // 303 + "Uložit a připojit", // 304 + "Znovu skenovat", // 305 + "Připojování k", // 306 + "Připojeno k", // 307 + "Nyní můžete tuto stránku zavřít.", // 308 + "Nelze se připojit k", // 309 + "Klikněte zde pro opakování pokusu", // 310 + "Možnosti", // 311 + "Vyberte WiFi", // 312 + "Žádné sítě nenalezeny. Obnovte pro opakované skenování.", // 313 + "Údaje uloženy", // 314 + "Nastavte heslo XDRGTK (max. 8 znaků)", // 315 + "ID" // 316 }, { "Magyar", // Hungarian @@ -2713,7 +2873,27 @@ static const char* const Languages[22][297] PROGMEM = { "Auto nyári idő(DST)\nNTP idő szerint", // 293 "Állítsa be az időzónát", // 294 "A napló több mint 130 bejegyzést tartalmaz, amelyeket a megtekintő nem tud feldolgozni. Kérlek, töltsd le a CSV fájlt a megtekintéshez.", // 295 - "Kanada" // 296 + "Kanada", // 296 + "Csatlakoztassa ezt az eszközt egy WiFi hálózathoz a távoli funkciók engedélyezéséhez.", // 297 + "WiFi beállítása", // 298 + "Rejtett hálózat", // 299 + "WiFi hálózat neve", // 300 + "Írja be az SSID-t vagy válasszon hálózatot fent", // 301 + "Jelszó", // 302 + "Írja be a jelszót", // 303 + "Mentés és csatlakozás", // 304 + "Újraszkennelés", // 305 + "Csatlakozás a következőhöz", // 306 + "Csatlakoztatva a következőhöz", // 307 + "Most már bezárhatja ezt az oldalt.", // 308 + "Nem sikerült csatlakozni a következőhöz", // 309 + "Kattintson ide az újrapróbálkozáshoz", // 310 + "Beállítások", // 311 + "WiFi kiválasztása", // 312 + "Nem található hálózat. Frissítse az újraszkenneléshez.", // 313 + "Adatok mentve", // 314 + "Állítsa be az XDRGTK jelszót (max. 8 karakter)", // 315 + "ID" // 316 }, { "Français", // French @@ -3012,7 +3192,27 @@ static const char* const Languages[22][297] PROGMEM = { "DST automatique\nsur l'heure NTP", // 293 "Définir le fuseau horaire", // 294 "Le journal de bord contient plus de 130 entrées que la liste ne peut pas afficher. Veuillez télécharger le fichier CSV.", // 295 - "Canada" // 296 + "Canada", // 296 + "Connectez cet appareil à un réseau WiFi pour activer les fonctions à distance.", // 297 + "Configurer le WiFi", // 298 + "Réseau caché", // 299 + "Nom du réseau WiFi", // 300 + "Entrez le SSID ou sélectionnez un réseau", // 301 + "Mot de passe", // 302 + "Entrez le mot de passe", // 303 + "Enregistrer et connecter", // 304 + "Scanner à nouveau", // 305 + "Connexion à", // 306 + "Connecté à", // 307 + "Vous pouvez maintenant fermer cette page.", // 308 + "Impossible de se connecter à", // 309 + "Cliquez ici pour réessayer", // 310 + "Options", // 311 + "Sélectionner le WiFi", // 312 + "Aucun réseau trouvé. Actualisez pour scanner à nouveau.", // 313 + "Identifiants enregistrés", // 314 + "Définir le mot de passe XDRGTK (max. 8 caractères)", // 315 + "ID" // 316 }, { "Български", // Bulgarian @@ -3311,7 +3511,27 @@ static const char* const Languages[22][297] PROGMEM = { "Автоматично лятно\nвреме по NTP", // 293 "Задаване на часова зона", // 294 "Дневникът съдържа над 130 записа, които не могат да бъдат обработени. Моля, изтеглете CSV файла за обработка.", // 295 - "Канада" // 296 + "Канада", // 296 + "Свържете това устройство към WiFi мрежа за отдалечени функции.", // 297 + "Настройка на WiFi", // 298 + "Скрита мрежа", // 299 + "Име на WiFi мрежа", // 300 + "Въведете SSID или изберете мрежа", // 301 + "Парола", // 302 + "Въведете парола", // 303 + "Запази и свържи", // 304 + "Сканиране отново", // 305 + "Свързване към", // 306 + "Свързан към", // 307 + "Можете да затворите тази страница.", // 308 + "Не може да се свърже към", // 309 + "Натиснете тук за нов опит", // 310 + "Опции", // 311 + "Изберете WiFi", // 312 + "Не са намерени мрежи. Опреснете за сканиране.", // 313 + "Данните са запазени", // 314 + "Задайте парола за XDRGTK (макс. 8 знака)", // 315 + "ID" // 316 }, { "Русский", // Russian @@ -3610,7 +3830,27 @@ static const char* const Languages[22][297] PROGMEM = { "Автоматическое летнее время по NTP", // 293 "Установить часовой пояс", // 294 "В логе более 130 записей, которые программа просмотра не может обработать. Загрузите файл CSV для его обработки.", // 295 - "Канада" // 296 + "Канада", // 296 + "Подключите это устройство к сети WiFi для включения удалённых функций.", // 297 + "Настройка WiFi", // 298 + "Скрытая сеть", // 299 + "Имя сети WiFi", // 300 + "Введите SSID или выберите сеть выше", // 301 + "Пароль", // 302 + "Введите пароль", // 303 + "Сохранить и подключить", // 304 + "Сканировать снова", // 305 + "Подключение к", // 306 + "Подключено к", // 307 + "Теперь вы можете закрыть эту страницу.", // 308 + "Не удалось подключиться к", // 309 + "Нажмите здесь, чтобы попробовать снова", // 310 + "Настройки", // 311 + "Выбор WiFi", // 312 + "Сети не найдены. Обновите для повторного сканирования.", // 313 + "Данные сохранены", // 314 + "Установите пароль XDRGTK (макс. 8 символов)", // 315 + "ID" // 316 }, { "Українська", // Ukranian @@ -3909,7 +4149,27 @@ static const char* const Languages[22][297] PROGMEM = { "Автоматичний літній\nчас за NTP", // 293 "Встановити часовий пояс", // 294 "Журнал містить понад 130 записів, які оглядач не може обробити. Будь ласка, завантажте файл CSV, щоб обробити його.", // 295 - "Канада" // 296 + "Канада", // 296 + "Підключіть цей пристрій до мережі WiFi для увімкнення віддалених функцій.", // 297 + "Налаштування WiFi", // 298 + "Прихована мережа", // 299 + "Назва мережі WiFi", // 300 + "Введіть SSID або оберіть мережу вище", // 301 + "Пароль", // 302 + "Введіть пароль", // 303 + "Зберегти і підключити", // 304 + "Сканувати знову", // 305 + "Підключення до", // 306 + "Підключено до", // 307 + "Тепер ви можете закрити цю сторінку.", // 308 + "Не вдалося підключитися до", // 309 + "Натисніть тут, щоб спробувати знову", // 310 + "Налаштування", // 311 + "Вибір WiFi", // 312 + "Мережі не знайдено. Оновіть для повторного сканування.", // 313 + "Дані збережено", // 314 + "Встановіть пароль XDRGTK (макс. 8 символів)", // 315 + "ID" // 316 }, { "Italiano", // Italian @@ -4208,7 +4468,27 @@ static const char* const Languages[22][297] PROGMEM = { "Auto DST su tempo NTP", // 293 "Imposta il fuso orario", // 294 "Registro dei log con + di 130 voci, il visualizzatore non può gestirle. Scarica il file CSV per gestirlo.", // 295 - "Canada" // 296 + "Canada", // 296 + "Collega questo dispositivo a una rete WiFi per abilitare le funzioni remote.", // 297 + "Configura WiFi", // 298 + "Rete nascosta", // 299 + "Nome rete WiFi", // 300 + "Inserisci SSID o seleziona una rete sopra", // 301 + "Password", // 302 + "Inserisci password", // 303 + "Salva e connetti", // 304 + "Scansiona di nuovo", // 305 + "Connessione a", // 306 + "Connesso a", // 307 + "Ora puoi chiudere questa pagina.", // 308 + "Impossibile connettersi a", // 309 + "Clicca qui per riprovare", // 310 + "Opzioni", // 311 + "Seleziona WiFi", // 312 + "Nessuna rete trovata. Aggiorna per scansionare di nuovo.", // 313 + "Credenziali salvate", // 314 + "Imposta password XDRGTK (max. 8 caratteri)", // 315 + "ID" // 316 }, { "Simplified Chinese", // Simplified Chinese @@ -4507,7 +4787,27 @@ static const char* const Languages[22][297] PROGMEM = { "联网自动同步本机时间", // 293 "设置时区", // 294 "该日志包含超过130个条目,观看者无法处理。请下载CSV文件进行处理。", // 295 - "加拿大" // 296 + "加拿大", // 296 + "将此设备连接到WiFi网络以启用远程功能。", // 297 + "配置WiFi", // 298 + "隐藏网络", // 299 + "WiFi网络名称", // 300 + "输入SSID或选择上方网络", // 301 + "密码", // 302 + "输入密码", // 303 + "保存并连接", // 304 + "重新扫描", // 305 + "正在连接", // 306 + "已连接到", // 307 + "您现在可以关闭此页面。", // 308 + "无法连接到", // 309 + "点击此处重试", // 310 + "选项", // 311 + "选择WiFi", // 312 + "未找到网络。刷新以重新扫描。", // 313 + "凭据已保存", // 314 + "设置XDRGTK密码(最多8个字符)", // 315 + "ID" // 316 }, { "Norsk", // Norwegian @@ -4806,7 +5106,27 @@ static const char* const Languages[22][297] PROGMEM = { "Auto sommertid med NTP", // 293 "Angi tidssone", // 294 "Loggbok har over 130 oppføringer.\nLast ned CSV for behandling.", // 295 - "Canada" // 296 + "Canada", // 296 + "Koble denne enheten til et WiFi-nettverk for å aktivere fjernfunksjoner.", // 297 + "Konfigurer WiFi", // 298 + "Skjult nettverk", // 299 + "WiFi-nettverksnavn", // 300 + "Skriv inn SSID eller velg et nettverk ovenfor", // 301 + "Passord", // 302 + "Skriv inn passord", // 303 + "Lagre og koble til", // 304 + "Skann på nytt", // 305 + "Kobler til", // 306 + "Koblet til", // 307 + "Du kan nå lukke denne siden.", // 308 + "Kunne ikke koble til", // 309 + "Klikk her for å prøve igjen", // 310 + "Alternativer", // 311 + "Velg WiFi", // 312 + "Ingen nettverk funnet. Oppdater for å skanne på nytt.", // 313 + "Legitimasjon lagret", // 314 + "Sett XDRGTK-passord (maks. 8 tegn)", // 315 + "ID" // 316 }, { "Español", // Spanish @@ -5105,7 +5425,27 @@ static const char* const Languages[22][297] PROGMEM = { "DST automático (NTP)", // 293 "Establecer zona horaria", // 294 "El registro tiene +130 entradas.\nDescargue el CSV.", // 295 - "Canadá" // 296 + "Canadá", // 296 + "Conecte este dispositivo a una red WiFi para habilitar las funciones remotas.", // 297 + "Configurar WiFi", // 298 + "Red oculta", // 299 + "Nombre de red WiFi", // 300 + "Ingrese SSID o seleccione una red arriba", // 301 + "Contraseña", // 302 + "Ingrese contraseña", // 303 + "Guardar y conectar", // 304 + "Escanear de nuevo", // 305 + "Conectando a", // 306 + "Conectado a", // 307 + "Ahora puede cerrar esta página.", // 308 + "No se pudo conectar a", // 309 + "Haga clic aquí para intentar de nuevo", // 310 + "Opciones", // 311 + "Seleccionar WiFi", // 312 + "No se encontraron redes. Actualice para escanear de nuevo.", // 313 + "Credenciales guardadas", // 314 + "Establecer contraseña XDRGTK (máx. 8 caracteres)", // 315 + "ID" // 316 }, { "Português", // Portuguese @@ -5404,7 +5744,27 @@ static const char* const Languages[22][297] PROGMEM = { "DST automático\nno horário NTP", // 293 "Definir fuso horário", // 294 "O diário de bordo contém mais de 130 entradas que o espectador não consegue processar. Descarregue o ficheiro CSV para processá-lo.", // 295 - "Canadá" // 296 + "Canadá", // 296 + "Conecte este dispositivo a uma rede WiFi para ativar recursos remotos.", // 297 + "Configurar WiFi", // 298 + "Rede oculta", // 299 + "Nome da rede WiFi", // 300 + "Digite o SSID ou selecione uma rede acima", // 301 + "Senha", // 302 + "Digite a senha", // 303 + "Salvar e conectar", // 304 + "Escanear novamente", // 305 + "Conectando a", // 306 + "Conectado a", // 307 + "Agora você pode fechar esta página.", // 308 + "Não foi possível conectar a", // 309 + "Clique aqui para tentar novamente", // 310 + "Opções", // 311 + "Selecionar WiFi", // 312 + "Nenhuma rede encontrada. Atualize para escanear novamente.", // 313 + "Credenciais salvas", // 314 + "Definir senha XDRGTK (máx. 8 caracteres)", // 315 + "ID" // 316 }, { "Srpski", // Serbian @@ -5703,7 +6063,27 @@ static const char* const Languages[22][297] PROGMEM = { "Auto DST na\nNTP vremenu", // 293 "Podesite vremensku zonu", // 294 "Dnevnik sadrži više od 130 unosa, što viewer ne može obraditi. Preuzmite CSV fajl za obradu.", // 295 - "Canada" // 296 + "Canada", // 296 + "Повежите овај уређај на WiFi мрежу за омогућавање даљинских функција.", // 297 + "Конфигурација WiFi", // 298 + "Скривена мрежа", // 299 + "Назив WiFi мреже", // 300 + "Унесите SSID или изаберите мрежу изнад", // 301 + "Лозинка", // 302 + "Унесите лозинку", // 303 + "Сачувај и повежи", // 304 + "Скенирај поново", // 305 + "Повезивање са", // 306 + "Повезано са", // 307 + "Сада можете затворити ову страницу.", // 308 + "Није могуће повезати се са", // 309 + "Кликните овде да покушате поново", // 310 + "Опције", // 311 + "Изаберите WiFi", // 312 + "Мреже нису пронађене. Освежите за поновно скенирање.", // 313 + "Подаци сачувани", // 314 + "Поставите XDRGTK лозинку (макс. 8 знакова)", // 315 + "ID" // 316 }, { "Suomi", // Finnish @@ -6002,7 +6382,27 @@ static const char* const Languages[22][297] PROGMEM = { "Auto DST\nNTP-ajassa", // 293 "Aseta aikavyöhyke", // 294 "Lokikirja sisältää yli 130 merkintää, joita katselija ei pysty käsittelemään. Lataa CSV-tiedosto sen käsittelemiseksi.", // 295 - "Kanada" // 296 + "Kanada", // 296 + "Yhdistä tämä laite WiFi-verkkoon etäominaisuuksien käyttöön ottamiseksi.", // 297 + "Määritä WiFi", // 298 + "Piilotettu verkko", // 299 + "WiFi-verkon nimi", // 300 + "Syötä SSID tai valitse verkko ylhäältä", // 301 + "Salasana", // 302 + "Syötä salasana", // 303 + "Tallenna ja yhdistä", // 304 + "Skannaa uudelleen", // 305 + "Yhdistetään kohteeseen", // 306 + "Yhdistetty kohteeseen", // 307 + "Voit nyt sulkea tämän sivun.", // 308 + "Ei voitu yhdistää kohteeseen", // 309 + "Napsauta tästä yrittääksesi uudelleen", // 310 + "Asetukset", // 311 + "Valitse WiFi", // 312 + "Verkkoja ei löydetty. Päivitä skannataksesi uudelleen.", // 313 + "Tunnukset tallennettu", // 314 + "Aseta XDRGTK-salasana (enint. 8 merkkiä)", // 315 + "ID" // 316 }, { "Dansk", // Danish @@ -6301,7 +6701,27 @@ static const char* const Languages[22][297] PROGMEM = { "Auto DST på\nNTP-tid", // 293 "Indstil tidszone", // 294 "Logbogen indeholder over 130 poster, som fremviseren ikke kan behandle. Download CSV-filen for at behandle den.", // 295 - "Canada" // 296 + "Canada", // 296 + "Forbind denne enhed til et WiFi-netværk for at aktivere fjernfunktioner.", // 297 + "Konfigurer WiFi", // 298 + "Skjult netværk", // 299 + "WiFi-netværksnavn", // 300 + "Indtast SSID eller vælg et netværk ovenfor", // 301 + "Adgangskode", // 302 + "Indtast adgangskode", // 303 + "Gem og forbind", // 304 + "Scan igen", // 305 + "Forbinder til", // 306 + "Forbundet til", // 307 + "Du kan nu lukke denne side.", // 308 + "Kunne ikke forbinde til", // 309 + "Klik her for at prøve igen", // 310 + "Indstillinger", // 311 + "Vælg WiFi", // 312 + "Ingen netværk fundet. Opdater for at scanne igen.", // 313 + "Legitimationsoplysninger gemt", // 314 + "Indstil XDRGTK-adgangskode (maks. 8 tegn)", // 315 + "ID" // 316 }, { "Svenska", // Swedish @@ -6600,6 +7020,26 @@ static const char* const Languages[22][297] PROGMEM = { "Auto NTP sommartid", // 293 "Ställ in tidszon", // 294 "Loggboken har mer än 130 poster, vilket visaren inte kan hantera. Ladda ner CSV för behandling.", // 295 - "Kanada" // 296 + "Kanada", // 296 + "Anslut denna enhet till ett WiFi-nätverk för att aktivera fjärrfunktioner.", // 297 + "Konfigurera WiFi", // 298 + "Dolt nätverk", // 299 + "WiFi-nätverksnamn", // 300 + "Ange SSID eller välj ett nätverk ovan", // 301 + "Lösenord", // 302 + "Ange lösenord", // 303 + "Spara och anslut", // 304 + "Skanna igen", // 305 + "Ansluter till", // 306 + "Ansluten till", // 307 + "Du kan nu stänga denna sida.", // 308 + "Kunde inte ansluta till", // 309 + "Klicka här för att försöka igen", // 310 + "Alternativ", // 311 + "Välj WiFi", // 312 + "Inga nätverk hittades. Uppdatera för att skanna igen.", // 313 + "Uppgifter sparade", // 314 + "Ställ in XDRGTK-lösenord (max. 8 tecken)", // 315 + "ID" // 316 } }; \ No newline at end of file diff --git a/lib/WiFiConnect/LICENSE b/lib/WiFiConnect/LICENSE deleted file mode 100644 index 61d1860..0000000 --- a/lib/WiFiConnect/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ -GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. \ No newline at end of file diff --git a/lib/WiFiConnect/WC_AP_HTML.h b/lib/WiFiConnect/WC_AP_HTML.h deleted file mode 100644 index e6a6be8..0000000 --- a/lib/WiFiConnect/WC_AP_HTML.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once - -/*! \def char AP_HTTP_HEAD[] PROGMEM -Start of HTML output - */ -const char AP_HTTP_HEAD[] PROGMEM = "{v}"; -/*! \def AP_HTTP_STYLE[] PROGMEM -Style for our access point -*/ -const char AP_HTTP_STYLE[] PROGMEM = ""; -/** Scripts for our page */ -const char AP_HTTP_SCRIPT[] PROGMEM = ""; -/** End of the header section and beginning of the body */ -const char AP_HTTP_HEAD_END[] PROGMEM = "
"; -/** Start of our HTMl configuration Form */ -const char AP_HTTP_PORTAL_OPTIONS[] PROGMEM = "
Connect this device to a WiFi network. Select the option to find a WiFi network.

"; -/** HTML snippet for wifi scanning */ -const char AP_HTTP_ITEM[] PROGMEM = "
{v} {r}%
"; -/** HTML form for saving wifi connection details */ -const char AP_HTTP_FORM_START[] PROGMEM ="

";; -/** HTML snippet for our custom parameters */ -const char AP_HTTP_FORM_PARAM[] PROGMEM = "
"; -/** The end of our HTML Form */ -const char AP_HTTP_FORM_END[] PROGMEM = "
"; -/** HTML snippet to recan for networks */ -const char AP_HTTP_SCAN_LINK[] PROGMEM = "
"; -/** HTML snippet for saved confirmation */ -// https://stackoverflow.com/questions/20760635/why-does-setting-xmlhttprequest-responsetype-before-calling-open-throw -// https://esprima.org/demo/validate.html -// https://javascript-minifier.com/ - -/* Use JavaScript to ping the ESP periodically @ the AP IP address. - * If it comes back as an AP again then we know the connection to the WiFi didn't work. - * We wait about 30 seconds to determine this outcome. This isn't 100% foolproof, but should be good enough. -*/ -/* - -*/ -const char AP_HTTP_SAVED[] PROGMEM = "
Credentials Saved.
Attempting to connect to WiFi network. Please wait....
Connected to {ap} !
You may now close this window.
Failed to connect to {ap}!
Click here to try again.
"; -/** End of the HTML page */ -const char AP_HTTP_END[] PROGMEM = "
"; -/** HTML snippet for our custom parameters portal form */ -const char AP_HTTP_PORTAL_PARAM_OPTIONS[] PROGMEM = "


"; -/** HTML snippet for our custom parameters save */ -const char AP_HTTP_FORM_PARAM_START[] PROGMEM ="
"; \ No newline at end of file diff --git a/lib/WiFiConnect/WiFiConnect.cpp b/lib/WiFiConnect/WiFiConnect.cpp deleted file mode 100644 index 44f2123..0000000 --- a/lib/WiFiConnect/WiFiConnect.cpp +++ /dev/null @@ -1,667 +0,0 @@ -#include "WiFiConnect.h" - -WiFiConnect::WiFiConnect() { - _apName[0]='\0'; - _apPassword[0]='\0'; -} - -void WiFiConnect::setAPModeTimeoutMins(int mins) { - if (mins > 0) _apTimeoutMins = mins; -} - -void WiFiConnect::setAPName(const char *apName) { - if(strlen(apName)>32) return; - if(strlen(apName) == 0 || (apName == NULL)) { - String ssid = "ESP_" + String(ESP_getChipId()); - strcpy(_apName,ssid.c_str()); - } else if (apName != NULL && strlen(apName)>0) strcpy(_apName,apName); -} - -const char* WiFiConnect::getAPName() { - if ((_apName == NULL ) || strlen(_apName)==0) setAPName(NULL); - return _apName; -} - -void WiFiConnect::addParameter(WiFiConnectParam *p) { - _params[_paramsCount] = p; - _paramsCount++; -} - -boolean WiFiConnect::startConfigurationPortal() { - return startConfigurationPortal(_apName, _apPassword); -} - -boolean WiFiConnect::startConfigurationPortal(const char *apName, const char *apPassword, bool paramsMode) { - _lastAPPage = millis(); - - delay(50); // Huh? - - if (WiFi.status() != WL_CONNECTED) { - if (paramsMode) startConfigurationPortal(apName, apPassword, false); - else WiFi.mode(WIFI_AP); - } else WiFi.mode(WIFI_AP_STA); // start an access point on the same channel we're already connected to. - dnsServer.reset(new DNSServer()); - server.reset(new WebServer(80)); - setAPName(apName); - - if (strlen(apPassword)>0){ - if (strlen(apPassword) < 8 || strlen(apPassword) > 63) apPassword = NULL; - strcpy(_apPassword,apPassword); - } - - if (_ap_static_ip) WiFi.softAPConfig(_ap_static_ip, _ap_static_gw, _ap_static_sn); - - if(strlen(apPassword) > 0) WiFi.softAP(_apName, _apPassword);//password option - else WiFi.softAP(_apName); - - delay(450); - - dnsServer->setErrorReplyCode(DNSReplyCode::NoError); - dnsServer->start(53, "*", WiFi.softAPIP()); - - if (paramsMode) { - server->on("/", std::bind(&WiFiConnect::handleParamRoot, this)); - server->on("/param", std::bind(&WiFiConnect::handleParams, this)); - server->on("/params", std::bind(&WiFiConnect::handleParams, this)); - server->on("/wifisave", std::bind(&WiFiConnect::handleWifiSave, this)); - server->on("/i", std::bind(&WiFiConnect::handleInfo, this)); - server->on("/fwlink", std::bind(&WiFiConnect::handleParamRoot, this)); //Microsoft captive portal. Maybe not needed. Might be handled by notFound handler. - server->on("/hotspot_detect.html", std::bind(&WiFiConnect::handleParamRoot, this)); - } else { // Config portal mode - server->on("/", std::bind(&WiFiConnect::handleRoot, this)); - server->on("/wifi", std::bind(&WiFiConnect::handleWifi, this, true)); // Auto Scan of APs - server->on("/0wifi", std::bind(&WiFiConnect::handleWifi, this, false)); // Manual entry form only - server->on("/wifisave", std::bind(&WiFiConnect::handleWifiSave, this)); - server->on("/i", std::bind(&WiFiConnect::handleInfo, this)); // Not of interest - commented out in static HTML - server->on("/r", std::bind(&WiFiConnect::handleReset, this)); - server->on("/fwlink", std::bind(&WiFiConnect::handleRoot, this)); //Microsoft captive portal. Maybe not needed. Might be handled by notFound handler. - server->on("/hotspot_detect.html", std::bind(&WiFiConnect::handleRoot, this)); - } // config portal - - server->onNotFound(std::bind(&WiFiConnect::handleNotFound, this)); - server->begin(); // Web server start - - _lastAPPage = millis(); - _readyToConnect = false; - while (true) { - dnsServer->processNextRequest(); - server->handleClient(); - if (_readyToConnect) { - _readyToConnect = false; - - if (autoConnect(_ssid.c_str(), _password.c_str(), WIFI_AP_STA)) { - - WiFi.mode(WIFI_STA); - delay(500); - break; // we connected! - } - } // ready to connect - - yield(); - } - - //teardown?? - server->close(); - server.reset(); - - dnsServer.reset(); - boolean con = (WiFi.status() == WL_CONNECTED); - if (!con) WiFi.mode(WIFI_STA); - return con; -} - -boolean WiFiConnect::autoConnect() { - return autoConnect(NULL, NULL, WIFI_STA); -} - -boolean WiFiConnect::autoConnect(char const *ssidName, char const *ssidPassword, WiFiMode_t acWiFiMode) { - WiFi.mode(acWiFiMode); - if (WiFi.status() == WL_CONNECTED) return true; - if (_sta_static_ip) WiFi.config(_sta_static_ip, _sta_static_gw, _sta_static_sn); - int c = 0; - while (c < _retryAttempts) { - long ms = millis(); - if (ssidName == NULL || strlen(ssidName)==0) { - wifi_config_t conf; - esp_wifi_get_config(WIFI_IF_STA, &conf); - - String stored_ssid = String(reinterpret_cast(conf.sta.ssid)); - if (stored_ssid == "") return false; - WiFi.begin(); // persistence is on by default, so if this WiFi connection should happen automatically - } else WiFi.begin(ssidName, ssidPassword); - - while (millis() - (unsigned long int)ms < ( (unsigned int)_connectionTimeoutSecs * 1000)) { - int ws = WiFi.status(); - if (ws == WL_CONNECTED) { - delay(500);//wait for ip to refresh - return true; - } else if (ws == WL_CONNECT_FAILED) { - delay(500); - } else { - delay(200); - yield(); - } - } c++; - } // attemps - return false; -} - -void WiFiConnect::setRetryAttempts(int attempts) { - if (attempts >= 1) { - _retryAttempts = attempts; - } -} - -void WiFiConnect::setConnectionTimeoutSecs(int timeout) { - if (timeout >= 1) _connectionTimeoutSecs = timeout; -} - -void WiFiConnect::resetSettings() { - WiFi.disconnect(true); - esp_wifi_restore(); - WiFi.begin("0", "0"); - delay(1000); - ESP.restart(); - delay(2000); -} - -const char* WiFiConnect::statusToString(int state) { - switch (state) { - case WL_CONNECTED: - return "WL_CONNECTED"; - case WL_CONNECT_FAILED: - return "WL_CONNECT_FAILED"; - case WL_CONNECTION_LOST: - return "WL_CONNECTION_LOST"; - case WL_DISCONNECTED: - return "WL_DISCONNECTED"; - case WL_SCAN_COMPLETED: - return "WL_SCAN_COMPLETED"; - case WL_NO_SSID_AVAIL: - return "WL_NO_SSID_AVAIL"; - case WL_IDLE_STATUS: - return "WL_IDLE_STATUS"; - case WL_NO_SHIELD: - return "WL_NO_SHIELD"; - default: - return "UNKNOWN CODE"; - } -} - -/**************************************************************************/ -/*! - @brief Handles the web request for root in the Parameters Portal and - sends back the html menu -*/ -/**************************************************************************/ -void WiFiConnect::handleParamRoot() { - if (captivePortal()) { // If captive portal redirect instead of displaying the page. - return; - } - _lastAPPage = millis(); - String page = FPSTR(AP_HTTP_HEAD); - page.replace("{v}", "Options"); - page += FPSTR(AP_HTTP_SCRIPT); - page += FPSTR(AP_HTTP_STYLE); - page += FPSTR(AP_HTTP_HEAD_END); - page += String(F("

")); - page += _apName; - page += String(F("

")); -// page += String(F("

WiFiConnect

")); - page += FPSTR(AP_HTTP_PORTAL_PARAM_OPTIONS); - page += FPSTR(AP_HTTP_END); - - server->sendHeader("Content-Length", String(page.length())); - server->send(200, "text/html", page); - -} -/**************************************************************************/ -/*! - @brief Handles the web request for displaying custom parameters - in the Parameters Portal and sends back the html -*/ -/**************************************************************************/ -void WiFiConnect::handleParams() { - _lastAPPage = millis(); - - String page = FPSTR(AP_HTTP_HEAD); - page.replace("{v}", "Config Params"); - page += FPSTR(AP_HTTP_SCRIPT); - page += FPSTR(AP_HTTP_STYLE); - page += FPSTR(AP_HTTP_HEAD_END); - page += FPSTR(AP_HTTP_FORM_PARAM_START); - char parLength[4]; - // add the extra parameters to the form - for (int i = 0; i < _paramsCount; i++) { - if (_params[i] == NULL) { - break; - } - - String pitem = FPSTR(AP_HTTP_FORM_PARAM); - if (_params[i]->getID() != NULL) { - pitem.replace("{i}", _params[i]->getID()); - pitem.replace("{n}", _params[i]->getID()); - pitem.replace("{p}", _params[i]->getPlaceholder()); - snprintf(parLength, 4, "%d", _params[i]->getValueLength()); - pitem.replace("{l}", parLength); - pitem.replace("{v}", _params[i]->getValue()); - pitem.replace("{c}", _params[i]->getCustomHTML()); - } else { - pitem = _params[i]->getCustomHTML(); - } - - page += pitem; - } - if (_params[0] != NULL) { - page += "
"; - } - - page += FPSTR(AP_HTTP_FORM_END); - - page += FPSTR(AP_HTTP_END); - - server->sendHeader("Content-Length", String(page.length())); - server->send(200, "text/html", page); -} -/**************************************************************************/ -/*! - @brief Handles the web request for displaying the menu in the - Access Point portal. -*/ -/**************************************************************************/ -void WiFiConnect::handleRoot() { - if (captivePortal()) { // If captive portal redirect instead of displaying the page. - return; - } - _lastAPPage = millis(); - String page = FPSTR(AP_HTTP_HEAD); - page.replace("{v}", "Options"); - page += FPSTR(AP_HTTP_SCRIPT); - page += FPSTR(AP_HTTP_STYLE); - page += FPSTR(AP_HTTP_HEAD_END); - page += String(F("

")); - page += _apName; - page += String(F("

")); - //page += String(F("

WiFiConnect

")); - page += FPSTR(AP_HTTP_PORTAL_OPTIONS); - page += FPSTR(AP_HTTP_END); - - server->sendHeader("Content-Length", String(page.length())); - server->send(200, "text/html", page); - - -} - -/**************************************************************************/ -/*! - @brief Handles the web request for entering the SSID and Password of - the network you want to connect too. - Optionally scans and shows available networks. - @param scan - Whether to scan for networks or not. -*/ -/**************************************************************************/ -void WiFiConnect::handleWifi(boolean scan) { - - _lastAPPage = millis(); - - String page = FPSTR(AP_HTTP_HEAD); - page.replace("{v}", "Select WiFi"); - page += FPSTR(AP_HTTP_SCRIPT); - page += FPSTR(AP_HTTP_STYLE); - page += FPSTR(AP_HTTP_HEAD_END); - - if (scan) { - int n = WiFi.scanNetworks(); - if (n == 0) { - page += F("No networks found. Refresh to scan again."); - } else { - - //sort networks - int indices[n]; - for (int i = 0; i < n; i++) { - indices[i] = i; - } - - // RSSI SORT - - // old sort - for (int i = 0; i < n; i++) { - for (int j = i + 1; j < n; j++) { - if (WiFi.RSSI(indices[j]) > WiFi.RSSI(indices[i])) { - std::swap(indices[i], indices[j]); - } - } - } - - String cssid; - for (int i = 0; i < n; i++) { - if (indices[i] == -1) continue; - cssid = WiFi.SSID(indices[i]); - for (int j = i + 1; j < n; j++) { - if (cssid == WiFi.SSID(indices[j])) { - indices[j] = -1; // set dup aps to index -1 - } - } - } - - //display networks in page - for (int i = 0; i < n; i++) { - if (indices[i] == -1) continue; // skip dups - int quality = getRSSIasQuality(WiFi.RSSI(indices[i])); - - if (_minimumQuality == -1 || _minimumQuality < quality) { - String item = FPSTR(AP_HTTP_ITEM); - String rssiQ; - rssiQ += quality; - item.replace("{v}", WiFi.SSID(indices[i])); - item.replace("{r}", rssiQ); -#if defined(ESP8266) - if (WiFi.encryptionType(indices[i]) != ENC_TYPE_NONE) { -#else - if (WiFi.encryptionType(indices[i]) != WIFI_AUTH_OPEN) { -#endif - item.replace("{i}", "l"); - } else { - item.replace("{i}", ""); - } - //DEBUG_WM(item); - page += item; - delay(0); - } - } - page += "
"; - } - } - - page += FPSTR(AP_HTTP_FORM_START); - char parLength[4]; - // add the extra parameters to the form - for (int i = 0; i < _paramsCount; i++) { - if (_params[i] == NULL) { - break; - } - - String pitem = FPSTR(AP_HTTP_FORM_PARAM); - if (_params[i]->getID() != NULL) { - pitem.replace("{i}", _params[i]->getID()); - pitem.replace("{n}", _params[i]->getID()); - pitem.replace("{p}", _params[i]->getPlaceholder()); - snprintf(parLength, 4, "%d", _params[i]->getValueLength()); - pitem.replace("{l}", parLength); - pitem.replace("{v}", _params[i]->getValue()); - pitem.replace("{c}", _params[i]->getCustomHTML()); - } else { - pitem = _params[i]->getCustomHTML(); - } - - page += pitem; - } - if (_params[0] != NULL) { - page += "
"; - } - - if (_sta_static_ip) { - - String item = FPSTR(AP_HTTP_FORM_PARAM); - item.replace("{i}", "ip"); - item.replace("{n}", "ip"); - item.replace("{p}", "Static IP"); - item.replace("{l}", "15"); - item.replace("{v}", _sta_static_ip.toString()); - - page += item; - - item = FPSTR(AP_HTTP_FORM_PARAM); - item.replace("{i}", "gw"); - item.replace("{n}", "gw"); - item.replace("{p}", "Static Gateway"); - item.replace("{l}", "15"); - item.replace("{v}", _sta_static_gw.toString()); - - page += item; - - item = FPSTR(AP_HTTP_FORM_PARAM); - item.replace("{i}", "sn"); - item.replace("{n}", "sn"); - item.replace("{p}", "Subnet"); - item.replace("{l}", "15"); - item.replace("{v}", _sta_static_sn.toString()); - - page += item; - - page += "
"; - } - - page += FPSTR(AP_HTTP_FORM_END); - page += FPSTR(AP_HTTP_SCAN_LINK); - - page += FPSTR(AP_HTTP_END); - - server->sendHeader("Content-Length", String(page.length())); - server->send(200, "text/html", page); -} -void WiFiConnect::handleWifiSave() { - _lastAPPage = millis(); - _ssid = server->arg("s").c_str(); - _ssid.trim(); - _password = server->arg("p").c_str(); - _password.trim(); - //parameters - for (int i = 0; i < _paramsCount; i++) { - if (_params[i] == NULL) { - break; - } - //read parameter - String value = server->arg(_params[i]->getID()).c_str(); - //store it in array - value.toCharArray(_params[i]->_value, _params[i]->_length); - } - - if (server->arg("ip") != "") { - //_sta_static_ip.fromString(server->arg("ip")); - String ip = server->arg("ip"); - optionalIPFromString(&_sta_static_ip, ip.c_str()); - } - if (server->arg("gw") != "") { - String gw = server->arg("gw"); - optionalIPFromString(&_sta_static_gw, gw.c_str()); - } - if (server->arg("sn") != "") { - String sn = server->arg("sn"); - optionalIPFromString(&_sta_static_sn, sn.c_str()); - } - - String page = FPSTR(AP_HTTP_HEAD); - page.replace("{v}", "Credentials Saved"); - page += FPSTR(AP_HTTP_SCRIPT); - page += FPSTR(AP_HTTP_STYLE); - page += FPSTR(AP_HTTP_HEAD_END); - page += FPSTR(AP_HTTP_SAVED); - page.replace("{ap}", _ssid); - page += FPSTR(AP_HTTP_END); - - server->sendHeader("Content-Length", String(page.length())); - server->send(200, "text/html", page); - _readyToConnect = true; -} -/**************************************************************************/ -/*! - @brief Handles the web request and shows basic information about the chip. - TODO: ESP32 information still needs completing. -*/ -/**************************************************************************/ -void WiFiConnect::handleInfo() { - _lastAPPage = millis(); - - String page = FPSTR(AP_HTTP_HEAD); - page.replace("{v}", "Info"); - page += FPSTR(AP_HTTP_SCRIPT); - page += FPSTR(AP_HTTP_STYLE); - page += FPSTR(AP_HTTP_HEAD_END); - page += F("
"); - page += F("
Chip ID
"); - page += ESP_getChipId(); - page += F("
"); - page += F("
Flash Chip ID
"); -#if defined(ESP8266) - page += ESP.getFlashChipId(); -#else - // TODO - page += F("TODO"); -#endif - page += F("
"); - page += F("
IDE Flash Size
"); - page += ESP.getFlashChipSize(); - page += F(" bytes
"); - page += F("
Real Flash Size
"); -#if defined(ESP8266) - page += ESP.getFlashChipRealSize(); -#else - // TODO - page += F("TODO"); -#endif - page += F(" bytes
"); - page += F("
Soft AP IP
"); - page += WiFi.softAPIP().toString(); - page += F("
"); - page += F("
Soft AP MAC
"); - page += WiFi.softAPmacAddress(); - page += F("
"); - page += F("
Station MAC
"); - page += WiFi.macAddress(); - page += F("
"); - page += F("
"); - page += FPSTR(AP_HTTP_END); - - server->sendHeader("Content-Length", String(page.length())); - server->send(200, "text/html", page); -} -/**************************************************************************/ -/*! - @brief Handles the reset web request and and restarts the chip. - Does not clear settings. -*/ -/**************************************************************************/ -void WiFiConnect::handleReset() { - _lastAPPage = millis(); - - String page = FPSTR(AP_HTTP_HEAD); - page.replace("{v}", "Info"); - page += FPSTR(AP_HTTP_SCRIPT); - page += FPSTR(AP_HTTP_STYLE); - page += FPSTR(AP_HTTP_HEAD_END); - page += F("Module will reset in a few seconds."); - page += FPSTR(AP_HTTP_END); - - server->sendHeader("Content-Length", String(page.length())); - server->send(200, "text/html", page); - - delay(5000); - ESP.restart(); - delay(2000); -} -/**************************************************************************/ -/*! - @brief Handles the 204 web request from Android devices -*/ -/**************************************************************************/ -void WiFiConnect::handle204() { - _lastAPPage = millis(); - handleRoot(); -} -/**************************************************************************/ -/*! - @brief Handles any web requests that are not found. -*/ -/**************************************************************************/ -void WiFiConnect::handleNotFound() { - if (captivePortal()) { // If captive portal redirect instead of displaying the error page. - return; - } - _lastAPPage = millis(); - String message = "File Not Found\n\n"; - message += "URI: "; - message += server->uri(); - message += "\nMethod: "; - message += ( server->method() == HTTP_GET ) ? "GET" : "POST"; - message += "\nArguments: "; - message += server->args(); - message += "\n"; - - for ( uint8_t i = 0; i < server->args(); i++ ) { - message += " " + server->argName ( i ) + ": " + server->arg ( i ) + "\n"; - } - server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); - server->sendHeader("Pragma", "no-cache"); - server->sendHeader("Expires", "-1"); - server->sendHeader("Content-Length", String(message.length())); - server->send ( 404, "text/plain", message ); -} - -/**************************************************************************/ -/*! - @brief Redirect to captive portal if we get a request for another domain. - Return true in that case so the page handler do not try to - handle the request again. - @return True if we have redirected to our portal, else false and contimue - to handle request -*/ -/**************************************************************************/ -boolean WiFiConnect::captivePortal() { - if (!isIp(server->hostHeader()) ) { - _lastAPPage = millis(); - String msg = "redirect\n"; - server->sendHeader("Location", String("http://") + toStringIp(server->client().localIP()), true); - server->sendHeader("Content-Length", String(msg.length())); - server->send ( 302, "text/plain", msg); // Empty content inhibits Content-length header so we have to close the socket ourselves. - //server->client().stop(); // Stop is needed because we sent no content length - - return true; - } - return false; -} - -int WiFiConnect::getRSSIasQuality(int RSSI) { - int quality = 0; - - if (RSSI <= -100) { - quality = 0; - } else if (RSSI >= -50) { - quality = 100; - } else { - quality = 2 * (RSSI + 100); - } - return quality; -} - -boolean WiFiConnect::isIp(String str) { - for (unsigned int i = 0; i < str.length(); i++) { - int c = str.charAt(i); - if (c != '.' && (c < '0' || c > '9')) { - return false; - } - } - return true; -} - -String WiFiConnect::toStringIp(IPAddress ip) { - String res = ""; - for (int i = 0; i < 3; i++) { - res += String((ip >> (8 * i)) & 0xFF) + "."; - } - res += String(((ip >> 8 * 3)) & 0xFF); - return res; -} - -void WiFiConnect::setAPStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn) { - _ap_static_ip = ip; - _ap_static_gw = gw; - _ap_static_sn = sn; -} - -void WiFiConnect::setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn) { - _sta_static_ip = ip; - _sta_static_gw = gw; - _sta_static_sn = sn; -} diff --git a/lib/WiFiConnect/WiFiConnect.h b/lib/WiFiConnect/WiFiConnect.h deleted file mode 100644 index c26de57..0000000 --- a/lib/WiFiConnect/WiFiConnect.h +++ /dev/null @@ -1,87 +0,0 @@ -#pragma once -#include -#include -#include -using fs::FS; -#include -#include -#include - -#include -#define ESP_getChipId() ((uint32_t)ESP.getEfuseMac())///< Gets an ID from the chip - -#include "WC_AP_HTML.h" -#include "WiFiConnectParam.h" - -class WiFiConnect { - public: - WiFiConnect(); - - boolean startConfigurationPortal(); - boolean startConfigurationPortal(const char* apName, const char* apPassword = NULL, bool paramsMode = false); - - void addParameter(WiFiConnectParam *p); - - void setAPName(const char* apName); - const char* getAPName(); - - void resetSettings(); - - boolean autoConnect(); - boolean autoConnect(const char* ssidName, const char* ssidPassword = NULL, WiFiMode_t acWiFiMode = WIFI_STA); - - void setAPStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn); - void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn); - - void setRetryAttempts(int attempts); - void setConnectionTimeoutSecs(int timeout); - void setAPModeTimeoutMins(int mins); - - boolean captivePortal(); - - //helpers - const char* statusToString(int state); - int getRSSIasQuality(int RSSI); - boolean isIp(String str); - String toStringIp(IPAddress ip); - private: - int _retryAttempts = 3; ///< Number of attempts when trying to connect to WiFi network - int _connectionTimeoutSecs = 10; ///< How log to wait for the connection to succeed or fail - int _apTimeoutMins = 3; ///< The amount of minutes of inactivity before the access point exits it routine - - long _lastAPPage = 0; - int _minimumQuality = 8; - int _paramsCount = 0; - boolean _readyToConnect = false; - String _ssid = " "; - String _password = " "; - - WiFiConnectParam* _params[WiFiConnect_MAX_PARAMS]; ///< Array to hold custom parameters - - std::unique_ptr dnsServer; - std::unique_ptr server; - - char _apName[33]; - char _apPassword[65]; - - IPAddress _ap_static_ip; ///< Variable for holding Static IP Address for the access point - IPAddress _ap_static_gw; ///< Variable for holding Static Gateway IP Address for the access point - IPAddress _ap_static_sn; ///< Variable for holding Static Subnet Mask IP Address for the access point - IPAddress _sta_static_ip; ///< Variable for holding Static IP Address for the network connection - IPAddress _sta_static_gw; ///< Variable for holding Static Gateway IP Address for the network connection - IPAddress _sta_static_sn; ///< Variable for holding Static Subnet Mask IP Address for the network connection - - void handleRoot(); - void handleParamRoot(); - void handleParams(); - void handleWifi(boolean scan); - void handleWifiSave(); - void handleInfo(); - void handleReset(); - void handle204(); - void handleNotFound(); - - template - auto optionalIPFromString(T *obj, const char *s) -> decltype(obj->fromString(s)) { return obj->fromString(s); } - bool optionalIPFromString(...) {return false;} -}; diff --git a/lib/WiFiConnect/WiFiConnectParam.cpp b/lib/WiFiConnect/WiFiConnectParam.cpp deleted file mode 100644 index 268e84c..0000000 --- a/lib/WiFiConnect/WiFiConnectParam.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "WiFiConnectParam.h" - -WiFiConnectParam::WiFiConnectParam(const char *custom) { - _id = NULL; - _placeholder = NULL; - _length = 0; - _value = NULL; - - _customHTML = custom; -} - -WiFiConnectParam::WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length) { - init(id, placeholder, defaultValue, length, ""); -} -WiFiConnectParam::WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom) { - init(id, placeholder, defaultValue, length, custom); -} - -void WiFiConnectParam::init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom) { - _id = id; - _placeholder = placeholder; - _length = length; - setValue(defaultValue); - - _customHTML = custom; -} - -void WiFiConnectParam::setValue(const char *newValue){ - if(_length > 0) { - // you know what was here in upstream - _value = new char[_length + 1]; - for (int i = 0; i < _length; i++) _value[i] = 0; - if (newValue != NULL) strncpy(_value, newValue, _length); - } -} - -const char* WiFiConnectParam::getValue() { - return _value; -} - -const char* WiFiConnectParam::getID() { - return _id; -} - -const char* WiFiConnectParam::getPlaceholder() { - return _placeholder; -} - -int WiFiConnectParam::getValueLength() { - return _length; -} - -const char* WiFiConnectParam::getCustomHTML() { - return _customHTML; -} diff --git a/lib/WiFiConnect/WiFiConnectParam.h b/lib/WiFiConnect/WiFiConnectParam.h deleted file mode 100644 index 1113f92..0000000 --- a/lib/WiFiConnect/WiFiConnectParam.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#ifndef WiFiConnect_MAX_PARAMS -#define WiFiConnect_MAX_PARAMS 10 ///< The maximum size of the param array and how many custom parameters we may have -#endif - -#include - -class WiFiConnectParam { - public: - WiFiConnectParam(const char *custom); - WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length); - WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom); - - const char *getID(); - const char *getValue(); - const char *getPlaceholder(); - int getValueLength(); - const char *getCustomHTML(); - void setValue(const char *newValue); - private: - const char *_id; - const char *_placeholder; - char *_value; - int _length; - const char *_customHTML; - - void init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom); - - friend class WiFiConnect; ///< Declarion for WiFiConnect class -}; diff --git a/lib/WiFiConnect/library.json b/lib/WiFiConnect/library.json deleted file mode 100644 index 6884d8e..0000000 --- a/lib/WiFiConnect/library.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "WifiConnect", - "version": "1.0", - "description": "A WiFi Manager for ESP8266 or ESP32", - "authors": - [ - { - "name": "Stuart Blair", - "email": "stuart@bfam.co.uk", - "maintainer": true - } - ], - "frameworks": "arduino", - "platforms": "espressif8266, espressif32" -} diff --git a/src/WifiConnect.cpp b/src/WifiConnect.cpp new file mode 100644 index 0000000..ddb666f --- /dev/null +++ b/src/WifiConnect.cpp @@ -0,0 +1,612 @@ +#include "WiFiConnect.h" + +#include + +#include "constants.h" + +// ---- CSS for the captive portal ---- + +static const char TPL_STYLE[] PROGMEM = + ""; + +// ---- JavaScript for the WiFi configuration page (AJAX scan, password toggle, hidden network) ---- + +static const char TPL_WIFI_JS[] PROGMEM = + "function scan(){" + "var nl=document.getElementById('nl');" + "nl.innerHTML='
';" + "var x=new XMLHttpRequest;" + "x.onload=function(){" + "try{var d=JSON.parse(x.responseText);var h='';" + "for(var i=0;i'" + "+''" + "+(n.e?'':'')+'';}" + "nl.innerHTML=h||'
'+T.nn+'
';" + "}catch(e){nl.innerHTML='
'+T.nn+'
';}};" + "x.onerror=function(){nl.innerHTML='
'+T.nn+'
';};" + "x.open('GET','/scan');x.send();}" + "function esc(s){var d=document.createElement('div');" + "d.appendChild(document.createTextNode(s));return d.innerHTML;}" + "function sel(el){" + "var s=el.querySelector('span').textContent;" + "document.getElementById('s').value=s;" + "document.getElementById('hn').checked=false;" + "document.getElementById('p').focus();}" + "function togglePw(){" + "var p=document.getElementById('p');" + "p.type=p.type==='password'?'text':'password';}" + "function toggleHn(){" + "var c=document.getElementById('hn').checked;" + "var s=document.getElementById('s');" + "if(c){s.value='';s.focus();}}" + "window.addEventListener('load',scan);"; + +// ---- WiFiConnectParam implementation ---- + +WiFiConnectParam::WiFiConnectParam(const char *custom) { + _id = NULL; + _placeholder = NULL; + _length = 0; + _value = NULL; + _customHTML = custom; +} + +WiFiConnectParam::WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length) { + init(id, placeholder, defaultValue, length, ""); +} + +void WiFiConnectParam::init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom) { + _id = id; + _placeholder = placeholder; + _length = length; + _value = NULL; + _customHTML = custom; + setValue(defaultValue); +} + +void WiFiConnectParam::setValue(const char *newValue) { + if (_length > 0) { + delete[] _value; + _value = new char[_length + 1]; + memset(_value, 0, _length + 1); + if (newValue != NULL) strncpy(_value, newValue, _length); + } +} + +const char* WiFiConnectParam::getValue() { + return _value; +} + +const char* WiFiConnectParam::getID() { + return _id; +} + +const char* WiFiConnectParam::getPlaceholder() { + return _placeholder; +} + +int WiFiConnectParam::getValueLength() { + return _length; +} + +const char* WiFiConnectParam::getCustomHTML() { + return _customHTML; +} + +// ---- WiFiConnect implementation ---- + +WiFiConnect::WiFiConnect() { + _apName[0] = '\0'; +} + +void WiFiConnect::setAPName() { + String ssid = "TEF_" + String((uint32_t)ESP.getEfuseMac()); + strcpy(_apName, ssid.c_str()); +} + +void WiFiConnect::addParameter(WiFiConnectParam *p) { + if (_paramsCount < WiFiConnect_MAX_PARAMS) { + _params[_paramsCount] = p; + _paramsCount++; + } +} + +boolean WiFiConnect::autoConnect() { + return autoConnect(NULL, NULL, WIFI_STA); +} + +boolean WiFiConnect::autoConnect(char const *ssidName, char const *ssidPassword, WiFiMode_t acWiFiMode) { + WiFi.mode(acWiFiMode); + + if (WiFi.status() == WL_CONNECTED) { + return true; + } + + int c = 0; + while (c < RETRY_ATTEMPTS) { + long ms = millis(); + + if (ssidName == NULL || strlen(ssidName) == 0) { + wifi_config_t conf; + esp_wifi_get_config(WIFI_IF_STA, &conf); + String stored_ssid = String(reinterpret_cast(conf.sta.ssid)); + if (stored_ssid == "") { + return false; + } + WiFi.begin(); + } else { + WiFi.begin(ssidName, ssidPassword); + } + + while (millis() - (unsigned long)ms < ((unsigned int)CONNECTION_TIMEOUT_SECS * 1000)) { + int ws = WiFi.status(); + if (ws == WL_CONNECTED) { + delay(500); + return true; + } else if (ws == WL_CONNECT_FAILED) { + delay(500); + } else { + delay(200); + yield(); + } + } + c++; + } + return false; +} + +boolean WiFiConnect::startConfigurationPortal() { + delay(50); + + if (WiFi.status() != WL_CONNECTED) { + WiFi.mode(WIFI_AP); + } else { + WiFi.mode(WIFI_AP_STA); + } + + dnsServer.reset(new DNSServer()); + server.reset(new WebServer(80)); + + setAPName(); + WiFi.softAP(_apName); + + delay(500); + + /* Setup the DNS server redirecting all domains to the AP IP */ + dnsServer->setErrorReplyCode(DNSReplyCode::NoError); + dnsServer->start(53, "*", WiFi.softAPIP()); + + /* Setup web pages: root, wifi config, scan API, logo, and not found */ + server->on("/", std::bind(&WiFiConnect::handleRoot, this)); + server->on("/wifi", std::bind(&WiFiConnect::handleWifi, this)); + server->on("/scan", std::bind(&WiFiConnect::handleScan, this)); + server->on("/wifisave", std::bind(&WiFiConnect::handleWifiSave, this)); + server->on("/logo.png", std::bind(&WiFiConnect::handleLogo, this)); + + /* Captive portal detection endpoints — redirect to root to trigger popup */ + server->on("/fwlink", std::bind(&WiFiConnect::handleRoot, this)); // Windows + server->on("/redirect", std::bind(&WiFiConnect::handleRoot, this)); // Windows 10+ + server->on("/hotspot-detect.html", std::bind(&WiFiConnect::handleRoot, this)); // Apple iOS/macOS + server->on("/library/test/success.html", std::bind(&WiFiConnect::handleRoot, this)); // Apple legacy + server->on("/generate_204", std::bind(&WiFiConnect::handleRoot, this)); // Android + server->on("/gen_204", std::bind(&WiFiConnect::handleRoot, this)); // Android alt + server->on("/connecttest.txt", std::bind(&WiFiConnect::handleRoot, this)); // Windows 11 + server->on("/ncsi.txt", std::bind(&WiFiConnect::handleRoot, this)); // Windows NCSI + + server->onNotFound(std::bind(&WiFiConnect::handleNotFound, this)); + + server->begin(); + + _readyToConnect = false; + while (true) { + dnsServer->processNextRequest(); + server->handleClient(); + if (_readyToConnect) { + _readyToConnect = false; + + if (autoConnect(_ssid.c_str(), _password.c_str(), WIFI_AP_STA)) { + WiFi.mode(WIFI_STA); + delay(500); + break; + } + } + yield(); + } + + server->close(); + server.reset(); + dnsServer.reset(); + + return (WiFi.status() == WL_CONNECTED); +} + +// ---- Page handlers ---- + +void WiFiConnect::handleRoot() { + if (captivePortal()) return; + + String page = F("" + "" + "" + ""); + page += textUI(311); + page += F(""); + page += FPSTR(TPL_STYLE); + page += F("
" + "

"); + page += _apName; + page += F("

"); + page += textUI(297); + page += F("
"); + + server->sendHeader("Content-Length", String(page.length())); + server->send(200, "text/html", page); +} + +void WiFiConnect::handleWifi() { + String page = F("" + "" + "" + ""); + page += textUI(312); + page += F(""); + page += FPSTR(TPL_STYLE); + page += F("
" + "

"); + page += _apName; + page += F("

"); + + // ---- Networks card ---- + page += F("

"); + page += textUI(298); + page += F("

" + "
"); + + // ---- Connection form card ---- + page += F("

"); + page += textUI(304); + page += F("

"); + + // Hidden network toggle + page += F(""); + + // SSID field + page += F(""); + + // Password field with SVG eye toggle + page += F("
"); + + // Custom parameters + for (int i = 0; i < _paramsCount; i++) { + if (_params[i] == NULL) break; + + if (_params[i]->getID() != NULL) { + char parLength[4]; + snprintf(parLength, 4, "%d", _params[i]->getValueLength()); + page += F("getCustomHTML(); + page += F(">"); + } else { + page += F("

"); + page += _params[i]->getCustomHTML(); + page += F("

"); + } + } + + // Submit button + page += F("
"); + + // JavaScript: inject translated text, then functions + String nnText = textUI(313); + nnText.replace("'", "\\'"); + page += F("
"); + + server->sendHeader("Content-Length", String(page.length())); + server->send(200, "text/html", page); +} + +void WiFiConnect::handleScan() { + int n = WiFi.scanNetworks(); + + String json = F("{\"n\":["); + + if (n > 0) { + // Sort by RSSI + int indices[n]; + for (int i = 0; i < n; i++) indices[i] = i; + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (WiFi.RSSI(indices[j]) > WiFi.RSSI(indices[i])) { + std::swap(indices[i], indices[j]); + } + } + } + + // Remove duplicates (must be RSSI sorted) + for (int i = 0; i < n; i++) { + if (indices[i] == -1) continue; + String cssid = WiFi.SSID(indices[i]); + for (int j = i + 1; j < n; j++) { + if (cssid == WiFi.SSID(indices[j])) indices[j] = -1; + } + } + + bool first = true; + for (int i = 0; i < n; i++) { + if (indices[i] == -1) continue; + int quality = getRSSIasQuality(WiFi.RSSI(indices[i])); + if (quality < MINIMUM_QUALITY) continue; + + if (!first) json += ','; + first = false; + + // Escape SSID for JSON + String ssid = WiFi.SSID(indices[i]); + ssid.replace("\\", "\\\\"); + ssid.replace("\"", "\\\""); + + json += F("{\"s\":\""); + json += ssid; + json += F("\",\"r\":"); + json += String(quality); + json += F(",\"e\":"); + json += (WiFi.encryptionType(indices[i]) != WIFI_AUTH_OPEN) ? '1' : '0'; + json += '}'; + } + } + + json += F("]}"); + server->send(200, "application/json", json); +} + +void WiFiConnect::handleWifiSave() { + _ssid = server->arg("s").c_str(); + _ssid.trim(); + _password = server->arg("p").c_str(); + _password.trim(); + + // Read custom parameters from form + for (int i = 0; i < _paramsCount; i++) { + if (_params[i] == NULL || _params[i]->getID() == NULL) continue; + String value = server->arg(_params[i]->getID()).c_str(); + value.toCharArray(_params[i]->_value, _params[i]->_length); + } + + String page = F("" + "" + "" + ""); + page += textUI(314); + page += F(""); + page += FPSTR(TPL_STYLE); + page += F("
" + "

"); + page += _apName; + page += F("

"); + + // Connecting spinner + page += F("
" + "
" + "

"); + page += textUI(306); + page += F(" "); + page += _ssid; + page += F(" ...

"); + + // Polling script: polls /foo every 3s; if AP responds → fail, if 20 timeouts → success + page += F(""); + + // Success message + page += F("
"); + page += textUI(307); + page += F(" "); + page += _ssid; + page += F("!
"); + page += textUI(308); + page += F("
"); + + // Failure message + page += F("
"); + page += textUI(309); + page += F(" "); + page += _ssid; + page += F(".
"); + page += textUI(310); + page += F("
"); + + page += F("
"); + + server->sendHeader("Content-Length", String(page.length())); + server->send(200, "text/html", page); + _readyToConnect = true; +} + +void WiFiConnect::handleLogo() { + fs::File file = SPIFFS.open("/logo.png", "r"); + if (!file) { + server->send(404, "text/plain", "Logo not found"); + return; + } + server->streamFile(file, "image/png"); + file.close(); +} + +void WiFiConnect::handleNotFound() { + if (captivePortal()) { + return; + } + + String message = "File Not Found\n\n"; + message += "URI: "; + message += server->uri(); + message += "\nMethod: "; + message += (server->method() == HTTP_GET) ? "GET" : "POST"; + message += "\nArguments: "; + message += server->args(); + message += "\n"; + + for (uint8_t i = 0; i < server->args(); i++) { + message += " " + server->argName(i) + ": " + server->arg(i) + "\n"; + } + + server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); + server->sendHeader("Pragma", "no-cache"); + server->sendHeader("Expires", "-1"); + server->sendHeader("Content-Length", String(message.length())); + server->send(404, "text/plain", message); +} + +boolean WiFiConnect::captivePortal() { + if (!isIp(server->hostHeader())) { + String msg = "redirect\n"; + server->sendHeader("Location", String("http://") + toStringIp(server->client().localIP()), true); + server->sendHeader("Content-Length", String(msg.length())); + server->send(302, "text/plain", msg); + return true; + } + return false; +} + +boolean WiFiConnect::isIp(String str) { + for (unsigned int i = 0; i < str.length(); i++) { + int c = str.charAt(i); + if (c != '.' && (c < '0' || c > '9')) { + return false; + } + } + return true; +} + +String WiFiConnect::toStringIp(IPAddress ip) { + String res = ""; + for (int i = 0; i < 3; i++) { + res += String((ip >> (8 * i)) & 0xFF) + "."; + } + res += String(((ip >> 8 * 3)) & 0xFF); + return res; +} + +int WiFiConnect::getRSSIasQuality(int RSSI) { + int quality = 0; + if (RSSI <= -100) { + quality = 0; + } else if (RSSI >= -50) { + quality = 100; + } else { + quality = 2 * (RSSI + 100); + } + return quality; +} \ No newline at end of file diff --git a/src/WifiConnect.h b/src/WifiConnect.h new file mode 100644 index 0000000..7f459b0 --- /dev/null +++ b/src/WifiConnect.h @@ -0,0 +1,81 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include "core.h" + +#define WiFiConnect_MAX_PARAMS 10 + +extern const char* textUI(uint16_t number); + +class WiFiConnect; +class WiFiConnectParam { +public: + WiFiConnectParam(const char *custom); + + WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length); + + const char *getID(); + const char *getValue(); + const char *getPlaceholder(); + int getValueLength(); + const char *getCustomHTML(); + +private: + const char *_id; + const char *_placeholder; + char *_value; + int _length; + const char *_customHTML; + + void init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom); + void setValue(const char *newValue); + + friend class WiFiConnect; +}; + +class WiFiConnect { +public: + WiFiConnect(); + + boolean autoConnect(); + void addParameter(WiFiConnectParam *p); + boolean startConfigurationPortal(); + +private: + static constexpr int RETRY_ATTEMPTS = 3; + static constexpr int CONNECTION_TIMEOUT_SECS = 10; + static constexpr int MINIMUM_QUALITY = 8; + + int _paramsCount = 0; + boolean _readyToConnect = false; + String _ssid; + String _password; + + WiFiConnectParam* _params[WiFiConnect_MAX_PARAMS]; + + std::unique_ptr dnsServer; + std::unique_ptr server; + + char _apName[33]; + + void setAPName(); + + boolean autoConnect(const char *ssidName, const char *ssidPassword, WiFiMode_t acWiFiMode); + + void handleRoot(); + void handleWifi(); + void handleScan(); + void handleWifiSave(); + void handleLogo(); + void handleNotFound(); + + boolean captivePortal(); + boolean isIp(String str); + String toStringIp(IPAddress ip); + int getRSSIasQuality(int RSSI); +}; \ No newline at end of file diff --git a/src/comms.cpp b/src/comms.cpp index 20bb944..fd39e26 100644 --- a/src/comms.cpp +++ b/src/comms.cpp @@ -1,5 +1,6 @@ #include "comms.h" #include +#include "graphics.h" extern mem presets[]; diff --git a/src/core.cpp b/src/core.cpp index d4e4b36..cd209aa 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -16,6 +16,7 @@ using fs::FS; #include "core.h" #include "main.h" #include "logbook.h" +#include "graphics.h" Console console(&tft); RTC_DATA_ATTR bool gpio_chip = false; diff --git a/src/gui.cpp b/src/gui.cpp index 81d34c0..ef3a34f 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -1,4 +1,5 @@ #include "gui.h" +#include "graphics.h" #include #include #include @@ -5210,7 +5211,7 @@ void DoMenu() { case ITEM3: { tftPrint(ACENTER, textUI(50), 155, 58, ActiveColor, ActiveColorSmooth, 28); - tftPrint(ACENTER, "ESP_" + String(ESP_getChipId()), 155, 98, PrimaryColor, PrimaryColorSmooth, 28); + tftPrint(ACENTER, "TEF_" + String((uint32_t)ESP.getEfuseMac()), 155, 98, PrimaryColor, PrimaryColorSmooth, 28); tftPrint(ACENTER, textUI(51), 155, 138, ActiveColor, ActiveColorSmooth, 28); tftPrint(ACENTER, "http://192.168.4.1", 155, 174, PrimaryColor, PrimaryColorSmooth, 16); char key[9]; diff --git a/src/main.cpp b/src/main.cpp index 8d6b6a6..c3fec89 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,6 +13,7 @@ #include "rds.h" #include "logbook.h" #include "comms.h" +#include "graphics.h" void Touch_IRQ_Handler() { touch_detect = true; diff --git a/src/rds.cpp b/src/rds.cpp index 45c668d..ec76b65 100644 --- a/src/rds.cpp +++ b/src/rds.cpp @@ -1,6 +1,7 @@ #include "rds.h" #include "constants.h" #include "utils.h" +#include "graphics.h" String HexStringold; float smoothBER = 0;