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
13 changes: 0 additions & 13 deletions examples/std/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions examples/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ defmt = "0.3"

embedded-usb-pd = { git = "https://github.com/OpenDevicePartnership/embedded-usb-pd", tag = "v0.1.0" }
embedded-services = { path = "../../embedded-service", features = ["log"] }
power-policy-service = { path = "../../power-policy-service", features = [
"log",
] }
cfu-service = { path = "../../cfu-service", features = ["log"] }
embedded-cfu-protocol = { git = "https://github.com/OpenDevicePartnership/embedded-cfu", tag = "v0.1.0" }

Expand Down Expand Up @@ -63,10 +60,6 @@ path = "src/bin/debug.rs"
name = "type-c-basic"
path = "src/bin/type_c/basic.rs"

[[bin]]
name = "type-c-service"
path = "src/bin/type_c/service.rs"

# Needed otherwise cargo will pull from git
[patch."https://github.com/OpenDevicePartnership/embedded-services"]
embedded-services = { path = "../../embedded-service" }
174 changes: 0 additions & 174 deletions examples/std/src/bin/type_c/service.rs

This file was deleted.

28 changes: 14 additions & 14 deletions type-c-service/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ pub const DEFAULT_TEST_DURATION: Duration = Duration::from_secs(15);

pub const DEFAULT_PER_CALL_TIMEOUT: Duration = Duration::from_secs(1);

const CONTROLLER0_ID: ControllerId = ControllerId(0);
const PORT0_ID: GlobalPortId = GlobalPortId(0);
const POWER0_ID: power::policy::DeviceId = power::policy::DeviceId(0);
const CFU0_ID: u8 = 0x00;

const CONTROLLER1_ID: ControllerId = ControllerId(1);
const PORT1_ID: GlobalPortId = GlobalPortId(1);
const POWER1_ID: power::policy::DeviceId = power::policy::DeviceId(1);
const CFU1_ID: u8 = 0x01;

const CONTROLLER2_ID: ControllerId = ControllerId(2);
const PORT2_ID: GlobalPortId = GlobalPortId(2);
const POWER2_ID: power::policy::DeviceId = power::policy::DeviceId(2);
const CFU2_ID: u8 = 0x02;
pub const CONTROLLER0_ID: ControllerId = ControllerId(0);
pub const PORT0_ID: GlobalPortId = GlobalPortId(0);
pub const POWER0_ID: power::policy::DeviceId = power::policy::DeviceId(0);
pub const CFU0_ID: u8 = 0x00;

pub const CONTROLLER1_ID: ControllerId = ControllerId(1);
pub const PORT1_ID: GlobalPortId = GlobalPortId(1);
pub const POWER1_ID: power::policy::DeviceId = power::policy::DeviceId(1);
pub const CFU1_ID: u8 = 0x01;

pub const CONTROLLER2_ID: ControllerId = ControllerId(2);
pub const PORT2_ID: GlobalPortId = GlobalPortId(2);
pub const POWER2_ID: power::policy::DeviceId = power::policy::DeviceId(2);
pub const CFU2_ID: u8 = 0x02;

/// Integration test trait
///
Expand Down
70 changes: 70 additions & 0 deletions type-c-service/tests/service.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//! Basic test of type-C service functionality

use embassy_sync::{
mutex::Mutex,
pubsub::{DynSubscriber, WaitResult},
};
use embassy_time::with_timeout;
use embedded_services::{
GlobalRawMutex, info, power,
type_c::{self, comms::DebugAccessoryMessage},
};
use embedded_usb_pd::type_c::Current;

use crate::common::{DEFAULT_PER_CALL_TIMEOUT, DEFAULT_TEST_DURATION, PORT0_ID, Test, mock};

mod common;

struct TestService;

impl Test for TestService {
async fn run(
&mut self,
mut type_c_receiver: DynSubscriber<'static, type_c::comms::CommsMessage>,
_power_policy_event_receiver: DynSubscriber<'static, power::policy::CommsMessage>,
port0: &'static Mutex<GlobalRawMutex, mock::ControllerState<'static>>,
_port1: &'static Mutex<GlobalRawMutex, mock::ControllerState<'static>>,
_port2: &'static Mutex<GlobalRawMutex, mock::ControllerState<'static>>,
) {
info!("Simulating debug accessory connection");
port0
.lock()
.await
.connect_debug_accessory_source(Current::UsbDefault)
.await;
let message = with_timeout(DEFAULT_PER_CALL_TIMEOUT, type_c_receiver.next_message()).await;
assert_eq!(
message,
Ok(WaitResult::Message(type_c::comms::CommsMessage::DebugAccessory(
DebugAccessoryMessage {
port: PORT0_ID,
connected: true
}
)))
);

info!("Simulating debug accessory disconnection");
port0.lock().await.disconnect().await;
let message = with_timeout(DEFAULT_PER_CALL_TIMEOUT, type_c_receiver.next_message()).await;
assert_eq!(
message,
Ok(WaitResult::Message(type_c::comms::CommsMessage::DebugAccessory(
DebugAccessoryMessage {
port: PORT0_ID,
connected: false
}
)))
);
}
}

#[tokio::test]
async fn service() {
common::run_test(
DEFAULT_TEST_DURATION,
type_c_service::service::config::Config::default(),
power_policy_service::config::Config::default(),
TestService,
)
.await;
}
Loading