I recently switched to Wifi from a USB-Ethernet adapter on a PiZero. Unfortunately, it will not reconnect if the AP drops. It looks like exactly the same problem in this ticket - https://github.com/Fourdee/DietPi/issues/396
and I made the adjustments recommended from the stackexchange post:
Go to /etc/ifplugd/action.d/ and rename the ifupdown file to ifupdown.original
Then do: cp /etc/wpa_supplicant/ifupdown.sh ./ifupdown
Finally: sudo reboot
That's all. Test this by turning off/on your AP; you should see that your Raspberry Pi properly reconnects.
It still doesn't reconnect unless unplug/replug the usb-wifi adapter or reboot the Pi Zero.
Any ideas?
Last edited by subaquatic on Thu Oct 20, 2016 4:03 pm, edited 1 time in total.
**EDIT - I spoke to soon. Still does not reconnect wifi after it drops. I've tried with different adapters, same problem. Interestngly, I have a B+ running dietpi and it reconnects just fine.
subaquatic wrote:Set the Wifi country and it started working
**EDIT - I spoke to soon. Still does not reconnect wifi after it drops. I've tried with different adapters, same problem. Interestngly, I have a B+ running dietpi and it reconnects just fine.
Yep expected results.
If the device is unplugged and plugged back in, the kernel will detect a hotplug event and automatically try to reconnect.
As for when the router WiFi drops, you'd need to make a script that monitors and checks for connection drops, to bring down and up the adapter.
So you could do something along the lines of (untested):
#!/bin/bash
while true
do
#check connection
# change 192.xxxx to your router IP address
if (( $(ping -c 1 192.168.0.1) != 0 )); then
# - reconnect
ifdown wlan0
ifup wlan0
# - wait 60 seconds before checking again
sleep 60
fi
done
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.