pub struct Advertiser { /* private fields */ }Expand description
Peat Beacon Advertiser
Manages building and updating BLE advertisements containing Peat beacons.
Implementations§
Source§impl Advertiser
impl Advertiser
Sourcepub fn new(config: DiscoveryConfig, node_id: NodeId) -> Self
pub fn new(config: DiscoveryConfig, node_id: NodeId) -> Self
Create a new advertiser with the given configuration and node ID
Sourcepub fn peat_lite(config: DiscoveryConfig, node_id: NodeId) -> Self
pub fn peat_lite(config: DiscoveryConfig, node_id: NodeId) -> Self
Create an advertiser for a Peat-Lite node
Sourcepub fn set_time_ms(&mut self, time_ms: u64)
pub fn set_time_ms(&mut self, time_ms: u64)
Set the current time (call periodically from platform)
Sourcepub fn with_tx_power(self, tx_power: i8) -> Self
pub fn with_tx_power(self, tx_power: i8) -> Self
Set TX power level
Sourcepub fn with_extended_advertising(self, enabled: bool) -> Self
pub fn with_extended_advertising(self, enabled: bool) -> Self
Enable extended advertising
Sourcepub fn with_encryption(
self,
beacon_key: BeaconKey,
mesh_id_bytes: [u8; 4],
) -> Self
pub fn with_encryption( self, beacon_key: BeaconKey, mesh_id_bytes: [u8; 4], ) -> Self
Enable encrypted advertising mode
In encrypted mode:
- Beacon identity (mesh_id + node_id) is encrypted
- Device name becomes generic “PEAT”
- Only mesh members with the beacon key can identify the node
§Arguments
beacon_key- Encryption key derived from mesh genesismesh_id_bytes- 4-byte mesh identifier for beacon identity
Sourcepub fn set_mode(&mut self, mode: AdvertisingMode)
pub fn set_mode(&mut self, mode: AdvertisingMode)
Set advertising mode
Sourcepub fn mode(&self) -> AdvertisingMode
pub fn mode(&self) -> AdvertisingMode
Get current advertising mode
Sourcepub fn set_beacon_key(&mut self, key: BeaconKey)
pub fn set_beacon_key(&mut self, key: BeaconKey)
Update encryption key (for key rotation)
Sourcepub fn state(&self) -> AdvertiserState
pub fn state(&self) -> AdvertiserState
Get current state
Sourcepub fn beacon(&self) -> &PeatBeacon
pub fn beacon(&self) -> &PeatBeacon
Get the current beacon
Sourcepub fn beacon_mut(&mut self) -> &mut PeatBeacon
pub fn beacon_mut(&mut self) -> &mut PeatBeacon
Get mutable access to the beacon
Sourcepub fn set_hierarchy_level(&mut self, level: HierarchyLevel)
pub fn set_hierarchy_level(&mut self, level: HierarchyLevel)
Update hierarchy level
Sourcepub fn set_capabilities(&mut self, caps: u16)
pub fn set_capabilities(&mut self, caps: u16)
Update capabilities
Sourcepub fn set_battery(&mut self, percent: u8)
pub fn set_battery(&mut self, percent: u8)
Update battery percentage
Sourcepub fn set_geohash(&mut self, geohash: u32)
pub fn set_geohash(&mut self, geohash: u32)
Update geohash
Sourcepub fn advertising_duration_ms(&self) -> Option<u64>
pub fn advertising_duration_ms(&self) -> Option<u64>
Get duration of current advertising session in milliseconds
Sourcepub fn increment_sequence(&mut self)
pub fn increment_sequence(&mut self)
Increment sequence number and invalidate cache
Sourcepub fn build_packet(&mut self) -> &AdvertisingPacket
pub fn build_packet(&mut self) -> &AdvertisingPacket
Build the advertising packet
Uses cached packet if available and not dirty.
Sourcepub fn rebuild_packet(&mut self) -> &AdvertisingPacket
pub fn rebuild_packet(&mut self) -> &AdvertisingPacket
Force rebuild of advertising packet
Sourcepub fn advertising_data(&mut self) -> Vec<u8> ⓘ
pub fn advertising_data(&mut self) -> Vec<u8> ⓘ
Get raw advertising data bytes
Sourcepub fn scan_response_data(&mut self) -> Option<Vec<u8>>
pub fn scan_response_data(&mut self) -> Option<Vec<u8>>
Get raw scan response bytes