pub struct PeatBeacon {
pub version: u8,
pub capabilities: u16,
pub node_id: NodeId,
pub hierarchy_level: HierarchyLevel,
pub geohash: u32,
pub battery_percent: u8,
pub seq_num: u16,
}Expand description
Peat Beacon data structure
Contains all information broadcast in a Peat BLE advertisement.
Fields§
§version: u8Protocol version (0-15)
capabilities: u16Node capabilities flags
node_id: NodeIdNode identifier
hierarchy_level: HierarchyLevelHierarchy level in the mesh
geohash: u32Geohash for location (24-bit, ~600m precision)
battery_percent: u8Battery percentage (0-100, 255 = unknown)
seq_num: u16Sequence number for deduplication
Implementations§
Source§impl PeatBeacon
impl PeatBeacon
Sourcepub fn with_capabilities(self, capabilities: u16) -> Self
pub fn with_capabilities(self, capabilities: u16) -> Self
Set capabilities
Sourcepub fn with_hierarchy_level(self, level: HierarchyLevel) -> Self
pub fn with_hierarchy_level(self, level: HierarchyLevel) -> Self
Set hierarchy level
Sourcepub fn with_geohash(self, geohash: u32) -> Self
pub fn with_geohash(self, geohash: u32) -> Self
Set geohash
Sourcepub fn with_battery(self, percent: u8) -> Self
pub fn with_battery(self, percent: u8) -> Self
Set battery percentage
Sourcepub fn increment_seq(&mut self)
pub fn increment_seq(&mut self)
Increment sequence number
Sourcepub fn encode_compact(&self) -> [u8; 10]
pub fn encode_compact(&self) -> [u8; 10]
Encode beacon to compact format (10 bytes for legacy advertising)
Compact format omits geohash and reserved bytes:
- Byte 0: Version | Capabilities high
- Byte 1: Capabilities low
- Bytes 2-5: Node ID
- Byte 6: Hierarchy level
- Byte 7: Battery percent
- Bytes 8-9: Sequence number
Sourcepub fn decode_compact(data: &[u8]) -> Option<Self>
pub fn decode_compact(data: &[u8]) -> Option<Self>
Decode beacon from compact format (10 bytes)
Sourcepub fn is_lite_node(&self) -> bool
pub fn is_lite_node(&self) -> bool
Check if this is a Peat-Lite node
Sourcepub fn supports_coded_phy(&self) -> bool
pub fn supports_coded_phy(&self) -> bool
Check if this node supports Coded PHY
Trait Implementations§
Source§impl Clone for PeatBeacon
impl Clone for PeatBeacon
Source§fn clone(&self) -> PeatBeacon
fn clone(&self) -> PeatBeacon
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PeatBeacon
impl Debug for PeatBeacon
Source§impl Default for PeatBeacon
impl Default for PeatBeacon
Source§impl PartialEq for PeatBeacon
impl PartialEq for PeatBeacon
impl Eq for PeatBeacon
impl StructuralPartialEq for PeatBeacon
Auto Trait Implementations§
impl Freeze for PeatBeacon
impl RefUnwindSafe for PeatBeacon
impl Send for PeatBeacon
impl Sync for PeatBeacon
impl Unpin for PeatBeacon
impl UnsafeUnpin for PeatBeacon
impl UnwindSafe for PeatBeacon
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.