pub struct Advertising {
pub local_name: Option<String>,
pub services: Vec<BluetoothUuid>,
pub interval: Option<(Duration, Duration)>,
}Expand description
What to put in the advertisement.
Apple honours only a local name and a service UUID list in the peripheral role — no manufacturer data, no service data. The packet holds 28 bytes for everything; service UUIDs that do not fit go to the overflow area, where only an Apple device scanning for them explicitly will see them.
Fields§
§local_name: Option<String>The name to advertise, if any.
services: Vec<BluetoothUuid>Service UUIDs to advertise, which is what a central filters on.
interval: Option<(Duration, Duration)>The preferred range between advertising events; None leaves it to the
platform. See Advertising::interval.
Implementations§
Source§impl Advertising
impl Advertising
Sourcepub fn local_name(self, name: impl Into<String>) -> Self
pub fn local_name(self, name: impl Into<String>) -> Self
The name centrals will show.
Sourcepub fn service(self, uuid: impl IntoUuid) -> Result<Self>
pub fn service(self, uuid: impl IntoUuid) -> Result<Self>
Advertise a service UUID, so centrals filtering for it find this device.
Sourcepub fn interval(self, min: Duration, max: Duration) -> Result<Self>
pub fn interval(self, min: Duration, max: Duration) -> Result<Self>
Prefer advertising every min to max: shorter is found sooner, at
the cost of power and airtime. Each scan window a central opens only
catches the events that fall inside it, so at BlueZ’s default of about
1.28 s a scanner — especially one next to a radio shared with Wi-Fi,
which drops some events — can miss a device for several windows in a
row.
A preference, honoured where the platform exposes one:
- Linux: BlueZ’s
MinInterval/MaxInterval, applied as given by BlueZ 5.82 (checked withbtmon). Older releases treated them as experimental and ignore them unlessbluetoothdruns withExperimental = truein/etc/bluetooth/main.conf(or-E). The system-wide default is[LE] MinAdvertisementInterval/MaxAdvertisementIntervalin the same file. - Android: the closest
AdvertiseSettingsmode — low latency (~100 ms) up to 175 ms, balanced (~250 ms) up to 500 ms, low power (~1 s) beyond. Without a preference Android uses low latency. - Apple and Windows expose no interval; CoreBluetooth advertises quickly while the app is in the foreground.
Fails if either bound is outside 20 ms–10.24 s or min > max.