hamishcunningham / fishy-wifi

Scripts, notes and the odd subaquatic gizmo for the ESP8266 and what-have-you.
GNU Affero General Public License v3.0
25 stars 13 forks source link

Captive Portal #11

Open Eroc33 opened 6 years ago

Eroc33 commented 6 years ago

Implement captive portal in joinme, and use joinme in the main waterelf32 sketch.

A decent portion of the required code appears to already be in place, but large chunks of code are commented out, and joinme is never used by waterelf32, so the file at least needs refactoring/cleanup and needs to be implemented in the main sketch.

layerzerolabs commented 6 years ago

me-no-dev/ESPAsyncWebServer#241 suggests that if we can demonstrate captive portal working on recent phones then this is valuable information. Tiny point but can you add esp32 label to this? Not sure if it merits the enhancement label or not - your call. Ta!

Eroc33 commented 6 years ago

I've been having some weird issues with the captive portal stuff. The example code in the DNSServer lib worked once, and then stopped, and I'm not really sure why. A little prodding with wireshark and similar tools suggests that the client device isn't getting the dns server ip from dhcp. Not really sure why, or how to resolve this.

Eroc33 commented 6 years ago

So this seems to have happened after updating the libraries, and it does look like there have been some changes to the IDF code around the DNS servers given in DHCP response recently. So this might actually be blocked by a bug/difficult to work-around change in the IDF code.

layerzerolabs commented 6 years ago

Which DNS library are you using? I think the one we have included is for the esp8266... sorry about that... Can you try this one and report back?

Eroc33 commented 6 years ago

As far as I can tell the DNS server itself works fine (I can directly query it with dig and get the expected results). The problem is there was a change in esp-idf which means the default DNS servers returned by the DHCP server on the esp is 0.0.0.0 so the client never queries the DNS server.

There is a function to change the dns settings that the DHCP server returns but for some reason I get a linker error when I try to use it.

layerzerolabs commented 6 years ago

Hmmm a fairly thorough google doesn't reveal much - so if your hypothesis is correct it must be fairly recent....

Can you try with an older version to confirm?

And if the expected dns config option doesn't work anymore then we should raise it as an issue on their github repository.

Eroc33 commented 6 years ago

Actually I've managed to figure out how to fix it by experimenting with the IDF. I thought it was a bug but it's more of a backwards incompatibility where the default behavior changed. Thankfully it's just a couple of additional lines before the old captive portal setup.

layerzerolabs commented 6 years ago

Fix it as in got captive portal working? Kudos - and feel free to compose a pull request if you like although we weren't expecting that already. ..

Bask in the warm glow of success....

Eroc33 commented 6 years ago

I've opened an issue over at https://github.com/espressif/esp-idf/issues/1285 and noted what the lines from the idf do, and mentioned the issue, in a comment. I think I should have a first-pass pull request ready by the end of today.

Eroc33 commented 6 years ago

Inital PR at https://github.com/hamishcunningham/fishy-wifi/pull/19

hamishcunningham commented 6 years ago

Merged, tnx