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

Integration test #7

Merged
merged 10 commits into from
Apr 3, 2024
Merged
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
16 changes: 14 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
pull_request:

jobs:
ci:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -24,7 +24,19 @@ jobs:
- name: Test
run: |
cd host
cargo test -- --nocapture
cargo test --lib -- --nocapture

- name: Build examples
run: for i in nrf-sdc; do pushd examples/$i; cargo fmt --check && cargo clippy && cargo build --release; popd; done;
#integration-tests:
# runs-on: self-hosted
# steps:
# - uses: actions/checkout@v4
# - name: Build
# env:
# TEST_ADAPTER_ONE: /dev/ttyACM0
# TEST_ADAPTER_TWO: /dev/ttyACM1
# RUST_LOG: info
# run: |
# cd host
# cargo test --test '*' -- --nocapture
14 changes: 7 additions & 7 deletions examples/nrf-sdc/src/bin/ble_bas_peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![no_main]
#![feature(impl_trait_in_assoc_type)]

use bt_hci::cmd::le::LeSetRandomAddr;
use bt_hci::cmd::SyncCmd;
use bt_hci::param::BdAddr;
use defmt::{error, info, unwrap};
Expand All @@ -12,7 +13,6 @@ use embassy_sync::blocking_mutex::raw::NoopRawMutex;
use embassy_time::{Duration, Timer};
use nrf_sdc::{self as sdc, mpsl, mpsl::MultiprotocolServiceLayer};
use sdc::rng_pool::RngPool;
use sdc::vendor::ZephyrWriteBdAddr;
use static_cell::StaticCell;
use trouble_host::{
adapter::{Adapter, HostResources},
Expand Down Expand Up @@ -40,8 +40,8 @@ async fn mpsl_task(mpsl: &'static MultiprotocolServiceLayer<'static>) -> ! {
fn bd_addr() -> BdAddr {
unsafe {
let ficr = &*pac::FICR::ptr();
let high = u64::from((ficr.deviceid[1].read().bits() & 0x0000ffff) | 0x0000c000);
let addr = high << 32 | u64::from(ficr.deviceid[0].read().bits());
let high = u64::from((ficr.deviceaddr[1].read().bits() & 0x0000ffff) | 0x0000c000);
let addr = high << 32 | u64::from(ficr.deviceaddr[0].read().bits());
BdAddr::new(unwrap!(addr.to_le_bytes()[..6].try_into()))
}
}
Expand Down Expand Up @@ -108,8 +108,8 @@ async fn main(spawner: Spawner) {
let mut sdc_mem = sdc::Mem::<3312>::new();
let sdc = unwrap!(build_sdc(sdc_p, &rng, mpsl, &mut sdc_mem));

info!("Advertising as {:02x}", bd_addr());
unwrap!(ZephyrWriteBdAddr::new(bd_addr()).exec(&sdc).await);
info!("Our address = {:02x}", bd_addr());
unwrap!(LeSetRandomAddr::new(bd_addr()).exec(&sdc).await);
Timer::after(Duration::from_millis(200)).await;

static HOST_RESOURCES: StaticCell<HostResources<NoopRawMutex, L2CAP_CHANNELS_MAX, PACKET_POOL_SIZE, L2CAP_MTU>> =
Expand All @@ -119,11 +119,11 @@ async fn main(spawner: Spawner) {
let adapter: Adapter<'_, NoopRawMutex, _, CONNECTIONS_MAX, L2CAP_CHANNELS_MAX> = Adapter::new(sdc, host_resources);
let config = AdvertiseConfig {
params: None,
data: &[
adv_data: &[
AdStructure::Flags(LE_GENERAL_DISCOVERABLE | BR_EDR_NOT_SUPPORTED),
AdStructure::ServiceUuids16(&[Uuid::Uuid16([0x0f, 0x18])]),
AdStructure::CompleteLocalName("Trouble"),
],
scan_data: &[AdStructure::CompleteLocalName(b"Trouble")],
};

let mut table: AttributeTable<'_, NoopRawMutex, 10> = AttributeTable::new();
Expand Down
13 changes: 8 additions & 5 deletions examples/nrf-sdc/src/bin/ble_l2cap_central.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![no_main]
#![feature(impl_trait_in_assoc_type)]

use bt_hci::cmd::le::LeSetRandomAddr;
use bt_hci::cmd::SyncCmd;
use bt_hci::param::BdAddr;
use defmt::{info, unwrap};
Expand All @@ -12,7 +13,6 @@ use embassy_sync::blocking_mutex::raw::NoopRawMutex;
use embassy_time::{Duration, Timer};
use nrf_sdc::{self as sdc, mpsl, mpsl::MultiprotocolServiceLayer};
use sdc::rng_pool::RngPool;
use sdc::vendor::ZephyrWriteBdAddr;
use static_cell::StaticCell;
use trouble_host::{
adapter::{Adapter, HostResources},
Expand Down Expand Up @@ -41,8 +41,8 @@ async fn mpsl_task(mpsl: &'static MultiprotocolServiceLayer<'static>) -> ! {
fn bd_addr() -> BdAddr {
unsafe {
let ficr = &*pac::FICR::ptr();
let high = u64::from((ficr.deviceid[1].read().bits() & 0x0000ffff) | 0x0000c000);
let addr = high << 32 | u64::from(ficr.deviceid[0].read().bits());
let high = u64::from((ficr.deviceaddr[1].read().bits() & 0x0000ffff) | 0x0000c000);
let addr = high << 32 | u64::from(ficr.deviceaddr[0].read().bits());
BdAddr::new(unwrap!(addr.to_le_bytes()[..6].try_into()))
}
}
Expand Down Expand Up @@ -117,7 +117,7 @@ async fn main(spawner: Spawner) {
let sdc = unwrap!(build_sdc(sdc_p, &rng, mpsl, &mut sdc_mem));

info!("Our address = {:02x}", bd_addr());
unwrap!(ZephyrWriteBdAddr::new(bd_addr()).exec(&sdc).await);
unwrap!(LeSetRandomAddr::new(bd_addr()).exec(&sdc).await);
Timer::after(Duration::from_millis(200)).await;

static HOST_RESOURCES: StaticCell<HostResources<NoopRawMutex, L2CAP_CHANNELS_MAX, PACKET_POOL_SIZE, L2CAP_MTU>> =
Expand All @@ -126,7 +126,10 @@ async fn main(spawner: Spawner) {

let adapter: Adapter<'_, NoopRawMutex, _, CONNECTIONS_MAX, L2CAP_CHANNELS_MAX> = Adapter::new(sdc, host_resources);

let config = ScanConfig { params: None };
let config = ScanConfig {
params: None,
filter_accept_list: &[],
};

// NOTE: Modify this to match the address of the peripheral you want to connect to
let target: BdAddr = BdAddr::new([0xf5, 0x9f, 0x1a, 0x05, 0xe4, 0xee]);
Expand Down
14 changes: 6 additions & 8 deletions examples/nrf-sdc/src/bin/ble_l2cap_peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![no_main]
#![feature(impl_trait_in_assoc_type)]

use bt_hci::cmd::le::LeSetRandomAddr;
use bt_hci::cmd::SyncCmd;
use bt_hci::param::BdAddr;
use defmt::{info, unwrap};
Expand All @@ -12,7 +13,6 @@ use embassy_sync::blocking_mutex::raw::NoopRawMutex;
use embassy_time::{Duration, Timer};
use nrf_sdc::{self as sdc, mpsl, mpsl::MultiprotocolServiceLayer};
use sdc::rng_pool::RngPool;
use sdc::vendor::ZephyrWriteBdAddr;
use static_cell::StaticCell;
use trouble_host::{
adapter::{Adapter, HostResources},
Expand Down Expand Up @@ -40,8 +40,8 @@ async fn mpsl_task(mpsl: &'static MultiprotocolServiceLayer<'static>) -> ! {
fn bd_addr() -> BdAddr {
unsafe {
let ficr = &*pac::FICR::ptr();
let high = u64::from((ficr.deviceid[1].read().bits() & 0x0000ffff) | 0x0000c000);
let addr = high << 32 | u64::from(ficr.deviceid[0].read().bits());
let high = u64::from((ficr.deviceaddr[1].read().bits() & 0x0000ffff) | 0x0000c000);
let addr = high << 32 | u64::from(ficr.deviceaddr[0].read().bits());
BdAddr::new(unwrap!(addr.to_le_bytes()[..6].try_into()))
}
}
Expand Down Expand Up @@ -116,7 +116,7 @@ async fn main(spawner: Spawner) {
let sdc = unwrap!(build_sdc(sdc_p, &rng, mpsl, &mut sdc_mem));

info!("Our address = {:02x}", bd_addr());
unwrap!(ZephyrWriteBdAddr::new(bd_addr()).exec(&sdc).await);
unwrap!(LeSetRandomAddr::new(bd_addr()).exec(&sdc).await);
Timer::after(Duration::from_millis(200)).await;

static HOST_RESOURCES: StaticCell<HostResources<NoopRawMutex, L2CAP_CHANNELS_MAX, PACKET_POOL_SIZE, L2CAP_MTU>> =
Expand All @@ -127,10 +127,8 @@ async fn main(spawner: Spawner) {

let config = AdvertiseConfig {
params: None,
data: &[
AdStructure::Flags(LE_GENERAL_DISCOVERABLE | BR_EDR_NOT_SUPPORTED),
AdStructure::CompleteLocalName("Trouble"),
],
adv_data: &[AdStructure::Flags(LE_GENERAL_DISCOVERABLE | BR_EDR_NOT_SUPPORTED)],
scan_data: &[AdStructure::CompleteLocalName(b"Trouble")],
};

let _ = join(adapter.run(), async {
Expand Down
8 changes: 0 additions & 8 deletions examples/rp-pico-w/.cargo/config.toml

This file was deleted.

59 changes: 0 additions & 59 deletions examples/rp-pico-w/Cargo.toml

This file was deleted.

36 changes: 0 additions & 36 deletions examples/rp-pico-w/build.rs

This file was deleted.

17 changes: 0 additions & 17 deletions examples/rp-pico-w/memory.x

This file was deleted.

Loading