Hi,
I'm having problems creating a flow which does the following:
In my car I have a wireless charger. Now, I want a flow that recognizes the wireless charging, then enables Bluetooth, then waits something like 120sec for my car to connect and then - if connected to car starts Google Maps, if not, disables Bluetooth again.
The trigger is clear and I also found the necessary Bluetooth Action, but how can I realize that Automagic waits like 2 minutes and then checks if car is connected via Bluetooth and then continues?
Thank you very much
Wait for Bluetooth to connect?
Moderator: Martin
Re: Wait for Bluetooth to connect?
Why don't just use action Connect/disconnect bluetooth devices? Then check if the bluetooth is connected. If not, use sleep 10 seconds and loop back to try Connect again. Use execution count to limit it to 6-10 times.
Your flow probably will be similar to this one : viewtopic.php?f=5&t=7314
Your flow probably will be similar to this one : viewtopic.php?f=5&t=7314
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Wait for Bluetooth to connect?
As Desmanto says, or, literally:mrHS wrote:Hi,
I'm having problems creating a flow which does the following:
In my car I have a wireless charger. Now, I want a flow that recognizes the wireless charging, then enables Bluetooth, then waits something like 120sec for my car to connect and then - if connected to car starts Google Maps, if not, disables Bluetooth again.
- recognizes the wireless charging,
http://automagic4android.com/en/help/co ... _connected
- then enables Bluetooth,
http://automagic4android.com/en/help/co ... ooth_state
- then waits something like 120sec for my car to connect and then
http://automagic4android.com/en/help/co ... tion_sleep
- if connected to car starts Google Maps, if not, disables Bluetooth again.
http://automagic4android.com/en/help/co ... _connected
http://automagic4android.com/en/help/co ... launch_app
http://automagic4android.com/en/help/co ... ooth_state
Re: Wait for Bluetooth to connect?
Thank you both - I created such a flow and in general it seems to work.
However, on every second launch of the flow, the bluetooth connection won't work and I don't know why. This is the log:
Any ideas what the problem could be?
Thank you!
However, on every second launch of the flow, the bluetooth connection won't work and I don't know why. This is the log:
The flow ends and won't start Google Maps...11.10.2018 11:38:01.798 [Autofahrt-Start] Start executing action 'Bluetooth Gerät verbinden/trennen: Verbinden Headset Audi MMI'
11.10.2018 11:38:01.925 [Autofahrt-Start] Action 'Bluetooth Gerät verbinden/trennen: Verbinden Headset Audi MMI' Could not connect the bluetooth device
11.10.2018 11:38:01.925 [Autofahrt-Start] End executing action 'Bluetooth Gerät verbinden/trennen: Verbinden Headset Audi MMI' and exception Could not connect the bluetooth device
11.10.2018 11:38:01.925 [Autofahrt-Start] Flow ends execution due to errors
11.10.2018 11:38:01.926 [Autofahrt-Start] Error:
ch.gridvision.ppam.androidautomagiclib.util.m: Could not connect the bluetooth device
at ch.gridvision.ppam.androidautomagic.model.a.p$1$1.run(SourceFile:184)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7002)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
11.10.2018 11:38:01.932 [Autofahrt-Start] Flow ended.
Any ideas what the problem could be?
Thank you!
Re: Wait for Bluetooth to connect?
Not sure. Maybe the MMI simply won't accept the connection request sometimes. I've not found Audi's MMI Bluetooth implementation (with my 2015 vintage MMI in an A3) all that great in general.
But I don't use that Action. In my case I take a different approach to this which may or may not work for you. Several flows are used to do the following:
Turn Bluetooth off whenever the display goes off or no Bluetooth devices are connected and then things are still the same after 5 mins and no power is connected. This works in general and is nothing to do with specifically being in the car or not. It just saves a little power when not using Bluetooth, otherwise I'd leave Bluetooth on all the time anyway. When I get in the car, Bluetooth gets turned on (if it's not already on) because another flow turns on Bluetooth when the power gets connected or the display turns on. I then find the phone automatically gets reconnected to the MMI as the MMI powers up. I don't use an Action to explicitly connect to the MMI. I think the phone and MMI automatically find each other as previously connected devices and connection is attempted. Not sure if it's the phone or MMI that initiates this automatically - I know I don't!
I use the Bluetooth connection state to the MMI to trigger what happens when I enter/exit the car with more flows
But I don't use that Action. In my case I take a different approach to this which may or may not work for you. Several flows are used to do the following:
Turn Bluetooth off whenever the display goes off or no Bluetooth devices are connected and then things are still the same after 5 mins and no power is connected. This works in general and is nothing to do with specifically being in the car or not. It just saves a little power when not using Bluetooth, otherwise I'd leave Bluetooth on all the time anyway. When I get in the car, Bluetooth gets turned on (if it's not already on) because another flow turns on Bluetooth when the power gets connected or the display turns on. I then find the phone automatically gets reconnected to the MMI as the MMI powers up. I don't use an Action to explicitly connect to the MMI. I think the phone and MMI automatically find each other as previously connected devices and connection is attempted. Not sure if it's the phone or MMI that initiates this automatically - I know I don't!
I use the Bluetooth connection state to the MMI to trigger what happens when I enter/exit the car with more flows
Re: Wait for Bluetooth to connect?
Execution policy for this flow ?
Xiaomi MI 6
Rom Miui 10 EU STABLE
Rom Miui 10 EU STABLE
Re: Wait for Bluetooth to connect?
Since you are dealing with trigger that you use too in action, better use SKIP. This minimize the possibility of loop-triggering the flow.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Wait for Bluetooth to connect?
For my flow above I use "Stop the current executing instance and then execute the newer instance". This is because, if the flow is re-triggered, it means a Bluetooth device has just disconnected again so I want the 5 min delay restarted. Otherwise it's possible Bluetooth will get disabled "early" if Bluetooth connections are a little unstable.Desmanto wrote:Since you are dealing with trigger that you use too in action, better use SKIP. This minimize the possibility of loop-triggering the flow.
The loop-trigger scenario is unlikely (and will only likely cause one extra execution of the flow) and occur only in the case if Bluetooth reconnected in the few milliseconds between the final condition that all Bluetooth devices are disconnected and Bluetooth being switched off
... and just thinking further, I should probably add an extra trigger for 'Power Source Disconnected', so the flow also starts when power is disconnected. This would be for the use case where all Bluetooth devices were disconnected with the power still connected so Bluetooth stays on - but then I disconnect the power - and I would want Bluetooth turned off 5 mins later if there were still no Bluetooth devices connected, the screen was off, and I was still on battery power.