Skip to main content

fluke_connect_client/
lib.rs

1//! Read live measurements from Fluke Connect Bluetooth Low Energy devices.
2//!
3//! Fluke Connect meters and adapters (the ir3000 FC infrared adapter, the
4//! 3000 FC multimeter, the 376 FC and 902 FC clamps, and the t3000 / v3000 /
5//! a3000 FC modules) share one vendor GATT profile. This crate decodes that
6//! profile and, with the default `ble` feature, connects to devices and
7//! streams their readings.
8//!
9//! # Layers
10//!
11//! - [`protocol`]: pure, I/O-free parsing of the binary reading record and
12//!   the ASCII display string, the source-agnostic [`Measurement`] view over
13//!   both, and the UUID table. Usable with `default-features = false`.
14//! - `transport` (feature `std`): a small async trait over a connected GATT
15//!   peripheral so the client can be driven by any Bluetooth stack or by a
16//!   test double.
17//! - `client` (feature `std`): the `FlukeDevice` type that subscribes to
18//!   readings and exposes the housekeeping characteristics.
19//! - `backend` (feature `ble`): the built-in
20//!   [btleplug](https://crates.io/crates/btleplug) transport.
21//! - `reconnect` (feature `ble`): a supervised stream over any device
22//!   subscription (measurements, readings, battery) that re-scans and
23//!   reconnects with backoff when the connection drops.
24//!
25//! # Hardware note
26//!
27//! The protocol was verified against an ir3000 FC attached to a Fluke 289.
28//! Other family members are expected to work but have not been tested by
29//! the authors.
30#![cfg_attr(not(feature = "std"), no_std)]
31#![cfg_attr(docsrs, feature(doc_cfg))]
32// Compile the README's examples as doctests; they need the built-in backend.
33#![cfg_attr(all(doctest, feature = "ble"), doc = include_str!("../README.md"))]
34
35#[cfg(test)]
36extern crate std;
37
38pub mod protocol;
39
40#[cfg(feature = "std")]
41#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
42pub mod client;
43#[cfg(feature = "std")]
44#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
45pub mod error;
46#[cfg(feature = "std")]
47#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
48pub mod transport;
49
50#[cfg(feature = "ble")]
51#[cfg_attr(docsrs, doc(cfg(feature = "ble")))]
52pub mod backend;
53#[cfg(feature = "ble")]
54#[cfg_attr(docsrs, doc(cfg(feature = "ble")))]
55pub mod reconnect;
56
57/// The btleplug version this crate links against.
58///
59/// Build a [`platform::Adapter`](btleplug::platform::Adapter) from it and
60/// hand it to [`backend::Adapter::from_btleplug`] when the application
61/// already owns a Bluetooth adapter.
62#[cfg(feature = "ble")]
63#[cfg_attr(docsrs, doc(cfg(feature = "ble")))]
64pub use btleplug;
65
66#[cfg(feature = "std")]
67pub use client::{DeviceInfo, FlukeDevice};
68#[cfg(feature = "std")]
69pub use error::{Error, Result};
70
71pub use protocol::{
72    AsciiReading, AsciiState, Attribute, Decade, Function, Magnitude, Measurement,
73    MeasurementNotification, ProtocolError, Reading, ReadingNotification, ReadingState, Unit,
74};