From a76a198ec6b5e381bb743aa349f306aa64c8ebee Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Tue, 28 Feb 2023 10:39:25 +0000 Subject: [PATCH] Do not overwrite RxInfo location if it is already set. --- chirpstack/src/uplink/mod.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/chirpstack/src/uplink/mod.rs b/chirpstack/src/uplink/mod.rs index 40cac1cb..cf66e5af 100644 --- a/chirpstack/src/uplink/mod.rs +++ b/chirpstack/src/uplink/mod.rs @@ -337,12 +337,17 @@ async fn update_gateway_metadata(ufs: &mut UplinkFrameSet) -> Result<()> { } }; - rx_info.location = Some(common::Location { - latitude: gw_meta.latitude, - longitude: gw_meta.longitude, - altitude: gw_meta.altitude as f64, - ..Default::default() - }); + // Do not overwrite the location if it is already set. In case of a 'virtual' it is + // possible that the location is already set in the RxInfo. Overwriting this with the + // location of the 'virtual' gateway would mean we will get the wrong location. + if rx_info.location.is_none() { + rx_info.location = Some(common::Location { + latitude: gw_meta.latitude, + longitude: gw_meta.longitude, + altitude: gw_meta.altitude as f64, + ..Default::default() + }); + } ufs.gateway_private_up_map .insert(gw_id, gw_meta.is_private_up);