#bluetooth #ble #bluetooth-le #encryption-key #reader #victron

victron_ble

Read data from Victron devices over Bluetooth Low Energy

3 unstable releases

0.2.3 Jan 30, 2025
0.2.2 Jan 30, 2025
0.1.1 Oct 19, 2024

#723 in Hardware support

Download history 254/week @ 2024-10-16 20/week @ 2024-10-23 1/week @ 2024-12-04 3/week @ 2024-12-11 449/week @ 2025-01-29

449 downloads per month

MIT license

25KB
420 lines

Victron BLE

Read data from Victron devices over Bluetooth Low Energy.

Some Victron devices broadcast some aspects of their state over Bluetooth on a regular basis. This crate makes it easy to access that data.

Currently only Solar Charger type devices are supported but support can be added for other device types if requested.

Basic Usage

Use the open_stream function to get a stream of state updates for a given Victron device:

let device_name = "Victon Bluetooth device name";
let device_encryption_key = hex::decode("Victron device encryption key").unwrap();

let mut device_state_stream = victron_ble::open_stream(
    device_name, 
    device_encryption_key
).unwrap();

while let Some(result) = device_state_stream.next().await {
    println!("{result:?}");
}

Encryption Key

The device status messages published by the Victron device are encrypted. In order to decrypt them the device encyption key is needed. This can be found for a given device using the Victron Connect app on iOS or Android.

Using the app, connect to the device, then go to Settings -> Product Info -> Encryption data.

Serialization

If you add the serde feature then the DeviceState enum will be (de)serializable.

Example

An example application is provided which prints the state of a given device to to the terminal.

cargo run --example example <Victron device name> <Victron device encryption key>

Ackowledgements

Various aspects of this crate are either inspired by or copied from these projects:

Dependencies

~3–35MB
~444K SLoC