nisargjhaveri / WirelessAndroidAutoDongle

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

Capture Android Auto Start Request #223

Open NabeelUppel opened 6 days ago

NabeelUppel commented 6 days ago

Hi @nisargjhaveri

I was debugging why it doesn't work with car despite it working fine in another and I came to conclusion that my headunit doesn't seem to send the accessory start request

I disabled the start script located at etc/lib.d/93_aawgd (just renamed aawgd to aagwd) and ran the binary locally in usr/bin and my phone would connect to bluetooth and the TCP server would start, I would get the connected to android auto on my phone but it seems as though my headunit has no idea that it's connected. Then it would timeout and try again.

When I plug in my phone via cable it works perfectly fine, so I figured that the problem lies between how the pi is communicating to the headunit.

I've tried the USB connection strategy mode and the Bluetooth is never turned on so I think my headunit is expecting something specific which I cannot figure out and that brings me to my point.

Is it possible to capture the handshake between my phone and headunit when connected via cable?

Phone: S22+ Car: Mazda 3 2015 Pi: Zero 2 W

NabeelUppel commented 6 days ago

Another thought I had which I'm not sure if possible and I'm not sure where to start with this is to emulate android usb.

As in using the otg port on the pi, make it so the headunit believes that a wired android is connected to it.

I think this is what AAWireless Dongle also makes use of calling it passthrough.

I have no idea how this software works low level, so if this is not possible then just say so.

NabeelUppel commented 6 days ago

Okay I think I got it working again!

I forked main, added some debug logs and used the workflow to build it.

I then factory reset my headunit.

Completely removed the bluetooth, WiFi, uninstalled AA updates via the play store from my phone..

Set it up android auto via my phone and bang its working again. No idea which step made a difference.

nisargjhaveri commented 3 days ago

Hi, @NabeelUppel! Glad that you got it working. There are some reports that suggest removing wifi/bt and Android Auto storage on phone helps or resetting headunit also helps sometimes for other dongle as well. Not really sure why though and what can be done to prevent the need?

Is it possible to capture the handshake between my phone and headunit when connected via cable?

It might be possible with some usb MITM hardware. It might also be possible with a Raspberry Pi 4. But in general, I found it a lot more involved. Even if we get the raw data transfer, we need to understand the protocol. It is using and try to replicate that.

Another thought I had which I'm not sure if possible and I'm not sure where to start with this is to emulate android usb.

We essentially do this. We present RPi as a MTP device with Pixel's usb vid/pid. The aim is to make headunit think a Android Phone is connected. The MTP implementation itself might be different, and we should see if there is a scope of improvement.

NabeelUppel commented 2 days ago

Hi, @NabeelUppel! Glad that you got it working. There are some reports that suggest removing wifi/bt and Android Auto storage on phone helps or resetting headunit also helps sometimes for other dongle as well. Not really sure why though and what can be done to prevent the need?

I'm also not sure, it seems to be working consistently now, I did manage to run it awhile back for a month or two and then it stopped. I'm sure you aware of this with the amount of issues I've opened up haha. If it stops working I'll trying clearing the bluetooth devices from my car before going nuclear and resetting.

Is it possible to capture the handshake between my phone and headunit when connected via cable?

It might be possible with some usb MITM hardware. It might also be possible with a Raspberry Pi 4. But in general, I found it a lot more involved. Even if we get the raw data transfer, we need to understand the protocol. It is using and try to replicate that.

What does the Pi4 have that makes it possible? I also tried looking into it and it seems quite obfuscated and didn't find much.

Another thought I had which I'm not sure if possible and I'm not sure where to start with this is to emulate android usb.

We essentially do this. We present RPi as a MTP device with Pixel's usb vid/pid. The aim is to make headunit think a Android Phone is connected. The MTP implementation itself might be different, and we should see if there is a scope of improvement.

Again man, I have to say great work on this it's super impressive.

Feel free to close this issue.