nrf-softdevice icon indicating copy to clipboard operation
nrf-softdevice copied to clipboard

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

Open HaoboGu opened this issue 5 months ago • 1 comments

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;

HaoboGu avatar Aug 29 '24 07:08 HaoboGu