HeadsetSidetone: log getSidetoneLevelSettings raw reply under -dd

Binary RE of LGHUB established that the 0x0604 wire 'level' is a
gain-step index, not a 0-100 percent: GHUB scales it through a step
count N sourced from getSidetoneLevelSettings (function 2). Solaar
writes a raw percent, which is only correct when N == 101 — so V2
headsets reporting a smaller N (G522/G325) get out-of-range step
writes the firmware silently clamps.

Function 2's byte layout couldn't be recovered from the binary (it
decodes in an inlined lambda). Probe it at build time and log the raw
reply so the next debug log captures where N sits — no behavior
change, gated on DEBUG so it only runs when diagnostics are on.
This commit is contained in:
Ken Sanislo 2026-05-15 11:39:26 -07:00 committed by Peter F. Patel-Schneider
parent d800fc4c54
commit c9db25a302
1 changed files with 9 additions and 0 deletions

View File

@ -1721,6 +1721,15 @@ class HeadsetSidetone(settings.Setting):
skip, prefix = 3, b"\x01\xff"
else:
skip, prefix = 2, b"\x01"
# getSidetoneLevelSettings (fn 2) carries the gain-step count that scales
# wire level <-> UI percent; its byte layout is unmapped. Log the raw
# reply under -dd so a user log pins it down.
if logger.isEnabledFor(logging.DEBUG):
try:
reply = device.feature_request(cls.feature, 0x20)
logger.debug("%s: getSidetoneLevelSettings raw reply: %s", cls.name, reply.hex() if reply else reply)
except Exception as e:
logger.debug("%s: getSidetoneLevelSettings probe raised %s", cls.name, e)
rw = settings.FeatureRW(cls.feature, **cls.rw_options)
validator = cls.validator_class.build(cls, device, read_skip_byte_count=skip, write_prefix_bytes=prefix)
if validator: