Hotspot fallback when WiFi network is out of range

Hello,

Is there a way to have an option in dietpi-config or some other way to automatically enable a WiFi hotspot if a preconfigured ssid is unable to connect, reconnect or out of range?

This would particularly be useful for raspberry Pi 0w projects where the only connectivity is wifi without dongles. It would be a nice backup way to access the dietpi and configure a new ssid.

Could also be useful for projects like file storage for example would be on the local network when near configured wifi and becomes a WiFi hotspot when on the go.

You could write a script that checks to which Wifi you are connected or which are available. If you are disconnected or if your specific SSID is not available, you bring up eth0 to gain internet access again and establish the hotspot.

you could check wifi availability with nmcli, for example.

You do not mean “WiFi Hotspot” but your mean the regular WiFi (client) connection to another hostspot, right? Please try to add other SSIDs via dietpi-config network option. You can add up to 5 WiFi slots/SSIDs there and when the connection really terminates, it wpa_supplicant may indeed connect automatically to the first alternative which is in range. But I have never tested this to be true.

I’m working on a new network config script, where I may add some general network connection fallback feature, i.e. to fallback from WiFi to Ethernet and the other way round, and maybe, when it doesn’t work OOTB with multiple SSIDs added, a way to add this for the same WiFi adapter as well.

nmcli is for managing NetworkManager which is not used on DietPi :wink:.

I guess the idea is, to have the system connected to local WiFi as default setup (device will be a WiFi client). As soon as the device is moving out of local WiFi range, a Hotspot should be activated to allow connecting to the device still (device will become a WiFi AP).

Oh wow, that’d be complex. So something like the dietpi-wifi-monitor.service but changing the wlan0 interface definition, starting hostapd and isc-dhcp-server when connection is lost. Reverting this when the SSID is in range is also not so trivial: An iw/iwlist scan needs to be done each loop iteration instead of a simple ifdown/ifup :thinking:. Should be however possible.