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]); + } +}