Crates.io | victron_ble |
lib.rs | victron_ble |
version | |
source | src |
created_at | 2024-10-19 06:56:24.221447 |
updated_at | 2024-10-19 07:07:20.193183 |
description | Read data from Victron devices over Bluetooth Low Energy. |
homepage | |
repository | https://github.com/felixwatts/victron_ble |
max_upload_size | |
id | 1415131 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Read data from Victron devices over Bluetooth Low Energy.
Some Victron devices use the BLE advertising data protocol to broadcast some aspects of their state on a regular basis. This crate enables you to easily decrypt and parse the broadcast data into usable form.
Currently only Solar Charger type devices are supported but support can be added for other device types if requested.
If you already have the manufacturer data from your Victron device you can use
the basic function parse_manufacturer_data
to decrypt and parse it.
let device_encryption_key = hex::decode("Victron device encryption key").unwrap();
// Sourced from the manufacturer data part of a BLE advertisement event
// The Victron manufacturer ID is 737
let device_manufacturer_data = [0x10, 0, 0, 0, 0 ];
let device_state_result = victron_ble::parse_manufacturer_data(&device_manufacturer_data, &device_encryption_key);
println!("{device_state_result:?}");
If you want the crate to handle the bluetooth side, including discovering the
device and receiving the manufacturer data then use the open_stream
function
which currently supports MacOS and Linux.
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
).await;
while let Some(result) = device_state_stream.recv().await {
println!("{result:?}");
}
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.
If you add the serde
feature then the DeviceState
enum will be (de)serializable.
Various aspects of this crate are either inspired by or copied from these projects:
And see the file is this repo: extra-manufacturer-data-2022-12-14.pdf