Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions type-c-service/src/service/power.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,17 @@ impl<'a, Reg: Registration<'a>> Service<'a, Reg> {
PowerPolicyEventData::ConsumerDisconnected => {
self.ucsi.psu_connected = false;
// Notify OPM because this can affect battery charging capability status
self.pend_ucsi_connected_ports().await;
if self.ucsi.notifications_enabled.battery_charge_change() {
self.pend_ucsi_connected_ports().await;
}
Ok(())
}
PowerPolicyEventData::ConsumerConnected(_) => {
self.ucsi.psu_connected = true;
// Notify OPM because this can affect battery charging capability status
self.pend_ucsi_connected_ports().await;
if self.ucsi.notifications_enabled.battery_charge_change() {
self.pend_ucsi_connected_ports().await;
}
Comment thread
RobertZ2011 marked this conversation as resolved.
Ok(())
}
_ => Ok(()), // Other events don't require any action from the service
Expand Down
10 changes: 5 additions & 5 deletions type-c-service/src/service/ucsi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ pub struct UcsiResponse {
#[derive(Default)]
pub(super) struct State {
/// PPM state machine
ppm_state_machine: StateMachine,
pub ppm_state_machine: StateMachine,
/// Currently enabled notifications
notifications_enabled: NotificationEnable,
pub notifications_enabled: NotificationEnable,
/// Queued pending port notifications
pending_ports: heapless::Deque<GlobalPortId, MAX_SUPPORTED_PORTS>,
pub pending_ports: heapless::Deque<GlobalPortId, MAX_SUPPORTED_PORTS>,
Comment thread
RobertZ2011 marked this conversation as resolved.
/// Ports that have a valid battery charging status capability
///
/// We provide a battery charging status only after the port has negotiated power.
/// This prevents the port from temporarily reporting slow or no charging before the contract has finalized.
valid_battery_charging_capability: heapless::FnvIndexSet<GlobalPortId, MAX_SUPPORTED_PORTS>,
pub valid_battery_charging_capability: heapless::FnvIndexSet<GlobalPortId, MAX_SUPPORTED_PORTS>,
/// PSU connected
pub(super) psu_connected: bool,
pub psu_connected: bool,
}

impl<'port, Reg: Registration<'port>> Service<'port, Reg> {
Expand Down
Loading