mirror of
https://gitea.farpn.net/w1cdn/mwtchahrd.git
synced 2025-11-03 13:36:36 -06:00
Split call and ssid.
This commit is contained in:
21
src/main.rs
21
src/main.rs
@@ -392,6 +392,19 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager, loc_st
|
||||
let my_lat = &cli.my_lat;
|
||||
let my_lon = &cli.my_lon;
|
||||
|
||||
// Split callsign and SSID if there are both
|
||||
let (source_call, source_ssid) = if source.contains("-") {
|
||||
let re_source = Regex::new(r"(?P<call>.*)-(?P<ssid>[\d])").unwrap();
|
||||
// Break captures into named values
|
||||
let callssid = re_source.captures(&source).unwrap();
|
||||
|
||||
(&callssid["call"].to_string(), &callssid["ssid"].to_string())
|
||||
} else {
|
||||
(&source, &"".to_string())
|
||||
};
|
||||
|
||||
//println!("{} - {}", source_call, source_ssid);
|
||||
|
||||
// If user provides an alternate Spothole URL, use that one
|
||||
let spothole_url = match &cli.spothole_alt {
|
||||
Some(spothole_alt) => spothole_alt,
|
||||
@@ -464,8 +477,6 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager, loc_st
|
||||
// Only send good locations on
|
||||
let json_lat = stored_loc[0].clone() ;
|
||||
let json_lon = stored_loc[1].clone() ;
|
||||
//let json_lat = if lat > -9999.0_f64 && lon > -9999.0_f64 { lat.to_string() } else { old_loc[0].clone() };
|
||||
//let json_lon = if lat > -9999.0_f64 && lon > -9999.0_f64 { lon.to_string() } else { old_loc[1].clone() };
|
||||
|
||||
println!("Stored location: {} {}", stored_loc[0].clone(), stored_loc[1].clone());
|
||||
|
||||
@@ -473,8 +484,8 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager, loc_st
|
||||
if summary == "UI" && cli.spothole {
|
||||
// POST JSON
|
||||
let packet = json!({
|
||||
"dx_call": &source,
|
||||
//"dx_aprs_ssid": "7",
|
||||
"dx_call": &source_call,
|
||||
"dx_aprs_ssid": &source_ssid,
|
||||
"de_call": &my_call,
|
||||
"de_latitude": &my_lat,
|
||||
"de_longitude": &my_lon,
|
||||
@@ -520,7 +531,7 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager, loc_st
|
||||
|
||||
|
||||
fn aprs_loc(packet: &str) -> (f64, f64) {
|
||||
// Capture different pieces of the location stringf
|
||||
// Capture different pieces of the location string
|
||||
let re_loc = Regex::new(r"(?P<latd>\d{2})(?P<latm>[\d ]{2}\.[\d ]{2})(?P<ns>[nsNS])/(?P<lond>\d{3})(?P<lonm>[\d ]{2}\.[\d ]{2})(?P<ew>[ewEW])").unwrap();
|
||||
|
||||
// Only proceed if there were captures
|
||||
|
||||
Reference in New Issue
Block a user