【发布时间】:2018-02-27 13:55:51
【问题描述】:
有没有人成功地获得强制门户以导致重定向内容弹出到 Arduino 或 ESP8266 上的特定登录页面? 我已经在阳光下尝试了一切,虽然我的 android 会抱怨未连接的互联网和其他东西,但它从来没有真正请求/建议打开浏览器,就像我在一些带有登录页面的开放式 wifi 热点上看到的那样. 我正在尝试实现实际上是非互联网连接设备,用户将在远程位置登录以显示他们已经到达,有点像 geocache 但使用 wifi 登录。我做了 dnsServer glob(所有名称到本地 IP),我做了一些 url 重定向。我尝试输入特定内容(而不是重定向),但没有弹出任何内容。
相关代码:
#include <ESPAsyncWebServer.h>
#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266mDNS.h>
IPAddress apIp ( 10, 10, 10, 10 );
AsyncWebServer asyncWebServer(80);
DNSServer dnsServer;
const char* captiveRedirect = "/index.htm";
String apSSID = "GeoCache";
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
dnsServer.start ( DNS_PORT, "*", apIp );
DBG_OUTPUT_PORT.println("Initializing MDNS for local hostname on AP");
if (MDNS.begin(apHostname)) {
MDNS.addService("http", "tcp", 80);
DBG_OUTPUT_PORT.println("MDNS responder started");
DBG_OUTPUT_PORT.print("You can now connect to http://");
DBG_OUTPUT_PORT.print(apHostname);
DBG_OUTPUT_PORT.println(".local");
}
//Android captive portal. Maybe not needed. Might be handled by notFound handler.
asyncWebServer.addRewrite( new AsyncWebRewrite("/generate_204", captiveRedirect));
//asyncWebServer.on ( "/generate_204", returnOK );
//Microsoft captive portal. Maybe not needed. Might be handled by notFound handler.
asyncWebServer.addRewrite( new AsyncWebRewrite("/fwlink", captiveRedirect));
//asyncWebServer.on ( "/fwlink", returnOK );
//Microsoft windows 10
//asyncWebServer.on ( "/connecttest.txt", returnOK );
asyncWebServer.addRewrite( new AsyncWebRewrite("/connecttest.txt", captiveRedirect));
// apple devices
asyncWebServer.addRewrite( new AsyncWebRewrite("/hotspot-detect.html", captiveRedirect));
//asyncWebServer.on ( "/hotspot-detect.html", returnOK );
asyncWebServer.addRewrite( new AsyncWebRewrite("/library/test/success.html", captiveRedirect));
//asyncWebServer.on ( "/library/test/success.html", returnOK );
// kindle
asyncWebServer.addRewrite( new AsyncWebRewrite("/kindle-wifi/wifistub.html", captiveRedirect));
//asyncWebServer.on ( "/kindle-wifi/wifistub.html", returnOK );
asyncWebServer.on("/delete", HTTP_DELETE, handleDelete);
// upload a file to /upload
asyncWebServer.on("/upload", HTTP_POST, returnOK, handleUpload);
// Catch-All Handlers
asyncWebServer.onFileUpload(handleUpload);
//asyncWebServer.onRequestBody(onBody);
asyncWebServer.on("/signin", HTTP_GET, addLog);
asyncWebServer.onNotFound(handleNotFound);
asyncWebServer.begin();
WiFi.mode(WIFI_AP);
WiFi.softAPConfig ( apIp, apIp, IPAddress ( 255, 255, 255, 0 ) );
WiFi.softAP(apSSID);
【问题讨论】:
-
我什至尝试在我的 handleNotFound 中设置一个特殊规则,根据本地 IP 和本地主机名检查 'request->host() 以执行不同的行为。还没有任何效果。
-
嗯,fwiw,我已经看到它在测试草图上工作,我现在不记得了。我知道这没什么用,除了鼓励……
-
多久以前?据我所知,我现在使用的方法“用于”在较旧的 android/ios 版本上工作,并且“可能”仍然可以在硬重置设备上工作(还没有机会进行 dns 缓存)
-
我刚刚在 Windows 上尝试了“强制门户”示例,它可以正常工作,包括打开一个标签页不知从何处指向一个重定向到演示文本的奇怪 URL。在 android 5.1 上,演示文本在单击通知后出现在嵌入式浏览器中。两者都是不错的用户体验...
-
嗯,即使看到请求,我也完全没有运气。我见过的最突出的例子(移动 rick roll)有一个开放线程,由人们分享我的经验。
标签: arduino esp8266 android-popupwindow arduino-esp8266 captiveportal