Compare commits

...

2 commits

Author SHA1 Message Date
Martin Brodbeck 64cf89b185 add power to RadioData 2023-11-29 19:55:17 +01:00
Martin Brodbeck 566983283a cleanup 2023-11-29 19:54:31 +01:00
4 changed files with 6 additions and 11 deletions

1
Cargo.lock generated
View file

@ -129,7 +129,6 @@ dependencies = [
"reqwest",
"serde",
"serde_derive",
"serde_json",
"tokio",
]

View file

@ -2,7 +2,7 @@
name = "clrigctl"
version = "0.1.0"
edition = "2021"
author = "Martin Brodbeck <info@rustysoft.de>"
authors = ["Martin Brodbeck <dg2smb@darc.de>"]
[dependencies]
config = { version = "0.13.4", features = ["yaml"] }
@ -10,6 +10,5 @@ home = "0.5.5"
reqwest = { version = "0.11.22", features = ["json","rustls"] }
serde = { version = "1.0.193", features = ["serde_derive"] }
serde_derive = "1.0.193"
serde_json = "1.0.108"
tokio = { version = "1.34.0", features = ["full"] }

View file

@ -1,5 +1,4 @@
use serde::Serialize;
use serde_json;
use reqwest::Client;
#[derive(Serialize)]
@ -8,13 +7,10 @@ pub struct RadioData {
pub radio: String,
pub frequency : String,
pub mode: String,
pub power: String,
}
#[tokio::main]
pub async fn upload(url: &str, radio_data: &RadioData) {
let radio_data_json = serde_json::to_string(radio_data).unwrap();
let res = Client::new().post(url).json(&radio_data_json).send().await.unwrap();
println!("{}", radio_data_json);
}
let _res = Client::new().post(url).json(&radio_data).send().await.unwrap();
}

View file

@ -10,8 +10,9 @@ fn main() {
let rd = RadioData {
key: settings.cloudlog.key,
radio: settings.cloudlog.identifier,
frequency: String::from("2400170000"),
frequency: String::from("14017000"),
mode: String::from("CW"),
power: String::from("5"),
};
cloudlog::upload(&settings.cloudlog.url, &rd);