feature request: connected Bluetooth name

479 views
Skip to first unread message

Richard Wallace

unread,
Mar 15, 2015, 3:59:09 PM3/15/15
to tas...@googlegroups.com
@Pent
As above really
Not sure if its possible, but maybe add to the %BLUE variable, so it can be either 'on', 'off, or 'devicename'?
As yet I haven't found a way to do this

Scott Windham

unread,
Mar 15, 2015, 5:28:13 PM3/15/15
to tas...@googlegroups.com

Secure setting can use name of a bluetooth device

Richard Wallace

unread,
Mar 15, 2015, 6:01:48 PM3/15/15
to tas...@googlegroups.com
How so?

Ian Ostrov

unread,
Mar 15, 2015, 8:11:28 PM3/15/15
to tas...@googlegroups.com
Bluetooth detection by Kanetic does it. There's a 30 day trial version of the plug-in available.

Phil

unread,
Mar 15, 2015, 9:05:57 PM3/15/15
to tas...@googlegroups.com

Since I only have a few BT devices connected with my phone, I just have a profile that activates on a specific BT name and sets a variable.  I then have another for each of the other devices and they each update the same variable.  The exit of each just unsets the same var.  However, if you have many BT devices I can see why this doesn't scale well, so it would be a nice addition to Tasker's variables, if possible.  At least with the WIFI connection, Tasker makes all of the connection data available (although it has to be parsed to extract the details).

Robert Ryan

unread,
Mar 16, 2015, 12:33:41 PM3/16/15
to tas...@googlegroups.com
I am sure that this information is available using Java, but I don't have enough knowledge to make it work.

Maybe one of our local Java gurus could lend a hand?

Scott Windham

unread,
Mar 16, 2015, 2:49:16 PM3/16/15
to tas...@googlegroups.com
From Secure setting >> Action >> BT connection >>  Select BT device and select CONNECT or DISCONNECT


Scott

On Sunday, March 15, 2015 at 6:01:48 PM UTC-4, Richard Wallace wrote:
How so?
Screenshot_2015-03-16-14-41-57.png

Richard Wallace

unread,
Mar 16, 2015, 4:11:58 PM3/16/15
to tas...@googlegroups.com
That's not what i want Sckt, I'm after the device name to use elsewhere in a task.
Java, yes I bet it is do-able.

Richard Wallace

unread,
Mar 16, 2015, 6:38:19 PM3/16/15
to tas...@googlegroups.com
Think I've figured it.
Java Bluetooth (203)
A1: Java Function [ Return:blue Class Or Object:BluetoothAdapter Function:getDefaultAdapter
{BluetoothAdapter} () Param:CONTEXT Param: Param: Param: Param: ]
A2: Java Function [ Return:%state Class Or Object:blue Function:getState
{int} () Param:blue Param:23 Param: Param: Param: ]
A3: Flash [ Text:%state Long:Off ]

This returns the constant value for state, so connected = 2

I just want to get the friendly name of the connected device now.
I can get the MAC address of a connected device but the friendly name would be better... Any Java people able to help!!?

Robert Ryan

unread,
Mar 16, 2015, 9:10:36 PM3/16/15
to tas...@googlegroups.com
I think you would need BluetoothProfile.getConnectedDevices(). To get the BluetoothProfile you need getProfileProxy(Context, BluetoothProfile.ServiceListener, int).

However, I can't figure out how to set up BluetoothProfile.ServiceListener.

Rich D

unread,
Mar 16, 2015, 9:41:33 PM3/16/15
to Tasker Google Groups Post


It looks like it would take some work but this information is in the shell command dumpsys bluetooth. Requires root.

Robert Ryan

unread,
Mar 16, 2015, 10:15:16 PM3/16/15
to tas...@googlegroups.com
True, but this info is also available without root.

Someone just needs to figure out the correct Java sequence.

Robert Ryan

unread,
Mar 19, 2015, 1:10:46 AM3/19/15
to tas...@googlegroups.com
I got it! The name can be retrieved when the device connects via an intent.

Profile: Bluetooth Connection (82)
Event: Intent Received [ Action:android.bluetooth.device.action.ACL_CONNECTED Cat:None Cat:None Scheme:* Mime Type:* ]
Enter: Anon (83)
A1: Java Function [ Return:adapter Class Or Object:BluetoothAdapter Function:getDefaultAdapter
{BluetoothAdapter} () Param: Param: Param: Param: Param: Param: Param: ]
A2: Java Function [ Return:device Class Or Object:adapter Function:getRemoteDevice
{BluetoothDevice} (String) Param:%android_bluetooth_device_extra_device Param: Param: Param: Param: Param: Param: ]
A3: Java Function [ Return:%name Class Or Object:device Function:getName
{String} () Param: Param: Param: Param: Param: Param: Param: ]
A4: Flash [ Text:%name Long:On ]

Richard Wallace

unread,
Mar 19, 2015, 5:32:10 AM3/19/15
to tas...@googlegroups.com
Going to try this on the way home in the car.
Just to confirm should action A2 Param really be a variable? i.e. %android_bluetooth_device_extra_device

Robert Ryan

unread,
Mar 19, 2015, 7:11:13 AM3/19/15
to tas...@googlegroups.com
Yes, that is where the intent is going to put the MAC address of the connected device. See the Tasker user's guide about how an intent's extra information is handled.

Richard Wallace

unread,
Mar 19, 2015, 7:09:48 PM3/19/15
to tas...@googlegroups.com
Works perfectly. Good work!

Richard Wallace

unread,
Mar 23, 2015, 5:20:22 AM3/23/15
to tas...@googlegroups.com
Just come back to this and it's not working now?

Robert Ryan

unread,
Mar 23, 2015, 6:56:49 AM3/23/15
to tas...@googlegroups.com
Not working in what way?

Does the task run when the device connects?

Is the MAC address being loaded into the variable?

What does the getName method return?

I have been using this multiple times per day and it has never failed for me.

nir

unread,
Apr 16, 2015, 7:54:21 PM4/16/15
to tas...@googlegroups.com
Maybe I have the answer , I took  your xml file import it and it works well, 
it has a profile and the tasks are inline in the profile, not a task linked to the profile.

I then cloned the profile and the cloned profile works well, I selected a new talk to run as a result of the profile event (task that is a copy of the content of the anonymous inline task you built) 
and surprise, it does not even get called, (added a first line to alert + look at the log)

so your profile works as long as it dose not call an external task-  is that possible ? seems like a bug in tasker and maybe what Richard is seeing 
can you try as well ? if it is reproducible, I can submit a bug to tasker developer

thanks

Robert Ryan

unread,
Apr 16, 2015, 8:33:42 PM4/16/15
to tas...@googlegroups.com
I can not duplcate the behavior that you descibe. I cloned the profile, unlinked the anonymous task and linked it to a totally unrelated named task.

That combination also works consistently, so I don't see what the problem is.

Are you sure you saved your changes by using the back key?

nir - gmail

unread,
Apr 16, 2015, 9:10:06 PM4/16/15
to tas...@googlegroups.com
yes I'm sure,

I also typed in your profile and link it , and it did not work - strange
--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/pm1LMiuWMSA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

Jay K

unread,
Jul 18, 2015, 7:16:42 PM7/18/15
to tas...@googlegroups.com
I can get the MAC address of a connected device but the friendly name would be better...
How can you get the MAC address of the connected device?
The solution of Robert described below works well, but it works when only the event time not in the state.
If I can get the MAC address of the connected device, I can get the friendly name of the device.

Robert Ryan

unread,
Jul 19, 2015, 12:13:50 AM7/19/15
to Support Forum

IIRC, only one bluetooth device can be connected at any one time. So, couldn't you just use the method I described and store the MAC address and friendly name in global variables? You could then use a variable value state for your context.

Jay K

unread,
Jul 19, 2015, 3:34:22 AM7/19/15
to tas...@googlegroups.com

IIRC, only one bluetooth device can be connected at any one time. So, couldn't you just use the method I described and store the MAC address and friendly name in global variables? You could then use a variable value state for your context.

Sure. I can use the state of variable value using the broadcast intent if Tasker start monitoring before the connection.
I also found about BluetoothProfile.ServiceListener. And I think it is the better way to do what I want, but I cannot figure it out using Java function.
Thanks anyway.


Reply all
Reply to author
Forward
0 new messages