Bluetooth Help

Post your questions and help other users.

Moderator: Martin

Post Reply
Ankit Bindal
Posts: 90
Joined: 12 Feb 2016 03:23

Bluetooth Help

Post by Ankit Bindal » 22 Jul 2016 15:54

Hi,
I tried to make an flow which connects Bluetooth device when disconnected after a sleep of 5 second.

But the problem is the flow end with an error after second loop.....

http://automagic4android.com/flow.php?i ... 234644163f

Please help.....

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: Bluetooth Help

Post by Bushmills » 22 Jul 2016 18:09

"with an error" is a bit vague, especially as you can read what error is produced. Not telling us what the "an error" is can only mean that you want us to guess. Ah, I got it - this is a kind of game, right?

Ankit Bindal
Posts: 90
Joined: 12 Feb 2016 03:23

Re: Bluetooth Help

Post by Ankit Bindal » 23 Jul 2016 03:00

23.07.2016 08:29:28.247 [Flow1] Starting to execute flow 'Flow1' with Context{global{global_mode=Normal,global_wallpaper=/storage/MicroSD/Images/Wallpapers/Screenshot_2016-02-06-19-56-41.jpg,global_free_ram=914,global_multiclipboard=[Bluetooth State: On, Bluetooth Device Disconnected: All devices, http://automagic4android.com/fl...,glob ... ger=Manual}}
23.07.2016 08:29:28.248 [Flow1] Start executing condition 'Bluetooth Device Connected: Any device'
23.07.2016 08:29:28.304 [Flow1] End executing condition 'Bluetooth Device Connected: Any device' with return value false
23.07.2016 08:29:28.343 [Flow1] Flow continues executing with the next step.
23.07.2016 08:29:28.344 [Flow1] Start executing action 'Sleep: 5s (keep device awake)'
23.07.2016 08:29:28.346 [Flow1] Action 'Sleep: 5s (keep device awake)' Sleeping for 5s (keep device awake)
23.07.2016 08:29:33.348 [Flow1] End executing action 'Sleep: 5s (keep device awake)'
23.07.2016 08:29:33.389 [Flow1] Flow continues executing with the next step.
23.07.2016 08:29:33.390 [Flow1] Start executing condition 'Bluetooth Device Connected: Any device'
23.07.2016 08:29:33.438 [Flow1] End executing condition 'Bluetooth Device Connected: Any device' with return value false
23.07.2016 08:29:33.482 [Flow1] Flow continues executing with the next step.
23.07.2016 08:29:33.483 [Flow1] Start executing condition 'Bluetooth Enabled'
23.07.2016 08:29:33.485 [Flow1] End executing condition 'Bluetooth Enabled' with return value true
23.07.2016 08:29:33.516 [Flow1] Flow continues executing with the next step.
23.07.2016 08:29:33.518 [Flow1] Start executing action 'Connect/Disconnect Bluetooth Device: Connect Headset I1100'
23.07.2016 08:29:33.534 [Flow1] Start executing action 'Connect/Disconnect Bluetooth Device: Connect Headset QCY-Q8'
23.07.2016 08:29:33.593 [Flow1] Action 'Connect/Disconnect Bluetooth Device: Connect Headset I1100' Successfully connected to the bluetooth device
23.07.2016 08:29:33.594 [Flow1] End executing action 'Connect/Disconnect Bluetooth Device: Connect Headset I1100'
23.07.2016 08:29:33.594 [Flow1] Action 'Connect/Disconnect Bluetooth Device: Connect Headset QCY-Q8' Successfully connected to the bluetooth device
23.07.2016 08:29:33.595 [Flow1] End executing action 'Connect/Disconnect Bluetooth Device: Connect Headset QCY-Q8'
23.07.2016 08:29:33.644 [Flow1] Flow continues executing with the next step.
23.07.2016 08:29:33.645 [Flow1] Start executing condition 'Bluetooth Device Connected: Any device'
23.07.2016 08:29:33.646 [Flow1] Start executing condition 'Bluetooth Device Connected: Any device'
23.07.2016 08:29:33.691 [Flow1] End executing condition 'Bluetooth Device Connected: Any device' with return value false
23.07.2016 08:29:33.693 [Flow1] End executing condition 'Bluetooth Device Connected: Any device' with return value false
23.07.2016 08:29:33.741 [Flow1] Flow continues executing with the next step.
23.07.2016 08:29:33.742 [Flow1] Start executing action 'Sleep: 5s (keep device awake)'
23.07.2016 08:29:33.743 [Flow1] Action 'Sleep: 5s (keep device awake)' Sleeping for 5s (keep device awake)
23.07.2016 08:29:33.745 [Flow1] Start executing action 'Sleep: 5s (keep device awake)'
23.07.2016 08:29:33.746 [Flow1] Action 'Sleep: 5s (keep device awake)' Sleeping for 5s (keep device awake)
23.07.2016 08:29:38.747 [Flow1] End executing action 'Sleep: 5s (keep device awake)'
23.07.2016 08:29:38.749 [Flow1] End executing action 'Sleep: 5s (keep device awake)'
23.07.2016 08:29:38.799 [Flow1] Flow continues executing with the next step.
23.07.2016 08:29:38.800 [Flow1] Start executing condition 'Bluetooth Device Connected: Any device'
23.07.2016 08:29:38.802 [Flow1] Start executing condition 'Bluetooth Device Connected: Any device'
23.07.2016 08:29:38.840 [Flow1] End executing condition 'Bluetooth Device Connected: Any device' with return value false
23.07.2016 08:29:38.841 [Flow1] End executing condition 'Bluetooth Device Connected: Any device' with return value false
23.07.2016 08:29:38.881 [Flow1] Flow continues executing with the next step.
23.07.2016 08:29:38.882 [Flow1] Start executing condition 'Bluetooth Enabled'
23.07.2016 08:29:38.884 [Flow1] End executing condition 'Bluetooth Enabled' with return value true
23.07.2016 08:29:38.885 [Flow1] Start executing condition 'Bluetooth Enabled'
23.07.2016 08:29:38.886 [Flow1] End executing condition 'Bluetooth Enabled' with return value true
23.07.2016 08:29:38.921 [Flow1] Flow continues executing with the next step.
23.07.2016 08:29:38.922 [Flow1] Start executing action 'Connect/Disconnect Bluetooth Device: Connect Headset I1100'
23.07.2016 08:29:38.928 [Flow1] Start executing action 'Connect/Disconnect Bluetooth Device: Connect Headset QCY-Q8'
23.07.2016 08:29:38.935 [Flow1] Start executing action 'Connect/Disconnect Bluetooth Device: Connect Headset I1100'
23.07.2016 08:29:38.941 [Flow1] Start executing action 'Connect/Disconnect Bluetooth Device: Connect Headset QCY-Q8'
23.07.2016 08:29:39.017 [Flow1] Action 'Connect/Disconnect Bluetooth Device: Connect Headset I1100' Could not connect the bluetooth device
23.07.2016 08:29:39.018 [Flow1] End executing action 'Connect/Disconnect Bluetooth Device: Connect Headset I1100' and exception Could not connect the bluetooth device
23.07.2016 08:29:39.019 [Flow1] Action 'Connect/Disconnect Bluetooth Device: Connect Headset QCY-Q8' Successfully connected to the bluetooth device
23.07.2016 08:29:39.020 [Flow1] End executing action 'Connect/Disconnect Bluetooth Device: Connect Headset QCY-Q8'
23.07.2016 08:29:39.020 [Flow1] Action 'Connect/Disconnect Bluetooth Device: Connect Headset I1100' Could not connect the bluetooth device
23.07.2016 08:29:39.021 [Flow1] End executing action 'Connect/Disconnect Bluetooth Device: Connect Headset I1100' and exception Could not connect the bluetooth device
23.07.2016 08:29:39.022 [Flow1] Action 'Connect/Disconnect Bluetooth Device: Connect Headset QCY-Q8' Successfully connected to the bluetooth device
23.07.2016 08:29:39.022 [Flow1] End executing action 'Connect/Disconnect Bluetooth Device: Connect Headset QCY-Q8'
23.07.2016 08:29:39.073 [Flow1] Flow ends execution due to errors
23.07.2016 08:29:39.074 [Flow1] Error:
ch.gridvision.ppam.androidautomagiclib.util.p: Could not connect the bluetooth device
at ch.gridvision.ppam.androidautomagic.c.a.r$1$1.run(SourceFile:187)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5253)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

23.07.2016 08:29:39.081 [Flow1] Error:
ch.gridvision.ppam.androidautomagiclib.util.p: Could not connect the bluetooth device
at ch.gridvision.ppam.androidautomagic.c.a.r$1$1.run(SourceFile:187)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5253)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

23.07.2016 08:29:39.095 [Flow1] Flow ended.

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: Bluetooth Help

Post by Bushmills » 23 Jul 2016 06:47

My impression is that you experience a timing problem, possibly a race condition. I'd change the flow such that connecting both devices at virtually the same moment is made impossible. Example where this happens is here:
23.07.2016 08:29:33.593 [Flow1] Action 'Connect/Disconnect Bluetooth Device: Connect Headset I1100' Successfully connected to the bluetooth device
23.07.2016 08:29:33.594 [Flow1] End executing action 'Connect/Disconnect Bluetooth Device: Connect Headset I1100'
23.07.2016 08:29:33.594 [Flow1] Action 'Connect/Disconnect Bluetooth Device: Connect Headset QCY-Q8' Successfully connected to the bluetooth device


User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: Bluetooth Help

Post by Bushmills » 23 Jul 2016 08:53

Catching the exception is not fixing the problem. You're merely hiding the symptoms.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Bluetooth Help

Post by Martin » 23 Jul 2016 09:50

In this case I would also recommend to not execute both connect actions in parallel since it's not well defined what Android effectively executed first in such a case.

Maybe you won't get the exception anymore when executing the actions sequentially (but this depends on Android version). If you still get the exception, you can switch to an exception-connection between the two actions and add a regular connection for the case when Android reported that it succeeded. Something like this should work:
http://automagic4android.com/flow.php?i ... ce87ac39ae
I also used the empty action container since it helps to make the connections easier to read.

Regards,
Martin

Post Reply