MCPcopy Create free account
hub / github.com/deviceplug/btleplug / test_advertisement_services

Function test_advertisement_services

tests/common/test_cases.rs:127–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

125}
126
127pub async fn test_advertisement_services() {
128 use btleplug::api::{Central, CentralEvent, ScanFilter};
129 use futures::StreamExt;
130 use std::time::Duration;
131 use tokio::time;
132
133 let adapter = peripheral_finder::get_adapter().await;
134 let mut events = adapter.events().await.unwrap();
135 adapter.start_scan(ScanFilter::default()).await.unwrap();
136
137 let mut found_services = false;
138 let timeout = time::sleep(Duration::from_secs(10));
139 tokio::pin!(timeout);
140
141 loop {
142 tokio::select! {
143 Some(event) = events.next() => {
144 if let CentralEvent::ServicesAdvertisement { services, .. } = event {
145 if services.contains(&gatt_uuids::CONTROL_SERVICE) {
146 found_services = true;
147 break;
148 }
149 }
150 }
151 _ = &mut timeout => break,
152 }
153 }
154
155 adapter.stop_scan().await.unwrap();
156 assert!(
157 found_services,
158 "Did not receive ServicesAdvertisement with Control Service UUID"
159 );
160}
161
162// ── Connection ──────────────────────────────────────────────────────
163

Callers

nothing calls this directly

Calls 4

get_adapterFunction · 0.85
eventsMethod · 0.45
start_scanMethod · 0.45
stop_scanMethod · 0.45

Tested by

no test coverage detected