Crate hlk_ld6002

Crate hlk_ld6002 

Source
Expand description

A library for community with HLK-LD6002 radar respiratory and heartbeat sensors.

§Usage

use embedded_io_adapters::std::FromStd;
use hlk_ld6002::{Data, MessageStream};
use serialport::ClearBuffer;
use std::time::Duration;

let port = serialport::new("/dev/ttyUSB0", 1_382_400)
    .timeout(Duration::from_millis(50))
    .open()
    .expect("Failed to open port");

let mut messages = MessageStream::new(FromStd::new(port));

let mut data = Data::default();

for message in messages.flatten() {
    data.update(message);
    println!("{data:?}");
}

Structs§

AsyncMessageStream
A wrapper around AsyncRead for reading messages from the sensor
Data
A helper struct to store the received data
MessageStream
A wrapper around Read for reading messages from the sensor

Enums§

LdError
Error type for reading data from the sensor
MessageBody
The decoded message from the sensor
MessageType
Message type sent by the sensor