fix: BatteryStatus-Mapping empirisch korrigiert
Byte-Zuordnung am echten HS80 verifiziert (Kabel ein/aus): 0x01 = Charging, 0x02 = Discharging, 0x03 = Low, 0x04 = Full Weicht vom ckb-next-Mapping ab. Verbose-Flag zeigt jetzt auch Property-Queries für weitere Diagnose.
This commit is contained in:
+9
-3
@@ -14,6 +14,7 @@ use crate::hid;
|
||||
/// und setzt beim Drop automatisch in den Hardware-Modus zurück.
|
||||
pub struct BragiDevice {
|
||||
device: HidDevice,
|
||||
verbose: bool,
|
||||
}
|
||||
|
||||
impl BragiDevice {
|
||||
@@ -32,13 +33,14 @@ impl BragiDevice {
|
||||
if verbose {
|
||||
eprintln!("[init] Gerät gefunden und geöffnet");
|
||||
}
|
||||
let bragi = Self { device };
|
||||
bragi.initialize(verbose)?;
|
||||
let bragi = Self { device, verbose };
|
||||
bragi.initialize()?;
|
||||
Ok(bragi)
|
||||
}
|
||||
|
||||
/// Vollständige Bragi-Handshake-Sequenz.
|
||||
fn initialize(&self, verbose: bool) -> Result<()> {
|
||||
fn initialize(&self) -> Result<()> {
|
||||
let verbose = self.verbose;
|
||||
// Phase 1: Receiver initialisieren
|
||||
// Wake-Up: Firmware-Version lesen
|
||||
let packet = protocol::build_get_packet(ENDPOINT_RECEIVER, Property::AppFirmware.id());
|
||||
@@ -118,6 +120,10 @@ impl BragiDevice {
|
||||
fn get_headset_property(&self, property: Property) -> Result<BragiResponse> {
|
||||
let packet = protocol::build_get_packet(ENDPOINT_HEADSET, property.id());
|
||||
let raw = hid::send_recv(&self.device, &packet)?;
|
||||
if self.verbose {
|
||||
let hex: Vec<String> = raw.iter().take(10).map(|b| format!("{b:02X}")).collect();
|
||||
eprintln!("[query] GET 0x{:02X} → {}", property.id(), hex.join(" "));
|
||||
}
|
||||
protocol::parse_response(&raw)
|
||||
}
|
||||
|
||||
|
||||
@@ -37,13 +37,18 @@ pub enum BatteryStatus {
|
||||
}
|
||||
|
||||
impl BatteryStatus {
|
||||
/// Konvertiert das Status-Byte in einen BatteryStatus.
|
||||
///
|
||||
/// Mapping empirisch ermittelt am HS80 RGB Wireless (2026-03-27):
|
||||
/// 0x00 = Offline, 0x01 = Charging, 0x02 = Discharging,
|
||||
/// 0x03 = Discharging (Low), 0x04 = FullyCharged
|
||||
pub fn from_byte(value: u8) -> Self {
|
||||
match value {
|
||||
0x00 => Self::Offline,
|
||||
0x01 => Self::Discharging,
|
||||
0x02 => Self::Low,
|
||||
0x03 | 0x04 => Self::Charging,
|
||||
0x05 => Self::FullyCharged,
|
||||
0x01 => Self::Charging,
|
||||
0x02 => Self::Discharging,
|
||||
0x03 => Self::Low,
|
||||
0x04 => Self::FullyCharged,
|
||||
other => Self::Unknown(other),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user