Controlling Bluetooth A2DP and HSP

1,155 views
Skip to first unread message

Scott Miller

unread,
Jul 2, 2014, 10:15:21 PM7/2/14
to tas...@googlegroups.com
I've seen a number of you talking about connecting Bluetooth to devices in your cars, and using Bluetooth Near to activate car profiles, and things like that. Until this week, I couldn't do any of that, but now that I have a new car, and it has Bluetooth connectivity, I can start to play. 

I'm looking for comments and suggestions that might improve my experience. 

For starters, I'm doing this on my Galaxy S4, Android 4.4.2, and Tasker 4.4b8 (currently).

I found that Bluetooth Near works ok, but it kills my battery. I was going to use this instead of a NFC tag to start my carmode, but the battery drain was so bad I couldn't leave it enabled. For now, I'm back to using NFC, but I'm open to suggestions to improve the experience.

My second issue, and more annoying than the first, is that I want to have two devices connected to my phone. This is probably different than most would do. I want to connect my BT earpiece to the A2DP profile, so that I can get navigation instructions discreetly. I use Waze primarily, and I don't want to annoy anyone else who might be in the car with me. But I want to connect my car to the HSP (phone) profile. The car has a great interface to the phone experience, and except for the sound quality coming over the speakers, I like it and want to use it.

So, here is my problem. Both of these devices want to connect to both profiles. Whichever gets there first takes control, and the other can do nothing about it. I have two plugins that I've tried. A2DP Connect by Jim Roal doesn't seem to do anything. He has a widget that works perfectly, but I want to automate this with Tasker. I think it may be that a new version is required for this version of Android, so I may reach out to him to see if he might update it. I also tried Bluetooth Auto Connect by UniqTec. That doesn't seem to do anything either. I've tried adding waits between actions, using disconnect before connect, etc. But I can do any of this manually, so it is possible to get the setup I want. I just can't seem to automate it. Any thoughts or comments welcome. 

Scott

Marta Hintz

unread,
Jul 2, 2014, 11:12:11 PM7/2/14
to tas...@googlegroups.com
for the bluetooth connect, select the bluetooth you want with which task you want it to work with.  I use the bluetooth auto connect (found on playstore), it has tasker ability to run app in  the configuration.   

Tasker also can select individual bluetooth (ID) for connection.  -  

Marta

Brandon Horwath

unread,
Jul 2, 2014, 11:59:22 PM7/2/14
to tas...@googlegroups.com
First, I just leave my BT on all day and don't notice much drain at all. Frequently toggling power to the radio uses more power than just leaving it on. That's the beauty of BT.

Second:

I also tried Bluetooth Auto Connect by UniqTec. That doesn't seem to do anything either. I've tried adding waits between actions, using disconnect before connect, etc. But I can do any of this manually, so it is possible to get the setup I want.

I've had great luck with this app.

What is the task description your using?

I've managed different connections using A2DP and HSP to vehicle audio and headset audio. Maybe I can help you with this.

Dave C

unread,
Jul 3, 2014, 1:24:17 AM7/3/14
to Tasker Group
On 2 Jul 2014, at 8:59 PM, Brandon Horwath <brandon...@gmail.com> wrote:

Frequently toggling power to the radio uses more power than just leaving it on.

There’s no physics explanation to support this statement. It’s not like the “turn off your engine and restart it” vs. “leaving it on” argument. There is no additional energy consumed to turn on BT. 

Dave

PS, please use Reply when replying to a group post. Doing otherwise breaks the link between threaded messages and makes following a discussion more of a chore. 

And please quote some from the previous message. It makes reading a thread much easier. 

Brandon Horwath

unread,
Jul 3, 2014, 3:08:45 AM7/3/14
to tas...@googlegroups.com
There’s no physics explanation to support this statement.

In a way... yes, there is. It may not apply to you though.

With a phone most people understand there is a difference between talk time and standby time. With Bluetooth, such analogy does not apply.

Bluetooth devices these days do more than just transmit audio, they allow information to sync across devices, often without user input, these things require varied levels of current to achieve.

Oh, there's lots of different factors involved though. Let me see if I can piece together a brief explanation...

BT uses a TDD multi-access scheme based around 625-us time slots. The connection can be peer-to-peer or multi-peer with master and one or more slave devices.
Communication between devices uses 14 predefined packet types in one, three, or five timeslots.
In essence, here it what occurs when powered on:
The synthesizer is enabled with microprocessor or baseband digital hardware, after tuning is complete the receiver/transmitter is enabled, a packet is sent querying for available connections, communications protocols are managed and actions taken, finally after the data are received/sent the active digital logic and radio will shut down.
Several concurrent processes may activate, what is important to analyze in these current proccesses is the average current.

In my situation, I use a lot of audio for my BT. Audio uses HV1, HV2, or HV3 packets. What is important is this:

HV3master=(1/6)((OneSlotTx + OneSlotRx)/+4(NoActiveTxRx))

HV3slave=(1/6)((OneSlotTx + OneSlotRx) / (+2 SlaveRxErr) / (+2 NoActiveTxRx)

So hypothetically:

OneSlotRx = OneSlotTx = (366 * 50mA + 259 * 20mA)/625 = 37.6mA

SlaveRxErr = (88 * 50mA + 537 * 20mA)/625 = 24.2mA

NoActiveTxRx = (625 * 20mA)/625 = 20mA

Using those in previous equations results in:

Master: 25.9mA
Slave: 27.3mA

Power bias favors the master in this situation since doing nothing uses less current than listening for a master transmission. Which is being forced everytime when powered on.

It is unusual, granted. However, given my situation and connection, including typical usage I find leaving my BT on all day uses less power than monitoring or toggling the radio.

Hope this helps.

Brad Minion

unread,
Jul 3, 2014, 10:22:07 AM7/3/14
to tas...@googlegroups.com
"So, here is my problem. Both of these devices want to connect to both profiles. Whichever gets there first takes control, and the other can do nothing about it."

Have you tried editing the BT profiles in your phone Settings/Bluetooth? On my phone for each Bluetooth paired device there is a check box each for phone and media audio if supported by that device. If you have that on yours you can uncheck the one you don't want in each profile.



--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, 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.

Scott Miller

unread,
Jul 3, 2014, 11:09:48 AM7/3/14
to tas...@googlegroups.com


> Have you tried editing the BT profiles in your phone Settings/Bluetooth? On my phone for each Bluetooth paired device there is a check box each for phone and media audio if supported by that device. If you have that on yours you can uncheck the one you don't want in each profile.
>

Yes. That's the manual intervention I am talking about. The checkbox indicates whether or not it's connected. Clear the checkbox, it disconnects from that profile. That condition is not remembered the next time that device tries connect, however. The device tries to connect to all profiles for which it is compatible. As far as I can tell, there is nothing in settings on the phone to prevent a device from connecting to a specific profile.

Scott

Scott Miller

unread,
Jul 3, 2014, 11:12:17 AM7/3/14
to tas...@googlegroups.com


On Jul 3, 2014 3:08 AM, "Brandon Horwath" wrote:
> Oh, there's lots of different factors involved though. Let me see if I can piece together a brief explanation...
>

Awesome! Are you an EE?

Scott Miller

unread,
Jul 3, 2014, 11:23:42 AM7/3/14
to tas...@googlegroups.com


On Jul 2, 2014 11:59 PM, "Brandon Horwath" wrote:

>> I also tried Bluetooth Auto Connect by UniqTec.

> I've had great luck with this app.
>
> What is the task description your using?
>
> I've managed different connections using A2DP and HSP to vehicle audio and headset audio. Maybe I can help you with this.

I will probably take you up on this. I'll post my task description later, but in the meantime, I've heard from both developers. It turns out the plugin I am using called A2DP Connect uses code from a widget app of the same name, but a different developer. The widget has been updated to A2DP Connect2 due to changes in Android 4.3 and later, so it is reasonable to assume those same changes are needed to get the plugin working. The downside is that I don't know who the developer is. The upside is that the code is all released as open source. So, I might finally take the plunge into Android programming.

I also have a suggestion to turn on logging in Bluetooth Auto Connect, and use its shortcuts to manually trigger changes and then see what shows up in the log. I'll be trying this later this evening. After that, I'll post my task description if there is still a problem.

Brad Minion

unread,
Jul 3, 2014, 12:09:10 PM7/3/14
to tas...@googlegroups.com
"Clear the checkbox, it disconnects from that profile. That condition is not remembered the next time that device tries connect, however."

Maybe my G2 works different. Before connecting to the BT device, I went in and turned off (un-checked) the phone audio option. When I connected to my BT device it said that it only connected to media audio and the phone audio option remained un-checked. Then I switched options and that seemed to work as well - connecting to phone audio only. I then did the same test but un-checking after connecting and it worked as well. Perhaps it's a device dependent thing.


--

Brandon Horwath

unread,
Jul 3, 2014, 12:19:57 PM7/3/14
to tas...@googlegroups.com
Awesome! Are you an EE?

Nooooo... lol.

Like Dave said, it doesn't make any sense ;-) so when I noticed some issues that didn't make any sense I did a lot of research.

During the course of my reading I came across a lot of info that honestly didn't make any sense until I dived a lot deeper into the technology involved.

For example, a HV1 packet uses 10 bytes, a HV3 packet uses 30 bytes. You would think HV3 uses greater current since it handles greater amounts of data. But, factor in the time slots required (much like passing data through a star network) and the fact that HV1 uses nearly twice as much current becomes obvious. I should mention HV1 is the standard for probably 85% of BT media audio capable devices. But, this is because HV3 uses a compressed 30 byte packet at a set lower time slot interval opposed to HV1 that continuously sends and receives at every opportunity.

From what I determined, my unique set of factors regarding my BT device usage meant toggling power and monitoring contexts was less efficient.

I feel I should mention, this wouldn't be the case for most tasker users. Toggling power can be more efficient for most.

Scott Miller

unread,
Jul 3, 2014, 12:25:25 PM7/3/14
to tas...@googlegroups.com


On Jul 3, 2014 12:09 PM, "Brad Minion" wrote:
>
> Perhaps it's a device dependent thing.
>

Could be. Does your selection choice remain the same between connection attempts and across reboots?

Brandon Horwath

unread,
Jul 3, 2014, 12:26:21 PM7/3/14
to tas...@googlegroups.com
Ah, and device class is a huge factor in current requirements at power on.

A +20dB class device has a current requirement four to six times a device rated at +0dB, and as much as eight times that of a -4dB rated device.

This comes into play when slaved, but the device needs to check those demands anyhow once powered on.

Scott Miller

unread,
Jul 4, 2014, 8:45:56 PM7/4/14
to tas...@googlegroups.com

It doesn't look like Bluetooth Auto Connect is going to work. From its own logs, when I tried to disconnect the existing connection, it actually tried to connect instead. If I can't disconnect first, I can't connect what I really want to connect.

I thought A2DP Volume might work, but no such luck. The A2DP Connect2 widget, so far, is the only thing that works. I have the source code to these two, and to the earlier version of the widget and also the plugin that I wanted to use originally. I need to setup a development environment and see if I can fix the plugin. For now, I'll just need to make the changes manually.

Scott

Brandon Horwath

unread,
Jul 4, 2014, 10:58:48 PM7/4/14
to tas...@googlegroups.com
From its own logs, when I tried to disconnect the existing connection, it actually tried to connect instead.

I have found a small issue with mine where disconnecting from a lower priority device and connecting to a higher priority results in failure to the higher priority and constant retry resulting to connect to the lower priority. Which fails and repeats if unavailable, or connects undesirably to the lower priority.

To get around this I toggle my Bluetooth radio to reset connection priorities, and that's not quite 100% successful all the time but pretty close.

Scott Miller

unread,
Jul 4, 2014, 11:09:29 PM7/4/14
to tas...@googlegroups.com


> I have found a small issue with mine where disconnecting from a lower priority device and connecting to a higher priority results in failure to the higher priority and constant retry resulting to connect to the lower priority. Which fails and repeats if unavailable, or connects undesirably to the lower priority.
>

It's quite possible this is what I encountered. I had to uninstall the app. It completely killed my battery in about two hours. I might be able to work this out if I spend enough time with it, but that doesn't seem practical. Because I do have a programming background, my interest is in fixing the plugin code, if I can get the development environment setup.

Brandon Horwath

unread,
Jul 5, 2014, 2:17:10 AM7/5/14
to tas...@googlegroups.com
That sounds like that might be what happened to you. It'll just keep cycling back and forth between two devices, one it can connect to and one it can't.

Since the one it connects to is lower priority after a disconnection and failure to connect to a higher priority, the app is intended to re-attempt the higher priority connection.

I say, 'intended' since that's why the developer wrote the app in the first place... his BT kept disconnecting from his car during driving and he wanted his device to automatically reconnect.

Toggling the BT radio after disconnecting from a low priority resets the connection priority assessed for the disconnection. So, in turn the app doesn't attempt to 're-connect' it just attempts the norms for priority connections; searches for highest priority and connects as available down the list.

I kinda wish this was the default method used by the app. It was implemented around BT 2.1 or 2.3 and most devices use BT 3.0 if not BT 4.0 now. The BT device random 'disconnect' issue problem is most likely no where near as common for most users.

Hope you get a solution implemented programmatically. I'm interested in any progress you make. Best of luck!

Scott Miller

unread,
Jul 14, 2014, 4:14:35 PM7/14/14
to tas...@googlegroups.com


> Hope you get a solution implemented programmatically. I'm interested in any progress you make. Best of luck!
>
>

I found out today that this is on the to-do list for Secure Settings. If interested, it's possible to vote for the feature here: https://intangibleobject.uservoice.com/forums/216738-general

Brandon Horwath

unread,
Jul 14, 2014, 5:40:51 PM7/14/14
to tas...@googlegroups.com

Scott Miller

unread,
Jul 14, 2014, 6:04:57 PM7/14/14
to tas...@googlegroups.com

Thanks. Corey gave me the other link in his reply to my inquiry.

Scott

Scott Miller

unread,
Nov 28, 2014, 6:17:17 PM11/28/14
to tas...@googlegroups.com

For anyone who previously was following this thread, I've been trying the most recent version of BT Autoconnect, and it seems to be working. I'm only using the Tasker plugin portion of it, and have disabled the options within the app itself. I still need to fine tune it, but it seems to be a probable solution.

Scott

Reply all
Reply to author
Forward
0 new messages