Skip to main content

Crate bluetooth_adv

Crate bluetooth_adv 

Source
Expand description

§bluetooth-adv

crates.io docs.rs

Bluetooth LE advertising data, parsed and decoded.

cargo add bluetooth-adv

Advertisement::parse reads the AD structures of an advertisement or scan response (Core Specification Supplement, Part A) into typed fields, naming companies, UUIDs and appearance from the SIG’s assigned numbers (bluetooth_numbers). beacon::decode then recognises beacon and sensor formats inside it.

Nothing here panics on any input: advertisements come off the air from devices nobody vetted, and every parser is fuzzed.

use bluetooth_adv::{Advertisement, beacon};
// Flags, then an iBeacon.
let data = hex::decode(
    "0201061aff4c000215e2c56db5dffb48d2b060d0f5a71096e000010002c5",
).unwrap();
let adv = Advertisement::parse(&data);
let beacons = beacon::decode(&adv, &beacon::Context::default());
assert!(matches!(beacons[0], beacon::Beacon::IBeacon(_)));

Part of bluetooth-bridge, maintained by Pulzar. See the user guide, the library guide and the API documentation.

License: MIT.

Modules§

beacon
Beacon and sensor formats found inside advertisements.

Structs§

AdStructure
One AD structure: a type and its data, borrowed from the advertisement.
AdStructures
An iterator over the AD structures of advertising or scan response data.
Advertisement
Every field an advertisement (or a scan response, or both concatenated) can carry, read into typed values.
DeviceId
The Device ID AD type (EIR): who made the device and which product it is.
Flags
The Flags AD type.
LocalName
The device’s local name.
Malformed
Where an advertisement stopped making sense.
ManufacturerData
Manufacturer specific data: a company identifier and the company’s bytes.
ServiceData
Service data: a UUID and the bytes the service defines.
ServiceUuid
A service UUID listed in the advertisement.

Enums§

Uuid
A Bluetooth UUID as it appeared on the wire: 16, 32 or 128 bits.

Functions§

format_address
Formats an address, given least significant byte first, the usual way: most significant byte first, colon separated, upper case.

Type Aliases§

AddressBytes
A Bluetooth device address as it appears on the air and in HCI: least significant byte first.