Struct esp32_nimble::BLEScan

source ·
pub struct BLEScan { /* private fields */ }

Implementations§

source§

impl BLEScan

source

pub fn active_scan(&mut self, active: bool) -> &mut Self

source

pub fn filter_duplicates(&mut self, val: bool) -> &mut Self

source

pub fn limited(&mut self, val: bool) -> &mut Self

Set whether or not the BLE controller only report scan results from devices advertising in limited discovery mode, i.e. directed advertising.

source

pub fn filter_policy(&mut self, val: ScanFilterPolicy) -> &mut Self

Sets the scan filter policy.

source

pub fn interval(&mut self, interval_msecs: u16) -> &mut Self

Set the interval to scan.

source

pub fn window(&mut self, window_msecs: u16) -> &mut Self

Set the window to actively scan.

source

pub fn on_result( &mut self, callback: impl FnMut(&mut Self, &BLEAdvertisedDevice) + Send + Sync + 'static ) -> &mut Self

Set a callback to be called when a new scan result is detected.

  • callback first parameter: The reference to Self
  • callback second parameter: Newly found device
source

pub fn on_completed( &mut self, callback: impl FnMut() + Send + Sync + 'static ) -> &mut Self

source

pub async fn find_device( &mut self, duration_ms: i32, callback: impl Fn(&BLEAdvertisedDevice) -> bool + Send + Sync ) -> Result<Option<BLEAdvertisedDevice>, BLEError>

Asynchronously finds a device.

Examples
let ble_device = BLEDevice::take().unwrap();
let ble_scan = ble_device.get_scan();
let name = "Device Name To Be Found";
let device = ble_scan.find_device(10000, |device| device.name() == name).await.unwrap();
source

pub async fn start(&mut self, duration_ms: i32) -> Result<(), BLEError>

source

pub fn stop(&mut self) -> Result<(), BLEError>

source

pub fn get_results(&mut self) -> Iter<'_, BLEAdvertisedDevice>

source

pub fn clear_results(&mut self)

Auto Trait Implementations§

§

impl !RefUnwindSafe for BLEScan

§

impl Send for BLEScan

§

impl Sync for BLEScan

§

impl Unpin for BLEScan

§

impl !UnwindSafe for BLEScan

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.