(
&self,
characteristic: &Characteristic,
data: &[u8],
mut write_type: WriteType,
)
| 340 | } |
| 341 | |
| 342 | async fn write( |
| 343 | &self, |
| 344 | characteristic: &Characteristic, |
| 345 | data: &[u8], |
| 346 | mut write_type: WriteType, |
| 347 | ) -> Result<()> { |
| 348 | let fut = CoreBluetoothReplyFuture::default(); |
| 349 | // If we get WriteWithoutResponse for a characteristic that only |
| 350 | // supports WriteWithResponse, slam the type to WriteWithResponse. |
| 351 | // Otherwise we won't handle the future correctly. |
| 352 | if write_type == WriteType::WithoutResponse |
| 353 | && !characteristic |
| 354 | .properties |
| 355 | .contains(CharPropFlags::WRITE_WITHOUT_RESPONSE) |
| 356 | { |
| 357 | write_type = WriteType::WithResponse |
| 358 | } |
| 359 | self.shared |
| 360 | .message_sender |
| 361 | .to_owned() |
| 362 | .send(CoreBluetoothMessage::WriteValue { |
| 363 | peripheral_uuid: self.shared.uuid, |
| 364 | service_uuid: characteristic.service_uuid, |
| 365 | characteristic_uuid: characteristic.uuid, |
| 366 | data: Vec::from(data), |
| 367 | write_type, |
| 368 | future: fut.get_state_clone(), |
| 369 | }) |
| 370 | .await?; |
| 371 | match fut.await { |
| 372 | CoreBluetoothReply::Ok => {} |
| 373 | CoreBluetoothReply::Err(msg) => return Err(Error::RuntimeError(msg)), |
| 374 | reply => panic!("Unexpected reply: {:?}", reply), |
| 375 | } |
| 376 | Ok(()) |
| 377 | } |
| 378 | |
| 379 | async fn read(&self, characteristic: &Characteristic) -> Result<Vec<u8>> { |
| 380 | let fut = CoreBluetoothReplyFuture::default(); |
nothing calls this directly
no test coverage detected