You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libraries/DNSServer/examples/CaptivePortalAdvanced/CaptivePortalAdvanced.ino
+25-25
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,21 @@
1
1
#include<ESP8266WiFi.h>
2
-
#include<WiFiClient.h>
2
+
#include<WiFiClient.h>
3
3
#include<ESP8266WebServer.h>
4
4
#include<DNSServer.h>
5
5
#include<ESP8266mDNS.h>
6
6
#include<EEPROM.h>
7
7
8
8
/*
9
-
* This example serves a "hello world" on a WLAN and a SoftAP at the same time.
10
-
* The SoftAP allow you to configure WLAN parameters at run time. They are not setup in the sketch but saved on EEPROM.
11
-
*
12
-
* Connect your computer or cell phone to wifi network ESP_ap with password 12345678. A popup may appear and it allow you to go to WLAN config. If it does not then navigate to http://192.168.4.1/wifi and config it there.
13
-
* Then wait for the module to connect to your wifi and take note of the WLAN IP it got. Then you can disconnect from ESP_ap and return to your regular WLAN.
14
-
*
15
-
* Now the ESP8266 is in your network. You can reach it through http://192.168.x.x/ (the IP you took note of) or maybe at http://esp8266.local too.
16
-
*
17
-
* This is a captive portal because through the softAP it will redirect any http request to http://192.168.4.1/
18
-
*/
9
+
This example serves a "hello world" on a WLAN and a SoftAP at the same time.
10
+
The SoftAP allow you to configure WLAN parameters at run time. They are not setup in the sketch but saved on EEPROM.
11
+
12
+
Connect your computer or cell phone to wifi network ESP_ap with password 12345678. A popup may appear and it allow you to go to WLAN config. If it does not then navigate to http://192.168.4.1/wifi and config it there.
13
+
Then wait for the module to connect to your wifi and take note of the WLAN IP it got. Then you can disconnect from ESP_ap and return to your regular WLAN.
14
+
15
+
Now the ESP8266 is in your network. You can reach it through http://192.168.x.x/ (the IP you took note of) or maybe at http://esp8266.local too.
16
+
17
+
This is a captive portal because through the softAP it will redirect any http request to http://192.168.4.1/
18
+
*/
19
19
20
20
/* Set these to your desired softAP credentials. They are not configurable at runtime */
21
21
constchar *softAP_ssid = "ESP_ap";
@@ -61,7 +61,7 @@ void setup() {
61
61
Serial.print("AP IP address: ");
62
62
Serial.println(WiFi.softAPIP());
63
63
64
-
/* Setup the DNS server redirecting all the domains to the apIP */
64
+
/* Setup the DNS server redirecting all the domains to the apIP */
Copy file name to clipboardExpand all lines: libraries/DNSServer/examples/CaptivePortalAdvanced/handleHttp.ino
+8-8
Original file line number
Diff line number
Diff line change
@@ -26,10 +26,10 @@ void handleRoot() {
26
26
27
27
/** Redirect to captive portal if we got a request for another domain. Return true in that case so the page handler do not try to handle the request again. */
28
28
boolean captivePortal() {
29
-
if (!isIp(server.hostHeader()) && server.hostHeader() != (String(myHostname)+".local")) {
29
+
if (!isIp(server.hostHeader()) && server.hostHeader() != (String(myHostname) + ".local")) {
30
30
Serial.print("Request redirected to captive portal");
0 commit comments