This commit is contained in:
Tomislav Kopić 2024-11-19 08:30:20 +01:00
parent e82c9e07ad
commit 0929f103c5
2 changed files with 6 additions and 5 deletions

View File

@ -12,3 +12,4 @@
platform = espressif32 platform = espressif32
board = lolin_s2_mini board = lolin_s2_mini
framework = arduino framework = arduino
lib_deps = adafruit/Adafruit SSD1306@^2.5.13

View File

@ -1,6 +1,6 @@
#include <ESP8266WiFi.h> #include <WiFi.h>
#include <WiFiClient.h> #include <WiFiClient.h>
#include <ESP8266WebServer.h> #include <WebServer.h>
#include <LittleFS.h> #include <LittleFS.h>
#include <DNSServer.h> #include <DNSServer.h>
#include <map> #include <map>
@ -24,7 +24,7 @@ public:
private: private:
Adafruit_SSD1306& display; Adafruit_SSD1306& display;
std::unique_ptr<ESP8266WebServer> server; std::unique_ptr<WebServer> server;
std::map<String, String> _ssids; std::map<String, String> _ssids;
String _ssid, _pass; String _ssid, _pass;
bool _hidden; bool _hidden;
@ -176,7 +176,7 @@ void cubeWifiManager::createAP() {
display.println(WiFi.softAPIP().toString()); display.println(WiFi.softAPIP().toString());
display.display(); display.display();
server.reset(new ESP8266WebServer(80)); server.reset(new WebServer(80));
DNSServer dnsServer; DNSServer dnsServer;
dnsServer.start(53, "*", WiFi.softAPIP()); dnsServer.start(53, "*", WiFi.softAPIP());
@ -303,7 +303,7 @@ void cubeWifiManager::handleRoot() {
// Get SSID and signal strength // Get SSID and signal strength
String ssid = WiFi.SSID(i); String ssid = WiFi.SSID(i);
int rssi = WiFi.RSSI(i); int rssi = WiFi.RSSI(i);
bool openNetwork = (WiFi.encryptionType(i) == ENC_TYPE_NONE); bool openNetwork = (WiFi.encryptionType(i) == WIFI_AUTH_OPEN);
// Show network with button to select // Show network with button to select
result += "<tr><td><button onclick=\"location.href='/select?ssid=" + urlEncode(ssid) + "'\">" + ssid + "</button></td><td>" + (openNetwork ? "(Open)" : "(Secured)") + "</td><td>" + String(rssi) + " dBm</td></tr>"; result += "<tr><td><button onclick=\"location.href='/select?ssid=" + urlEncode(ssid) + "'\">" + ssid + "</button></td><td>" + (openNetwork ? "(Open)" : "(Secured)") + "</td><td>" + String(rssi) + " dBm</td></tr>";