Mercurial > templog
diff rust/src/config.rs @ 596:ca8102feaca6 rust
sensor takes config parameter
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 06 Jan 2017 22:04:10 +0800 |
parents | e87655ed8429 |
children | a440eafa84a9 |
line wrap: on
line diff
--- a/rust/src/config.rs Thu Jan 05 23:26:00 2017 +0800 +++ b/rust/src/config.rs Fri Jan 06 22:04:10 2017 +0800 @@ -1,44 +1,41 @@ extern crate toml; -use toml::{Encoder,Decoder}; -use serde::Serializer; use serde::Serialize; -#[derive(Deserialize,Serialize,Debug)] +#[derive(Deserialize,Serialize,Debug,Clone)] #[allow(non_snake_case)] pub struct Config { - FRIDGE_SLEEP: u32, - SENSOR_SLEEP: u32, - UPLOAD_SLEEP: u32, + pub FRIDGE_SLEEP: u64, + pub SENSOR_SLEEP: u64, + pub UPLOAD_SLEEP: u64, - FRIDGE_DELAY: u32, - FRIDGE_WORT_INVALID_TIME: u32, + pub FRIDGE_DELAY: u64, + pub FRIDGE_WORT_INVALID_TIME: u64, - MAX_READINGS: u32, + pub MAX_READINGS: u32, - PARAMS_FILE: String, + pub PARAMS_FILE: String, - SENSOR_BASE_DIR: String, - FRIDGE_GPIO_PIN: u32, + pub SENSOR_BASE_DIR: String, + pub FRIDGE_GPIO_PIN: u32, - AMBIENT_NAME: String, - FRIDGE_NAME: String, - WORT_NAME: String, - INTERNAL_TEMPERATURE: String, + pub AMBIENT_NAME: String, + pub FRIDGE_NAME: String, + pub WORT_NAME: String, + pub INTERNAL_TEMPERATURE: String, - HMAC_KEY: String, - SERVER_URL: String, - UPDATE_URL: String, - SETTINGS_URL: String, + pub HMAC_KEY: String, + pub SERVER_URL: String, + pub UPDATE_URL: String, + pub SETTINGS_URL: String, } impl Config { pub fn new() -> Self { Config { - FRIDGE_SLEEP: 60, // this value works. may affect the algorithm - SENSOR_SLEEP: 15, // same for this. - UPLOAD_SLEEP: 83, // nice and prime + SENSOR_SLEEP: 5, + UPLOAD_SLEEP: 83, FRIDGE_DELAY: 600, // 10 mins, to avoid fridge damage from frequent cycling off/on FRIDGE_WORT_INVALID_TIME: 300, // 5 mins @@ -66,7 +63,7 @@ } } - pub fn to_toml_string(self) -> String { + pub fn to_toml_string(&self) -> String { let mut e = toml::Encoder::new(); self.serialize(&mut e).unwrap(); toml::Value::Table(e.toml).to_string()