check if any bluetooth device connected

1,227 views
Skip to first unread message

torcolia...@gmail.com

unread,
Dec 21, 2014, 4:56:24 PM12/21/14
to automa...@googlegroups.com
Hi there,
I'm having trouble using the "bluetooth device connected?" block: i can only check if a specific device is connected (using device name and/or mac address), but that's not what i need... I also tried to save in a variable the mac address and check if it's blank or any other value... But this too is not working. I'm using a nexus 5 with KitKat.
Thanx in advance for your help

Automate developer

unread,
Dec 21, 2014, 5:14:58 PM12/21/14
to automa...@googlegroups.com, torcolia...@gmail.com
What are you trying to do?

If you leave the "device name" and "device address" fields empty the block should proceed when any device connects, or disconnects.

torcolia...@gmail.com

unread,
Dec 21, 2014, 5:53:49 PM12/21/14
to automa...@googlegroups.com
I'm trying to check if any device is connected... I'm leaving name and mac address fields blank, but even when a device is connected the max address variabile results an empty string.
Here you can find the .flo I developed

https://www.dropbox.com/s/vk7ht1mgjugmis3/Bluetooth%20auto.flo?dl=0

Automate developer

unread,
Dec 21, 2014, 7:34:58 PM12/21/14
to automa...@googlegroups.com, torcolia...@gmail.com
Try using the "Blutetooth device connected" as the decision block it i, there's no need for the extra "Expression true" block after it.
What the output variables are assigned when a decision is false, isn't really documentet. Currently, most block assigns null to them, but i may change that soon.

Also, your flow are polling the state every 3 minute. Don't use polling, its not recommended nor required, and it will unnecessarily drain the battery.

If you wait a for a BT device to connect or disconnect, a single "Bluetooth Device connected" block with the proceed option set to "When changed" will suffice.

Alessandro Torcoli

unread,
Dec 22, 2014, 5:02:02 AM12/22/14
to Automate developer, automa...@googlegroups.com
I already tried to use the "Bluetooth device connected?" block by its own, but it doesn't work if I leave blank name and mac addrees... It forces me to choose a device or simply it takes the "no" path, but I don't want to choose a device, I want it to work for any device. I think I'm not rhe only one with this issue, 'cause other flows I downloaded from the community use a cycle to verify if any of the device paired in the past is connected.

My flow is polling every 3 minutes because I want it to turn bluetooth on and verify if there is any device to connect to, if not I want it to turn the bluetooth off again, so the block has to work in "immediately" mode and not in "when changed".

Thanks again for your help

Automate developer

unread,
Dec 22, 2014, 1:59:24 PM12/22/14
to automa...@googlegroups.com, henrik.l...@gmail.com, torcolia...@gmail.com
Checking the "address" variable from both the YES and NO path coming from the "Bluetooth device connected" block is basically the same as using a single "Bluetooth device connected" block, it's just using unnecessary blocks.

A device can never be connected if Bluetooth is disabled. The following flow should turn BT off when a device disconnects:
            :
+-----------+
|           |
|  When BT device connected?----+
|           |                   |
+-----------+               Disable BT
|                               |
+-------------------------------+         
           

On Monday, December 22, 2014 11:02:02 AM UTC+1, Alessandro Torcoli wrote:
I already tried to use the "Bluetooth device connected?" block by its own, but it doesn't work if I leave blank name and mac addrees... It forces me to choose a device or simply it takes the "no" path, but I don't want to choose a device, I want it to work for any device. I think I'm not rhe only one with this issue, 'cause other flows I downloaded from the community use a cycle to verify if any of the device paired in the past is connected.

My flow is polling every 3 minutes because I want it to turn bluetooth on and verify if there is any device to connect to, if not I want it to turn the bluetooth off again, so the block has to work in "immediately" mode and not in "when changed".

Thanks again for your help

Alessandro Torcoli

unread,
Dec 22, 2014, 4:46:08 PM12/22/14
to Automate developer, automa...@googlegroups.com
Sorry pal, I think you are focusing on the wrong detail. 
I tried to check the address from both the yes and no path 'cause the "bluetooth device connected block" is not working as I suppose it should when I don't select a name and/or mac address: I thought it should exit the YES path if any bluetooth device was connected, the NO path if none is connected... But unless I fill in a name or mac address is always getting out on the NO path, so I tried to check by myself if, at least, the block would fill the variable.

So, answer my question: how am i supposed to check if any device is connected by bluetooth? And please, don't tell me to use that block by itself cause it's not working.

Automate developer

unread,
Dec 22, 2014, 6:46:57 PM12/22/14
to automa...@googlegroups.com, henrik.l...@gmail.com, torcolia...@gmail.com
This is how the "Bluetooth device connected" should work, unless there's a bug:

With proceed "When changed"; the YES path will be followed when a device connects. If you return to the block with the device still connected, the NO path will be followed when a device disconnects. If address and/or name are set it only triggers when that specific device connects/disconnects, if neither address nor name are se,t then when any device connects/disconnects.

With proceed "Immediately"; the YES path is followed when a/the device is currently connected, and the NO path if a/the is not currently connected.

I'll investigate if there any bug.



On Monday, December 22, 2014 10:46:08 PM UTC+1, Alessandro Torcoli wrote:
Sorry pal, I think you are focusing on the wrong detail. 
I tried to check the address from both the yes and no path 'cause the "bluetooth device connected block" is not working as I suppose it should when I don't select a name and/or mac address: I thought it should exit the YES path if any bluetooth device was connected, the NO path if none is connected... But unless I fill in a name or mac address is always getting out on the NO path, so I tried to check by myself if, at least, the block would fill the variable.

So, answer my question: how am i supposed to check if any device is connected by bluetooth? And please, don't tell me to use that block by itself cause it's not working.

Rob Lund

unread,
Jun 20, 2017, 9:27:30 AM6/20/17
to Automate, henrik.l...@gmail.com, torcolia...@gmail.com
I'm seeing behavior similar to the OP.  When I use the "When changed" option of the "Bluetooth device connected?" block, and with blank address and name and type, I don't get a proceed when either 1 of my 2 devices connect.

Is this feature broken?  I'd rather not loop continuously to check.

Henrik "The Developer" Lindqvist

unread,
Jun 20, 2017, 5:40:36 PM6/20/17
to Automate, henrik.l...@gmail.com, torcolia...@gmail.com
It's only with Proceed "Immediately" what the block uses a hack, with Proceed "When changed" it just awaits the proper system broadcast. Try using the Broadcast receive block with action "android.bluetooth.device.action.ACL_CONNECTED" or "android.bluetooth.device.action.ACL_DISCONNECTED" to check if the system sends it accordingly.

Rob Lund

unread,
Jun 21, 2017, 9:04:19 AM6/21/17
to Automate, henrik.l...@gmail.com, torcolia...@gmail.com
So actually, I discovered a bug in my flow.  Your Proceed "When Changed" is working perfectly.  I had put a Bluetooth Enabled block before this one and had it accidentally set to "When Changed" as well.  Duh!  I change that one to "Immediately" and now my whole flow is working very nicely.

Thanks!
Reply all
Reply to author
Forward
0 new messages