From 0a04609e07c151381131a130747ab69b8632e810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Pel=C3=A1ez?= <112709352+DaPelaez89@users.noreply.github.com> Date: Mon, 5 Oct 2026 11:19:22 -0500 Subject: [PATCH] Create TrustProtocol.cs Trust brand protocol, not tested yet --- .../Sources/Trust/TrustProtocol.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/DeviceBatteryInfo/Sources/Trust/TrustProtocol.cs diff --git a/src/DeviceBatteryInfo/Sources/Trust/TrustProtocol.cs b/src/DeviceBatteryInfo/Sources/Trust/TrustProtocol.cs new file mode 100644 index 0000000..186f950 --- /dev/null +++ b/src/DeviceBatteryInfo/Sources/Trust/TrustProtocol.cs @@ -0,0 +1,18 @@ +internal sealed class TrustProtocol() : HidProtocol("Trust", vendorId: 0x145F, reportLength: 20) +{ + public override IReadOnlyList Devices { get; } = + [ + new("BAYO II", 0x031E), + ]; + + public override async Task ReadAsync( + HidChannel channel, HidDeviceInfo device, CancellationToken cancellationToken) + { + var response = await channel.ExchangeAsync( + request: BuildBatteryRequest(), + isComplete: r => r.Length > 4 && r[1] == 0x10, + cancellationToken); + + return BatteryReading.FromPercent(response[4]); + } +}