BimmerGestalt / AAIdrive

Implementations of some Android Auto features as unofficial IDrive apps
MIT License
525 stars 89 forks source link

App Only works when Phone is connected before engine start #510

Open bastianp01 opened 2 years ago

bastianp01 commented 2 years ago

Hi. I have the Problem that the Androidauto idrive App Only works when I connect the Phone to the car before I start the engine. After connecting the Phone I need to wait about 45 seconds until myBMW App, androidauto idrive and Spotify is started on the Phone. Then I can start the car and the App works finde in my idrive with Spotify. If i connect the Phone after the car is already started it does not work at all. Is there anything I am doing wrong? Thanks for help!

jezikk82 commented 2 years ago

Can you share more details on the problem. What version of AAID you use, what Android version on what phone and which version of iDrive ?

I havent seen that kind of the problem. Often my phone connect to car during driving (I also use headphones with hands free profile) and full process take 10-15sec max.

bogdan-calapod commented 2 years ago

I havent seen that kind of the problem. Often my phone connect to car during driving (I also use headphones with hands free profile) and full process take 10-15sec max.

Same here - on an S21 it "just works", I don't have to think much about how or when the bluetooth connection starts.

Maybe there is some battery life saving/optimization setting you can check off ?

jezikk82 commented 2 years ago

I'm on Xiaomi mi11 and have the same as @bogdan-calapod Try to disable battery saving for MyBMW & AAID

bastianp01 commented 2 years ago

Hi! Here are some more Details. The Phone is a samsung Galaxy a40 with Android 11. The AAId Version is 1.3.1. My BMW is 428i From 2014 with Navigation professionell. I think its idrive4 Battery saving options for All Apps are deactivated. When I connect my Phone to the car when the car is already on, all apps start automatically (mybmw AAId and Spotify) but it does not really connect to AAId. No Spotify icon appears in the idrive no calender App and so on The Main menue of AAId App on the Phone shows grey with the Information that it is trying to connect to the car. Then it turns Green, saying that it is connected (still without Spotify in the idrive) and then it turns grey again and tries to reconnect and so on. In the same intervall the Volumen of the music (Bluetooth spotify) turns up and down. When I connected the Phone before I Start the car it really takes a while until the Phone started all three Apps. Around 45 sec. But Then it works fine and stable

LACNR commented 2 years ago

Eventually your phone needs an update or your iDrive, go to this website, enter your VIN and download the if available update, if it was never done it might will add better support for more phones, other fixes etc.

https://www.bmw.com/en/footer/software-updates.html

Since your BMW is from 2014 the compatibility with MyBMW might be limited as well as the support with the phone and additional apps, I would even recommend you to install the old BMW Conncted 6.4 Version (from an alternate app store, you don't need to use it just install and nothing else only need it for the protocol. I can give you a link to that as well.

dancadar commented 2 years ago

Eventually your phone needs an update or your iDrive, go to this website, enter your VIN and download the if available update, if it was never done it might will add better support for more phones, other fixes etc.

https://www.bmw.com/en/footer/software-updates.html

Since your BMW is from 2014 the compatibility with MyBMW might be limited as well as the support with the phone and additional apps, I would even recommend you to install the old BMW Conncted 6.4 Version (from an alternate app store, you don't need to use it just install and nothing else only need it for the protocol. I can give you a link to that as well.

Will BMW Connected still work? I can't login to it anymore.

dancadar commented 2 years ago

I have the same issue. Everything works as it should be if I connect the phone before engine start, but it will keep disconnecting if I plug it in after regardless if I am using my BMW or BMW connected app. I have NBT pro (id4) and it behaves the same on multiple android phones. I will try to get some logs from the device, maybe it will help.

Otherwise, great app.

A small update: it looks like the issue is with BMW connected /My BMW app as these seem to connect and reconnect all the time if the phone is plugged after the engine is started.

LACNR commented 2 years ago

Eventually your phone needs an update or your iDrive, go to this website, enter your VIN and download the if available update, if it was never done it might will add better support for more phones, other fixes etc. https://www.bmw.com/en/footer/software-updates.html Since your BMW is from 2014 the compatibility with MyBMW might be limited as well as the support with the phone and additional apps, I would even recommend you to install the old BMW Conncted 6.4 Version (from an alternate app store, you don't need to use it just install and nothing else only need it for the protocol. I can give you a link to that as well.

Will BMW Connected still work? I can't login to it anymore.

You don't need to login into BMW Connected app, just install it nothingelse don't open it, it will run in the background when you connect the car and have MyBMW installed as well, but you need an older Version of Connected (6.4, because will not work the removed the functions to promoten MyBMW).

bastianp01 commented 2 years ago

Eventually your phone needs an update or your iDrive, go to this website, enter your VIN and download the if available update, if it was never done it might will add better support for more phones, other fixes etc. https://www.bmw.com/en/footer/software-updates.html Since your BMW is from 2014 the compatibility with MyBMW might be limited as well as the support with the phone and additional apps, I would even recommend you to install the old BMW Conncted 6.4 Version (from an alternate app store, you don't need to use it just install and nothing else only need it for the protocol. I can give you a link to that as well.

Will BMW Connected still work? I can't login to it anymore.

You don't need to login into BMW Connected app, just install it nothingelse don't open it, it will run in the background when you connect the car and have MyBMW installed as well, but you need an older Version of Connected (6.4, because will not work the removed the functions to promoten MyBMW).

Thanks for your help. My car has the most recent Software installed and I tried the BMW connected App with the same result. I had this older Version of BMW connected. Same Problem... From time to time it worked to connect the Phone when the car Was running. But only in like 5% of All attempts Then I found out that it works with almost 100% when I connect the Phone before engine Start more or less by random. I think that was even before I switched to mybmw App. But with mybmw App I have the same Problem. Maybe the Problem lies with the car... Its like it is Not accepting the connection after the System start anymore.

bastianp01 commented 2 years ago

I have the same issue. Everything works as it should be if I connect the phone before engine start, but it will keep disconnecting if I plug it in after regardless if I am using my BMW or BMW connected app. I have NBT pro (id4) and it behaves the same on multiple android phones. I will try to get some logs from the device, maybe it will help.

Otherwise, great app.

A small update: it looks like the issue is with BMW connected /My BMW app as these seem to connect and reconnect all the time if the phone is plugged after the engine is started.

I also tried different phones.. But I never tried a high end Phone. Mybe my Phone is too slow or the Hardware is too weak? I tried an old huawei nova 2 and a Galaxy a3 from 2017 and my galaxy a40... They all are not very high Performance Devices... It was said that it works fine on S21... Maybe that is the problem?? What Phone Do you use?

jezikk82 commented 2 years ago

For sure phone is not the problem. My wife is using S7 (5-6 years old maybemore) with AAID and it works fine.

dancadar commented 2 years ago

Got the logs from both AAIDrive and My BMW. At first, i connected the phone before engine start. Everything went ok. Then i've unplugged the phone and plugged it back - it keept connecting and then disconnecting. Here are the logs:

AAIDrive https://pastebin.pl/view/7bf035e7

My BMW https://pastebin.pl/view/60ebee76

Jmmigueis commented 2 years ago

Hi all good morning \ good afternoon,

I have a Galaxy S21 updated with the latest software, and a BMW F32 from 2014 (NBT iD4) with the latest BMW updates as well, and I'm having the exact same issues as described. For a while, I had even given up on AAIdrive as I just couldn't get it to connect, but yesterday after updating to the latest version, for a brief glorious moment, everything worked. I then had to park the car, and 10mins later when I came back, couldn't get anything to connect. The app was constantly losing and regaining connection every couple of seconds. For the record, I didn't have the BMW Connected app installed, only the latest AAIDrive, and the latest MyBMW ones. I'll try it again later on this afternoon when connecting everything with the car off, and see how it handles, and installing the Connected app. I can gladly provide the logs as well if needed, as this is a great project, and I'm really keen on getting it to work.

hufman commented 2 years ago

Thank you for the logs @dancadar ! From the AAIdrive log, the lines that say Received car status announcement indicate that MyBMW is repeatedly telling us that the car is attached and detached. The USB state stayed solidly connected in accessory mode the entire time during the 5 minutes you were watching the car.

I agree that the engine status should not affect this. Is there perhaps a correlation with Bluetooth connection status? Waiting long enough for the engine to start would mean that Bluetooth is more likely to connect, and BMWConnected/MyBMW has initialization code that runs when Bluetooth connects. Perhaps there's some weird conflict between the Bluetooth app connection logic and the USB app connection logic. Try force-killing MyBMW and turning off Bluetooth before connecting, to see if that changes anything.

bastianp01 commented 2 years ago

Just to make sure that I did not made a missleading description of the problem. I meant I have to connect the phone before I can power up the cars system. The problem exists even if I power up the car without starting the enginge before phone connection.

So you mean we can try the sequence

  1. MyBMW App off
  2. Bluetooth off
  3. Start the car
  4. connect the phone via USB
  5. activate Bluetooth

Is that correct? The myBMW App starts automatically when I connect the Phone. Thats correct right?

hufman commented 2 years ago

Yes, that sounds like a good order that should reliably work, as a baseline, and then variations later can help narrow down what specifically is happening wrong. With MyBMW's remote access functionality going away soon for ID4 cars, it may be interesting to consider using BMW Connected Classic by itself, which I've heard other users mention can be more reliable for ID4 cars.

dancadar commented 2 years ago

Just to make sure that I did not made a missleading description of the problem. I meant I have to connect the phone before I can power up the cars system. The problem exists even if I power up the car without starting the enginge before phone connection.

So you mean we can try the sequence

  1. MyBMW App off
  2. Bluetooth off
  3. Start the car
  4. connect the phone via USB
  5. activate Bluetooth

Is that correct? The myBMW App starts automatically when I connect the Phone. Thats correct right?

Tried this without luck, the app still could not connect. However, I am now 100% sure it's an issue with My BMW/BMw Connect and not with AAIDrive: My BMW app did NOT get the milage from the car until I connected the phone to the car BEFORE starting up, that's why I am inclined to say it's a connexion issue on BMW apps.

bastianp01 commented 2 years ago

Same here. I tried the sequence but it did not connect to the car. What might be the differece between connecting before and after starting the cars Systems? Is there any kind of Firewall in the idrive system preventing other Software to connect after Power up ? Is there any id4 user where it works without problems? Maybe its a general problem with id4?

Jmmigueis commented 2 years ago

Tried the same as well, and no luck. Same pattern as before, with the app seeing the connection initially, but kept losing it after a couple of seconds. In the NBT it never seemed to connect, as it recognized the phone as being in Accessory Mode, but showed a message requesting to go to the Play Store, and download the Connected app, even though both it (6.4) and the MyBMW apps were installed. Could it be something with the actual BMW official apps ? I'm asking this because I have an older iPhone, with only the MyBmw app installed, and once it's conneccted to the dock, it automatically recognizes the app, and uses the apps fine.

LACNR commented 2 years ago

One thing could be that neither app is not set as start as default and have priority, in my case I choose to be BMW Connected 6.4 the default app, because at the time last year MyBMW did not support apps for ID4++. Maybe the apps are conflicting each other if one isn't set as default.

In my case it doesn't matter the car only needs to be unlocked or at least the electronics/ignition to be turned on (no engine start). But it also connects anytime when I connect when the engine is running already. Though, once in awhile I do have the case that it doesn't recognize the AAiD but usually reconnecting the USB cable solves the problem.

Tjh1968 commented 2 years ago

I know I'm late commenting on this, but I have the same issue.

I have a 2015 bmw f36 with id4 NBT evo. My Samsung note 8 on android 9 would connect fine every time and pull the apps through. Once I upgraded to a s22 ultra running android 12 , AAIdrive would constantly connect then disconnect.

I now have it working ( to a degree) Uninstall My bmw app version 2.3 or whatever it was. Download an older version 1.5 and install. Download and install Bmw connected ( even though it no longer connects to bmw). Make sure AAidrive and Mybmw and Android auto have unrestricted battery use instead of optimised. Make sure they all have permission for notifications.

Start car or ignition and then connect phone via USB. I gave permission for my phone to use Mybmw whenever the phone is connected. Then launch AAidrive and it should connect.

This loads my music apps onto the idrive and remains stable. If I remove the phone whilst the ignition or engine is still on , I have to force close mybmw and AAidrive then plug the USB lead back in. Let the phone connect using Mybmw then launch AAidrive.

Hope this makes sense. The newer Mybmw app versions cause the continuous disconnections.

6i6i commented 10 months ago

Hello,

I am also quite late at this topic. Because I explored this topic now too. (ID4) At first I have to say I used a Samsung Galaxy S9 (Android10) with latest avaiblable MyBMW App for 2 years now without any Problems. Now I had to change to a new phone which is a Samsung Galaxy A40 (Android 13) and the Problems started. Sometimes even the NBT HU crashes because the phone/myBMW App connects and disconnects so fast. In about 5% of the cases the connection is OK and stable. I think it has to be a Problem with the Version of myBMW App or Android or Samsung. Can someone confirm, that the Android 13 with myBMW 3.7.2 is working with ID4 ?

Thank you

6i6i commented 10 months ago

I just tried it again yesterday with an old Galaxy A3 (Android 9). The myBMW app version is the same myBMW 3.7.2 and there it is working. So it must have something todo with the Android 13 or the Samsung Crap that is installed on the phone.

6i6i commented 10 months ago

I just did a quick test with the following after I found [https://github.com/BimmerGestalt/AAIdrive/issues/320]

.) Galaxy A3 with only myBMW App connected via USB to the car and running SimpleSSHD ssh server. Additionally connected via Wifi to my Galaxy A54 that has opened an Hotspot. .) Galaxy A54 running AAIdrive and additionally ConnectBot SSH Client, that is connected to the SimpleSSHD Server on the Galaxy A3 and doing port forwarding (localhost:4004 forwarded to localhost:4004 on the Galaxy A3 .) AAIdrive connected immediately and all Featuers worked so far

I will no try to automate the connection process via Macrodroid and will report here if It is sucessfull and practicable

6i6i commented 10 months ago

I did the automation with MacroDroid and after some rides with this setup I can say it works. Not fully reliable as with direct USB connection, but It works ok.

@hufman would it be possible, to add an additional expert setting in AAIdrive to enter an IP Adress for the app connection? That would reduce the complexity of the setup a little bit as I could possible get rid of the SSH tunnel port forwarding.

hufman commented 10 months ago

Ew that's gross lol! I suppose it would be possible to add an extra IP to check during car probing, and it looks like all the app modules should support connecting to arbitrary hosts instead of being hardcoded to localhost.

6i6i commented 10 months ago

OK. that would be great. I think after that it could be enough, to have a app like "https://play.google.com/store/apps/details?id=com.elixsr.portforwarder&hl=de_AT&gl=US" installed on the "Gateway" Phone to just forward the myBMW localhost:4004 Port to the IP of the Wifi Interface on the same port.

I really would like to try out getting dev environment of AAIdrive working again and get this sorted out on my own, but unfortunately my phone is a company owned one and usb debugging is not allowed :-(. So I can only install "official" google play versions.

hufman commented 10 months ago

I added a new Advanced Setting to let you put in an extra IP to check for the car ports, and published it to the Open Beta in the App Store. Try it out @6i6i and hopefully it works for you!

6i6i commented 10 months ago

Hi @hufman. Thank you very much vor the fast implementation. I already tried it out and it works ! You'll get some coffee again afterwards :-D

I removed the SSH tunnel and added only the application "https://play.google.com/store/apps/details?id=com.elixsr.portforwarder&hl=de_AT&gl=US" to my "Gateway phone" (I had to install the APK because on play store the app refused to install as the android version on my gateway phone is to new). Then I added a rule for portforward from interface wlan0 with port 4004 to 127.0.0.1:4004. This I automated with macrodroid to automatically start the forwarding when Wifi is connected.

6i6i commented 9 months ago

FYI: I forked FWD: https://github.com/6i6i/FwdPortForwardingApp and added some changes so that i now established the tunnel when the app is opened.

Currently it is really working well and also not have to connect my main phone is really cool. Only the connection of HASS Gestalt aaidrive addon is not possible.

hufman commented 9 months ago

That's good to hear! Hass Gestalt should receive and utilize the given host properly, please check logcat to see any connection logs.