From 4d000b92e9b4cbecf2296a2d65526c38cf08e14d Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Tue, 27 Sep 2022 11:28:35 +0100 Subject: [PATCH] Fix PositionSolution decoding from JSON. Depending the algorithm type, some fields might or might not be present. This change updates these fields to Option. --- chirpstack/src/integration/loracloud/client.rs | 9 +++++---- chirpstack/src/integration/loracloud/mod.rs | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/chirpstack/src/integration/loracloud/client.rs b/chirpstack/src/integration/loracloud/client.rs index a0e12159..bd84a76a 100644 --- a/chirpstack/src/integration/loracloud/client.rs +++ b/chirpstack/src/integration/loracloud/client.rs @@ -663,11 +663,12 @@ pub struct LoraDownlink { // PositionSolution implements the Positition Solution object. #[derive(Serialize, Deserialize, Clone)] pub struct PositionSolution { - pub ecef: Vec, + pub algorithm_type: Option, + pub ecef: Option>, pub llh: Vec, - pub capture_time_gps: f64, - pub gdop: f64, - pub accuracy: f32, + pub capture_time_gps: Option, + pub gdop: Option, + pub accuracy: Option, pub timestamp: f64, } diff --git a/chirpstack/src/integration/loracloud/mod.rs b/chirpstack/src/integration/loracloud/mod.rs index d4423e3e..e65dd570 100644 --- a/chirpstack/src/integration/loracloud/mod.rs +++ b/chirpstack/src/integration/loracloud/mod.rs @@ -192,6 +192,9 @@ impl Integration { return Err(anyhow!("{}", resp.error)); } + self.handle_response_integration_event(vars, pl, &resp.result) + .await?; + if self.config.modem_geolocation_services.parse_tlv && resp.result.stream_records.is_some() { self.handle_response_tlv_records( @@ -202,9 +205,6 @@ impl Integration { .await?; } - self.handle_response_integration_event(vars, pl, &resp.result) - .await?; - if let Some(v) = &resp.result.downlink { self.handle_response_downlink(pl, v).await?; } @@ -427,7 +427,7 @@ impl Integration { longitude: result.llh[1], altitude: result.llh[2], source: source.into(), - accuracy: result.accuracy, + accuracy: result.accuracy.unwrap_or_default(), }), };