26 lines
701 B
Rust
26 lines
701 B
Rust
mod mqtt_pub;
|
|
mod system_values;
|
|
mod device_var;
|
|
|
|
use std::env;
|
|
|
|
extern crate paho_mqtt as mqtt;
|
|
|
|
fn main() {
|
|
|
|
device_var::read_env_var();
|
|
|
|
let mut cli = mqtt_pub::init_cli();
|
|
|
|
cli = mqtt_pub::publish_message(cli, "temperature", &system_values::get_temperature().to_string());
|
|
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);
|
|
}
|