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

Function get_descriptor_value

src/corebluetooth/central_delegate.rs:902–935  ·  view source on GitHub ↗
(descriptor: &CBDescriptor)

Source from the content-addressed store, hash-verified

900}
901
902fn get_descriptor_value(descriptor: &CBDescriptor) -> Vec<u8> {
903 trace!("Getting data!");
904 let v = unsafe { descriptor.value() }.map(|value| unsafe {
905 let mut clazz = value.class();
906 // Find the root class until we reach NSObject
907 while let Some(superclass) = clazz.superclass() {
908 if superclass == NSObject::class() {
909 break;
910 }
911 clazz = superclass;
912 }
913
914 match clazz.name() {
915 "NSString" => {
916 let d: Retained<NSString> = Retained::cast(value);
917 d.to_string().into_bytes()
918 }
919 "NSData" => {
920 let d: Retained<NSData> = Retained::cast(value);
921 d.bytes().into()
922 }
923 "NSNumber" => {
924 let d: Retained<NSNumber> = Retained::cast(value);
925 d.stringValue().to_string().into_bytes()
926 }
927 _ => {
928 error!("Unknown descriptor value class: {:?}", clazz);
929 Vec::new()
930 }
931 }
932 });
933 trace!("BluetoothGATTDescriptor::get_value -> {:?}", v);
934 v.unwrap_or_default()
935}
936
937fn peripheral_debug(peripheral: &CBPeripheral) -> String {
938 let uuid = unsafe { peripheral.identifier() }.UUIDString();

Callers

nothing calls this directly

Calls 2

valueMethod · 0.80
nameMethod · 0.80

Tested by

no test coverage detected