fix(device): restore Clone WINC flag + surface health telemetry (closes #331, #335) - #348
Conversation
#331, #335) #331: DeviceCapabilities.Clone() omitted HasWincWifiModule, so every clone (including DeviceMetadata.CopyFrom) silently reset the WINC flag to false, steering consumers away from required WINC handling. Add the missing copy and replace the hand-listed Clone test with a reflection-based round-trip that fails if any future property is dropped from Clone(). #335: The protobuf status message carries device health (battery %, board temp, power/device status) but Core decoded and discarded it. Add a DeviceHealth type on DeviceMetadata, populate it in UpdateFromProtobuf (which runs before the classified StatusMessageReceived event fires), and round-trip it through CopyFrom. Battery/temp are nullable and only set when the message carries the field (proto3 has no presence, so 0 == not-reported); the raw power/device codes are exposed as-is. Verified on real hardware (Nq1, FW 3.7.2): battery=100%, power/device status populate from live status messages. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
PR Summary by QodoFix Clone WINC capability and expose device health telemetry
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo
Context used 1.
|
…nded battery, captured-payload test - Coerce DeviceMetadata.Health and .Capabilities setters to a fresh instance on null, so a consumer assigning null can't NRE the status-processing path (Qodo #1). - Accept BattStatus only when in the documented 1..100 range; ignore out-of-range readings, which also avoids the uint->int wrap-to-negative for very large values (Qodo #3). - Add a health test that serializes a status message to wire bytes and decodes it back through the protobuf parser (captured-payload path per #335), plus out-of-range-battery and null-Health tests (Qodo #2). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
agentic_review |
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 0d94a63 |
… round 2) BatteryPercent/BoardTemperatureCelsius docs claimed null when "the most recent status message did not report it", but UpdateFromProtobuf intentionally preserves the last-known reading across partial frames. Reworded to state the sticky semantics: a value is the last one the device actually reported (may predate the latest frame), and null means "never reported since construction". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 44b4ff0 |
Summary
Two related metadata/capabilities fixes that share the Clone/CopyFrom round-trip path.
#331 —
DeviceCapabilities.Clone()silently droppedHasWincWifiModuleClone()copied 8 of 9 properties, so every clone (and thereforeDeviceMetadata.CopyFrom) reset the WINC flag tofalse— a false negative that steers consumers away from required WINC-specific handling (power-on-before-probe, WINC flash tool, bridge-mode activation).HasWincWifiModulecopy.Clonetest with a reflection-based round-trip that fails if any future property is dropped fromClone(), closing the bug class.#335 — surface device health telemetry (battery %, board temp, power/device status)
The protobuf status message carries
BattStatus,TempStatus,PwrStatus,DeviceStatus; Core decoded the message but threw these away (only discovery readPwrStatus).DeviceHealthtype exposed asDeviceMetadata.Health.UpdateFromProtobuf, which runs before the classifiedStatusMessageReceivedevent fires — so consumers readingdevice.Metadata.Healthin that handler see current values.int?and only assigned when the message carries the field (proto3 has no presence →0== not reported); raw power/device codes exposed as-is.CopyFrom/Clone(deep-copied, per fix: DeviceCapabilities.Clone() silently drops HasWincWifiModule #331).Testing
dotnet test— 1590 pass, 0 fail.HasWincWifiModule=True; live status messages populateBattery%=100,Pwr=1,DevStatus=3. (Board temp reported as absent on this USB-powered unit — correctly surfaced asnull.)Closes #331, closes #335.