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,
)
| 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. |
| 19 | pub 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 | |
| 43 | use jni::objects::JClass; |
| 44 | use jni::JNIEnv; |