pub trait AranetDevice: Send + Sync {
Show 16 methods
// Required methods
fn is_connected<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn name(&self) -> Option<&str>;
fn address(&self) -> &str;
fn device_type(&self) -> Option<DeviceType>;
fn read_current<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<CurrentReading>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn read_device_info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<DeviceInfo>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn read_rssi<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<i16>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn read_battery<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u8>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_history_info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<HistoryInfo>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn download_history<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<HistoryRecord>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn download_history_with_options<'life0, 'async_trait>(
&'life0 self,
options: HistoryOptions,
) -> Pin<Box<dyn Future<Output = Result<Vec<HistoryRecord>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_interval<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<MeasurementInterval>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn set_interval<'life0, 'async_trait>(
&'life0 self,
interval: MeasurementInterval,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_calibration<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<CalibrationData>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Trait abstracting Aranet device operations.
This trait enables writing code that works with both real Bluetooth devices and mock devices for testing. Implement this trait for any type that can provide Aranet sensor data.
§Example
use aranet_core::{AranetDevice, Result};
async fn print_reading<D: AranetDevice>(device: &D) -> Result<()> {
let reading = device.read_current().await?;
println!("CO2: {} ppm", reading.co2);
Ok(())
}Required Methods§
Sourcefn is_connected<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn is_connected<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check if the device is connected.
Sourcefn disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Disconnect from the device.
Sourcefn address(&self) -> &str
fn address(&self) -> &str
Get the device address or identifier.
On Linux/Windows this is typically the MAC address. On macOS this is a UUID since MAC addresses are not exposed.
Sourcefn device_type(&self) -> Option<DeviceType>
fn device_type(&self) -> Option<DeviceType>
Get the detected device type, if available.
Sourcefn read_current<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<CurrentReading>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn read_current<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<CurrentReading>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Read the current sensor values.
Sourcefn read_device_info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<DeviceInfo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn read_device_info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<DeviceInfo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Read device information (model, serial, firmware version, etc.).
Sourcefn read_rssi<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<i16>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn read_rssi<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<i16>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Read the current RSSI (signal strength) in dBm.
More negative values indicate weaker signals. Typical values range from -30 (strong) to -90 (weak).
Sourcefn read_battery<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u8>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn read_battery<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u8>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Read the battery level (0-100).
Sourcefn get_history_info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<HistoryInfo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_history_info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<HistoryInfo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get information about stored history.
Sourcefn download_history<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<HistoryRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn download_history<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<HistoryRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Download all historical readings.
Sourcefn download_history_with_options<'life0, 'async_trait>(
&'life0 self,
options: HistoryOptions,
) -> Pin<Box<dyn Future<Output = Result<Vec<HistoryRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn download_history_with_options<'life0, 'async_trait>(
&'life0 self,
options: HistoryOptions,
) -> Pin<Box<dyn Future<Output = Result<Vec<HistoryRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Download historical readings with custom options.
Sourcefn get_interval<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<MeasurementInterval>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_interval<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<MeasurementInterval>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the current measurement interval.
Sourcefn set_interval<'life0, 'async_trait>(
&'life0 self,
interval: MeasurementInterval,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_interval<'life0, 'async_trait>(
&'life0 self,
interval: MeasurementInterval,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Set the measurement interval.
Sourcefn get_calibration<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<CalibrationData>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_calibration<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<CalibrationData>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Read calibration data from the device.
Provided Methods§
Sourcefn connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Connect to the device.
For devices that are already connected, this should be a no-op. For devices that support reconnection, this should attempt to reconnect.
The default implementation returns Ok(()) for backwards compatibility.