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

Method write

src/droidplug/peripheral.rs:362–382  ·  view source on GitHub ↗
(
        &self,
        characteristic: &Characteristic,
        data: &[u8],
        write_type: WriteType,
    )

Source from the content-addressed store, hash-verified

360 }
361
362 async fn write(
363 &self,
364 characteristic: &Characteristic,
365 data: &[u8],
366 write_type: WriteType,
367 ) -> Result<()> {
368 let future = self.with_obj(|env, obj| {
369 let uuid = JUuid::new(env, characteristic.uuid)?;
370 let data_obj = super::jni_utils::arrays::slice_to_byte_array(env, data)?;
371 let write_type = match write_type {
372 WriteType::WithResponse => 2,
373 WriteType::WithoutResponse => 1,
374 };
375 JSendFuture::try_from(obj.write(uuid, data_obj.into(), write_type)?)
376 })?;
377 let result_ref = future.await?;
378 self.with_obj(|env, _obj| {
379 let result = JPollResult::from_env(env, result_ref.as_obj())?;
380 get_poll_result(env, result).map(|_| {})
381 })
382 }
383
384 async fn read(&self, characteristic: &Characteristic) -> Result<Vec<u8>> {
385 let future = self.with_obj(|env, obj| {

Callers

nothing calls this directly

Calls 3

slice_to_byte_arrayFunction · 0.85
get_poll_resultFunction · 0.85
with_objMethod · 0.80

Tested by

no test coverage detected