Captive portal for esp-idf instead of Arduino

jcsbanks
Posts: 303
Joined: Tue Mar 28, 2017 8:03 pm

Captive portal for esp-idf instead of Arduino

Postby jcsbanks » Thu Jun 13, 2019 12:22 pm

https://hackaday.com/2019/06/10/captiva ... mera-hack/

I see this for Arduino (the captive portal implementation looks easy to use), but cannot find anything for esp-idf.

chegewara
Posts: 1501
Joined: Wed Jun 14, 2017 9:00 pm

Re: Captive portal for esp-idf instead of Arduino

Postby chegewara » Thu Jun 13, 2019 4:14 pm

Recently i found this one and with very few changes it works:
https://github.com/cornelis-61/esp32_Captdns

jcsbanks
Posts: 303
Joined: Tue Mar 28, 2017 8:03 pm

Re: Captive portal for esp-idf instead of Arduino

Postby jcsbanks » Mon Jun 17, 2019 5:24 pm

It does work well thanks, just by including the .h, adding the .c file, calling captdnsInit() and then making sure the http server processes any http GET request.

In the index.html to which I redirect, I added:

if (!document.location.hostname.startsWith("192")){
window.location = "http://192.168.4.1";
}

because then when the IP address of the ESP32 as STA or AP is used in a browser it does not redirect. There may be better ways to do the redirect so our true IP address shows in the address bar instead of the url from which the DNS server received to supply our index.html

It would be interesting to work out how to then disable the DNS server once the redirect has occurred so that the Android device recognises that there is no internet connection and fails over to the cellular and also prevent the ESP32 from having to deal with a flurry of headers that are too long.

markevens
Posts: 14
Joined: Sat Aug 01, 2020 6:31 am

Re: Captive portal for esp-idf instead of Arduino

Postby markevens » Tue May 04, 2021 1:32 pm

Can any please share your code it's very helpful for everyone.
or In this example https://github.com/cornelis-61/esp32_Captdns
How can we start http server instead of that socket connection

Who is online

Users browsing this forum: Bing [Bot], the-remote-engineer and 56 guests