You are not logged in.

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

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

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: 19,739

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

#5 2018-09-20 14:42:50

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

Re: Bluetooth Headset Battery Status

Thanks for all the effort and the hint about Wireshark. Until now Wireshark comes only on my mind at tcp/udp big_smile

I captured a connection (including a switch from HSP/HFP to A2DP) with tcpdump: https://cmss.loges.org/files/blutooth_h … ction.pcap
For now I didn't take a deep look on it, but there are a lot of protocols involved:

* Host Controller Interface (HCI)
* Logical Link Control and Adaptation Layer Protocol (L2CAP)
* Session Description Protocol (SDP)
* Radio Frequency Communication (RFCOMM)
* Headset Profile (HSP)
* Audio/Video Distribution Transport Protocol Profile (AVDTP)
* Session Border Controller (SBC)


So while in my first post I didn't now what to do next, now i got a lot of interesting stuff big_smile

Edit:

In the pcap I searched for GATT (btgatt), Hands Free AG (bthfp) but found nothing.
For A/V Remote Control Target (btavctp) i found some packages but only "PlaybackStatusChanged" or "VolumeChanged".
Not sure if bthsp is correct for "Headset AG", but i can see at least "Gain of Speaker" or "Gain of Microphone" with it.

I will try to capture a longer period as soon i got more time for it smile

Last edited by Norkos (2018-09-20 15:54:43)

Offline

#6 2019-05-28 22:15:50

rata
Member
Registered: 2006-04-10
Posts: 46

Re: Bluetooth Headset Battery Status

Hi everyone,

I've been trying to obtain battery info from a similar bluetooth device on archlinux and haven't made much progress. I posted a question on stackoverflow about it:
https://stackoverflow.com/questions/490 … e-on-linux
Today I found out that we are not alone. This person is having no luck either on ubuntu:
https://stackoverflow.com/questions/541 … dset-linux

Have you guys made any progress since the last post?

Cheers

Offline

#7 2019-05-29 13:22:16

HalosGhost
Forum Moderator
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 2,089
Website

Re: Bluetooth Headset Battery Status

rata wrote:

Hi everyone,

Hi.

I've been trying to obtain battery info from a similar bluetooth device on archlinux and haven't made much progress.

Though this may be true, I doubt it is exactly the same issue. Even if it is, this is a months-old topic. Please open a new topic, and if it is reasonably closely-related, link to this one.

I posted a question on stackoverflow about it:

Please do not expect people to click on a link to just go somewhere else to read the description of your issue. Reproduce it here.

Closing.

All the best,

-HG

Offline

Board footer

Powered by FluxBB