#[non_exhaustive]#[repr(u8)]pub enum DeviceType {
Aranet4 = 241,
Aranet2 = 242,
AranetRadon = 243,
AranetRadiation = 244,
}Expand description
Type of Aranet device.
This enum is marked #[non_exhaustive] to allow adding new device types
in future versions without breaking downstream code.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Aranet4 = 241
Aranet4 CO2, temperature, humidity, and pressure sensor.
Aranet2 = 242
Aranet2 temperature and humidity sensor.
AranetRadon = 243
Aranet Radon sensor.
AranetRadiation = 244
Aranet Radiation sensor.
Implementations§
Source§impl DeviceType
impl DeviceType
Sourcepub fn from_name(name: &str) -> Option<Self>
pub fn from_name(name: &str) -> Option<Self>
Detect device type from a device name.
Analyzes the device name (case-insensitive) to determine the device type
based on common naming patterns. Uses word-boundary-aware matching to avoid
false positives (e.g., "Aranet4" won’t match "NotAranet4Device").
§Examples
use aranet_types::DeviceType;
assert_eq!(DeviceType::from_name("Aranet4 12345"), Some(DeviceType::Aranet4));
assert_eq!(DeviceType::from_name("Aranet2 Home"), Some(DeviceType::Aranet2));
assert_eq!(DeviceType::from_name("Aranet4"), Some(DeviceType::Aranet4));
assert_eq!(DeviceType::from_name("AranetRn+ 306B8"), Some(DeviceType::AranetRadon));
assert_eq!(DeviceType::from_name("RN+ Radon"), Some(DeviceType::AranetRadon));
assert_eq!(DeviceType::from_name("Aranet Radiation"), Some(DeviceType::AranetRadiation));
assert_eq!(DeviceType::from_name("Aranet\u{2622} 30ED1"), Some(DeviceType::AranetRadiation));
assert_eq!(DeviceType::from_name("Unknown Device"), None);Sourcepub fn has_temperature(&self) -> bool
pub fn has_temperature(&self) -> bool
Returns true if this device type has a temperature sensor.
Sourcepub fn has_humidity(&self) -> bool
pub fn has_humidity(&self) -> bool
Returns true if this device type has a humidity sensor.
Sourcepub fn has_pressure(&self) -> bool
pub fn has_pressure(&self) -> bool
Returns true if this device type has a pressure sensor.
Sourcepub fn readings_characteristic(&self) -> Uuid
pub fn readings_characteristic(&self) -> Uuid
Returns the BLE characteristic UUID for reading current sensor values.
- Aranet4: Uses
CURRENT_READINGS_DETAIL(f0cd3001) - Other devices: Use
CURRENT_READINGS_DETAIL_ALT(f0cd3003)
§Examples
use aranet_types::DeviceType;
use aranet_types::ble;
assert_eq!(DeviceType::Aranet4.readings_characteristic(), ble::CURRENT_READINGS_DETAIL);
assert_eq!(DeviceType::Aranet2.readings_characteristic(), ble::CURRENT_READINGS_DETAIL_ALT);Trait Implementations§
Source§impl Clone for DeviceType
impl Clone for DeviceType
Source§fn clone(&self) -> DeviceType
fn clone(&self) -> DeviceType
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for DeviceType
Source§impl Debug for DeviceType
impl Debug for DeviceType
Source§impl<'de> Deserialize<'de> for DeviceType
impl<'de> Deserialize<'de> for DeviceType
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for DeviceType
impl Display for DeviceType
impl Eq for DeviceType
Source§impl Hash for DeviceType
impl Hash for DeviceType
Source§impl PartialEq for DeviceType
impl PartialEq for DeviceType
Source§fn eq(&self, other: &DeviceType) -> bool
fn eq(&self, other: &DeviceType) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for DeviceType
impl Serialize for DeviceType
impl StructuralPartialEq for DeviceType
Source§impl TryFrom<u8> for DeviceType
impl TryFrom<u8> for DeviceType
Source§fn try_from(value: u8) -> Result<Self, Self::Error>
fn try_from(value: u8) -> Result<Self, Self::Error>
Convert a byte value to a DeviceType.
§Examples
use aranet_types::DeviceType;
assert_eq!(DeviceType::try_from(0xF1), Ok(DeviceType::Aranet4));
assert_eq!(DeviceType::try_from(0xF2), Ok(DeviceType::Aranet2));
assert!(DeviceType::try_from(0x00).is_err());