Skip to content

Comments

power-policy: Add PSU type to capabilities flags#627

Merged
RobertZ2011 merged 3 commits intoOpenDevicePartnership:mainfrom
RobertZ2011:power-policy-psu-type
Dec 18, 2025
Merged

power-policy: Add PSU type to capabilities flags#627
RobertZ2011 merged 3 commits intoOpenDevicePartnership:mainfrom
RobertZ2011:power-policy-psu-type

Conversation

@RobertZ2011
Copy link
Contributor

@RobertZ2011 RobertZ2011 commented Dec 9, 2025

Also update events to use full power capability structs.

Breaking

Breaking due to replacing usages of PowerCapability with ConsumerPowerCapability. The former is still accessible as a public member within the latter; migration is to use that public member.

@RobertZ2011 RobertZ2011 self-assigned this Dec 9, 2025
Copilot AI review requested due to automatic review settings December 9, 2025 21:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the power policy system by adding PSU (Power Supply Unit) type information to capability flags, enabling the system to distinguish between different power source types (Type-C, DC Jack, custom types). The changes also refactor the communication events to use complete power capability structures (ConsumerPowerCapability and ProviderPowerCapability) instead of just the bare PowerCapability, ensuring that flag information is preserved throughout the system.

Key Changes:

  • Introduced a new PsuType enum with support for Type-C, DC Jack, and custom application-defined types
  • Extended both Consumer and Provider flags to include PSU type information via bitfields
  • Updated all power policy events and communications to use full capability structs with flags

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
embedded-service/src/power/policy/flags.rs Added PsuType enum and integrated it into Consumer/Provider flags bitfields; converted Consumer unconstrained_power from u8 to bool; migrated Provider from unit struct to bitfield
embedded-service/src/power/policy/mod.rs Updated CommsData enum variants to carry full ConsumerPowerCapability and ProviderPowerCapability structures
embedded-service/src/power/policy/charger.rs Updated PolicyEvent and ChargeController trait to accept ConsumerPowerCapability instead of PowerCapability
type-c-service/src/wrapper/power.rs Set PsuType::TypeC for all Type-C power capabilities; refactored contract handling to work with full capability structs
power-policy-service/src/provider.rs Updated post_provider_connected to accept ProviderPowerCapability instead of PowerCapability
power-policy-service/src/consumer.rs Updated PolicyEvent calls to pass full ConsumerPowerCapability; constructed proper capability struct for disconnect scenario
power-policy-service/src/charger.rs Updated to access capability field from ConsumerPowerCapability struct
battery-service/src/context.rs Extracted .capability field from ConsumerPowerCapability when storing power info
Cargo.toml Formatting change for rstest dependency declaration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RobertZ2011 RobertZ2011 force-pushed the power-policy-psu-type branch from 0b3a503 to 36baaa6 Compare December 9, 2025 21:50
Copilot AI review requested due to automatic review settings December 9, 2025 21:55
@RobertZ2011 RobertZ2011 force-pushed the power-policy-psu-type branch from 36baaa6 to ab04102 Compare December 9, 2025 21:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RobertZ2011 RobertZ2011 added the BREAKING CHANGE Marks breaking changes label Dec 9, 2025
@RobertZ2011 RobertZ2011 marked this pull request as ready for review December 9, 2025 22:02
@RobertZ2011 RobertZ2011 requested review from a team as code owners December 9, 2025 22:02
@RobertZ2011 RobertZ2011 force-pushed the power-policy-psu-type branch 2 times, most recently from 63185f0 to 526f523 Compare December 15, 2025 17:50
@RobertZ2011 RobertZ2011 enabled auto-merge (squash) December 15, 2025 18:57
asasine
asasine previously approved these changes Dec 15, 2025
Also update events to use full power capability structs.
Also add embassy time feature that was required for certain tests to
build
Copilot AI review requested due to automatic review settings December 16, 2025 21:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

williampMSFT
williampMSFT previously approved these changes Dec 17, 2025
Copy link
Contributor

@williampMSFT williampMSFT left a comment

Choose a reason for hiding this comment

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

:shipit:

@jerrysxie
Copy link
Contributor

@RobertZ2011 Please announce this breaking change on on Zulip if it has not been done already.

@RobertZ2011 RobertZ2011 merged commit 586030f into OpenDevicePartnership:main Dec 18, 2025
14 checks passed
@RobertZ2011 RobertZ2011 deleted the power-policy-psu-type branch December 18, 2025 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BREAKING CHANGE Marks breaking changes

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants