nisargjhaveri / WirelessAndroidAutoDongle

Use Wireless Android Auto with a car that supports only wired Android Auto using a Raspberry Pi.
MIT License
331 stars 43 forks source link

Turn off bluetooth once the launch handshake is complete #18

Closed nisargjhaveri closed 7 months ago

nisargjhaveri commented 8 months ago

Fix #17

hkfuertes commented 8 months ago

I'm building and I will test this today... anyway poweroff powers off the bluetooth? We should also power it on if the TCP socket is disconnected or when we reset the usb gadget... I guess that the only time that the bluetooth should be disconnected (or off) is while the TCP connection is live.

I will test this pr today anyway, Thankyou very much!

nisargjhaveri commented 8 months ago

We should also power it on if the TCP socket is disconnected or when we reset the usb gadget...

We do enable bluetooth as part of the connect call while reconnecting in case if some failure in the proxy. Though, as a side note, tcp failures are not handled very well so far. But it does reconnect well if the usb fails. https://github.com/nisargjhaveri/AAWirelessDongle/blob/1552ae61391b51b78f0d2d8523cc784b657ec80a/aa_wireless_dongle/package/aawg/src/aawgd.cpp#L29

I guess that the only time that the bluetooth should be disconnected (or off) is while the TCP connection is live.

Yes, that's the idea. More precisely, the bluetooth will now only be turned on while trying to connect to a phone once the headunit sends start accessory request.

gamelaster commented 7 months ago

Hi folks! I began testing this firmware today (I will do until Friday, I still didn't tried BT calls yet), but what I immediately noticed, is trouble with pairing. Due to the fact that it disconnected the device after sending request to connect via RFCOMM failed, I couldn't connect again, so it took me few RPi resets to properly pair and successfully connect to the headunit.

The solution for this would be, that app checks if there is active proxy between phone and headunit, and if not, periodically try to request connection to phone, so even this fails, RPi will try to connect to phone and engage connection.

gamelaster commented 7 months ago

Past few days, BT calls were rock solid, so I guess this solved my issue, and it's OK to merge. Great job folks!

nisargjhaveri commented 7 months ago

Thanks @gamelaster for testing this out!

Due to the fact that it disconnected the device after sending request to connect via RFCOMM failed, I couldn't connect again, so it took me few RPi resets to properly pair and successfully connect to the headunit.

Could you explain this more, is this new with these changes? We don't power off unless the AA "handshake" completes.

gamelaster commented 7 months ago

Could you explain this more, is this new with these changes? We don't power off unless the AA "handshake" completes.

@nisargjhaveri Oh, sorry, I didn't checked out how exactly it works. Although, I just had quite issues after I updated the firmware, to pair it again, and actually trigger the connection mechanism, I needed to re-plug RPi like 3 times to get it working at all. Could be related to #23 , as if my connection dropped during session, only way to reconnect was to replug RPi.

Also, I don't think this behavior is caused by this PR, so I guess it's OK to merge it, and continue discussion in #23