Write some data to the characteristic. Returns an error if the write couldn't be send or (in the case of a write-with-response) if the device returns an error.
(
&self,
characteristic: &Characteristic,
data: &[u8],
write_type: WriteType,
)
| 526 | /// Write some data to the characteristic. Returns an error if the write couldn't be send or (in |
| 527 | /// the case of a write-with-response) if the device returns an error. |
| 528 | async fn write( |
| 529 | &self, |
| 530 | characteristic: &Characteristic, |
| 531 | data: &[u8], |
| 532 | write_type: WriteType, |
| 533 | ) -> Result<()> { |
| 534 | let ble_service = &*self |
| 535 | .shared |
| 536 | .ble_services |
| 537 | .get(&characteristic.service_uuid) |
| 538 | .ok_or_else(|| Error::NotSupported("Service not found for write".into()))?; |
| 539 | let ble_characteristic = ble_service |
| 540 | .characteristics |
| 541 | .get(&characteristic.uuid) |
| 542 | .ok_or_else(|| Error::NotSupported("Characteristic not found for write".into()))?; |
| 543 | ble_characteristic.write_value(data, write_type).await |
| 544 | } |
| 545 | |
| 546 | /// Enables either notify or indicate (depending on support) for the specified characteristic. |
| 547 | /// This is a synchronous call. |
no test coverage detected