Bluetooth Battery Level

Is there any app or any other way to identify the battery level of the connected bluetooth earphones?

4 Likes

Unfortunately no :frowning:
The information is there, but not being parsed by anything as far as i can tell.
I.e. I have seen AT+IPHONEACCEV in the journal log, but it doesn’t appear to be captured by anything.
To me it appears like it would be easy to capture and expose on dbus for somebody that is “at home” in the Bluetooth subsystem. But i guess the main question is how to make it work with upstream and make the functionality maintainable through future changes in the area.

2 Likes

This used to work in older versions , however one of the 1.1x updates broke it and it’s broken ever since.

3 Likes

Wow! Is there any info on this somewhere?

Maybe this could be brought up here:


…or perhaps next time around.

Edit: wrong link

It seems BlueZ will finally start exposing easily accessible battery readings among the normal D-Bus properties.

SFOS seems to be tracking upstream BlueZ pretty close, so hopefully this can be included in not too long.
Plumbing it in to the GUI should then become almost trivial :slight_smile:

6 Likes

@attah Are there any news on this?

2 Likes

Hmm, looks like we should already have it +/- build and configuration options.
(And another update landed in the repos just last week, presumably in preparation for 4.6).

1 Like

I already had a leftover attempt at enabling it in the config file, and i have now added the command line switch to the systemd unit. I have rebuilt the package(s) with --enable-experimental, and i have even removed some of the code that skips experimental attributes. Still nothing for my headphones.

Then i tried my mouse - and there it was. So now i need to step back all the changes and see what actually did it - if anything.

The exact same command that didn’t get me any battery status for my headphones on the phone does work on my computer. The source was listed as ‘Apple accessory indication’, no less… so compatibility should be great. But there i’m actually one version behind current SFOS. I’ll have to keep digging for the difference another day…

Edit: After googling a bit just now, i refreshed my memory. This needs a new Pulseaudio. And newer still than the stalled upgrade to 15. It’s so backwards that it failed to stick in my memory i guess. Might be backportable, might be a trivial uplift when 15 gets picked back up… not sure.

4 Likes

I got some Infos for my Sony In-Ears:

[defaultuser@XperiaXZ2Compact ~]$ bluetoothctl
Failed to register agent: org.freedesktop.DBus.Error.AuthFailed
[WF-C500]# info
Device 30:53:C1:E6:70:51 (public)
        Name: WF-C500
        Alias: WF-C500
        Class: 0x00240404
        Icon: audio-headset
        Paired: yes
        Bonded: yes
        Trusted: yes
        Blocked: no
        Connected: yes
        LegacyPairing: no
        UUID: Vendor specific           (00000000-deca-fade-deca-deafdecacaff)
        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)
        UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
        UUID: Vendor specific           (764cbf0d-bbcb-438f-a8bb-6b92759d6053)
        UUID: Vendor specific           (8901dfa8-5c7e-4d8f-9f0c-c2b70683f5f0)
        UUID: Vendor specific           (956c7b26-d49a-4ba8-b03f-b17d393cb6e2)
        Modalias: usb:v054Cp0DD4d1000

Pressed Pause:
[CHG] Transport /org/bluez/hci0/dev_30_53_C1_E6_70_51/sep1/fd17 State: idle

Pressed Play:
[CHG] Transport /org/bluez/hci0/dev_30_53_C1_E6_70_51/sep1/fd17 State: active

Increase Volume 3 times:
[CHG] Transport /org/bluez/hci0/dev_30_53_C1_E6_70_51/sep1/fd17 Volume: 0x004f (79)
[CHG] Transport /org/bluez/hci0/dev_30_53_C1_E6_70_51/sep1/fd17 Volume: 0x0053 (83)
[CHG] Transport /org/bluez/hci0/dev_30_53_C1_E6_70_51/sep1/fd17 Volume: 0x0057 (87)

A decreasing battery level should be automatically notified.

I am trying to find the UUID and key from which I can read the actual battery level.

        Status: RUNNING
        Name: bluez_sink.30_53_C1_E6_70_51.a2dp_sink
        Beschreibung: WF-C500
        Treiber: module-bluez5-device.c
        Abtastwert-Angabe: s16le 2ch 44100Hz
        Kanalzuordnung: front-left,front-right
        Besitzer-Modul: 41
        Stumm: nein
        Lautstärke: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                Verteilung 0,00
        Basis-Lautstärke: 65536 / 100% / 0,00 dB
        Quellen-Monitor: bluez_sink.30_53_C1_E6_70_51.a2dp_sink.monitor
        Latenz: 50159 usec, eingestellt 45317 usec
        Flags: HARDWARE DECIBEL_VOLUME LATENCY 
        Eigenschaften:
                bluetooth.protocol = "a2dp_sink"
                device.description = "WF-C500"
                device.string = "30:53:C1:E6:70:51"
                device.api = "bluez"
                device.class = "sound"
                device.bus = "bluetooth"
                device.form_factor = "headset"
                bluez.path = "/org/bluez/hci0/dev_30_53_C1_E6_70_51"
                bluez.class = "0x240404"
                bluez.alias = "WF-C500"
                device.icon_name = "audio-headset-bluetooth"
                device.intended_roles = "phone"
                x-maemo.mode = "bta2dp"
                x-maemo.accessory_hwid = ""
        Ports:
                headset-output: Headset (type: Headset, priority: 0, available)
        Aktiver Port: headset-output
        Formate:
                pcm

I did not understand why they hide such important information like battery level.

1 Like

I don’t think you will have much luck querying the battery level that way (beyond what Bluez is already capable to, possibly after setting flags). I.e. If your device is as well-behaved as my mouse, you can get it - but so can Bluez. However, for a lot of headphones it seems to use this iPhone accessory stuff that needs help in Pulse.

Please use code blocks when pasting logs.

1 Like

I have now reverted all my changes on the phone, and it seems that i still have the battery service, though with one attribute less.

gdbus introspect --system --dest org.bluez --object-path /org/bluez/hci0/dev_E8_0E_8D_62_88_72 -r -p
  interface org.bluez.Battery1 {
    properties:
      readonly y Percentage = 0x64;
  };

And after setting Experimental = true in /etc/bluetooth/main.conf.

  interface org.bluez.Battery1 {
    properties:
      readonly y Percentage = 0x64;
      readonly s Source = 'GATT Battery Service';
  };

And of course 0x64 = 100.
So it seems we have all we need here, except downstream stuff like Pulse reporting back to Bluez the battery status they (for whatever reason) get hold of.