From d20188e152d530ae36c341e932e9a507ef0527e5 Mon Sep 17 00:00:00 2001 From: mattbk Date: Tue, 28 Oct 2025 21:37:44 -0500 Subject: [PATCH] Split call and ssid. --- src/main.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 596fc8c..6aff823 100644 --- a/src/main.rs +++ b/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.*)-(?P[\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\d{2})(?P[\d ]{2}\.[\d ]{2})(?P[nsNS])/(?P\d{3})(?P[\d ]{2}\.[\d ]{2})(?P[ewEW])").unwrap(); // Only proceed if there were captures