USB PD: extended Alert event 5 is rejected although it is defined

Open Beginner friendly
#90 1 comment 0 reactions 1 assignee View on GitHub

@RobertZ2011 is already working on this.

Since Oct 26, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
73/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
embedded-iot

Research direction

Read the extended-alert conversion in src/ado.rs around lines 124–130 and the test_ado_try_from_standard_alerts test around lines 220–279. Add support for event 5 and its encode path as suggested, then run the relevant tests and confirm the event is accepted; consider the noted downstream exhaustive-match compatibility impact.

Written by the indexing model from the issue text.

Description

bug conformance

Summary

The extended alert parser handles events 1 through 4 only. Event 5 is defined by the current PD specification and is rejected.

What the specification requires

USB PD R3.2 V1.2 S6.4.5, Table 6.25 (Extended Alert Event Type):

5 - Source is about to reduce Source Capabilities

What the code does

src/ado.rs#L124-L130:

0x80 => match raw.extended_alert_type() {
    0x01 => Ok(Ado::PowerStateChange),
    0x02 => Ok(Ado::PowerButtonPress),
    0x03 => Ok(Ado::PowerButtonRelease),
    0x04 => Ok(Ado::ControllerInitiatedWake),
    _ => Err(InvalidType(raw.0)),
},

A conforming 0x80000005 alert is rejected rather than reporting impending capability reduction.

Failing test

test_ado_try_from_standard_alerts on branch audit. The test previously asserted that event 5 is invalid; that assertion is now inverted:

    raw.set_extended_alert_type(0x04);
    assert_eq!(Ado::try_from(raw).unwrap(), Ado::ControllerInitiatedWake);

    // USB PD R3.2 V1.2 Table 6.25 (Extended Alert Event Type) defines:
    //   "5 - Source is about to reduce Source Capabilities"
    // A conforming extended alert carrying event 5 must not be rejected.
    raw.set_extended_alert_type(0x05);
    assert!(
        Ado::try_from(raw).is_ok(),
        "extended alert event 5 (Source about to reduce Source Capabilities) is defined by \
         USB PD R3.2 V1.2 Table 6.25 and must be accepted"
    );
}

Suggested fix

Add the variant and its encode path. Adding an enum variant is breaking for downstream exhaustive matches.

Dominant language
Rust
Stars
2
Forks
8
Avg merge
1d 10h
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenDevicePartnership/embedded-usb-pd

All issues in OpenDevicePartnership/embedded-usb-pd

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.