You are not logged in.

#1 2018-04-24 13:32:17

Norkos
Member
From: Berlin
Registered: 2017-04-24
Posts: 4

Bluetooth Headset Battery Status

Hi,

I want to get the battery status from my Bluetooth headset.
It seems it does not support the GATT-Profile, but my android phone shows the battery status (LinageOS and Stock 8.1).

Its a: "Marshall Monitor Bluetooth" witch is advertised with "Bluetooth v4.0 aptX".

I connected it using "A2DP" and it plays the music without any problems:

using bluetoothctl (Version 5.49).

[bluetooth]# connect 00:5A:5A:A6:61:87
Attempting to connect to 00:5A:5A:A6:61:87
[CHG] Device 00:5A:5A:A6:61:87 Connected: yes
Connection successful
[CHG] Device 00:5A:5A:A6:61:87 ServicesResolved: yes

If GATT is found there should be more output from the Device (says: https://docs.ubuntu.com/core/en/stacks/ … t-services ).
But this is all i got.

info gives me this:

[MONITOR BLUETOOTH]# info
Device 00:5A:5A:A6:61:87 (public)
	Name: MONITOR BLUETOOTH
	Alias: MONITOR BLUETOOTH
	Class: 0x00240404
	Icon: audio-card
	Paired: yes
	Trusted: yes
	Blocked: no
	Connected: yes
	LegacyPairing: no
	UUID: Headset                   (00001108-0000-1000-8000-00805f9b34fb)
	UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
	UUID: Advanced Audio Distribu.. (0000110d-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
	UUID: Handsfree                 (0000111e-0000-1000-8000-00805f9b34fb)

I assume the UUID's are services/features of the device. But there is no "Battery Service".
I read that there are some proprietary ways to submit the battery status, but when android it get's it should be possible for me as well, or?

I'am tring on gathering more information's about these services.
With D-Feet I find some interfaces of the device, but now I'am stuck and don't know what i can do next.

Here a Screenshot of D-Feet: https://ibb.co/mzcKPH

--
So any ideas are appreciated smile

Offline

#2 2018-08-11 07:58:06

IAPark
Member
Registered: 2018-08-11
Posts: 2

Re: Bluetooth Headset Battery Status

I've just looked into this way too much and while you probably don't care at this point and I don't have a firm answer yet, let me tell you what I've found out in case anyone else wants to take a look.

I'm guessing Android is using the hands free profile to get battery information. According to Wikipedia the Hands free protocol supports sending battery information and there is a spec sheet that seems to confirm it (https://www.bluetooth.org/docman/handle … _id=292287). I'm still very unclear about a bunch of how bluetooth works, but I'm going to be continuing to pursue this a bit and so maybe I'll be able to update with more information.

Offline

#3 2018-08-11 14:44:36

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 16,062

Re: Bluetooth Headset Battery Status

You may look into Wireshark.  It now handles Bluetooth traffic and has a nice protocol analyzer to allow you to see what are being transmitted and received.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#4 2018-08-13 05:34:48

IAPark
Member
Registered: 2018-08-11
Posts: 2

Re: Bluetooth Headset Battery Status

As promised I did some more searching. Actually a lot more searching.

I've found 4 ways to get battery levels only one of which works on my headphones.

* GATT
* Hands Free AG
* A/V Remote Control Target
* And the one that worked: Headset AG with apple specific command

The search started with finding that the Hands Free Profile can report battery info. To find out if my device supported it I had to write a python script with Bluez's d-bus integration. to get my headphones connect so I could log the info. I went through implementing a lot of the connection procedure before I realized that my device didn't support the relevant feature.

The A/V Remote Control Target should also in theory support devices reporting battery level, but I don't think my device supports it. I didn't go into much detail to confirm though.

The headset profile was pure luck though. I was looking at Wireshark and happened to see

AT+IPHONEACCEV=2,1,5,2,0\r

. I'd missed it before because it was only sent when first connecting, but a bit after the initial negotiation. The Bluetooth headset profile doesn't support battery reporting, but it looks like Apple has their own command for iphones. It seems that in recent version Android supports it too. If you want to interact with it through code though you may have problems since PulseAudio implements their own support for this profile. I have to confess now that I'm not actually on Arch at the moment, so I'm not sure what the config for the Arch version looks like, but for me I had to compile from source with the

--disable-bluez5-native-headset

set. This means there won't be any support for pulse audio hooking into the volume control on the device. I don't really care, but you might.

Here's where android handles getting the battery level

If anyone else wants any info about this I'd be happy to share, but I suspect the interest isn't probably all that great.

I think you can find the same info that I did without too much Googling given the above.

Offline

Board footer

Powered by FluxBB