From 5923bc830e7eb8fd438051972e770d1c11c9cdcb Mon Sep 17 00:00:00 2001 From: Ollo Date: Wed, 4 Oct 2023 20:41:29 +0200 Subject: [PATCH 1/2] Added returncode for main function --- client/bin/src/main.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/client/bin/src/main.rs b/client/bin/src/main.rs index 35ca3fa..cf2e782 100644 --- a/client/bin/src/main.rs +++ b/client/bin/src/main.rs @@ -1,8 +1,7 @@ -use std::{time::Duration, fmt::format}; +use std::time::Duration; use bit::BitIndex; use chrono_tz::Europe::Berlin; use chrono::{DateTime, NaiveDateTime, Utc, Timelike}; -use chrono::prelude::*; use std::time::{SystemTime, UNIX_EPOCH}; use openweathermap::forecast::Weather; use substring::Substring; @@ -19,6 +18,7 @@ use embedded_graphics::{ use std::net::UdpSocket; use std::{env, thread}; use std::io; +use std::process::ExitCode; use openweathermap::forecast::Forecast; use straba::NextDeparture; @@ -336,14 +336,14 @@ fn check_connection(ipaddress: String) -> bool { return device_online; } -fn main() { +fn main() -> ExitCode { let args: Vec = env::args().collect(); - match args.len() { // no arguments passed 1 => { // show a help message help(); + return ExitCode::SUCCESS; } // one argument passed 2 => { @@ -353,7 +353,7 @@ fn main() { let mut device_online = check_connection(ip.to_string()); if !device_online { println!("{} not online", ip); - return + return ExitCode::FAILURE; } let receiver = openweathermap::init_forecast("Mannheim", @@ -409,6 +409,7 @@ fn main() { _ => { // show a help message help(); + return ExitCode::SUCCESS; } } } From e42b08bcf3489d513dc088710f4db50882c8384d Mon Sep 17 00:00:00 2001 From: Ollo Date: Wed, 4 Oct 2023 20:43:08 +0200 Subject: [PATCH 2/2] Update StraBa every 50 seconds --- client/bin/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/bin/src/main.rs b/client/bin/src/main.rs index cf2e782..f7ce8b4 100644 --- a/client/bin/src/main.rs +++ b/client/bin/src/main.rs @@ -389,7 +389,7 @@ fn main() -> ExitCode { } } - if (straba_res.request_time + 60) < seconds as i64 { + if (straba_res.request_time + 50) < seconds as i64 { device_online = check_connection(ip.to_string()); // request once a minute new data if device_online == true {