()
| 125 | } |
| 126 | |
| 127 | pub 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 |
nothing calls this directly
no test coverage detected