pub struct PassiveMonitor { /* private fields */ }Expand description
Passive monitor for Aranet devices using BLE advertisements.
This allows monitoring multiple devices without establishing connections, which is useful for scenarios where:
- You need to monitor more devices than the BLE connection limit
- Low power consumption is important
- Real-time data isn’t critical (advertisement interval is typically 4+ seconds)
Implementations§
Source§impl PassiveMonitor
impl PassiveMonitor
Sourcepub fn new(options: PassiveMonitorOptions) -> Self
pub fn new(options: PassiveMonitorOptions) -> Self
Create a new passive monitor with the given options.
Sourcepub fn subscribe(&self) -> Receiver<PassiveReading>
pub fn subscribe(&self) -> Receiver<PassiveReading>
Subscribe to passive readings.
Returns a receiver that will receive readings as they are detected.
Sourcepub fn subscriber_count(&self) -> usize
pub fn subscriber_count(&self) -> usize
Get the number of active subscribers.
Sourcepub fn start(
self: &Arc<Self>,
cancel_token: CancellationToken,
) -> JoinHandle<()>
pub fn start( self: &Arc<Self>, cancel_token: CancellationToken, ) -> JoinHandle<()>
Start the passive monitor.
This spawns a background task that continuously scans for BLE advertisements and parses Aranet device data.
The task runs until the cancellation token is triggered.
Sourcepub async fn get_last_reading(
&self,
device_id: &str,
) -> Option<AdvertisementData>
pub async fn get_last_reading( &self, device_id: &str, ) -> Option<AdvertisementData>
Get the last known reading for a device.
Sourcepub async fn known_devices(&self) -> Vec<String>
pub async fn known_devices(&self) -> Vec<String>
Get all known device IDs.
Sourcepub async fn clear_cache(&self)
pub async fn clear_cache(&self)
Clear the reading cache.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PassiveMonitor
impl !RefUnwindSafe for PassiveMonitor
impl Send for PassiveMonitor
impl Sync for PassiveMonitor
impl Unpin for PassiveMonitor
impl !UnwindSafe for PassiveMonitor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more