Skip to content

Commit

Permalink
Update scan document
Browse files Browse the repository at this point in the history
  • Loading branch information
taks committed Sep 14, 2024
1 parent d2e0a16 commit ffd68db
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/ble_security.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl BLESecurity {

/// Set up for pairing in RPA(Resolvable Private Address).
///
/// ( see: https://github.com/taks/esp32-nimble/issues/24 )
/// ( see: <https://github.com/taks/esp32-nimble/issues/24> )
pub fn resolve_rpa(&mut self) -> &mut Self {
self
.set_security_init_key(enums::PairKeyDist::ENC | enums::PairKeyDist::ID)
Expand Down
41 changes: 23 additions & 18 deletions src/client/ble_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@ use crate::{BLEAdvertisedData, BLEDevice};
use core::ffi::c_void;
use esp_idf_svc::sys;

/// Scan for ble devices.
///
/// # Examples
///
/// ```
/// let ble_device = BLEDevice::take();
/// let ble_scan = BLEScan::new();
/// let name = "Device Name To Be Found";
/// let device = ble_scan
/// .start(ble_device, 10000, |device, data| {
/// if let Some(device_name) = data.name() {
/// if device_name == name {
/// return Some(*device);
/// }
/// }
/// None
/// })
/// .await
/// .unwrap();
/// ```
pub struct BLEScan {
scan_params: sys::ble_gap_disc_params,
signal: Signal<()>,
Expand Down Expand Up @@ -65,24 +85,9 @@ impl BLEScan {
self
}

/// # Examples
///
/// ```
/// let ble_device = BLEDevice::take();
/// let ble_scan = BLEScan::new();
/// let name = "Device Name To Be Found";
/// let device = ble_scan
/// .start(ble_device, 10000, |device, data| {
/// if let Some(device_name) = data.name() {
/// if device_name == name {
/// return Some(*device);
/// }
/// }
/// None
/// })
/// .await
/// .unwrap();
/// ```
/// The callback function must return Option type.
/// If it returns None, the scan continues.
/// If Some(r) is returned, the scan stops and the start function returns the return value of the callback.
pub async fn start<F, R>(
&mut self,
_ble_device: &BLEDevice,
Expand Down

0 comments on commit ffd68db

Please sign in to comment.