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
impl MeshManager
Sourcepub fn new(
node_id: NodeId,
my_level: HierarchyLevel,
config: TopologyConfig,
) -> Self
pub fn new( node_id: NodeId, my_level: HierarchyLevel, config: TopologyConfig, ) -> Self
Create a new mesh manager
Sourcepub fn my_level(&self) -> HierarchyLevel
pub fn my_level(&self) -> HierarchyLevel
Get our hierarchy level
Sourcepub fn state(&self) -> ManagerState
pub fn state(&self) -> ManagerState
Get current state
Sourcepub fn on_topology_event(&self, callback: TopologyCallback)
pub fn on_topology_event(&self, callback: TopologyCallback)
Register a callback for topology events
Sourcepub fn set_time_ms(&self, time_ms: u64)
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
Sourcepub fn time_ms(&self) -> u64
pub fn time_ms(&self) -> u64
Get the current time Note: Returns u64 but internally stored as usize for 32-bit compatibility
Sourcepub fn topology(&self) -> MeshTopology
pub fn topology(&self) -> MeshTopology
Get a snapshot of the current topology
Sourcepub fn has_parent(&self) -> bool
pub fn has_parent(&self) -> bool
Check if we have a parent
Sourcepub fn child_count(&self) -> usize
pub fn child_count(&self) -> usize
Get number of children
Sourcepub fn can_accept_child(&self) -> bool
pub fn can_accept_child(&self) -> bool
Check if we can accept more children
Sourcepub fn connected_peers(&self) -> Vec<NodeId>
pub fn connected_peers(&self) -> Vec<NodeId>
Get all connected peer IDs
Sourcepub fn get_peer_info(&self, node_id: &NodeId) -> Option<PeerInfo>
pub fn get_peer_info(&self, node_id: &NodeId) -> Option<PeerInfo>
Get peer info for a node
Sourcepub fn process_beacon(&self, beacon: &HiveBeacon, rssi: i8)
pub fn process_beacon(&self, beacon: &HiveBeacon, rssi: i8)
Process a beacon from a discovered node
This updates our list of potential parents
Sourcepub fn select_best_parent(&self) -> Option<ParentCandidate>
pub fn select_best_parent(&self) -> Option<ParentCandidate>
Select best parent from candidates
Returns the best candidate based on RSSI, age, and failure history
Sourcepub fn connect_parent(
&self,
node_id: NodeId,
level: HierarchyLevel,
rssi: i8,
) -> Result<()>
pub fn connect_parent( &self, node_id: NodeId, level: HierarchyLevel, rssi: i8, ) -> Result<()>
Connect to a node as our parent
Sourcepub fn disconnect_parent(&self, reason: DisconnectReason) -> Option<NodeId>
pub fn disconnect_parent(&self, reason: DisconnectReason) -> Option<NodeId>
Disconnect from our parent
Sourcepub fn accept_child(&self, node_id: NodeId, level: HierarchyLevel) -> Result<()>
pub fn accept_child(&self, node_id: NodeId, level: HierarchyLevel) -> Result<()>
Accept a child connection
Sourcepub fn remove_child(&self, node_id: &NodeId, reason: DisconnectReason) -> bool
pub fn remove_child(&self, node_id: &NodeId, reason: DisconnectReason) -> bool
Remove a child
Sourcepub fn start_failover(&self) -> Result<()>
pub fn start_failover(&self) -> Result<()>
Start parent failover process
Sourcepub fn complete_failover(
&self,
new_parent: Option<(NodeId, HierarchyLevel, i8)>,
) -> Result<()>
pub fn complete_failover( &self, new_parent: Option<(NodeId, HierarchyLevel, i8)>, ) -> Result<()>
Complete failover by connecting to new parent
Sourcepub fn update_rssi(&self, node_id: &NodeId, rssi: i8)
pub fn update_rssi(&self, node_id: &NodeId, rssi: i8)
Update RSSI for a connected peer
Sourcepub fn record_failure(&self, node_id: &NodeId)
pub fn record_failure(&self, node_id: &NodeId)
Record a connection failure for a node
Sourcepub fn age_candidates(&self, elapsed_ms: u64)
pub fn age_candidates(&self, elapsed_ms: u64)
Age all candidates (call periodically)
Sourcepub fn should_switch_parent(&self) -> Option<ParentCandidate>
pub fn should_switch_parent(&self) -> Option<ParentCandidate>
Check if we should switch parents (better option available)