power-policy-interface: Port disconnect reasons from v0.1 - #948
Open
RobertZ2011 wants to merge 3 commits into
Open
power-policy-interface: Port disconnect reasons from v0.1#948RobertZ2011 wants to merge 3 commits into
RobertZ2011 wants to merge 3 commits into
Conversation
RobertZ2011
force-pushed
the
disconnect-flag-changes
branch
3 times, most recently
from
August 24, 2026 20:30
95095a0 to
72ce097
Compare
RobertZ2011
force-pushed
the
disconnect-flag-changes
branch
4 times, most recently
from
August 24, 2026 21:21
9a747e5 to
c7534ba
Compare
RobertZ2011
force-pushed
the
disconnect-flag-changes
branch
from
August 24, 2026 21:27
c7534ba to
60f8051
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the power-policy interface and its consumers to replace legacy bitfield-style flags with normal Rust structs, and to model consumer disconnects using a structured DisconnectReason (wrapped in DisconnectFlags) rather than separate boolean flags. It also extends Type-C service behavior to propagate a hard-reset disconnect reason through the power-policy event path.
Changes:
- Replace
ConsumerDisconnectboolean flags withDisconnectFlags { reason: Option<DisconnectReason> }and update all notification/event plumbing accordingly. - Refactor
ConsumerFlags/ProviderFlagsfrom bitfield-backed types to plain Rust structs (and update tests/mocks/examples). - Add Type-C hard reset handling that tears down the current contract and emits a disconnect event with a reset reason (plus a new test covering it).
Reviewed changes
Copilot reviewed 22 out of 26 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| type-c-service/tests/power.rs | Updates tests to use struct-based flags and validates disconnect reasons (including new hard reset coverage). |
| type-c-service/tests/debug_accessory.rs | Updates provider capability construction to the new ProviderFlags struct. |
| type-c-service/src/controller/power.rs | Migrates capability flags to struct fields; emits structured disconnect reasons; adds hard reset teardown path. |
| type-c-service/src/controller/mod.rs | Routes pd_hard_reset status events into the new hard reset teardown handler. |
| type-c-service/src/controller/max_sink_voltage.rs | Switches renegotiation disconnect signaling to DisconnectReason::ManualRenegotiation. |
| type-c-interface-mocks/tests/connect_disconnect.rs | Updates expected capabilities to use struct-based flags. |
| type-c-interface-mocks/src/port/mod.rs | Updates mock port state updates to use struct-based flags. |
| power-policy-service/tests/unconstrained.rs | Updates consumer flag usage to struct defaults/fields. |
| power-policy-service/tests/provider.rs | Updates provider flag usage to struct defaults. |
| power-policy-service/tests/consumer.rs | Updates disconnect assertions to reason-based disconnects and refactors related test naming. |
| power-policy-service/tests/common/mod.rs | Renames helper to assert disconnect “reason” via DisconnectFlags instead of legacy flags. |
| power-policy-service/src/service/mod.rs | Updates notifier plumbing and disconnect processing to carry DisconnectFlags/DisconnectReason. |
| power-policy-service/src/service/consumer.rs | Updates consumer selection/switch logic to produce a single disconnect reason and carry it through events. |
| power-policy-interface/src/service/notification.rs | Updates service notifier trait to accept DisconnectFlags. |
| power-policy-interface/src/service/event.rs | Updates service event payloads to use DisconnectFlags. |
| power-policy-interface/src/psu/notification.rs | Updates PSU notifier/handler traits to accept DisconnectFlags. |
| power-policy-interface/src/psu/event.rs | Updates PSU event payloads and notifier adapters to use DisconnectFlags. |
| power-policy-interface/src/charger/tests.rs | Updates helper capability construction to use ConsumerFlags::default(). |
| power-policy-interface/src/capability.rs | Replaces bitfield-based flag types with plain structs and introduces DisconnectReason + DisconnectFlags. |
| power-policy-interface/Cargo.toml | Drops bitfield/num_enum dependencies that were only needed for bitfield-based flags. |
| power-policy-interface-test-mocks/src/psu.rs | Updates mock PSU to construct provider flags via Default and notify disconnects via DisconnectFlags. |
| examples/std/src/bin/power_policy.rs | Updates example capability construction to struct-based consumer flags. |
| examples/std/Cargo.lock | Removes bitfield/num_enum from the example’s resolved dependency set. |
| examples/rt685s-evk/Cargo.lock | Removes bitfield/num_enum from the example’s resolved dependency set. |
| examples/pico-de-gallo/Cargo.lock | Removes bitfield/num_enum from the example’s resolved dependency set. |
| Cargo.lock | Removes bitfield/num_enum from the workspace resolved dependency set for power-policy-interface. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
RobertZ2011
force-pushed
the
disconnect-flag-changes
branch
from
August 24, 2026 22:08
60f8051 to
bbee585
Compare
Implement these flag structs as plain Rust structs. This reduces complexity and the number of dependencies.
Port disconnect reasons from v0.1 branch.
RobertZ2011
force-pushed
the
disconnect-flag-changes
branch
from
August 24, 2026 22:12
bbee585 to
5587b7f
Compare
RobertZ2011
marked this pull request as ready for review
August 24, 2026 22:12
RobertZ2011
requested review from
asasine,
chchongmsft,
colindonahue,
gjpmsft,
kurtjd,
seanbrns and
thdesil
August 24, 2026 22:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port changes from v0.1 that introduce an enum for disconnect reasons instead of separate flags. Also refactor existing power policy flag structs to use normal Rust structs instead of bitfield representations.