bfitz70
Posts: 2
Joined: Thu Feb 08, 2018 1:30 am

RPi configred as Access Point to configure Wifi?

Thu Feb 08, 2018 1:50 am

Someone out there must have done this already - Ideally I'm looking for a Raspbian Lite image pre-configured to do the following -

1. Boot up RPi that is configured as an Access Point (no internet)
2. Connect to the RPi using a browser (cellphone/desktop - doesn't matter)
3. RPi serves up a simple form which allows you to enter your Wifi Credentials (SSID & Password)
*obviously an httpd server would automatically run at bootup that serves a the form as a CGI
4. Save the form
5. The CGI then configures the Wifi configs with your SSID & Password
6. CGI 'unconfigures' itself as an Access Point and re-configures for WiFI
7. Reboot
8. You have just configured your first IoT RPi to connect to your wifi in a semi-automated fashion (at least now without being an advanced user via SSH or Terminal)

I will give this a few days to see if anyone has a reliable Raspbian Lite image - or the steps on how to do this before I spend much time on it. I realize the complexity of this request but I'm certain that logic can be put in at boot to check if the device is successfully connected to Wifi - otherwise enable itself as an Access Point so that it is always accessible via a browser (Access Point to configure itself with Wifi) or SSH (Wifi) ... If this is not available then I'll make an image that will function as close as possible to the logic that I outlined - it really is needed if you would want to mass market your own IoT devices that you don't intend to have a keyboard/screen to configure wifi.

epoch1970
Posts: 3070
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: RPi configred as Access Point to configure Wifi?

Thu Feb 08, 2018 3:26 pm

I suspect nobody has done that because there is a lot of "if..." in that last paragraph.

You really need a button or some other input to reset to AP mode, or the device's behaviour will be confusing.
- Imagine someone reboots the AP while you boot your Pi, it reverts to AP mode; and you sit there waiting for it to appear on the network.
- Or at boots, it tries very hard to connect to the configured network; But then if you've changed location you expect to see the AP and it takes ages to show up.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Paul Hutch
Posts: 354
Joined: Fri Aug 25, 2017 2:58 pm
Location: Blackstone River Valley, MA, USA
Contact: Website

Re: RPi configred as Access Point to configure Wifi?

Thu Feb 08, 2018 4:05 pm

I've been planning to work out a system like this myself because I've so far not found anything similar. So if you do start working on the idea I'll be glad to help out if you want.

User avatar
B.Goode
Posts: 7870
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: RPi configred as Access Point to configure Wifi?

Thu Feb 08, 2018 4:27 pm

Mime Industries, who make Raspberry Pi compatible robot kits, have support for this mode of configuration of their latest MeArmPi product.

http://learn.mime.co.uk/docs/using-your-mearm-pi/

User avatar
dividuum
Posts: 119
Joined: Sun Jun 16, 2013 1:18 pm
Location: Germany
Contact: Website

Re: RPi configred as Access Point to configure Wifi?

Fri Feb 09, 2018 4:19 pm

epoch1970 wrote:
Thu Feb 08, 2018 3:26 pm
I suspect nobody has done that because there is a lot of "if..." in that last paragraph.
Not at all :-)

I can confirm that I've actually done exactly what OP outlined for the info-beamer hosted digital signage linux system. I think I also solved a few of the problems you've outlined:
epoch1970 wrote:
Thu Feb 08, 2018 3:26 pm
- Imagine someone reboots the AP while you boot your Pi, it reverts to AP mode; and you sit there waiting for it to appear on the network.
- Or at boots, it tries very hard to connect to the configured network; But then if you've changed location you expect to see the AP and it takes ages to show up.
That is indeed a problem. Our solution is: If WiFi is configured and doesn't work within the first 2 minutes of booting up: Start the configuration access point. But only for 10 minutes. After that, revert back to the configured network. So if the WiFi is down for some reason while booting, the device won't be in the configured network for a maximum of 10 minutes. After that it'll automatically return. If the user change their WiFi configuration, they have to restart their device, wait a moment and the configuration access point will come back up. While it is active, a small icon is blinking in the corner to give a visual indication of that the device is doing. See here: https://info-beamer.com/blog/info-beame ... table-0007 (scroll to the WiFi Configuration Interface section).

So far that worked pretty well.
info-beamer hosted - A user and programmer friendly digital signage platform for the Pi: https://info-beamer.com/hosted

epoch1970
Posts: 3070
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: RPi configred as Access Point to configure Wifi?

Fri Feb 09, 2018 7:28 pm

Ok, that sounds smart. Well done!
(Still, I'd prefer a button. Just a matter of taste.)
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
dividuum
Posts: 119
Joined: Sun Jun 16, 2013 1:18 pm
Location: Germany
Contact: Website

Re: RPi configred as Access Point to configure Wifi?

Fri Feb 09, 2018 7:48 pm

epoch1970 wrote:
Fri Feb 09, 2018 7:28 pm
(Still, I'd prefer a button. Just a matter of taste.)
I agree. If the Pi had a hardware button, I'd totally use that. I haven't looked too deeply into WPS, but I feel like there might be neat way to make the configuration interface toggle-able that way. Not sure though. Might be worth looking into.
info-beamer hosted - A user and programmer friendly digital signage platform for the Pi: https://info-beamer.com/hosted

epoch1970
Posts: 3070
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: RPi configred as Access Point to configure Wifi?

Fri Feb 09, 2018 8:38 pm

If your beamer is a client: WPS is deemed insecure, many APs do not support it and wise admins disable it.
If your beamer is the AP: some clients don't support WPS at all, eg iOS.

It's kind of a shame iOS doesn't even support network config by QR, that could have been nice. Just flash the screen and you're home.
Android does that, iOS not.
Oops. Now iOS11 does that too it seems. A quick search told me the QR format is the same as for Android.

EDIT. Just tried with an iPad and a semi-random online QR generator. It's worky. You have to use the iOS camera app, when it sees the QR it will prompt you to join.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
dividuum
Posts: 119
Joined: Sun Jun 16, 2013 1:18 pm
Location: Germany
Contact: Website

Re: RPi configred as Access Point to configure Wifi?

Sat Feb 10, 2018 11:51 am

epoch1970 wrote:
Fri Feb 09, 2018 8:38 pm
If your beamer is a client: WPS is deemed insecure, many APs do not support it and wise admins disable it.
If your beamer is the AP: some clients don't support WPS at all, eg iOS.
Yeah. That doesn't sound too good. I figured WPS might be used as a signal to trigger starting the configuration access point in the first place. So if anyone tries WPS push button, start the access point. Kind of abusing it as a wireless button, nothing more :-)
epoch1970 wrote:
Fri Feb 09, 2018 8:38 pm
EDIT. Just tried with an iPad and a semi-random online QR generator. It's worky. You have to use the iOS camera app, when it sees the QR it will prompt you to join.
Can confirm. Just tried it. Thanks. I didn't realize that was a supported feature. Using that in this use case feels a clunky though: While connecting with the correct credentials works flawlessly, the fact that the configuration AP created by the Pi isn't a "real internet connection" kind of breaks the flow. The network implements a captive portal. This usually forces IOS to launch a browser window with the sign-in web page - which in the case of info-beamer is a page were the user configures the real WiFi credentials that the Pi should use. When using QR codes, this popup browser doesn't appear unless the user opens any app that requires network connectivity. In my tests, launching a browser or opening the IOS WiFi settings page triggered this. So right now it's:

Scan QR Code → Confirm network join → ??????????? → browser with sign-in page pops up → configure Pi network with it

The ??? part is where the user gets confused because nothing happens unless a browser or the WiFi settings page is opened. When manually selecting the WiFi and entering its credentials, the flow looks like this:

Select configuration WiFi → Enter credentials → browser with sign-in page pops up → configure Pi network with it

Maybe I'm missing something? The other downside is probably that the password of the temporary configuration network is broadcasted in form of an QR code to anyone seeing the screen. This might not always be a good idea.
info-beamer hosted - A user and programmer friendly digital signage platform for the Pi: https://info-beamer.com/hosted

epoch1970
Posts: 3070
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: RPi configred as Access Point to configure Wifi?

Sat Feb 10, 2018 3:23 pm

I was thinking of the guy who puts the video projector in the room and starts it.
The Pi does his "no net? AP, then" thing, and the screen displays the QR code.
So the guy flashes the screen with his phone, that gives him access to that AP and he can configure the network.
And you can use a different password/ssid every time if you wish.

I've read a few pages on info-beamer yesterday (I liked what I saw), I've noticed you have some info screen giving the ID of the projector etc. Why not add a QR there if the projector needs configuring?
Last edited by epoch1970 on Sat Feb 10, 2018 3:25 pm, edited 1 time in total.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Paul Hutch
Posts: 354
Joined: Fri Aug 25, 2017 2:58 pm
Location: Blackstone River Valley, MA, USA
Contact: Website

Re: RPi configred as Access Point to configure Wifi?

Sat Feb 10, 2018 3:24 pm

Thanks for all the information everyone.

It appears that the successful implementations are only in products without open source code, is that correct?

User avatar
dividuum
Posts: 119
Joined: Sun Jun 16, 2013 1:18 pm
Location: Germany
Contact: Website

Re: RPi configred as Access Point to configure Wifi?

Sat Feb 10, 2018 6:37 pm

epoch1970 wrote:
Sat Feb 10, 2018 3:23 pm
I was thinking of the guy who puts the video projector in the room and starts it.
The Pi does his "no net? AP, then" thing, and the screen displays the QR code.
So the guy flashes the screen with his phone, that gives him access to that AP and he can configure the network.
Except that the step before configuring the network is unclear. At least in my quick experiments I explicitly had to open up a browser before the captive portal detection of IOS triggered the login website, which in my case is the WiFi configuration page. Which is a bit counterintuitive as otherwise just nothing happens.
epoch1970 wrote:
Sat Feb 10, 2018 3:23 pm
And you can use a different password/ssid every time if you wish.
That is indeed pretty neat. I'm still not sure if it's a good idea to instantly allow anyone to open the WiFi configuration page by just reading the QR code. The current system requires at least the password set for the AP created by the Pi. That way reconfiguration is limited to people that know the "reconfiguration password". Using an QR code would open that up to the public.

epoch1970 wrote:
Sat Feb 10, 2018 3:23 pm
I've read a few pages on info-beamer yesterday (I liked what I saw), I've noticed you have some info screen giving the ID of the projector etc. Why not add a QR there if the projector needs configuring?
Mostly for the reasons mentioned above. And because the current system works pretty well. But I'll keep the QR in mind for the future.
info-beamer hosted - A user and programmer friendly digital signage platform for the Pi: https://info-beamer.com/hosted

epoch1970
Posts: 3070
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: RPi configred as Access Point to configure Wifi?

Sat Feb 10, 2018 9:07 pm

dividuum wrote:
Sat Feb 10, 2018 6:37 pm
Except that the step before configuring the network is unclear ... I'll keep the QR in mind for the future.
Yes, that's probably enough OT discussion for this thread :)
But before closing:
- With a "normal" AP (not a hotspot thing), yesterday my iOS11 device gave me no grief when connecting to my hostapd instance on the Pi
- Let's say it's setup time; start a normal AP but let it accept 1, maybe 2 clients max
- Display the QR (wifi config) to connect to the network until a DHCP lease has been given, then
- Display the QR (http:// URL) to reach the configuration page until that page is hit, then
- Display login instructions or a contact point for the admin that has defined the global site password if that was configured.
And if you like active threat response -I always fear of self-inflicted DoS- you could ban offenders from the AP once they've failed a few times at entering the password.

Just my 2cts. I don't manage APs at hackers conferences every day ;)
Cheers.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
B.Goode
Posts: 7870
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: RPi configred as Access Point to configure Wifi?

Tue Feb 13, 2018 3:53 pm

Another example of an RPi OS image that presents a wireless hotspot that allows association with an upstream WiFi network:

https://hacks.mozilla.org/2018/02/how-t ... s-gateway/

Paul Hutch
Posts: 354
Joined: Fri Aug 25, 2017 2:58 pm
Location: Blackstone River Valley, MA, USA
Contact: Website

Re: RPi configred as Access Point to configure Wifi?

Tue Feb 13, 2018 4:02 pm

Thanks for finding out this open implementation.

The Mozilla source code is here:
https://github.com/mozilla-iot/gateway-wifi-setup

It is based on this RasPi3 open source code here:
https://github.com/davidflanagan/wifi-setup

bfitz70
Posts: 2
Joined: Thu Feb 08, 2018 1:30 am

Re: RPi configred as Access Point to configure Wifi?

Wed Feb 21, 2018 2:54 am

dividuum wrote:
Fri Feb 09, 2018 4:19 pm
epoch1970 wrote:
Thu Feb 08, 2018 3:26 pm
I suspect nobody has done that because there is a lot of "if..." in that last paragraph.
Not at all :-)

I can confirm that I've actually done exactly what OP outlined for the info-beamer hosted digital signage linux system. I think I also solved a few of the problems you've outlined:
epoch1970 wrote:
Thu Feb 08, 2018 3:26 pm
- Imagine someone reboots the AP while you boot your Pi, it reverts to AP mode; and you sit there waiting for it to appear on the network.
- Or at boots, it tries very hard to connect to the configured network; But then if you've changed location you expect to see the AP and it takes ages to show up.
That is indeed a problem. Our solution is: If WiFi is configured and doesn't work within the first 2 minutes of booting up: Start the configuration access point. But only for 10 minutes. After that, revert back to the configured network. So if the WiFi is down for some reason while booting, the device won't be in the configured network for a maximum of 10 minutes. After that it'll automatically return. If the user change their WiFi configuration, they have to restart their device, wait a moment and the configuration access point will come back up. While it is active, a small icon is blinking in the corner to give a visual indication of that the device is doing. See here: https://info-beamer.com/blog/info-beame ... table-0007 (scroll to the WiFi Configuration Interface section).

So far that worked pretty well.
Hi, ,this is exactly what I'm looking to do but I need the process embedded into my Raspberry Pi Zero W .. do you offer a non-hosted solution?

User avatar
dividuum
Posts: 119
Joined: Sun Jun 16, 2013 1:18 pm
Location: Germany
Contact: Website

Re: RPi configred as Access Point to configure Wifi?

Wed Feb 21, 2018 3:45 am

bfitz70 wrote:
Wed Feb 21, 2018 2:54 am
Hi, ,this is exactly what I'm looking to do but I need the process embedded into my Raspberry Pi Zero W .. do you offer a non-hosted solution?
Sorry, I don't. Also it's tightly integrated into the custom Linux distribution that info-beamer hosted is using, so it wouldn't work in Raspbian without quite a bit of work.
info-beamer hosted - A user and programmer friendly digital signage platform for the Pi: https://info-beamer.com/hosted

kurucu
Posts: 1
Joined: Tue Jun 25, 2019 12:15 am

Re: RPi configred as Access Point to configure Wifi?

Tue Jun 25, 2019 12:19 am

There's a nice library here https://github.com/jasbur/RaspiWiFi that does this - could easily be forked and tweaked to adjust the behaviour to your needs.

Return to “Advanced users”