Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Captive Portal to enter AccessPoint credentials #1221

Closed
MaBecker opened this issue Aug 18, 2017 · 11 comments
Closed

Implement Captive Portal to enter AccessPoint credentials #1221

MaBecker opened this issue Aug 18, 2017 · 11 comments

Comments

@MaBecker
Copy link
Contributor

MaBecker commented Aug 18, 2017

Started to work on Captive Portal to enter SSID and Password to easily connect a Wifi enable Espruino device to a local AP. All this is based on UPD dgram from @opichals .

[-] implement a wrapper module for all wifi devices
[x] setup dns server to handle IP4 request
[x] with own ip
[x] setup http server
[x] redirect to own http server
[-] present page to enter SSID and Password
[-] create a CaptivePortal JS module

First version of CaptivePortal.js is still ESP specific because the first topic is missing.

@gfwilliams What are your thoughts about such a wifi device wrapper?

Any hints, comments or wishes are welcome.

@gfwilliams
Copy link
Member

Ideally, I'd like to make Wifi a built-in object for all boards... Maybe tweaking one or two of the commands so it was possible to implement them on more platforms (some are sync, when other platforms require async).

There's an at branch where I was looking at this for ESP8266. To be honest I think that would be a better use of time?

@opichals
Copy link
Contributor

Just an idea here:

It would be cool if the wifi capable Espruino firmware 'shipped' with such a thing built-in and the only thing the user would have to do to start working with such a board would just be to plug it in a USB and connect to it using his dev machine/phone. It could give the user a choice to connect to his wifi router and provide the Espruino IDE links (or even redirects) allowing for a smooth onboarding.

Once router-connected it could advertise itself as an Espruino capable via mDNS (just like the esp8226 version does at the moment) and allow for local discoverability.

@gfwilliams
Copy link
Member

Yes, that's what I'd been thinking as well. I've been experimenting with compiling in JS code, and it works pretty well - so that could be a good option for this I think.

@MaBecker
Copy link
Contributor Author

Great, so this will be a cool firmware enhancement!

@MaBecker
Copy link
Contributor Author

MaBecker commented Feb 17, 2018

I think a more useful variant of having a captive portal is to have a captiveForm

  • open a captive portal (dns and http server)
  • present given form or default form (sid & pass)
  • collect postData
  • close captive portal (dns and http server)
  • return postData via callback
 captiveForm.open({'callback':callback,'FormName':'captiveForm'});

This allows user to setup their on captive form or use the default form

Note: 'captiveForm' is a name of a 'Storage' file/item

@gfwilliams
Copy link
Member

Personally I think this is more of a getting started thing that we'd want pre-installed - so customisation wouldn't be a big deal as long as it was easy for people to change the code to roll their own?

Once configured, potentially we could also look at using this to serve up an iframe to espruino.com/ide with a websocket server for the IDE? It shouldn't actually require much code.

@wilberforce
Copy link
Member

wilberforce commented Apr 10, 2018

@MaBecker

I've extended your starting code:

https://gist.github.com/wilberforce/cc6025a535b8a4c7e2910d4ba7845f11

It scans for wifi ssid, adds that to the drop list, and allows you to enter a password and connect to the network.

Still very much proof of concept....

process.memory();
={ "free": 995, "usage": 405, "total": 1400, "history": 13,
  "gc": 0, "gctime": 1.992 }
> 

Might use too much space on the ESP8266, but more useful on the ESP32 or Espruino Wifi perhaps (I don't have one to test with)

img_4097

img_4098

@gfwilliams
Copy link
Member

Very nice. If this went into flash (which it would) then it could hopefully be tweaked such that it didn't use any RAM once WiFi had been connected?

@wilberforce
Copy link
Member

Yes. I would like to use the Storage module to save a list of known access points and passwords.

Then on start up:

Test for conection. If ok done.
Try to connect to last connection. If ok done.
Scan the network, try to connect to the strongest with a known saved password... work the through the list.
If this fails then start as an AP and fire up the active portal... on connect, stop AP.

I might be over complicating things here!

So extending the concept of wifi.save to work with known existing networks, and only on failure do the captive portal.

@MaBecker
Copy link
Contributor Author

Wow - great work

@MaBecker
Copy link
Contributor Author

time to close it ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants