Ubuntu bluetooth headset battery

Проверьте состояние батареи наушников Bluetooth в Linux

Возможно ли получить состояние батареи наушников Bluetooth, подключенных к Linux, Android показывает это, поэтому мне было интересно, если это было возможно??

6 ответов

Я не уверен насчет состояния в Ubuntu, но в Arch Linux в настоящее время вам не нужно писать собственные сценарии для получения информации о батарее Bluetooth.

Пакет bluez имеет экспериментальную поддержку запроса данных о батарее Bluetooth-гарнитуры. Просто включите экспериментальные функции, отредактировав

Затем вам просто нужно перезапустить службу Bluetooth, используя

systemctl restart bluetooth 

Повторно подключитесь к устройству и

теперь также должен показывать состояние батареи. например

Device 28:11:A5:47:6C:6E (public) Name: Cloud Walker Alias: Cloud Walker Class: 0x00240418 Icon: audio-headphones Paired: yes . Battery Percentage: 0x3c (60) 

Решение с использованием upower, предложенное danjjl, теперь также должно работать.

И теперь процент уровня заряда батареи также должен отображаться в диалоговом окне настроек Gnome Power.

Я написал простой скрипт на Python, который выполняет эту работу. Он использует AT-команды для связи с устройством через RFCOMM и печатает уровень заряда батареи, если устройство поддерживается.

(Для запуска скрипта вам понадобится Python 3.6.0 или новее)

Это может работать не со всеми bluetooth-гарнитурами, но на странице «Проблемы» я предложил несколько обходных решений, которые могут помочь.

В Ubuntu вы можете просто перейти в settings->power чтобы увидеть состояние батареи системы и подключенных устройств.

Да, я знаю, что это Bluetooth-мышь Microsoft в системе Linux. но, эй, Microsoft теперь новая крутая компания;)

upower может использоваться с терминала для составления списка устройств питания, прослушивания событий устройства и запроса истории и статистики.

Если ваше устройство указано upower -e Вы можете запустить upower —dump чтобы узнать уровень заряда батареи вашего устройства.

$ upower --dump . Device: /org/freedesktop/UPower/devices/mouse_dev_C1_FC_26_13_A9_58 native-path: /org/bluez/hci0/dev_C1_FC_26_13_A9_58 model: MX Anywhere 2S serial: C1:FC:26:13:A9:58 power supply: no updated: Wed 31 Dec 1969 06:00:00 PM CST (1550719462 seconds ago) has history: yes has statistics: no mouse present: yes rechargeable: no state: unknown warning-level: none percentage: 50% icon-name: 'battery-missing-symbolic' . 

Источник

Читайте также:  Подключить два компьютера через блютуз

How to get the battery info of a bluetooth device?

I’ve searched a lot and didn’t find the proper solution for the problem I’m facing. I wonder if is there a way to see the battery level of a headset connected via bluetooth. I’ve checked the output of bluetoothctl already and it shows me the following information:

[EDIFIER W800BT]# info Device 04:FE:A1:E9:70:DE (public) Name: EDIFIER W800BT Alias: EDIFIER W800BT 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: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb) UUID: Handsfree (0000111e-0000-1000-8000-00805f9b34fb) [EDIFIER W800BT]# show Controller 74:40:BB:FE:F3:7C (public) Name: kennet Alias: kennet Class: 0x001c010c Powered: yes Discoverable: yes Pairable: yes UUID: Headset AG (00001112-0000-1000-8000-00805f9b34fb) UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb) UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb) UUID: OBEX File Transfer (00001106-0000-1000-8000-00805f9b34fb) UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb) UUID: OBEX Object Push (00001105-0000-1000-8000-00805f9b34fb) UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb) UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb) UUID: IrMC Sync (00001104-0000-1000-8000-00805f9b34fb) UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb) UUID: Audio Sink (0000110b-0000-1000-8000-00805f9b34fb) UUID: Vendor specific (00005005-0000-1000-8000-0002ee000001) UUID: Message Notification Se.. (00001133-0000-1000-8000-00805f9b34fb) UUID: Phonebook Access Server (0000112f-0000-1000-8000-00805f9b34fb) UUID: Message Access Server (00001132-0000-1000-8000-00805f9b34fb) UUID: Headset (00001108-0000-1000-8000-00805f9b34fb) Modalias: usb:v1D6Bp0246d0530 Discovering: no 
➜ ~ hcitool dev Devices: hci0 74:40:BB:FE:F3:7C 
➜ ~ ls -l /sys/class/bluetooth/hci0/power/ total 0 -rw-r--r-- 1 root root 4096 dez 27 19:11 async -rw-r--r-- 1 root root 4096 dez 27 19:11 autosuspend_delay_ms -rw-r--r-- 1 root root 4096 dez 27 19:11 control -r--r--r-- 1 root root 4096 dez 27 19:11 runtime_active_kids -r--r--r-- 1 root root 4096 dez 27 19:11 runtime_active_time -r--r--r-- 1 root root 4096 dez 27 19:11 runtime_enabled -r--r--r-- 1 root root 4096 dez 27 19:11 runtime_status -r--r--r-- 1 root root 4096 dez 27 19:11 runtime_suspended_time -r--r--r-- 1 root root 4096 dez 27 19:11 runtime_usage 

Источник

Check Bluetooth headphones battery status in Linux

Is it possible to get the battery status of Bluetooth headphones connected to Linux? Android shows it so I was wondering if it was possible.

6 Answers 6

I am not sure about the state under Ubuntu, but under Arch Linux you do not need to write your own scripts to get bluetooth battery information nowadays.

Читайте также:  Роутер asus совместное сосуществование bluetooth

The bluez package has experimental support for querying bluetooth headset battery data. Simply enable experimental features by editing

Then, you just need to restart the bluetooth service using

systemctl restart bluetooth 

Reconnect to your device, and

should now also show the battery status. e.g.

Device 28:11:A5:47:6C:6E (public) Name: Cloud Walker Alias: Cloud Walker Class: 0x00240418 Icon: audio-headphones Paired: yes . Battery Percentage: 0x3c (60) 

The solution using upower as given by danjjl should also work now.

And now the battery level percentage should show up in Gnome Power settings dialog as well.

Thanks, just got this working on Arch thanks to your answer! It also gets it showing in the Power settings UI for Gnome too! Ubuntu must have enabled the Experimental bit in their upstream of bluez . I just added some UI screenshots as well as example output from bluetoothctl info . Oddly though, bluetoothctl info only shows one device, e.g. not my MX Master mouse battery as well. I’m looking forward to these battery levels showing natively in the system tray settings dropdown too!

I wrote a simple python script that does the job. It uses AT commands to communicate with the device via RFCOMM and prints the battery level if the device is supported.

(You need Python 3.6.0 or newer to run the script)

It might not work with all bluetooth headsets but I’ve provided a couple of workarounds in the ‘Issues’ page that might help.

@Qui-GonJinn it’s a command line tool. It simply prints the battery level, for example something like this: Battery level for XX:YY:ZZ:AA:BB:CC is 80%

Using port .2 I get is offline (16, ‘Device or resource busy’) . Using other ports I get is offline (111, ‘Connection refused’) .

In ubuntu you can go simply to settings->power to see the battery status of system and connected devices.

enter image description here

Yes, I know it’s a Microsoft Bluetooth mouse on a Linux System . but hey, Microsoft is the new cool company now 😉

Читайте также:  Не соединяется блютуз колонка

This is what: systemctl status bluetooth

enter image description here

This is what: bluetoothctl devices shows:

enter image description here

The JBL was disconnected and the Creative speaker is connected with power. So the resulting ones with batteries (Keychron and Mouse) show up in the settings->power dialog.

NOTE: If upower -d not show the device, It’s power level may not display in settings .
// I had a mouse shown, but a headphone not.

Unfortunately, I don’t see the first section «Devices» on my machine. I’ve the same Ubuntu20.04.1 LTS.

Hmm, seems you don’t have any connected devices. Probably a last check if BT stack is running. You can check it with systemctl status bluetooth Which should state loaded and active. If that is the case you can use bluetoothctl which open an internal cli. Enter devices which should give a list of the connected devices. I add the outputs for my system in the answer above.

Seems to be dependent on the device. I found the issue and comment from the maintainer below in the gnome.org gitlab issues Source,see here: Quote: «.. the device needs to show up in the output of upower -d to show up in the Power Settings panel (whether that’s a laptop or a desktop). Right now, this means only devices which export their battery status in the kernel, and Bluetooth LE devices which export the battery via the BATT profile are supported...»

upower can be used from a terminal to list power devices, listening to device events and querying history and statistics.

If your device is listed by upower -e you can run upower —dump to retrieve the battery level of your device.

$ upower --dump . Device: /org/freedesktop/UPower/devices/mouse_dev_C1_FC_26_13_A9_58 native-path: /org/bluez/hci0/dev_C1_FC_26_13_A9_58 model: MX Anywhere 2S serial: C1:FC:26:13:A9:58 power supply: no updated: Wed 31 Dec 1969 06:00:00 PM CST (1550719462 seconds ago) has history: yes has statistics: no mouse present: yes rechargeable: no state: unknown warning-level: none percentage: 50% icon-name: 'battery-missing-symbolic' . 

Источник

Оцените статью
Adblock
detector