Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test wip #249

Closed
wants to merge 6 commits into from
Closed
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ TrouBLE is a Bluetooth Low Energy (BLE) Host implementation written in Rust, wit

## What is a Host?


A BLE Host is one side of the Host Controller Interface (HCI). The BLE specification defines the software of a BLE implementation in terms of a `controller` (lower layer) and a `host` (upper layer).

These communicate via a standardized protocol, that may run over different transports such as as UART, USB or a custom in-memory IPC implementation.
Expand Down
2 changes: 1 addition & 1 deletion examples/esp32/src/consts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// Size of L2CAP packets
#[cfg(not(any(feature = "esp32c2", feature = "esp32c6", feature = "esp32h2")))]
pub const L2CAP_MTU: usize = 128;
pub const L2CAP_MTU: usize = 251;
// Some esp chips only accept an MTU >= 255
#[cfg(any(feature = "esp32c2", feature = "esp32c6", feature = "esp32h2"))]
pub const L2CAP_MTU: usize = 255;
33 changes: 22 additions & 11 deletions examples/tests/src/probe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,28 @@ impl<'d> DeviceUnderTest<'d> {
}

pub async fn run(self, firmware: String) -> Result<FirmwareLogs, anyhow::Error> {
let mut flasher = Command::new("probe-rs")
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.arg("run")
.arg(&firmware)
.arg("--chip")
.arg(&self.target.config().chip)
.arg("--probe")
.arg(&self.target.config().probe)
.spawn()
.unwrap();
let mut flasher = if self.target.config().chip.starts_with("esp32") {
Command::new("espflash")
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.arg("flash")
.arg(&firmware)
.arg("--monitor")
.spawn()
.unwrap()
} else {
Command::new("probe-rs")
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.arg("run")
.arg(&firmware)
.arg("--chip")
.arg(&self.target.config().chip)
.arg("--probe")
.arg(&self.target.config().probe)
.spawn()
.unwrap()
};

let stdout = flasher.stdout.take().unwrap();
let stderr = flasher.stderr.take().unwrap();
Expand Down
8 changes: 6 additions & 2 deletions examples/tests/tests/ble_l2cap_central.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use futures::future::select;
use futures::future::join;
use std::time::Duration;
use tokio::select;
use trouble_example_tests::{serial, TestContext};
Expand Down Expand Up @@ -107,11 +107,15 @@ async fn run_l2cap_central_test(labels: &[(&str, &str)], firmware: &str) {
}
});

tokio::time::timeout(Duration::from_secs(60), select(central, peripheral))
tokio::time::timeout(Duration::from_secs(60), join(peripheral, central))
.await
.map_err(|_| {
println!("Test timed out");
assert!(false);
})
.map(|(p, c)| {
p.expect("peripheral failed").unwrap();
c.expect("central failed").unwrap();
})
.unwrap();
}
8 changes: 6 additions & 2 deletions examples/tests/tests/ble_l2cap_peripheral.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use futures::future::select;
use futures::future::join;
use std::time::Duration;
use tokio::select;
use trouble_example_tests::{serial, TestContext};
Expand Down Expand Up @@ -92,11 +92,15 @@ async fn run_l2cap_peripheral_test(labels: &[(&str, &str)], firmware: &str) {
}
});

tokio::time::timeout(Duration::from_secs(60), select(peripheral, central))
tokio::time::timeout(Duration::from_secs(60), join(peripheral, central))
.await
.map_err(|_| {
println!("Test timed out");
assert!(false);
})
.map(|(p, c)| {
p.expect("peripheral failed").unwrap();
c.expect("central failed").unwrap();
})
.unwrap();
}
Loading