Expand description
§bluetooth-adv
Bluetooth LE advertising data, parsed and decoded.
cargo add bluetooth-advAdvertisement::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.
- Device
Id - The Device ID AD type (EIR): who made the device and which product it is.
- Flags
- The Flags AD type.
- Local
Name - The device’s local name.
- Malformed
- Where an advertisement stopped making sense.
- Manufacturer
Data - Manufacturer specific data: a company identifier and the company’s bytes.
- Service
Data - Service data: a UUID and the bytes the service defines.
- Service
Uuid - 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§
- Address
Bytes - A Bluetooth device address as it appears on the air and in HCI: least significant byte first.