Skip to content

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

Open
@HaoboGu

Description

@HaoboGu

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions