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

Function test_discover_peripheral_by_name

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

Source from the content-addressed store, hash-verified

11// ── Discovery ───────────────────────────────────────────────────────
12
13pub async fn test_discover_peripheral_by_name() {
14 use btleplug::api::Central;
15
16 let adapter = peripheral_finder::get_adapter().await;
17 let info = adapter
18 .adapter_info()
19 .await
20 .expect("Failed to get adapter info");
21 assert!(!info.is_empty(), "Adapter info should not be empty");
22 let _state = adapter
23 .adapter_state()
24 .await
25 .expect("Failed to get adapter state");
26
27 let peripheral = peripheral_finder::find_and_connect().await;
28 let props = peripheral.properties().await.unwrap().unwrap();
29 let name = props.local_name.unwrap_or_default();
30 let expected = std::env::var("BTLEPLUG_TEST_PERIPHERAL")
31 .unwrap_or_else(|_| gatt_uuids::TEST_PERIPHERAL_NAME.to_string());
32 assert_eq!(name, expected);
33 peripheral.disconnect().await.unwrap();
34}
35
36pub async fn test_discover_services() {
37 let peripheral = peripheral_finder::find_and_connect().await;

Callers

nothing calls this directly

Calls 6

get_adapterFunction · 0.85
find_and_connectFunction · 0.85
adapter_infoMethod · 0.45
adapter_stateMethod · 0.45
propertiesMethod · 0.45
disconnectMethod · 0.45

Tested by

no test coverage detected