Arduino 带弹出窗口的ESP8266捕获门户

Arduino 带弹出窗口的ESP8266捕获门户,arduino,esp8266,android-popupwindow,arduino-esp8266,captiveportal,Arduino,Esp8266,Android Popupwindow,Arduino Esp8266,Captiveportal,是否有人成功地获得了一个捕获门户,使重定向内容弹出到Arduino或ESP8266上的特定登录页? 我尝试了所有的方法,虽然我的android会抱怨没有连接的互联网和其他东西,但它从来没有像我在一些开放的wifi热点上看到的那样请求/建议打开浏览器。 我正在尝试实现一种非互联网连接的设备,用户可以在远程位置登录以显示他们已经到达,有点像geocache,但使用wifi登录。我做了DNSServerGlob(所有名称都指向本地IP),我做了许多url重定向。我尝试过输入特定内容(而不是重新定向),

是否有人成功地获得了一个捕获门户,使重定向内容弹出到Arduino或ESP8266上的特定登录页? 我尝试了所有的方法,虽然我的android会抱怨没有连接的互联网和其他东西,但它从来没有像我在一些开放的wifi热点上看到的那样请求/建议打开浏览器。 我正在尝试实现一种非互联网连接的设备,用户可以在远程位置登录以显示他们已经到达,有点像geocache,但使用wifi登录。我做了DNSServerGlob(所有名称都指向本地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);
#包括
#包括
#包括
#包括
IPAddress-apIp(10,10,10,10);
异步Web服务器异步Web服务器(80);
DNSServer DNSServer;
const char*captiveRedirect=“/index.htm”;
字符串apSSID=“GeoCache”;
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
dnsServer.start(DNS_端口,“*”,apIp);
DBG_OUTPUT_PORT.println(“为AP上的本地主机名初始化MDN”);
if(MDNS.begin(apHostname)){
addService(“http”,“tcp”,80);
DBG_OUTPUT_PORT.println(“MDNS响应程序已启动”);
DBG_OUTPUT_PORT.print(“您现在可以连接到http://”);
DBG_输出_端口打印(apHostname);
DBG_输出_端口.println(“.local”);
}
//安卓专属门户。也许不需要。可能由notFound处理程序处理。
addRewrite(新的AsyncWebRewrite(“/generate_204”,captiveRedirect));
//asyncWebServer.on(“/generate_204”,returnOK);
//微软专属门户。也许不需要。可能由notFound处理程序处理。
addRewrite(新的AsyncWebRewrite(“/fwlink”,CaptiveDirect));
//asyncWebServer.on(“/fwlink”,returnOK);
//微软视窗10
//asyncWebServer.on(“/connecttest.txt”,returnOK);
addRewrite(新的AsyncWebRewrite(“/connecttest.txt”,CaptiveDirect));
//苹果设备
addRewrite(新的AsyncWebRewrite(“/hotspot detect.html”,captiveRedirect));
//asyncWebServer.on(“/hotspot detect.html”,returnOK);
addRewrite(新的AsyncWebRewrite(“/library/test/success.html”,CaptiveDirect));
//asyncWebServer.on(“/library/test/success.html”,returnOK);
//点燃
addRewrite(新的AsyncWebRewrite(“/kindle wifi/wifistub.html”,CaptiveDirect));
//asyncWebServer.on(“/kindle wifi/wifistub.html”,returnOK);
asyncWebServer.on(“/delete”,HTTP_delete,handleDelete);
//上传文件到/上传
asyncWebServer.on(“/upload”,HTTP\u POST,returnOK,handleUpload);
//捕获所有处理程序
onFileUpload(handleUpload);
//asyncWebServer.onRequestBody(onBody);
asyncWebServer.on(“/signin”,HTTP\u GET,addLog);
asyncWebServer.onNotFound(handleNotFound);
asyncWebServer.begin();
WiFi.模式(WiFi\u AP);
WiFi.softAPConfig(apIp,apIp,IPAddress(255,255,255,0));
WiFi.softAP(apSSID);
在循环()中,必须包括:

dnsServer.processNextRequest();
以前

server.handleClient(); //Handling of incoming requests
然后,创建一个notfound路由器:

server.onNotFound([]() {
    char * msg = "HELLO<br>Default landing page<br>";
    server.send(200, "text/html", msg );
  });
server.onNotFound([](){
char*msg=“HELLO
默认登录页
”; 发送(200,“text/html”,msg); });
我甚至尝试在handleNotFound中设置一个特殊规则,根据本地IP和本地主机名检查“request->host()”以执行不同的行为。什么都还没起作用。嗯,fwiw,我看到它在测试草图上起作用,我现在想不起来了。我知道这没有什么帮助,除了鼓励…多久以前?据我所知,我现在使用的方法“用于”旧的android/ios版本,并且“可能”仍然适用于硬重置设备(还没有机会进行dns缓存),我只是在windows上尝试了“捕获门户”示例,它起了作用,包括在不知从何处打开一个指向重定向到演示文本的奇怪url的选项卡。在安卓5.1上,点击通知后,演示文本出现在嵌入式浏览器中。这两个都是不错的用户体验……嗯,我甚至连看到请求都没有运气。我所见过的最突出的例子(移动rick roll)有一个开放的线程,分享我的经验的人都在使用它。问题是它从来没有收到请求,因为Android(从4.4版到7版)显然只要求google名称服务器(例如8.8.8.8)对于google generate_204主机的地址。我的短期修复方法是将softAP配置为8.8.8.8作为IP,因为它没有连接internet。更好的解决方案是使用低级lwIP代码欺骗8.8.8.8地址。但我已经有好几年没有编写IP堆栈了,甚至没有用C编写过。