WirelessAndroidAutoDongle
WirelessAndroidAutoDongle copied to clipboard
Fix segmentation fault when starting too fast.
Nisarg,
Since the beginning I had sometimes problems with starting the aawgd. Fortunately it occurs not every time, but since I installed my additional binary for remote opening my door using LoRa (it was also autostarting), then the problem was even more visible. All the time aawgd was not able to start - I had to add about 6-7 seconds delay before the start in the startup script OR start it manually after ssh log-in.
Yesterday I spent a whole day debugging this problem. I found out that the aawgd segfaults when starting up. The call which was leading to crash was:
m_adapter->powered->set_value(on);
I was testing the m_adapter and powered - and those was not null.
Finally I was able to create a fix for this problem. It is in this PR...
It seems that it is working great now (starts so fast, that even automatic music playing is starting, which was not always the case in my car), but please leave it open as I would like to test it several more days to make sure...
Hi, OK, I tested it and here are my results: I tested fresh starting the Pi for about 30 times. The daemon started fine without any problems (successfull AA connection) all time besides two cases (which are rather not related to this fix):
This with
hci0: BCM: Reading device address failed (-110)
and this with some
Bluetooth device already connected, disconnecting loop.
One of the above (the first one IIRC) was a segfault and the aawgd was not running, the other case it was running (but cannot connect to my phone and AA; it connects fine after an aawgd restart).
When I reverted this PR's fix from the binary - It is not starting mostly every time, so I believe this is a proper solution for this problem.
Nisarg,
Regarding this issue, I am starting to wonder if the problem isn't is that bluetoothd is not ready when staring. In case of my project I have this:
1970-01-01, 00:00:04.928 [INFO] bluetooth: 🥏 Opened bluetooth adapter hci0 with address B8:27:EB:CD:D6:B2
1970-01-01, 00:00:04.940 [ERROR] main: Bluetooth error: internal error: D-Bus error org.bluez.Error.Busy
1970-01-01, 00:00:04.940 [INFO] main: Trying to recover...
On second try (after a second) it is opened successfully.