…
This commit is contained in:
parent
a33109f062
commit
364f9c7f31
6 changed files with 188 additions and 12 deletions
20
src/cloudlog.rs
Normal file
20
src/cloudlog.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
use serde::Serialize;
|
||||
use serde_json;
|
||||
use reqwest::Client;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct RadioData {
|
||||
pub key: String,
|
||||
pub radio: String,
|
||||
pub frequency : String,
|
||||
pub mode: 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);
|
||||
}
|
14
src/main.rs
14
src/main.rs
|
@ -1,10 +1,18 @@
|
|||
mod cloudlog;
|
||||
mod settings;
|
||||
|
||||
use settings::Settings;
|
||||
use crate::cloudlog::RadioData;
|
||||
|
||||
fn main() {
|
||||
let settings = Settings::new()
|
||||
.expect("Could not read settings.");
|
||||
let settings = Settings::new().expect("Could not read settings.");
|
||||
|
||||
println!("{:?}", settings);
|
||||
let rd = RadioData {
|
||||
key: settings.cloudlog.key,
|
||||
radio: settings.cloudlog.identifier,
|
||||
frequency: String::from("2400170000"),
|
||||
mode: String::from("CW"),
|
||||
};
|
||||
|
||||
cloudlog::upload(&settings.cloudlog.url, &rd);
|
||||
}
|
||||
|
|
|
@ -4,23 +4,23 @@ use serde_derive::Deserialize;
|
|||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[allow(unused)]
|
||||
struct Cloudlog {
|
||||
url: String,
|
||||
key: String,
|
||||
identifier: String,
|
||||
pub struct Cloudlog {
|
||||
pub url: String,
|
||||
pub key: String,
|
||||
pub identifier: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[allow(unused)]
|
||||
struct Flrig {
|
||||
host: String,
|
||||
port: String,
|
||||
pub struct Flrig {
|
||||
pub host: String,
|
||||
pub port: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[allow(unused)]
|
||||
pub struct Settings {
|
||||
cloudlog: Cloudlog,
|
||||
pub cloudlog: Cloudlog,
|
||||
flrig: Flrig,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue