add battery level & load setting by device.env
This commit is contained in:
11
src/main.rs
11
src/main.rs
@@ -1,11 +1,15 @@
|
||||
mod mqtt_pub;
|
||||
mod system_values;
|
||||
mod device_var;
|
||||
|
||||
use std::env;
|
||||
|
||||
extern crate paho_mqtt as mqtt;
|
||||
extern crate dotenv;
|
||||
|
||||
fn main() {
|
||||
|
||||
device_var::read_env_var();
|
||||
|
||||
println!("Resp Temperature : {}", system_values::get_temperature());
|
||||
|
||||
let mut cli = mqtt_pub::init_cli();
|
||||
@@ -14,5 +18,10 @@ fn main() {
|
||||
cli = mqtt_pub::publish_message(cli, "storage", &system_values::get_storage().to_string());
|
||||
cli = mqtt_pub::publish_message(cli, "mem", &system_values::get_mem().to_string());
|
||||
|
||||
let battery = env::var("BATTERY").unwrap().to_string();
|
||||
if battery == "true" {
|
||||
cli = mqtt_pub::publish_message(cli, "battery", &system_values::get_battery().to_string());
|
||||
}
|
||||
|
||||
mqtt_pub::disconnect(cli);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user