drogue_ttn/v2/
http.rs

1//! Mappings for the HTTP integration.
2
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5use serde_json::Value;
6use url::Url;
7
8/// Uplink message.
9#[derive(Clone, Debug, Serialize, Deserialize)]
10pub struct Uplink {
11    pub app_id: String,
12    pub dev_id: String,
13    pub hardware_serial: String,
14    pub port: u16,
15    pub counter: u32,
16    #[serde(default)]
17    pub is_retry: bool,
18    #[serde(default)]
19    pub confirmed: bool,
20
21    #[serde(skip_serializing_if = "Value::is_null", default)]
22    pub payload_fields: Value,
23    #[serde(with = "crate::Base64Standard")]
24    pub payload_raw: Vec<u8>,
25
26    pub metadata: Metadata,
27
28    #[serde(skip_serializing_if = "Option::is_none", default)]
29    pub downlink_url: Option<Url>,
30}
31
32/// Metadata section.
33#[derive(Clone, Debug, Serialize, Deserialize)]
34pub struct Metadata {
35    pub time: DateTime<Utc>,
36    pub frequency: Option<f64>,
37    pub modulation: Option<String>,
38    pub data_rate: Option<String>,
39    pub bit_rate: Option<u32>,
40    pub coding_rate: Option<String>,
41
42    #[serde(flatten)]
43    pub coordinates: Option<Coordinates>,
44
45    #[serde(skip_serializing_if = "Vec::is_empty", default)]
46    pub gateways: Vec<Gateway>,
47}
48
49/// Gateway information.
50#[derive(Clone, Debug, Serialize, Deserialize)]
51pub struct Gateway {
52    pub gtw_id: String,
53    #[serde(default)]
54    pub channel: u32,
55    pub rssi: f64,
56    #[serde(default)]
57    pub snr: f64,
58    #[serde(default)]
59    pub rf_chain: i32,
60    #[serde(flatten)]
61    pub coordinates: Option<Coordinates>,
62}
63
64/// Location coordinates.
65#[derive(Clone, Debug, Serialize, Deserialize)]
66pub struct Coordinates {
67    pub longitude: f64,
68    pub latitude: f64,
69    pub altitude: f64,
70}