lbdroid / FFMpeg-DashCam

DashCam recording for Android car radios.
8 stars 4 forks source link

Pi wifi fails to reconnect to hotspot on short stop acc off #22

Closed lbdroid closed 7 years ago

lbdroid commented 7 years ago

For instance, you stop to fill the gas, or you drop the kids off at school.

The string of events;

1) Start the car, radio enables hotspot, pi boots up, pi connects to hotspot, radio initiates recording process. 2) Drive for a while, recording video. 3) Arrive at short stop destination, ignition off, accessory power off. a) radio sees that power is off, checks again a few more times over the course of 25 seconds and confirms that power is indeed off. b) radio sends STOP RECORDING instruction to pi. c) pi sends confirmation of STOP back to radio. d) radio shuts off wifi hotspot. 4) Elapsed time from accessory power off to accessory power back on LESS THAN 5 MINUTES. Means that the radio never reached sleep mode and never shut off power to the pi. Pi does not reboot. 5) Ignition switch turned back on, accessory power goes on, radio wakes up, recognizes that power is back on. 6) radio, seeing power being back on, reactivates wifi hotspot. 7) Pi does NOT reconnect to wifi. a) radio obviously does not see that pi is available. b) radio cannot send START RECORDING instruction. c) Pi sits there like a moron doing nothing when it should be recording video.

Now apparently this problem is quite common, but not particularly visible to most users on account of the fact that most wifi access points remain on perpetually. Nevertheless, there are a few "solutions" that may be useful. 1) switch network interfaces from wpa-conf to wpa-roam. This is supposed to monitor network connectivity and reconnect as needed (currently testing). 2) dumbdumb style cronjob that checks if it is connected to the internet by pinging 8.8.8.8 and resetting the interface if not connected. 3) send instruction to reset wifi interface or reboot to pi when about to shut down hotspot.

Note that option 2 has some serious problems; a) There is a very good chance that there WON'T be any access to 8.8.8.8, even if the wifi is properly connected. Solved by switching to IP address of the radio. b) If its not connected and there is no interface available, it will keep resetting the interface like a complete moron. c) Long time between iterations means long time before recording can be resumed.

lbdroid commented 7 years ago

Since beginning testing on solution #1, I have had one instance where the pi appeared to fail to connect to the wifi hotspot, but I didn't actually have the option at the time to check if it was the wifi that was failing to connect, or it the program had crashed. There are some instances where I have observed the program crashing, I'll have to track that down.

lbdroid commented 7 years ago

Apparently, this didn't entirely fix it. Still getting occasional failure to reconnect.