Skip to main content

bluetooth_adv/
lib.rs

1#![doc = include_str!("../README.md")]
2#![deny(unsafe_code)]
3
4mod ad;
5pub mod beacon;
6mod reader;
7mod uuid;
8
9pub use ad::{
10    AdStructure, AdStructures, Advertisement, DeviceId, Flags, LocalName, Malformed,
11    ManufacturerData, ServiceData, ServiceUuid,
12};
13pub use uuid::Uuid;
14
15/// A Bluetooth device address as it appears on the air and in HCI: least
16/// significant byte first.
17pub type AddressBytes = [u8; 6];
18
19/// Formats an address, given least significant byte first, the usual way:
20/// most significant byte first, colon separated, upper case.
21pub fn format_address(addr: &AddressBytes) -> String {
22    let mut s = String::with_capacity(17);
23    for (i, b) in addr.iter().rev().enumerate() {
24        if i > 0 {
25            s.push(':');
26        }
27        s.push_str(&format!("{b:02X}"));
28    }
29    s
30}
31
32// The repository README's Rust examples run as doctests, so they cannot rot.
33#[cfg(doctest)]
34#[doc = include_str!("../../../README.md")]
35struct ReadmeDoctests;