All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 0/1] Fix com.bluez.battery1 randomly missing percentage
@ 2024-07-24  8:53 Yancey Chiew
  2024-07-24  8:53 ` [PATCH BlueZ 1/1] profiles/battery: Fix batt random lose percentage Yancey Chiew
  0 siblings, 1 reply; 3+ messages in thread
From: Yancey Chiew @ 2024-07-24  8:53 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Yancey Chiew

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(-)

-- 
2.45.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH BlueZ 1/1] profiles/battery: Fix batt random lose percentage
  2024-07-24  8:53 [PATCH BlueZ 0/1] Fix com.bluez.battery1 randomly missing percentage Yancey Chiew
@ 2024-07-24  8:53 ` Yancey Chiew
  2024-07-24 10:40   ` Fix com.bluez.battery1 randomly missing percentage bluez.test.bot
  0 siblings, 1 reply; 3+ messages in thread
From: Yancey Chiew @ 2024-07-24  8:53 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Yancey Chiew

Fix an error related to "Trying to update an unregistered battery",
which causes the battery1 dbus service to fail to provide the
initial value until the battery level changes.

battery.c:batt_io_value_cb() maybe run earlier than
battery.c:batt_io_ccc_written_cb(), which causes the percentage
to be updated in the batt structure when the dbus interface
has not been registered.

After the dbus interface is registered, the function to update
the battery percentage is skipped again because the battery level
has not changed yet.
---
 profiles/battery/battery.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c
index 02d024d92..b2699c0d7 100644
--- a/profiles/battery/battery.c
+++ b/profiles/battery/battery.c
@@ -94,13 +94,15 @@ static void parse_battery_level(struct batt *batt,
 	uint8_t percentage;
 
 	percentage = value[0];
+
+	if (!batt->battery) {
+		warn("Trying to update an unregistered battery");
+		return;
+	}
+
 	if (batt->percentage != percentage) {
 		batt->percentage = percentage;
 		DBG("Battery Level updated: %d%%", percentage);
-		if (!batt->battery) {
-			warn("Trying to update an unregistered battery");
-			return;
-		}
 		btd_battery_update(batt->battery, batt->percentage);
 	}
 }
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: Fix com.bluez.battery1 randomly missing percentage
  2024-07-24  8:53 ` [PATCH BlueZ 1/1] profiles/battery: Fix batt random lose percentage Yancey Chiew
@ 2024-07-24 10:40   ` bluez.test.bot
  0 siblings, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2024-07-24 10:40 UTC (permalink / raw)
  To: linux-bluetooth, yanceychiew

[-- Attachment #1: Type: text/plain, Size: 949 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=873475

---Test result---

Test Summary:
CheckPatch                    PASS      0.44 seconds
GitLint                       PASS      0.28 seconds
BuildEll                      PASS      24.83 seconds
BluezMake                     PASS      1661.64 seconds
MakeCheck                     PASS      13.09 seconds
MakeDistcheck                 PASS      179.23 seconds
CheckValgrind                 PASS      251.92 seconds
CheckSmatch                   PASS      355.14 seconds
bluezmakeextell               PASS      118.93 seconds
IncrementalBuild              PASS      1448.45 seconds
ScanBuild                     PASS      1011.74 seconds



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-24 10:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-24  8:53 [PATCH BlueZ 0/1] Fix com.bluez.battery1 randomly missing percentage Yancey Chiew
2024-07-24  8:53 ` [PATCH BlueZ 1/1] profiles/battery: Fix batt random lose percentage Yancey Chiew
2024-07-24 10:40   ` Fix com.bluez.battery1 randomly missing percentage bluez.test.bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.