subscribe_notify_characteristic.rs | Panic on upwrap() after peripheral.subscribe()
alexanderturner opened this issue · comments
Alexander Turner commented
Describe the bug
New to rust so bare with me. I'm trying to run the subscribe_notify_characteristic.rs example and the app is panicking with an upwrap() error after peripheral.subscribe(&characteristic).await? is called.
Additional context
thread '<unnamed>' panicked at 'called Option::unwrap()\ on a `None` value', /Users/aturner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btleplug-0.11.1/src/corebluetooth/internal.rs:706:76
println!("Discover peripheral {:?} services...", local_name);
peripheral.discover_services().await?;
for characteristic in peripheral.characteristics() {
println!("Checking characteristic {:?}", characteristic);
// Subscribe to notifications from the characteristic with the selected
// UUID.
if characteristic.uuid == NOTIFY_CHARACTERISTIC_UUID
&& characteristic.properties.contains(CharPropFlags::NOTIFY)
{
println!("Subscribing to characteristic {:?}", characteristic.uuid);
peripheral.subscribe(&characteristic).await?;
// Print the first 4 notifications received.
let mut notification_stream =
peripheral.notifications().await?;
// // Process while the BLE connection is not broken or stopped.
while let Some(data) = notification_stream.next().await {
println!(
"Received data from {:?} [{:?}]: {:?}",
local_name, data.uuid, data.value
);
}
}
}
Peripheral is an ESP32-S3 and has no issues with notification with other mobile libraries.