pub struct HealthStatus {
pub battery_percent: u8,
pub heart_rate: Option<u8>,
pub activity: u8,
pub alerts: u8,
}Expand description
Health status data with LWW semantics
Fields§
§battery_percent: u8Battery percentage (0-100)
heart_rate: Option<u8>Heart rate BPM (optional)
activity: u8Activity level — non-validated u8 render hint (see
HealthStatus::decode). Current emitters use 0=still/standing,
3=PossibleFall; 4+ is reserved for sender-side extensions and
receivers treat unknown values as “no animation.”
alerts: u8Alert status flags
Implementations§
Source§impl HealthStatus
impl HealthStatus
Sourcepub const ALERT_MAN_DOWN: u8 = 0x01
pub const ALERT_MAN_DOWN: u8 = 0x01
Alert flag: Man down
Sourcepub const ALERT_LOW_BATTERY: u8 = 0x02
pub const ALERT_LOW_BATTERY: u8 = 0x02
Alert flag: Low battery
Sourcepub const ALERT_OUT_OF_RANGE: u8 = 0x04
pub const ALERT_OUT_OF_RANGE: u8 = 0x04
Alert flag: Out of range
Sourcepub const ALERT_CUSTOM_1: u8 = 0x08
pub const ALERT_CUSTOM_1: u8 = 0x08
Alert flag: Custom alert 1
Sourcepub fn with_heart_rate(self, hr: u8) -> Self
pub fn with_heart_rate(self, hr: u8) -> Self
Set heart rate
Sourcepub fn with_activity(self, activity: u8) -> Self
pub fn with_activity(self, activity: u8) -> Self
Set activity level
Sourcepub fn clear_alert(&mut self, flag: u8)
pub fn clear_alert(&mut self, flag: u8)
Clear alert flag
Sourcepub fn decode(data: &[u8]) -> Option<Self>
pub fn decode(data: &[u8]) -> Option<Self>
Decode from bytes with validation
§Security
Validates battery percentage and heart rate are within physiological bounds. Rejects garbage data that could indicate spoofing or corruption.
Activity is intentionally not validated — it’s a u8 render
hint (animation/icon selection), not a security-load-bearing
discriminator. Receivers should treat unknown values as “no
animation” and keep the rest of the peripheral intact. Re-adding
a range check here silently drops entire peripherals (callsign,
battery, location) for any peer reporting a value outside the
known set; that was the failure mode that motivated this carve-out.
Trait Implementations§
Source§impl Clone for HealthStatus
impl Clone for HealthStatus
Source§fn clone(&self) -> HealthStatus
fn clone(&self) -> HealthStatus
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HealthStatus
impl Debug for HealthStatus
Source§impl Default for HealthStatus
impl Default for HealthStatus
Source§fn default() -> HealthStatus
fn default() -> HealthStatus
Source§impl PartialEq for HealthStatus
impl PartialEq for HealthStatus
Source§fn eq(&self, other: &HealthStatus) -> bool
fn eq(&self, other: &HealthStatus) -> bool
self and other values to be equal, and is used by ==.