Add self-creation for controller

This commit is contained in:
Tobias Reisinger 2023-11-25 00:39:44 +01:00
parent d193000aec
commit 4e3df272c3
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
10 changed files with 105 additions and 14 deletions
emgauwa-controller/src

View file

@ -1,5 +1,6 @@
use emgauwa_lib::{constants, utils};
use serde_derive::Deserialize;
use crate::driver::Driver;
#[derive(Clone, Debug, Deserialize)]
#[serde(default)]
@ -17,6 +18,15 @@ pub struct Logging {
pub file: String,
}
#[derive(Clone, Debug, Deserialize)]
#[serde(default)]
#[allow(unused)]
pub struct Relay {
pub driver: Driver,
pub pin: u8,
pub inverted: bool,
}
#[derive(Clone, Debug, Deserialize)]
#[serde(default)]
#[allow(unused)]
@ -24,6 +34,8 @@ pub struct Settings {
pub core: Core,
pub database: String,
pub logging: Logging,
pub name: String,
pub relays: Vec<Relay>,
}
impl Default for Settings {
@ -32,6 +44,18 @@ impl Default for Settings {
core: Core::default(),
database: String::from("sqlite://emgauwa-controller.sqlite"),
logging: Logging::default(),
name: String::from("Emgauwa Controller"),
relays: Vec::new(),
}
}
}
impl Default for Relay {
fn default() -> Self {
Relay {
driver: Driver::Gpio,
pin: 0,
inverted: false,
}
}
}