Rust bindings for libdivecomputer, a cross-platform and open source library for communication with dive computers from various manufacturers.
This repository contains 2 crates:
| Name | Description | Links |
|---|---|---|
libdivecomputer |
Safe, idiomatic high-level Rust bindings | |
libdivecomputer-sys |
Unsafe auto-generated FFI bindings |
use libdivecomputer::{Context, Descriptor, LogLevel};
fn main() -> libdivecomputer::Result<()> {
let ctx = Context::builder()
.log_level(LogLevel::Warning)
.build()?;
// List all supported dive computers.
for desc in Descriptor::iter(&ctx)? {
println!("{desc} (family: {})", desc.family());
}
Ok(())
}See the libdivecomputer crate README for more examples, including scanning for devices, downloading dives, and parsing dive data.
Serial, USB, USB HID, IrDA, Bluetooth, BLE, and USB Storage.
BLE support requires the ble feature (enabled by default), which uses btleplug.
- Linux (fully supported)
- Android (supported, requires NDK)
- macOS, iOS, Windows (cross-compilation targets defined, not fully tested)
autoreconf(autotools)gccor compatible C compiler
git submodule update --init
cargo build --releasecargo run --example device_scanner # scan for dive computers
cargo run --example device_download -- -d "Shearwater Petrel 3" -t BLE # download dives
cargo run --example dive_parser -- -d "Suunto EON Steel" dives/*.bin # parse saved dives
# Low-level sys crate examples
cargo run -p libdivecomputer-sys --example list # list supported devices
cargo run -p libdivecomputer-sys --example version # print library versionLicensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Note that libdivecomputer has its own LGPL-2.1 license.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.