Scanner

Struct Scanner 

Source
pub struct Scanner { /* private fields */ }
Expand description

BLE Scanner for discovering HIVE nodes

Handles beacon reception, filtering, deduplication, and device tracking.

Note: This type requires the std feature for full functionality.

Implementations§

Source§

impl Scanner

Source

pub fn new(config: DiscoveryConfig) -> Self

Create a new scanner with default settings

Source

pub fn set_time_ms(&mut self, time_ms: u64)

Set the current time (call periodically from platform)

Source

pub fn set_filter(&mut self, filter: ScanFilter)

Set the scan filter

Source

pub fn set_device_timeout_ms(&mut self, timeout_ms: u64)

Set device timeout in milliseconds

Source

pub fn state(&self) -> ScannerState

Get current state

Source

pub fn start(&mut self)

Start scanning

Source

pub fn pause(&mut self)

Pause scanning

Source

pub fn stop(&mut self)

Stop scanning

Source

pub fn process_advertisement(&mut self, adv: ParsedAdvertisement) -> bool

Process a received advertisement

Returns true if this is a new or updated device that passes the filter.

Source

pub fn get_device(&self, node_id: &NodeId) -> Option<&TrackedDevice>

Get a tracked device by node ID

Source

pub fn get_node_id_for_address(&self, address: &str) -> Option<&NodeId>

Get node ID for an address

Source

pub fn devices(&self) -> impl Iterator<Item = &TrackedDevice>

Get all tracked devices

Source

pub fn devices_by_rssi(&self) -> Vec<&TrackedDevice>

Get devices sorted by RSSI (strongest first)

Source

pub fn devices_by_hierarchy(&self) -> Vec<&TrackedDevice>

Get devices sorted by hierarchy level (highest first)

Source

pub fn device_count(&self) -> usize

Get count of tracked devices

Source

pub fn remove_stale(&mut self) -> usize

Remove stale devices

Returns the number of devices removed.

Source

pub fn clear(&mut self)

Clear all tracked devices

Source

pub fn find_best_parent( &self, our_level: HierarchyLevel, ) -> Option<&TrackedDevice>

Find the best parent candidate

Selects based on hierarchy level (prefer higher) and RSSI (prefer stronger).

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.