Page 1 of 1

Wifi: fallback to access point if no available networks

Posted: Thu Feb 07, 2013 10:02 am
by wimble
I've got my Pi wifi'd up, with a couple of network connections configured (as per the instructions at http://elinux.org/RPi_Peripherals). This connects the Pi to the appropriate network when the interface is brought up.

But what happens if there's no appropriate wifi available? Does anybody know if there's a way to start the wifi, with a pre-configured SID, so that at least I'd be able to have a private connection into the Pi, and could then SSH in, and continue work?

If it's not obvious, I'm intending this for completely headless access, so I don't have to take a keyboard or screen with me: I can just SSH across from my phone.

Re: Wifi: fallback to access point if no available networks

Posted: Tue Feb 12, 2013 11:31 am
by lukeguk
I am very interested in doing this too.

Would setting the pi up as an access point (there are a few tutorials on this) work? I want to be able to SSH into my pi from an app on my phone when out and about without wifi. If seems that I would need a wifi adapter that supports AP mode, which my current Edimax one doesn't.

Re: Wifi: fallback to access point if no available networks

Posted: Tue Feb 12, 2013 12:42 pm
by adigraham
I too am looking into how this could be done, basically I want this:-

RPI with Openelec installed hidden in the car dash and connected to my car stereo with ad-hoc wifi network and XBMC Commander app on my iphone controlling what i play.

When the car is outside my house to have the wifi change to normal wifi to then allow a rsync with my home nas to check for updated music etc.

All help appreciated!

Re: Wifi: fallback to access point if no available networks

Posted: Tue Feb 12, 2013 4:05 pm
by SirLagz
Something like this ?
http://sirlagz.net/2013/01/22/script-st ... goes-down/

You could potentially use this script to bring up the wifi connection and run an rsync as well when you get back home, though I haven't coded that bit yet.

Re: Wifi: fallback to access point if no available networks

Posted: Tue Feb 12, 2013 4:31 pm
by adigraham
hey, lol was bookmarking your site earlier!

Yeah thats what we want (friend of mine too wants a raspcarputer :)

Do you think a script will suffice?

Re: Wifi: fallback to access point if no available networks

Posted: Tue Feb 12, 2013 4:51 pm
by wimble
Yup, that looks very much like the sort of thing I was after. Hmm... I wonder whether it's possible to integrate it with ifup and ifdown to avoid the polling. I'll give it a go this evening.

Integrating it with ifup is probably a bad idea: it would drop the access point just because a better external network appeared, and it may not be possible to detect the external network in such cases, anyway. But hooking it into ifdown would be nice.

Re: Wifi: fallback to access point if no available networks

Posted: Wed Feb 13, 2013 12:35 am
by SirLagz
That script actually needs some improvements.
I'm not sure how you would integrate it into ifup or ifdown...I don't really see a reason why you would want to either.

At the moment, I don't think that script will reconnect to a network when it comes back into range, purely because it can't poll for networks when hostapd is running as far as I can recall. I need to do some more testing with that aspect of it though.

Re: Wifi: fallback to access point if no available networks

Posted: Wed Feb 13, 2013 10:44 am
by wimble
SirLagz wrote:I'm not sure how you would integrate it into ifup or ifdown...I don't really see a reason why you would want to either.
Simply because I dislike having to constantly poll to see whether an action needs to be performed. 99% of the time there's nothing to be done (the wifi is connected), and on the occasions where it is needed, it would have been useful to have it done *sooner* (eg. with cron, the finest resolution is a minute, so, on average, you're going to have 30 seconds before the access point is brought up). Tying it into the existing networking scripts means that the work will be done as soon as it's needed, and there are no unnecessary tests.

I didn't get around to resolving this last night, but I did find enough about wpa_supplicant to find out that I need to find out more. Hi-ho! It's off to read the internet I go!

Re: Wifi: fallback to access point if no available networks

Posted: Wed Feb 13, 2013 12:22 pm
by SirLagz
Probably best putting the script into /etc/network/if-down.d/ then, in which scripts run when ifdown is run.

Re: Wifi: fallback to access point if no available networks

Posted: Wed Feb 13, 2013 12:28 pm
by adigraham
Great work guys!

A friend and myself are going to build Openelec RPis this weekend, so if we can help you guys then shout.