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

Method drain_write_without_response_queue

src/corebluetooth/internal.rs:1029–1072  ·  view source on GitHub ↗
(&mut self, peripheral_uuid: Uuid)

Source from the content-addressed store, hash-verified

1027 }
1028
1029 fn drain_write_without_response_queue(&mut self, peripheral_uuid: Uuid) {
1030 if let Some(peripheral) = self.peripherals.get_mut(&peripheral_uuid) {
1031 while let Some(pending) = peripheral.write_without_response_queue.pop_front() {
1032 if !unsafe { peripheral.peripheral.canSendWriteWithoutResponse() } {
1033 peripheral.write_without_response_queue.push_front(pending);
1034 break;
1035 }
1036 if let Some(service) = peripheral.services.get(&pending.service_uuid) {
1037 if let Some(characteristic) =
1038 service.characteristics.get(&pending.characteristic_uuid)
1039 {
1040 unsafe {
1041 peripheral.peripheral.writeValue_forCharacteristic_type(
1042 &NSData::from_vec(pending.data),
1043 &characteristic.characteristic,
1044 CBCharacteristicWriteType::CBCharacteristicWriteWithoutResponse,
1045 );
1046 }
1047 pending
1048 .fut
1049 .lock()
1050 .unwrap()
1051 .set_reply(CoreBluetoothReply::Ok);
1052 } else {
1053 pending
1054 .fut
1055 .lock()
1056 .unwrap()
1057 .set_reply(CoreBluetoothReply::Err(
1058 "Characteristic no longer available".into(),
1059 ));
1060 }
1061 } else {
1062 pending
1063 .fut
1064 .lock()
1065 .unwrap()
1066 .set_reply(CoreBluetoothReply::Err(
1067 "Service no longer available".into(),
1068 ));
1069 }
1070 }
1071 }
1072 }
1073
1074 fn read_value(
1075 &mut self,

Callers

nothing calls this directly

Calls 2

set_replyMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected