Change WiFi config programmatically

Hi,

I would like to generally have the WiFi of my Yun switched off and only start it up from time to time to probe whether I am in reach of a pre-defined network (its for a mobile sensor). If yes, I’d like to connect to it and then run some more code. I searched a lot and can’t find anything of the sort - has anyone ever tried something like this? I struggle already at programmatically connecting to an arbitrary WiFi.

Cheers,
Joscha

Joscha,

Just an idea, not something I've tested...

The wireless parameters are stored in a file located here:
/etc/config/wireless

So by renaming that file to perhaps wirelessX and rebooting the linux side (if necessary), you could force disconnection.

mv /etc/config/wireless /etc/config/wirelessX
reboot

By changing the name back and rebooting again (if necessary), it should reconnect

mv /etc/config/wirelessX /etc/config/wireless
reboot

You might have to reestablish the Bridge if your reboot the linux side alone.

That won't strictly disable the wireless, it will still be powered if that's an issue. But you should be able to disconnect from networks like that.


Do you really have to disconnect from the network even if it is present or could you just let the Yun connect any time it can and ping the router/AP/whatever to determine whether you are currently connected?