type-c-service: Pull PortStatus changes from v0.1 - #949
Conversation
071c2c4 to
b088f50
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the Type-C/PD status surface area by refactoring PortStatus to carry richer negotiated-contract data (SinkContract/SourceContract) including optional PD-specific details, instead of embedding a few boolean flags directly on PortStatus. The Type-C service is adjusted to consume the new contract shape (notably for sink-ready timeout selection), and tests/mocks/examples are updated to construct the new contract structures. This aligns the codebase with the PortStatus changes pulled from the referenced v0.1 work, and centralizes partner-reported PDO flags behind contract methods.
Changes:
- Introduce
SinkContract/SourceContract(+PdSinkInfo/PdSourceInfo) and updatePortStatusto use them. - Update Type-C service logic to derive power/timeout decisions from contract capability + PD info (
epr_capable(),unconstrained_power(), etc.). - Update unit/integration tests, interface mocks, and std examples to build the new contract structures.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| type-c-service/tests/unconstrained.rs | Update unconstrained-power test setup to populate SinkContract + PD fixed-data flags. |
| type-c-service/tests/power.rs | Adjust many test fixtures to use SinkContract/SourceContract wrappers instead of raw PowerCapability. |
| type-c-service/tests/debug_accessory.rs | Update debug accessory status fixture to use SourceContract::from_capability. |
| type-c-service/src/service/ucsi.rs | Update UCSI charging-status derivation to read contract.capability. |
| type-c-service/src/controller/power.rs | Use SinkContract helpers and derive sink-ready timeout selection from epr_capable(). |
| type-c-service/src/controller/max_sink_voltage.rs | Align sink-ready deadline setup with the new EPR-capable detection on the sink contract. |
| type-c-interface/src/port/pd.rs | Adjust docs referencing removed PortStatus fields (partner PDO info now lives under contracts). |
| type-c-interface/src/control/pd.rs | Add new contract + PD info structs and update PortStatus fields accordingly. |
| type-c-interface-mocks/tests/connect_disconnect.rs | Update assertions to validate contract capability + derived flags rather than removed PortStatus booleans. |
| type-c-interface-mocks/src/port/mod.rs | Update mock plug() to populate the new contract structures and PD fixed-data flags. |
| examples/std/src/lib/type_c/mock_controller.rs | Update std mock controller to populate contract PD info (including unconstrained flag). |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| /// Returns whether this port reports unconstrained power to the system. | ||
| /// | ||
| /// This is the port's own determination and can differ from | ||
| /// [`PortStatus::unconstrained_power`], which is what the partner reports in its PDO. | ||
| /// [`PortStatus`], which is what the partner reports in its PDO. | ||
| fn reports_unconstrained_power(&self) -> bool; |
| let timeout = Self::check_sink_ready_timeout_duration( | ||
| new_status | ||
| .available_sink_contract | ||
| .is_some_and(|contract| contract.epr_capable()), | ||
| ); |
Pull in changes from PRs OpenDevicePartnership#941. Assisted-by: GitHub Copilot:GPT-5.6 Sol Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
b088f50 to
78f8ca7
Compare
Pull in changes from PR #941.
Assisted-by: GitHub Copilot:GPT-5.6 Sol