Skip to content

Commit

Permalink
FIx examples to work with BLEDevice::new_client() call
Browse files Browse the repository at this point in the history
  • Loading branch information
codepainters committed Oct 6, 2024
1 parent 1077209 commit e952a3f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions examples/ble_client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bstr::ByteSlice;
use esp32_nimble::{uuid128, BLEClient, BLEDevice, BLEScan};
use esp32_nimble::{uuid128, BLEDevice, BLEScan};
use esp_idf_svc::hal::{
prelude::Peripherals,
task::block_on,
Expand Down Expand Up @@ -31,7 +31,7 @@ fn main() -> anyhow::Result<()> {
.await?;

if let Some(device) = device {
let mut client = BLEClient::new();
let mut client = ble_device.new_client();
client.on_connect(|client| {
client.update_conn_params(120, 120, 0, 60).unwrap();
});
Expand Down
4 changes: 2 additions & 2 deletions examples/ble_l2cap_client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bstr::ByteSlice;
use core::str;
use esp32_nimble::{l2cap::L2capClient, BLEClient, BLEDevice, BLEScan};
use esp32_nimble::{l2cap::L2capClient, BLEDevice, BLEScan};
use esp_idf_svc::hal::task::block_on;

fn main() -> anyhow::Result<()> {
Expand All @@ -25,7 +25,7 @@ fn main() -> anyhow::Result<()> {
.await?;

if let Some(device) = device {
let mut client = BLEClient::new();
let mut client = ble_device.new_client();
client.connect(&device.addr()).await.unwrap();

let mut l2cap = L2capClient::connect(&client, 0x1002, 512).await.unwrap();
Expand Down
12 changes: 6 additions & 6 deletions examples/ble_secure_client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use esp32_nimble::{enums::*, utilities::BleUuid, BLEClient, BLEDevice, BLEScan};
use esp32_nimble::{enums::*, utilities::BleUuid, BLEDevice, BLEScan};
use esp_idf_svc::hal::task::block_on;
use log::*;

Expand All @@ -9,9 +9,9 @@ fn main() -> anyhow::Result<()> {
esp_idf_svc::log::EspLogger::initialize_default();

block_on(async {
let device = BLEDevice::take();
device.set_power(PowerType::Default, PowerLevel::P9)?;
device
let ble_device = BLEDevice::take();
ble_device.set_power(PowerType::Default, PowerLevel::P9)?;
ble_device
.security()
.set_auth(AuthReq::all())
.set_io_cap(SecurityIOCap::KeyboardOnly);
Expand All @@ -22,7 +22,7 @@ fn main() -> anyhow::Result<()> {
.active_scan(true)
.interval(100)
.window(99)
.start(device, 10000, |device, data| {
.start(ble_device, 10000, |device, data| {
if data.is_advertising_service(&SERVICE_UUID) {
return Some(*device);
}
Expand All @@ -37,7 +37,7 @@ fn main() -> anyhow::Result<()> {

info!("Advertised Device: {:?}", device);

let mut client = BLEClient::new();
let mut client = ble_device.new_client();
client.connect(&device.addr()).await?;
client.on_passkey_request(|| 123456);
client.secure_connection().await?;
Expand Down

0 comments on commit e952a3f

Please sign in to comment.