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

Function test_advertisement_manufacturer_data

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

Source from the content-addressed store, hash-verified

90}
91
92pub async fn test_advertisement_manufacturer_data() {
93 use btleplug::api::{Central, CentralEvent, ScanFilter};
94 use futures::StreamExt;
95 use std::time::Duration;
96 use tokio::time;
97
98 let adapter = peripheral_finder::get_adapter().await;
99 let mut events = adapter.events().await.unwrap();
100 adapter.start_scan(ScanFilter::default()).await.unwrap();
101
102 let mut found_manufacturer_data = false;
103 let timeout = time::sleep(Duration::from_secs(10));
104 tokio::pin!(timeout);
105
106 loop {
107 tokio::select! {
108 Some(event) = events.next() => {
109 if let CentralEvent::ManufacturerDataAdvertisement { manufacturer_data, .. } = event {
110 if manufacturer_data.contains_key(&gatt_uuids::MANUFACTURER_COMPANY_ID) {
111 found_manufacturer_data = true;
112 break;
113 }
114 }
115 }
116 _ = &mut timeout => break,
117 }
118 }
119
120 adapter.stop_scan().await.unwrap();
121 assert!(
122 found_manufacturer_data,
123 "Did not receive ManufacturerDataAdvertisement with company ID 0xFFFF"
124 );
125}
126
127pub async fn test_advertisement_services() {
128 use btleplug::api::{Central, CentralEvent, ScanFilter};

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