HiveBeacon

Struct HiveBeacon 

Source
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: u8

Protocol version (0-15)

§capabilities: u16

Node capabilities flags

§node_id: NodeId

Node identifier

§hierarchy_level: HierarchyLevel

Hierarchy level in the mesh

§geohash: u32

Geohash for location (24-bit, ~600m precision)

§battery_percent: u8

Battery percentage (0-100, 255 = unknown)

§seq_num: u16

Sequence number for deduplication

Implementations§

Source§

impl HiveBeacon

Source

pub fn new(node_id: NodeId) -> Self

Create a new beacon with the given node ID

Source

pub fn hive_lite(node_id: NodeId) -> Self

Create a beacon for a HIVE-Lite node

Source

pub fn with_capabilities(self, capabilities: u16) -> Self

Set capabilities

Source

pub fn with_hierarchy_level(self, level: HierarchyLevel) -> Self

Set hierarchy level

Source

pub fn with_geohash(self, geohash: u32) -> Self

Set geohash

Source

pub fn with_battery(self, percent: u8) -> Self

Set battery percentage

Source

pub fn increment_seq(&mut self)

Increment sequence number

Source

pub fn encode(&self) -> [u8; 16]

Encode beacon to bytes (full 16-byte format)

Source

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
Source

pub fn decode(data: &[u8]) -> Option<Self>

Decode beacon from bytes (full 16-byte format)

Source

pub fn decode_compact(data: &[u8]) -> Option<Self>

Decode beacon from compact format (10 bytes)

Source

pub fn is_lite_node(&self) -> bool

Check if this is a HIVE-Lite node

Source

pub fn can_relay(&self) -> bool

Check if this node can relay messages

Source

pub fn supports_coded_phy(&self) -> bool

Check if this node supports Coded PHY

Trait Implementations§

Source§

impl Clone for HiveBeacon

Source§

fn clone(&self) -> HiveBeacon

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HiveBeacon

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HiveBeacon

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for HiveBeacon

Source§

fn eq(&self, other: &HiveBeacon) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for HiveBeacon

Source§

impl StructuralPartialEq for HiveBeacon

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.