If the first connection between headunit and dongle/phone by cause of timeout or similar, the code now retrying all the process after 30 seconds if the channel is not establish, this must be sufficient for the mayority of the headunits.
If the wifi connection dongle <-> phone is interrupted and not recovered, for example if you go out the car less time than the car needs to poweroff the dongle, each 30 seconds the process are going to retry the connection to restore the comunication when you go back to the car.
All is done by a new external program that interact with the code by means of signals (SIGINT) because I don't found a way to kill and restart the code itself from inside, no parent/child/fork works for problems with the bluetooth UUID that don't release.
With this modifications, the device gets:
I only test in rpi4 in this case