Power policy event pass and clean-up#747
Power policy event pass and clean-up#747RobertZ2011 wants to merge 12 commits intoOpenDevicePartnership:v0.2.0from
Conversation
1ff2ae6 to
5b931a9
Compare
There was a problem hiding this comment.
Pull request overview
This PR reintroduces power-policy service event broadcasting and refactors naming by introducing a shared Named trait, updating PSU implementations accordingly, and adding/expanding tests to validate provider and unconstrained behavior.
Changes:
- Add
embedded_services::named::Namedand updatePsuto requireNamedinstead of definingname()directly. - Add power-policy service event broadcasting via configurable event senders, plus introduce
EventDatafor device-agnostic service events. - Add/expand power-policy service integration tests for consumer/provider/unconstrained flows.
Reviewed changes
Copilot reviewed 15 out of 22 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| type-c-service/src/wrapper/proxy.rs | Implements Named for PowerProxyDevice to satisfy updated Psu: Named bound. |
| power-policy-service/tests/unconstrained.rs | Adds unconstrained multi-device flow test using service event receiver assertions. |
| power-policy-service/tests/provider.rs | Adds provider connection/upgrade behavior tests and validates service events. |
| power-policy-service/tests/consumer.rs | Updates consumer tests to validate service-level events instead of only mock calls. |
| power-policy-service/tests/common/mod.rs | Extends test harness to provide a service event channel/receiver and adds assertion helpers. |
| power-policy-service/tests/common/mock.rs | Updates mock PSU simulation API and implements Named for the mock device. |
| power-policy-service/src/service/task.rs | Updates task generics to support event broadcasting sender types. |
| power-policy-service/src/service/provider.rs | Moves/expands provider disconnect handling into provider module and broadcasts provider events. |
| power-policy-service/src/service/mod.rs | Adds event_senders and implements broadcast_event; updates detach/disconnect flows accordingly. |
| power-policy-service/src/service/consumer.rs | Updates service impl generics and uses Named for logging. |
| power-policy-service/Cargo.toml | Comment formatting tweak. |
| power-policy-interface/src/service/event.rs | Adds EventData and From<Event> conversion; renames generics to PSU. |
| power-policy-interface/src/psu/mod.rs | Changes Psu to extend Named and removes fn name() from Psu. |
| examples/std/src/bin/type_c/unconstrained.rs | Updates power-policy service construction to pass event sender storage (currently discard). |
| examples/std/src/bin/type_c/ucsi.rs | Updates power-policy service task signature and adds discard event sender storage. |
| examples/std/src/bin/type_c/service.rs | Updates power-policy service construction to pass event sender storage (discard). |
| examples/std/src/bin/power_policy.rs | Updates example PSU to implement Named and passes discard event sender storage. |
| examples/rt685s-evk/src/bin/type_c_cfu.rs | Updates power-policy service task signature and adds discard event sender storage. |
| examples/rt685s-evk/src/bin/type_c.rs | Updates power-policy service task signature and adds discard event sender storage. |
| embedded-service/src/named.rs | Introduces Named trait. |
| embedded-service/src/lib.rs | Exposes named module. |
| embedded-service/src/event.rs | Adds DiscardSender and MapSender utilities for event sending pipelines. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
5b931a9 to
50c4c4b
Compare
50c4c4b to
44539e4
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 22 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
44539e4 to
ceef927
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 22 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
f62040d to
ec00c9d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 24 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
embedded-service/src/event.rs:15
Sender/Receiveruseimpl Futurein their method signatures, butFutureisn’t in scope in this module. This won’t compile unless you importcore::future::Future(or fully qualify it ascore::future::Futurein the signatures).
//! Common traits for event senders and receivers
use core::marker::PhantomData;
use embassy_sync::channel::{DynamicReceiver, DynamicSender};
/// Common event sender trait
pub trait Sender<E> {
/// Attempt to send an event
///
/// Return none if the event cannot currently be sent
fn try_send(&mut self, event: E) -> Option<()>;
/// Send an event
fn send(&mut self, event: E) -> impl Future<Output = ()>;
}
You can also share your feedback on Copilot code review. Take the survey.
ec00c9d to
18d82b3
Compare
18d82b3 to
2fa818d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 24 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
embedded-service/src/event.rs:15
Futureis referenced in theSender/Receivertrait method signatures (and later impls) but isn’t imported or fully qualified in this file, which will fail to compile. Adduse core::future::Future;(or qualify ascore::future::Future) near the top.
/// Common event sender trait
pub trait Sender<E> {
/// Attempt to send an event
///
/// Return none if the event cannot currently be sent
fn try_send(&mut self, event: E) -> Option<()>;
/// Send an event
fn send(&mut self, event: E) -> impl Future<Output = ()>;
}
You can also share your feedback on Copilot code review. Take the survey.
Rename the current `'a` lifetime to `'device` for clarity. Introduce a separate `device_storage` lifetime since a single lifetime overconstrains things and can lead to situations where borrows live too long and lead to issues with drops.
A receiver might only care that an event has happened and not what PSU generated the event. Currently, such a receiver would have to be generic over a PSU type that it never uses. Introduce `EventData` as a version of `Event` for use in these cases. Also rename `D` generic argument to `PSU` for clarity.
Rename for clarity.
Add event broadcasting based on `Sender<_>` trait, a few utility structs, and update tests to check broadcast events.
Rename to match corresponding registration struct.
2fa818d to
799b585
Compare
Namedtrait