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

Method write

src/winrtble/peripheral.rs:528–544  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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.

Callers 2

update_propertiesMethod · 0.45
connectMethod · 0.45

Calls 2

getMethod · 0.65
write_valueMethod · 0.45

Tested by

no test coverage detected