pub struct HiveBeacon {
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
HIVE Beacon data structure
Contains all information broadcast in a HIVE 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 HiveBeacon
impl HiveBeacon
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 HIVE-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 HiveBeacon
impl Clone for HiveBeacon
Source§fn clone(&self) -> HiveBeacon
fn clone(&self) -> HiveBeacon
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 HiveBeacon
impl Debug for HiveBeacon
Source§impl Default for HiveBeacon
impl Default for HiveBeacon
Source§impl PartialEq for HiveBeacon
impl PartialEq for HiveBeacon
impl Eq for HiveBeacon
impl StructuralPartialEq for HiveBeacon
Auto Trait Implementations§
impl Freeze for HiveBeacon
impl RefUnwindSafe for HiveBeacon
impl Send for HiveBeacon
impl Sync for HiveBeacon
impl Unpin for HiveBeacon
impl UnwindSafe for HiveBeacon
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