#[non_exhaustive]pub struct Advertisement {Show 29 fields
pub flags: Option<Flags>,
pub services: Vec<ServiceUuid>,
pub solicited_services: Vec<Uuid>,
pub local_name: Option<LocalName>,
pub broadcast_name: Option<String>,
pub tx_power: Option<i8>,
pub appearance: Option<u16>,
pub appearance_name: Option<String>,
pub class_of_device: Option<u32>,
pub device_id: Option<DeviceId>,
pub service_data: Vec<ServiceData>,
pub manufacturer_data: Vec<ManufacturerData>,
pub peripheral_connection_interval: Option<(u16, u16)>,
pub advertising_interval: Option<u32>,
pub public_target_addresses: Vec<AddressBytes>,
pub random_target_addresses: Vec<AddressBytes>,
pub le_address: Option<(String, bool)>,
pub le_role: Option<u8>,
pub uri: Option<String>,
pub le_supported_features: Option<Vec<u8>>,
pub resolvable_set_identifier: Option<[u8; 6]>,
pub sm_tk: Option<[u8; 16]>,
pub sm_oob_flags: Option<u8>,
pub le_sc_confirmation: Option<[u8; 16]>,
pub le_sc_random: Option<[u8; 16]>,
pub ssp_hash: Option<[u8; 16]>,
pub ssp_randomizer: Option<[u8; 16]>,
pub other: Vec<RawAd>,
pub malformed: Option<Malformed>,
}Expand description
Every field an advertisement (or a scan response, or both concatenated) can carry, read into typed values.
A field whose length is wrong for its type is kept in Advertisement::other
instead, so nothing the device sent is lost.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.flags: Option<Flags>Flags.
services: Vec<ServiceUuid>Service UUIDs, 16, 32 and 128-bit, complete and incomplete lists.
solicited_services: Vec<Uuid>Service Solicitation UUIDs.
local_name: Option<LocalName>Shortened or Complete Local Name (the complete one wins).
broadcast_name: Option<String>Broadcast_Name (LE Audio broadcasts).
tx_power: Option<i8>TX Power Level, dBm.
appearance: Option<u16>Appearance, raw.
appearance_name: Option<String>Appearance category and subcategory names.
class_of_device: Option<u32>Class of Device (BR/EDR), 24 bits.
device_id: Option<DeviceId>Device ID.
service_data: Vec<ServiceData>Service Data, 16, 32 and 128-bit.
manufacturer_data: Vec<ManufacturerData>Manufacturer Specific Data (more than one is allowed in practice).
peripheral_connection_interval: Option<(u16, u16)>Peripheral Connection Interval Range, in 1.25 ms units; 0xFFFF means no bound.
advertising_interval: Option<u32>Advertising Interval (or Advertising Interval - long), in 0.625 ms units.
public_target_addresses: Vec<AddressBytes>Public Target Addresses.
random_target_addresses: Vec<AddressBytes>Random Target Addresses.
le_address: Option<(String, bool)>LE Bluetooth Device Address: the address, and whether it is random.
le_role: Option<u8>LE Role: 0 peripheral only, 1 central only, 2 both preferring peripheral, 3 both preferring central.
uri: Option<String>URI, with its scheme expanded from the assigned numbers.
le_supported_features: Option<Vec<u8>>LE Supported Features (bit mask, octet 0 first).
resolvable_set_identifier: Option<[u8; 6]>Resolvable Set Identifier (Coordinated Set Identification).
sm_tk: Option<[u8; 16]>Security Manager TK Value (legacy OOB pairing).
sm_oob_flags: Option<u8>Security Manager Out of Band Flags.
le_sc_confirmation: Option<[u8; 16]>LE Secure Connections Confirmation Value (OOB).
le_sc_random: Option<[u8; 16]>LE Secure Connections Random Value (OOB).
ssp_hash: Option<[u8; 16]>Simple Pairing Hash C-192 or C-256 (BR/EDR OOB), the last one seen.
ssp_randomizer: Option<[u8; 16]>Simple Pairing Randomizer R-192 or R-256, the last one seen.
other: Vec<RawAd>Every other structure, by type, with its SIG name: Mesh, BIGInfo, Indoor Positioning, Transport Discovery, Encrypted Advertising Data, unassigned types, and any field whose length was wrong for its type.
malformed: Option<Malformed>Set when a structure’s length ran past the end of the data; every structure before it was still read.
Implementations§
Source§impl Advertisement
impl Advertisement
Sourcepub fn parse(data: &[u8]) -> Advertisement
pub fn parse(data: &[u8]) -> Advertisement
Reads every AD structure in data. Never fails: what cannot be read
is kept as bytes or marked Advertisement::malformed.
Sourcepub fn extend(&mut self, data: &[u8])
pub fn extend(&mut self, data: &[u8])
Adds the structures in data (a scan response, say) to this advertisement.
Sourcepub fn service_data_for(&self, uuid: impl Into<Uuid>) -> Option<&[u8]>
pub fn service_data_for(&self, uuid: impl Into<Uuid>) -> Option<&[u8]>
The service data for a UUID.
Sourcepub fn manufacturer_data_for(&self, company_id: u16) -> Option<&[u8]>
pub fn manufacturer_data_for(&self, company_id: u16) -> Option<&[u8]>
The manufacturer data for a company.