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

What will happen if I use gatt_client::read and gatt_client::run simultaneously #275

Open
HaoboGu opened this issue Aug 29, 2024 · 1 comment

Comments

@HaoboGu
Copy link
Contributor

HaoboGu commented Aug 29, 2024

For example, in ble_bas_central example:

    let client: BatteryServiceClient = unwrap!(gatt_client::discover(&conn).await);

    // Read
    let reader = async {
        loop {
            // Keep reading the battery level
            let val = unwrap!(client.battery_level_read().await);
            info!("Read bat level: {} using read", val);
        }    
    };

    // Enable battery level notifications from the peripheral
    client.battery_level_cccd_write(true).await.unwrap();

    // Receive notifications
    let client_run = gatt_client::run(&conn, &client, |event| match event {
        BatteryServiceClientEvent::BatteryLevelNotification(val) => {
            info!("battery level notification: {}", val);
        }
    });
    
    // Run reader and client simultaneously
    join(reader, client_run).await;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@HaoboGu and others