|
本帖最后由 iakihsoug 于 2020-12-4 22:51 编辑
- #include <ESP8266WiFi.h>
- #include <DNSServer.h>
- #include <ESP8266WebServer.h>
- const byte DNS_PORT = 53;
- IPAddress apIP(172, 217, 28, 1);
- DNSServer dnsServer;
- ESP8266WebServer webServer(80);
- String responseHTML = ""
- "<!DOCTYPE html><html lang='en'><head>"
- "<meta name='viewport' content='width=device-width'>"
- "<title>CaptivePortal</title></head><body>"
- "<h1>Hello World!</h1><p>This is a captive portal example."
- " All requests will be redirected here.</p></body></html>";
- void setup() {
- delay(1000);
- Serial.begin(74880);
- Serial.println();
- WiFi.mode(WIFI_AP);
- WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
- WiFi.softAP("DNSServer CaptivePortal example");
- // if DNSServer is started with "*" for domain name, it will reply with
- // provided IP to all DNS request
- dnsServer.start(DNS_PORT, "*", apIP);
- // replay to all requests with same HTML
- webServer.onNotFound([]() {
- webServer.send(200, "text/html", responseHTML);
- });
- webServer.begin();
- }
- void loop() {
- dnsServer.processNextRequest();
- webServer.handleClient();
- }
复制代码 源码如上
手机输入密码连接热点后,串口显示如下报错
- --------------- CUT HERE FOR EXCEPTION DECODER ---------------
- Exception (9):
- epc1=0x40208fea epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000006 depc=0x00000000
- >>>stack>>>
- ctx: cont
- sp: 3ffffe40 end: 3fffffc0 offset: 0190
- <<<stack<<<
复制代码 google说是内存未对齐,但是新手实在不知道从哪里下手
有没有哪位大哥可以帮小弟看看?
|
|