MeshManager

Struct MeshManager 

Source
pub struct MeshManager { /* private fields */ }
Expand description

Manages the BLE mesh topology

Responsible for:

  • Tracking parent/child/peer connections
  • Parent selection and failover
  • Connection lifecycle management
  • Publishing topology events

Implementations§

Source§

impl MeshManager

Source

pub fn new( node_id: NodeId, my_level: HierarchyLevel, config: TopologyConfig, ) -> Self

Create a new mesh manager

Source

pub fn node_id(&self) -> &NodeId

Get our node ID

Source

pub fn my_level(&self) -> HierarchyLevel

Get our hierarchy level

Source

pub fn state(&self) -> ManagerState

Get current state

Source

pub fn start(&self) -> Result<()>

Start the mesh manager

Source

pub fn stop(&self) -> Result<()>

Stop the mesh manager

Source

pub fn on_topology_event(&self, callback: TopologyCallback)

Register a callback for topology events

Source

pub fn set_time_ms(&self, time_ms: u64)

Set the current time (for testing or embedded without RTC) Note: Uses usize internally for 32-bit platform compatibility

Source

pub fn time_ms(&self) -> u64

Get the current time Note: Returns u64 but internally stored as usize for 32-bit compatibility

Source

pub fn topology(&self) -> MeshTopology

Get a snapshot of the current topology

Source

pub fn has_parent(&self) -> bool

Check if we have a parent

Source

pub fn parent(&self) -> Option<NodeId>

Get our parent’s node ID

Source

pub fn children(&self) -> Vec<NodeId>

Get list of children

Source

pub fn child_count(&self) -> usize

Get number of children

Source

pub fn can_accept_child(&self) -> bool

Check if we can accept more children

Source

pub fn connected_peers(&self) -> Vec<NodeId>

Get all connected peer IDs

Source

pub fn get_peer_info(&self, node_id: &NodeId) -> Option<PeerInfo>

Get peer info for a node

Source

pub fn process_beacon(&self, beacon: &HiveBeacon, rssi: i8)

Process a beacon from a discovered node

This updates our list of potential parents

Source

pub fn select_best_parent(&self) -> Option<ParentCandidate>

Select best parent from candidates

Returns the best candidate based on RSSI, age, and failure history

Source

pub fn connect_parent( &self, node_id: NodeId, level: HierarchyLevel, rssi: i8, ) -> Result<()>

Connect to a node as our parent

Source

pub fn disconnect_parent(&self, reason: DisconnectReason) -> Option<NodeId>

Disconnect from our parent

Source

pub fn accept_child(&self, node_id: NodeId, level: HierarchyLevel) -> Result<()>

Accept a child connection

Source

pub fn remove_child(&self, node_id: &NodeId, reason: DisconnectReason) -> bool

Remove a child

Source

pub fn start_failover(&self) -> Result<()>

Start parent failover process

Source

pub fn complete_failover( &self, new_parent: Option<(NodeId, HierarchyLevel, i8)>, ) -> Result<()>

Complete failover by connecting to new parent

Source

pub fn update_rssi(&self, node_id: &NodeId, rssi: i8)

Update RSSI for a connected peer

Source

pub fn record_failure(&self, node_id: &NodeId)

Record a connection failure for a node

Source

pub fn age_candidates(&self, elapsed_ms: u64)

Age all candidates (call periodically)

Source

pub fn should_switch_parent(&self) -> Option<ParentCandidate>

Check if we should switch parents (better option available)

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> 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, 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.