Page 1 of 1

Static IP if wifi not found.

Posted: Thu Aug 08, 2019 11:25 pm
by roontoon
I am using the code below for two locations that I regularly have my pi, my question is I also take the pi to maker faires and run the pi headless. Is there a way to set up the wifi on the pi so if it does not find the two networks below it will assign an add hoc IP address (192.168.*.*) so I can still control my 3d printer if there is no access to the local wifi AP .

Code: Select all

network={
    ssid="hackerspace"
    psk=“password”
    id_str="hackerspace"
}

network={
    ssid="Frontier2992"
    psk=“password”
    id_str="home"
}

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

Re: Static IP if wifi not found.

Posted: Fri Aug 09, 2019 10:47 am
by epoch1970
I think you have 2 options.
One would be to switch from client mode to AP mode, stopping wpa_supplicant and launching hostapd+dnsmasq as required. There is a recent thread about that.
The other would be to use wpa_supplicant in AP mode and let its network selection algorithm decide whether to start a client configuration or an AP configuration (mode=2). Then rely on autoipv4/v6 for IP address distribution and mDNS for the name service (in the .local) domain.

The second option is lighter as it relies on wpa_supplicant in any circumstance. It should work ok, the only part I haven’t tried myself is actually letting wpa_supplicant autoselect between a client and a “mode=2” network block.

Re: Static IP if wifi not found.

Posted: Sun Aug 11, 2019 12:29 am
by blimpyway
Comitup worked on my pi zero w https://github.com/davesteele/comitup

There-s also a bootable sd image with it installed and enabled.

Re: Static IP if wifi not found.

Posted: Sun Aug 11, 2019 2:46 pm
by bls
A simple, easy-to-install and use implementation of the second method epoch1970 mentioned (using wpa_supplicant only) can be found at https://github.com/gitbls/autoAP