Simplify captive portal to compressed single page (#2872)

This commit is contained in:
wilberforce 2022-02-17 17:02:10 +13:00 committed by GitHub
parent 38259c96c9
commit 36ddd9dd69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 125 additions and 192 deletions

View file

@ -0,0 +1,107 @@
#pragma once
// Generated from https://github.com/esphome/esphome-webserver
#include "esphome/core/hal.h"
namespace esphome {
namespace captive_portal {
const uint8_t INDEX_GZ[] PROGMEM = {
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xdd, 0x58, 0x09, 0x6f, 0xdc, 0x36, 0x16, 0xfe, 0x2b,
0xac, 0x92, 0x74, 0x34, 0x8d, 0xc5, 0xd1, 0x31, 0x97, 0x35, 0xd2, 0x14, 0x89, 0x37, 0x45, 0x0b, 0x24, 0x69, 0x00,
0xbb, 0x5d, 0x14, 0x69, 0x00, 0x73, 0x24, 0x6a, 0xc4, 0x58, 0xa2, 0x54, 0x91, 0x9a, 0x23, 0x83, 0xd9, 0xdf, 0xde,
0x47, 0x52, 0x73, 0x38, 0x6b, 0x2f, 0x90, 0x62, 0x8b, 0xa2, 0x4d, 0x6c, 0x9a, 0xc7, 0x3b, 0x3f, 0xf2, 0xf1, 0x3d,
0x2a, 0xfa, 0x2a, 0xad, 0x12, 0xb9, 0xad, 0x29, 0xca, 0x65, 0x59, 0xcc, 0x23, 0xd5, 0xa2, 0x82, 0xf0, 0x65, 0x4c,
0x39, 0x8c, 0x28, 0x49, 0xe7, 0x51, 0x49, 0x25, 0x41, 0x49, 0x4e, 0x1a, 0x41, 0x65, 0xfc, 0xd3, 0xcd, 0x77, 0xce,
0x14, 0x0d, 0xe6, 0x51, 0xc1, 0xf8, 0x1d, 0x6a, 0x68, 0x11, 0xb3, 0xa4, 0xe2, 0x28, 0x6f, 0x68, 0x16, 0xa7, 0x44,
0x92, 0x90, 0x95, 0x64, 0x49, 0x15, 0x81, 0x66, 0xe3, 0xa4, 0xa4, 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x5c, 0x0e,
0xf4, 0xe7, 0xa7, 0xdf, 0x01, 0xf1, 0x69, 0xfc, 0xac, 0x8e, 0x12, 0x00, 0x00};
} // namespace captive_portal
} // namespace esphome

View file

@ -4,60 +4,27 @@
#include "esphome/core/log.h"
#include "esphome/core/application.h"
#include "esphome/components/wifi/wifi_component.h"
#include "captive_index.h"
namespace esphome {
namespace captive_portal {
static const char *const TAG = "captive_portal";
void CaptivePortal::handle_index(AsyncWebServerRequest *request) {
AsyncResponseStream *stream = request->beginResponseStream("text/html");
stream->print(F("<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" "
"content=\"width=device-width,initial-scale=1,user-scalable=no\"/><title>"));
stream->print(App.get_name().c_str());
stream->print(F("</title><link rel=\"stylesheet\" href=\"/stylesheet.css\">"));
stream->print(F("<script>function c(l){document.getElementById('ssid').value=l.innerText||l.textContent; "
"document.getElementById('psk').focus();}</script>"));
stream->print(F("</head>"));
stream->print(F("<body><div class=\"main\"><h1>WiFi Networks</h1>"));
if (request->hasArg("save")) {
stream->print(F("<div class=\"info\">The ESP will now try to connect to the network...<br/>Please give it some "
"time to connect.<br/>Note: Copy the changed network to your YAML file - the next OTA update will "
"overwrite these settings.</div>"));
}
void CaptivePortal::handle_config(AsyncWebServerRequest *request) {
AsyncResponseStream *stream = request->beginResponseStream("application/json");
stream->addHeader("cache-control", "public, max-age=0, must-revalidate");
stream->printf(R"({"name":"%s","aps":[{})", App.get_name().c_str());
for (auto &scan : wifi::global_wifi_component->get_scan_result()) {
if (scan.get_is_hidden())
continue;
stream->print(F("<div class=\"network\" onclick=\"c(this)\"><a href=\"#\" class=\"network-left\">"));
if (scan.get_rssi() >= -50) {
stream->print(F("<img src=\"/wifi-strength-4.svg\">"));
} else if (scan.get_rssi() >= -65) {
stream->print(F("<img src=\"/wifi-strength-3.svg\">"));
} else if (scan.get_rssi() >= -85) {
stream->print(F("<img src=\"/wifi-strength-2.svg\">"));
} else {
stream->print(F("<img src=\"/wifi-strength-1.svg\">"));
// Assumes no " in ssid, possible unicode isses?
stream->printf(R"(,{"ssid":"%s","rssi":%d,"lock":%d})", scan.get_ssid().c_str(), scan.get_rssi(),
scan.get_with_auth());
}
stream->print(F("<span class=\"network-ssid\">"));
stream->print(scan.get_ssid().c_str());
stream->print(F("</span></a>"));
if (scan.get_with_auth()) {
stream->print(F("<img src=\"/lock.svg\">"));
}
stream->print(F("</div>"));
}
stream->print(F("<h3>WiFi Settings</h3><form method=\"GET\" action=\"/wifisave\"><input id=\"ssid\" name=\"ssid\" "
"length=32 placeholder=\"SSID\"><br/><input id=\"psk\" name=\"psk\" length=64 type=\"password\" "
"placeholder=\"Password\"><br/><br/><button type=\"submit\">Save</button></form><br><hr><br>"));
stream->print(F("<h1>OTA Update</h1><form method=\"POST\" action=\"/update\" enctype=\"multipart/form-data\"><input "
"type=\"file\" name=\"update\"><button type=\"submit\">Update</button></form>"));
stream->print(F("</div></body></html>"));
stream->print(F("]}"));
request->send(stream);
}
void CaptivePortal::handle_wifisave(AsyncWebServerRequest *request) {
@ -68,7 +35,7 @@ void CaptivePortal::handle_wifisave(AsyncWebServerRequest *request) {
ESP_LOGI(TAG, " Password=" LOG_SECRET("'%s'"), psk.c_str());
wifi::global_wifi_component->save_wifi_sta(ssid, psk);
wifi::global_wifi_component->start_scanning();
request->redirect("/?save=true");
request->redirect("/?save");
}
void CaptivePortal::setup() {}
@ -98,44 +65,21 @@ void CaptivePortal::start() {
this->active_ = true;
}
const char STYLESHEET_CSS[] PROGMEM =
R"(*{box-sizing:inherit}div,input{padding:5px;font-size:1em}input{width:95%}body{text-align:center;font-family:sans-serif}button{border:0;border-radius:.3rem;background-color:#1fa3ec;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%;padding:0}.main{text-align:left;display:inline-block;min-width:260px}.network{display:flex;justify-content:space-between;align-items:center}.network-left{display:flex;align-items:center}.network-ssid{margin-bottom:-7px;margin-left:10px}.info{border:1px solid;margin:10px 0;padding:15px 10px;color:#4f8a10;background-color:#dff2bf})";
const char LOCK_SVG[] PROGMEM =
R"(<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M12 17a2 2 0 0 0 2-2 2 2 0 0 0-2-2 2 2 0 0 0-2 2 2 2 0 0 0 2 2m6-9a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2h1V6a5 5 0 0 1 5-5 5 5 0 0 1 5 5v2h1m-6-5a3 3 0 0 0-3 3v2h6V6a3 3 0 0 0-3-3z"/></svg>)";
void CaptivePortal::handleRequest(AsyncWebServerRequest *req) {
if (req->url() == "/") {
this->handle_index(req);
AsyncWebServerResponse *response = req->beginResponse_P(200, "text/html", INDEX_GZ, sizeof(INDEX_GZ));
response->addHeader("Content-Encoding", "gzip");
req->send(response);
return;
} else if (req->url() == "/config.json") {
this->handle_config(req);
return;
} else if (req->url() == "/wifisave") {
this->handle_wifisave(req);
return;
} else if (req->url() == "/stylesheet.css") {
req->send_P(200, "text/css", STYLESHEET_CSS);
return;
} else if (req->url() == "/lock.svg") {
req->send_P(200, "image/svg+xml", LOCK_SVG);
return;
}
AsyncResponseStream *stream = req->beginResponseStream("image/svg+xml");
stream->print(F("<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\"><path d=\"M12 3A18.9 18.9 0 0 "
"0 .38 7C4.41 12.06 7.89 16.37 12 21.5L23.65 7C20.32 4.41 16.22 3 12 "));
if (req->url() == "/wifi-strength-4.svg") {
stream->print(F("3z"));
} else {
if (req->url() == "/wifi-strength-1.svg") {
stream->print(F("3m0 2c3.07 0 6.09.86 8.71 2.45l-5.1 6.36a8.43 8.43 0 0 0-7.22-.01L3.27 7.4"));
} else if (req->url() == "/wifi-strength-2.svg") {
stream->print(F("3m0 2c3.07 0 6.09.86 8.71 2.45l-3.21 3.98a11.32 11.32 0 0 0-11 0L3.27 7.4"));
} else if (req->url() == "/wifi-strength-3.svg") {
stream->print(F("3m0 2c3.07 0 6.09.86 8.71 2.45l-1.94 2.43A13.6 13.6 0 0 0 12 8C9 8 6.68 9 5.21 9.84l-1.94-2."));
}
stream->print(F("4A16.94 16.94 0 0 1 12 5z"));
}
stream->print(F("\"/></svg>"));
req->send(stream);
}
CaptivePortal::CaptivePortal(web_server_base::WebServerBase *base) : base_(base) { global_captive_portal = this; }
float CaptivePortal::get_setup_priority() const {
// Before WiFi

View file

@ -58,7 +58,7 @@ class CaptivePortal : public AsyncWebHandler, public Component {
return false;
}
void handle_index(AsyncWebServerRequest *request);
void handle_config(AsyncWebServerRequest *request);
void handle_wifisave(AsyncWebServerRequest *request);

View file

@ -1,55 +0,0 @@
<!-- HTTP_HEAD -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
<title>{{ App.get_name() }}</title>
<link rel="stylesheet" href="./stylesheet.css">
<script>
function c(l) {
document.getElementById('ssid').value = l.innerText || l.textContent;
document.getElementById('psk').focus();
}
</script>
</head>
<body>
<div class="main">
<h1>WiFi Networks</h1>
<div class="info">
The ESP will now try to connect to the network...<br/>
Please give it some time to connect.<br/>
Note: Copy the changed network to your YAML file - the next OTA update will overwrite these settings.
</div>
<div class="network" onclick="c(this)">
<a href="#" class="network-left">
<img src="./wifi-strength-4.svg">
<span class="network-ssid">AP1</span>
</a>
<img src="./lock.svg">
</div>
<div class="network" onclick="c(this)">
<a href="#" class="network-left">
<img src="./wifi-strength-2.svg">
<span class="network-ssid">AP2</span>
</a>
</div>
<h3>WiFi Settings</h3>
<form method="GET" action="/wifisave">
<input id="ssid" name="ssid" length=32 placeholder="SSID"><br/>
<input id="psk" name="psk" length=64 type="password" placeholder="Password"><br/>
<br/>
<button type="submit">Save</button>
</form>
<br><hr>
<br>
<h1>OTA Update</h1>
<form method="POST" action="/update" enctype="multipart/form-data">
<input type="file" name="update">
<button type="submit">Update</button>
</form>
</div>
</body>
</html>

View file

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M12 17a2 2 0 0 0 2-2 2 2 0 0 0-2-2 2 2 0 0 0-2 2 2 2 0 0 0 2 2m6-9a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2h1V6a5 5 0 0 1 5-5 5 5 0 0 1 5 5v2h1m-6-5a3 3 0 0 0-3 3v2h6V6a3 3 0 0 0-3-3z"/></svg>

Before

Width:  |  Height:  |  Size: 307 B

View file

@ -1,58 +0,0 @@
* {
box-sizing: inherit;
}
div, input {
padding: 5px;
font-size: 1em;
}
input {
width: 95%;
}
body {
text-align: center;
font-family: sans-serif;
}
button {
border: 0;
border-radius: 0.3rem;
background-color: #1fa3ec;
color: #fff;
line-height: 2.4rem;
font-size: 1.2rem;
width: 100%;
padding: 0;
}
.main {
text-align: left;
display: inline-block;
min-width: 260px;
}
.network {
display: flex;
justify-content: space-between;
align-items: center;
}
.network-left {
display: flex;
align-items: center;
}
.network-ssid {
margin-bottom: -7px;
margin-left: 10px;
}
.info {
border: 1px solid;
margin: 10px 0px;
padding: 15px 10px;
color: #4f8a10;
background-color: #dff2bf;
}

View file

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M12 3A18.9 18.9 0 0 0 .38 7C4.41 12.06 7.89 16.37 12 21.5L23.65 7C20.32 4.41 16.22 3 12 3m0 2c3.07 0 6.09.86 8.71 2.45l-5.1 6.36a8.43 8.43 0 0 0-7.22-.01L3.27 7.44A16.94 16.94 0 0 1 12 5z"/></svg>

Before

Width:  |  Height:  |  Size: 268 B

View file

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M12 3A18.9 18.9 0 0 0 .38 7C4.41 12.06 7.89 16.37 12 21.5L23.65 7C20.32 4.41 16.22 3 12 3m0 2c3.07 0 6.09.86 8.71 2.45l-3.21 3.98a11.32 11.32 0 0 0-11 0L3.27 7.44A16.94 16.94 0 0 1 12 5z"/></svg>

Before

Width:  |  Height:  |  Size: 267 B

View file

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M12 3A18.9 18.9 0 0 0 .38 7C4.41 12.06 7.89 16.37 12 21.5L23.65 7C20.32 4.41 16.22 3 12 3m0 2c3.07 0 6.09.86 8.71 2.45l-1.94 2.43A13.6 13.6 0 0 0 12 8C9 8 6.68 9 5.21 9.84l-1.94-2.4A16.94 16.94 0 0 1 12 5z"/></svg>

Before

Width:  |  Height:  |  Size: 286 B

View file

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M12 3A18.9 18.9 0 0 0 .38 7C4.41 12.06 7.89 16.37 12 21.5L23.65 7C20.32 4.41 16.22 3 12 3z"/></svg>

Before

Width:  |  Height:  |  Size: 171 B