ult*_*tex 6 linux bluetooth bluez android-bluetooth
我使用使用蓝牙4.1版的蓝牙耳机。当我与android连接时,它会显示电池状态。但是使用Linux(Ubuntu 18.04),我无法获取电池状态。我尝试了bluetoothctl,与/sys/class/power_supply其他问题一样查找文件,但是他们没有帮助我。
askubuntu.com/questions/53880/可以通过任何方式检查苹果无线外围设备的电池百分比
stackoverflow.com/questions/49078659/check-battery-level-of-connected-bluetooth-device-on-linux
我的蓝牙设备不使用GATT配置文件。它使用A2DP接收器来传输音频。
我看了Bluez文档。他们都说与GATT配置文件有关并获取属性。
有没有办法在Linux中正确实用地读取电池状态?Android设备如何获取电池状态?它是Linux蓝牙堆栈的弱点吗?
自从Dmitry Sharshakov 提出此拉取请求以来,PipeWire 支持报告电池状态(对于使用 Apple HFP AT 命令的设备)。bluetoothd它使用 bluez 的 Battery Provider API,该 API 仍处于实验阶段,仅在使用该标志启动时才可用-E。
在 Arch Linux 上,应该足以运行
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
Run Code Online (Sandbox Code Playgroud)
并且应该会显示耳机电池电量。要以编程方式获取电池电量,您可以使用 UPower 的 DBus API。
| 归档时间: |
|
| 查看次数: |
2219 次 |
| 最近记录: |