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

Function find_descriptor

tests/android/rust/src/lib.rs:19–41  ·  view source on GitHub ↗

The `common::find_descriptor` function is used by descriptor tests in test_cases. It references `super::find_descriptor`, so we provide it at crate root.

(
    peripheral: &btleplug::platform::Peripheral,
    char_uuid: uuid::Uuid,
    descriptor_uuid: uuid::Uuid,
)

Source from the content-addressed store, hash-verified

17// The `common::find_descriptor` function is used by descriptor tests in test_cases.
18// It references `super::find_descriptor`, so we provide it at crate root.
19pub fn find_descriptor(
20 peripheral: &btleplug::platform::Peripheral,
21 char_uuid: uuid::Uuid,
22 descriptor_uuid: uuid::Uuid,
23) -> btleplug::api::Descriptor {
24 use btleplug::api::Peripheral as _;
25 let services = peripheral.services();
26 for service in &services {
27 for char in &service.characteristics {
28 if char.uuid == char_uuid {
29 for desc in &char.descriptors {
30 if desc.uuid == descriptor_uuid {
31 return desc.clone();
32 }
33 }
34 }
35 }
36 }
37 panic!(
38 "descriptor {} not found on characteristic {}",
39 descriptor_uuid, char_uuid
40 );
41}
42
43use jni::objects::JClass;
44use jni::JNIEnv;

Callers

nothing calls this directly

Calls 1

servicesMethod · 0.45

Tested by

no test coverage detected