initial commit

This commit is contained in:
Aaska Black Wolf
2026-06-30 14:35:43 +02:00
parent b040576e58
commit 28c2f60c82
4 changed files with 1590 additions and 0 deletions
+5
View File
@@ -16,3 +16,8 @@ target/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Added by cargo
/target
Generated
+1521
View File
File diff suppressed because it is too large Load Diff
+11
View File
@@ -0,0 +1,11 @@
[package]
name = "ve-instant-readout"
version = "0.1.0"
edition = "2024"
[dependencies]
dbus = "0.9.11"
hex = "0.4.3"
tokio = "1.52.3"
tokio-stream = "0.1.18"
victron_ble = "1.0.0"
+53
View File
@@ -0,0 +1,53 @@
use std::{env, println};
use tokio_stream::StreamExt;
#[tokio::main]
async fn main() {
let args: Vec<String> = env::args().collect();
println!("{args:?}");
if args.len() != 3 {
println!("Usage: cargo run <victron device name> <victron device encryption key>");
return;
}
let device_name = args.get(1).unwrap();
let device_encryption_key = hex::decode(args.get(2).unwrap())
.expect("Invalid device encryption key, it should be hex encoded.");
let mut device_state_stream =
victron_ble::open_stream(device_name.into(), device_encryption_key).unwrap();
while let Some(result) = device_state_stream.next().await {
match result {
Ok(_device_state) => analyse_result(&_device_state),
Err(e) => println!("{e}"),
}
}
}
fn analyse_result( state: &victron_ble::DeviceState ) {
println!("Result:");
println!("{state:?}");
match state {
victron_ble::DeviceState::BatteryMonitor(victron_ble::BatteryMonitorState {
battery_voltage_v,
aux_input,
..
}) => {
match battery_voltage_v {
Some(v) => println!("Voltage: {}V", v),
None => {},
}
//println!("{:?}", aux_input);
let temp_k = format!("{:?}", aux_input);
println!("{}", temp_k);
if temp_k.starts_with("TemperatureK") {
let temp = &temp_k[13..temp_k.len()-1];
println!("Temperature: {}K", temp);
}
}
_ => {},
}
}