Fix PositionSolution decoding from JSON.

Depending the algorithm type, some fields might or might not be present.
This change updates these fields to Option<T>.
This commit is contained in:
Orne Brocaar 2022-09-27 11:28:35 +01:00
parent 2abc85afa6
commit 4d000b92e9
2 changed files with 9 additions and 8 deletions

View File

@ -663,11 +663,12 @@ pub struct LoraDownlink {
// PositionSolution implements the Positition Solution object.
#[derive(Serialize, Deserialize, Clone)]
pub struct PositionSolution {
pub ecef: Vec<f64>,
pub algorithm_type: Option<String>,
pub ecef: Option<Vec<f64>>,
pub llh: Vec<f64>,
pub capture_time_gps: f64,
pub gdop: f64,
pub accuracy: f32,
pub capture_time_gps: Option<f64>,
pub gdop: Option<f64>,
pub accuracy: Option<f32>,
pub timestamp: f64,
}

View File

@ -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(),
}),
};