pub struct AddressRotationHandler { /* private fields */ }Expand description
Handler for BLE address rotation
Maintains mappings between device names and node IDs to handle address rotation gracefully.
Implementations§
Source§impl AddressRotationHandler
impl AddressRotationHandler
Sourcepub fn register_device(&mut self, name: &str, address: &str, node_id: NodeId)
pub fn register_device(&mut self, name: &str, address: &str, node_id: NodeId)
Register a new device
Creates mappings for name, address, and node ID.
Sourcepub fn lookup_by_name(&self, name: &str) -> Option<NodeId>
pub fn lookup_by_name(&self, name: &str) -> Option<NodeId>
Look up a device by name
Returns the node ID if the name is known.
Sourcepub fn lookup_by_address(&self, address: &str) -> Option<NodeId>
pub fn lookup_by_address(&self, address: &str) -> Option<NodeId>
Look up a device by address
Returns the node ID if the address is known.
Sourcepub fn get_address(&self, node_id: &NodeId) -> Option<&String>
pub fn get_address(&self, node_id: &NodeId) -> Option<&String>
Get the current address for a node
Sourcepub fn on_device_discovered(
&mut self,
name: &str,
address: &str,
) -> Option<DeviceLookupResult>
pub fn on_device_discovered( &mut self, name: &str, address: &str, ) -> Option<DeviceLookupResult>
Handle a device discovery, detecting address rotation
This is the main entry point for handling discovered devices. It checks if we know this device by name and handles address rotation automatically.
Returns:
Some(DeviceLookupResult)if the device was found by name (existing device)Noneif this is a new device
Sourcepub fn update_address(&mut self, name: &str, new_address: &str) -> bool
pub fn update_address(&mut self, name: &str, new_address: &str) -> bool
Update the address for a device (used when address rotation is detected)
Sourcepub fn update_name(&mut self, node_id: NodeId, new_name: &str)
pub fn update_name(&mut self, node_id: NodeId, new_name: &str)
Update the name for a device (e.g., when callsign is received)
Sourcepub fn remove_device(&mut self, node_id: &NodeId)
pub fn remove_device(&mut self, node_id: &NodeId)
Remove a device from all mappings
Sourcepub fn device_count(&self) -> usize
pub fn device_count(&self) -> usize
Get the number of tracked devices
Sourcepub fn stats(&self) -> AddressRotationStats
pub fn stats(&self) -> AddressRotationStats
Get statistics about tracked mappings