bluest icon indicating copy to clipboard operation
bluest copied to clipboard

BLE Descriptor Write Operations on MacOS

Open mj-bhaptics opened this issue 10 months ago • 1 comments

It seems like the write functionality of descriptors isn't working properly on MacOS. when I write, there's a problem where it panics and terminates. What am I doing wrong? I'm creating a DFU implementation.

let descriptors = control_char.descriptors().await?;
let cccd_descriptor = descriptors.iter()
    .find(|d| d.uuid() == *DFU_CLIENT_CONFIG_CHAR)
    .ok_or("DFU_CLIENT_CONFIG_CHAR not found")?;

let current_value = cccd_descriptor.read().await?;
println!("Current CCCD value: {}", hex::encode(&current_value));

cccd_descriptor.write(&INDICATION_VALUE.to_vec()).await?;
println!("CCCD configured for indications");

fatal runtime error: Rust cannot catch foreign exceptions

Image

mj-bhaptics avatar Feb 27 '25 06:02 mj-bhaptics

The CCCD is a privileged descriptor, you should not read/write it directly. Instead use the characteristic's notify method. That will enable notifications or indications (depending on the characteristic properties) and report them until the stream is dropped.

alexmoon avatar Feb 27 '25 14:02 alexmoon