mirror of
https://gitea.farpn.net/w1cdn/mwtchahrd.git
synced 2025-10-20 00:14:09 -05:00
Spot packets to spothole.app if desired.
This commit is contained in:
30
src/main.rs
30
src/main.rs
@ -68,6 +68,10 @@ struct Cli {
|
|||||||
#[arg(short = 'o', long, default_value_t = false)]
|
#[arg(short = 'o', long, default_value_t = false)]
|
||||||
spothole: bool,
|
spothole: bool,
|
||||||
|
|
||||||
|
/// Spotting frequency
|
||||||
|
#[arg(short = 'f', long, default_value_t = 14105000)]
|
||||||
|
freq: u32,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a byte slice into a hex-dump string for debugging purposes.
|
/// Convert a byte slice into a hex-dump string for debugging purposes.
|
||||||
@ -369,6 +373,7 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) {
|
|||||||
let basic_destination = hdr.callto_str();
|
let basic_destination = hdr.callto_str();
|
||||||
let timestamp = Local::now().format("%H:%M:%S").to_string();
|
let timestamp = Local::now().format("%H:%M:%S").to_string();
|
||||||
let spotter = &cli.spotter;
|
let spotter = &cli.spotter;
|
||||||
|
let freq = &cli.freq;
|
||||||
|
|
||||||
// Filter and compute the text from the payload only once.
|
// Filter and compute the text from the payload only once.
|
||||||
let text = filter_text(&frame.payload);
|
let text = filter_text(&frame.payload);
|
||||||
@ -408,8 +413,28 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) {
|
|||||||
|
|
||||||
// If Spothole is enabled
|
// If Spothole is enabled
|
||||||
if summary == "UI" && cli.spothole {
|
if summary == "UI" && cli.spothole {
|
||||||
let body = reqwest::blocking::get("https://spothole.app/api/v1/spots?limit=1");
|
// curl --request POST --header "Content-Type: application/json"
|
||||||
println!("body = {body:?}");
|
// --data '{"dx_call":"M0TRT","time":1760019539, "freq":14200000,
|
||||||
|
// "comment":"Test spot please ignore", "de_call":"M0TRT"}' https://spothole.app/api/v1/spot
|
||||||
|
|
||||||
|
// POST JSON
|
||||||
|
let packet = json!({
|
||||||
|
"dx_call": &source,
|
||||||
|
"de_call": &spotter,
|
||||||
|
"freq": &freq,
|
||||||
|
"comment": &text,
|
||||||
|
"mode": "PKT",
|
||||||
|
"mode_type": "DATA",
|
||||||
|
"mode_source": "SPOT",
|
||||||
|
"time": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
||||||
|
});
|
||||||
|
let client = reqwest::blocking::Client::new();
|
||||||
|
let res = client.post("https://spothole.app/api/v1/spot")
|
||||||
|
.json(&packet)
|
||||||
|
.send();
|
||||||
|
println!("res = {res:?}");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send UDP
|
// Send UDP
|
||||||
@ -423,6 +448,7 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) {
|
|||||||
"spotter": &spotter,
|
"spotter": &spotter,
|
||||||
"summary": &summary,
|
"summary": &summary,
|
||||||
"text": &text,
|
"text": &text,
|
||||||
|
"freq": &freq,
|
||||||
"timestamp": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
"timestamp": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
||||||
"type": "data"
|
"type": "data"
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user