bluest
bluest copied to clipboard
BLE Descriptor Write Operations on MacOS
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(¤t_value));
cccd_descriptor.write(&INDICATION_VALUE.to_vec()).await?;
println!("CCCD configured for indications");
fatal runtime error: Rust cannot catch foreign exceptions
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.