Reputation: 1036
I use Bluetooth headset that use Bluetooth version 4.1. When I connect with android it shows the battery status. But with Linux (Ubuntu 18.04) I cannot get battery status. I tried with bluetoothctl
, looking file in /sys/class/power_supply
as in other questions, But they didn't help me.
stackoverflow.com/questions/49078659/check-battery-level-of-connected-bluetooth-device-on-linux
My bluetooth device don't use GATT profile. It uses A2DP sink for streaming audio.
I looked Bluez documentation. They all said is do with GATT profile and get the attributes.
Is there a way to read battery status even with pragmatically in Linux properly? How does android device get the battery status? Is it a weakness of Linux Bluetooth stack?
Upvotes: 13
Views: 11031
Reputation: 51
NOTE
Remember to edit the file in sudo or doas or root mode.
Open /etc/bluetooth/main.conf
in a text editor.
Go to Line where it is written # Experimental = false
Change the line to Experimental = true
and also remember to remove the #
symbol for the line to make it a command instead of a comment.
Then Run this command
sudo systemctl restart bluetooth
And You are done. Enjoy :)
Upvotes: 3
Reputation: 2570
Since this pull request by Dmitry Sharshakov, PipeWire has support for reporting battery status (with devices that use Apple HFP AT commands). It uses bluez's Battery Provider API, which is still experimental and is only available if bluetoothd
is started with the -E
flag.
On Arch Linux, it should be enough to run
cp /usr/lib/systemd/system/bluetooth.service /etc/systemd/system/
sed -i -r 's/ExecStart=.+/& -E/' /etc/systemd/system/bluetooth.service
systemctl daemon-reload
systemctl restart bluetooth
And the headset battery level should appear. To get the battery level programatically, you can then use UPower's DBus API.
Upvotes: 9