Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subscribe_notify_characteristic.rs | Panic on upwrap() after peripheral.subscribe() #340

Open
alexanderturner opened this issue Sep 24, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@alexanderturner
Copy link

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.

@alexanderturner alexanderturner added the bug Something isn't working label Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant