mbox series

[BlueZ,0/1] Fix com.bluez.battery1 randomly missing percentage

Message ID 20240724085318.209318-1-YanceyChiew@gmail.com
Headers show
Series Fix com.bluez.battery1 randomly missing percentage | expand

Message

Yancey Chiew July 24, 2024, 8:53 a.m. UTC
For more than a year, I often found that the
org.bluez.Battery1 dbus interface randomly failed to
obtain the battery level of some devices.

When this happens, it is always accompanied by a
"Trying to update an unregistered battery" log.

Finally, I found a bug in battery.c:parse_battery_level().
Except when called for the first time, it will wait
until the battery percentage changes before updating
the value in the dbus interface.

For BLE devices, changes in battery percentage will
take a long time, which is enough for the device
to disconnect/reconnect multiple times due to
sleep/wake-up. And every reconnection has a chance to
cause "Trying to update an unregistered battery".

This is a new version of the previous patch, fixes
the style problem.
> id: 20240723082843.184915-1-YanceyChiew () gmail ! com

Yancey Chiew (1):
  profiles/battery: Fix batt random lose percentage

 profiles/battery/battery.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)