• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

main/11-Mar-2024-487321

CMakeLists.txtD11-Mar-2024238 75

MakefileD11-Mar-2024185 92

README.mdD11-Mar-20244.7 KiB9778

example_test.pyD11-Mar-20244.9 KiB14386

sdkconfig.defaultsD11-Mar-202461 32

README.md

1# Captive Portal Example
2
3(See the README.md file in the upper level 'examples' directory for more information about examples.)
4
5This example demonstrates a simple captive portal that will redirect all DNS IP questions to point to the softAP and redirect all HTTP requests to the captive portal root page. Triggers captive portal (sign in) pop up on Android, iOS and Windows. Note that the example will not redirect HTTPS requests.
6
7## How to Use Example
8
9Before project configuration and build, be sure to set the correct chip target using `idf.py set-target <chip_name>`.
10
11### Hardware Required
12
13* A development board with ESP32/ESP32-S2/ESP32-C3 SoC (e.g., ESP32-DevKitC, ESP-WROVER-KIT, etc.)
14* A USB cable for power supply and programming
15* WiFi interface
16
17### Configure the project
18
19Open the project configuration menu (`idf.py menuconfig`).
20
21In the `Example Configuration` menu:
22
23* Set the Wi-Fi configuration.
24    * Set `SoftAP SSID`
25    * Set `SoftAP Password`
26    * Set `Maximal STA connections`
27
28When using the legacy GNU Make build system, set `Default serial port` under `Serial flasher config`.
29
30### Build and Flash
31
32Build the project and flash it to the board, then run monitor tool to view serial output:
33
34```
35idf.py -p PORT flash monitor
36```
37
38(To exit the serial monitor, type ``Ctrl-]``.)
39
40See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
41
42## Example Output
43
44```
45I (733) example: Set up softAP with IP: 192.168.4.1
46I (743) example: wifi_init_softap finished. SSID:'esp32_ssid' password:'esp32_pwd'
47I (753) example: Starting server on port: '80'
48I (753) example: Registering URI handlers
49I (763) example_dns_redirect_server: Socket created
50I (763) example_dns_redirect_server: Socket bound, port 53
51I (773) example_dns_redirect_server: Waiting for data
52I (1873) wifi:new:<1,1>, old:<1,1>, ap:<1,1>, sta:<255,255>, prof:1
53I (1873) wifi:station: e8:84:a5:18:8f:80 join, AID=1, bgn, 40U
54I (2203) example: station e8:84:a5:18:8f:80 join, AID=1
55I (2833) example_dns_redirect_server: Received 50 bytes from 192.168.4.2 | DNS reply with len: 66
56I (2843) example_dns_redirect_server: Waiting for data
57I (3043) example_dns_redirect_server: Received 39 bytes from 192.168.4.2 | DNS reply with len: 55
58I (3043) example_dns_redirect_server: Waiting for data
59I (3043) example_dns_redirect_server: Received 42 bytes from 192.168.4.2 | DNS reply with len: 58
60I (3053) example_dns_redirect_server: Waiting for data
61W (3203) wifi:<ba-add>idx:4 (ifx:1, e8:84:a5:18:8f:80), tid:0, ssn:9, winSize:64
62I (3533) example: Redirecting to root
63I (5693) example_dns_redirect_server: Received 37 bytes from 192.168.4.2 | DNS reply with len: 53
64I (5693) example_dns_redirect_server: Waiting for data
65I (5783) example_dns_redirect_server: Received 46 bytes from 192.168.4.2 | DNS reply with len: 62
66I (5783) example_dns_redirect_server: Waiting for data
67I (6303) example_dns_redirect_server: Received 41 bytes from 192.168.4.2 | DNS reply with len: 57
68I (6303) example_dns_redirect_server: Waiting for data
69I (6303) example_dns_redirect_server: Received 41 bytes from 192.168.4.2 | DNS reply with len: 57
70I (6313) example_dns_redirect_server: Waiting for data
71I (6593) example: Redirecting to root
72I (9623) example: Redirecting to root
73I (12913) example: Redirecting to root
74I (13263) example_dns_redirect_server: Received 34 bytes from 192.168.4.2 | DNS reply with len: 50
75I (13273) example_dns_redirect_server: Waiting for data
76I (13273) example_dns_redirect_server: Received 34 bytes from 192.168.4.2 | DNS reply with len: 50
77I (13283) example_dns_redirect_server: Waiting for data
78I (16303) example_dns_redirect_server: Received 32 bytes from 192.168.4.2 | DNS reply with len: 48
79I (16303) example_dns_redirect_server: Waiting for data
80I (18073) example: Redirecting to root
81I (18273) example_dns_redirect_server: Received 34 bytes from 192.168.4.2 | DNS reply with len: 50
82I (18273) example_dns_redirect_server: Waiting for data
83I (18273) example_dns_redirect_server: Received 34 bytes from 192.168.4.2 | DNS reply with len: 50
84I (18283) example_dns_redirect_server: Waiting for data
85I (20683) example_dns_redirect_server: Received 42 bytes from 192.168.4.2 | DNS reply with len: 58
86I (20683) example_dns_redirect_server: Waiting for data
87I (20753) example: Redirecting to root
88I (21323) example: Redirecting to root
89I (22683) example_dns_redirect_server: Received 48 bytes from 192.168.4.2 | DNS reply with len: 64
90I (22693) example_dns_redirect_server: Waiting for data
91I (23443) example_dns_redirect_server: Received 48 bytes from 192.168.4.2 | DNS reply with len: 64
92I (23453) example_dns_redirect_server: Waiting for data
93I (23473) example: Serve root
94I (23503) example_dns_redirect_server: Received 48 bytes from 192.168.4.2 | DNS reply with len: 64
95I (23513) example_dns_redirect_server: Waiting for data
96```
97