mbox series

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

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

Message

Yancey Chiew July 23, 2024, 8:28 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".

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

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