Skip to content

theCarlG/libdivecomputer-rs

Repository files navigation

libdivecomputer-rs

Rust bindings for libdivecomputer, a cross-platform and open source library for communication with dive computers from various manufacturers.

Crates.io Docs dependency status Build status

This repository contains 2 crates:

Name Description Links
libdivecomputer Safe, idiomatic high-level Rust bindings Crates.io Docs
libdivecomputer-sys Unsafe auto-generated FFI bindings Crates.io Docs

Quick Start

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.

Supported Transports

Serial, USB, USB HID, IrDA, Bluetooth, BLE, and USB Storage.

BLE support requires the ble feature (enabled by default), which uses btleplug.

Platform Support

  • Linux (fully supported)
  • Android (supported, requires NDK)
  • macOS, iOS, Windows (cross-compilation targets defined, not fully tested)

Prerequisites

  • autoreconf (autotools)
  • gcc or compatible C compiler

Building

git submodule update --init
cargo build --release

Examples

cargo 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 version

License

Licensed under either of

at your option.

Note that libdivecomputer has its own LGPL-2.1 license.

Contribution

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.

About

Rust bindings for libdivecomputer

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages