Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/protocol_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ impl From<FwVersion> for u32 {
}
}

impl From<u32> for FwVersion {
fn from(ver: u32) -> Self {
Self {
variant: (ver & 0xFF) as u8,
minor: ((ver >> 8) & 0xFFFF) as u16,
major: ((ver >> 24) & 0xFF) as u8,
}
}
}
Comment on lines +43 to +51
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The From implementation duplicates the existing FwVersion::new() method (lines 28-34). Consider deprecating FwVersion::new() in favor of using From::from() consistently throughout the codebase, or remove this From implementation if FwVersion::new() is preferred. Having both can lead to inconsistency in how FwVersion instances are created from u32 values.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? Can't we just call new()?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jerrysxie Was used from ADO side, not need for now, close this PR.

Comment on lines +43 to +51
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding tests for the From and From trait implementations to verify that conversion between FwVersion and u32 is bidirectional and preserves values correctly. The test module (starting at line 1082) includes tests for other protocol structures but lacks coverage for these conversion traits.

Copilot uses AI. Check for mistakes.

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
/// LSB first Representation of GetFwVersionResponse
Expand Down
Loading