Skip to content

Commit 5edf13c

Browse files
committed
Remove the "stat" entry in the PUSH_DATA packet when the object is null (#32)
1 parent 5bd6f7b commit 5edf13c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/structs.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ impl PushData {
182182
#[derive(Serialize)]
183183
pub struct PushDataPayload {
184184
pub rxpk: Vec<RxPk>,
185+
#[serde(skip_serializing_if = "Option::is_none")]
185186
pub stat: Option<Stat>,
186187
}
187188

@@ -750,7 +751,7 @@ mod tests {
750751

751752
assert_eq!(
752753
str::from_utf8(&b[12..]).unwrap(),
753-
r#"{"rxpk":[{"time":"1970-01-01T00:00:00+00:00","tmms":1000,"tmst":16909060,"freq":868.3,"chan":1,"rfch":1,"stat":1,"modu":"LORA","datr":"SF12BW125","codr":"4/5","rssi":-160,"lsnr":5.5,"size":3,"data":"AQID"}],"stat":null}"#
754+
r#"{"rxpk":[{"time":"1970-01-01T00:00:00+00:00","tmms":1000,"tmst":16909060,"freq":868.3,"chan":1,"rfch":1,"stat":1,"modu":"LORA","datr":"SF12BW125","codr":"4/5","rssi":-160,"lsnr":5.5,"size":3,"data":"AQID"}]}"#
754755
);
755756
}
756757

@@ -805,7 +806,7 @@ mod tests {
805806

806807
assert_eq!(
807808
str::from_utf8(&b[12..]).unwrap(),
808-
r#"{"rxpk":[{"time":"1970-01-01T00:00:00+00:00","tmms":1000,"tmst":16909060,"freq":868.3,"chan":1,"rfch":2,"stat":1,"modu":"FSK","datr":50000,"codr":null,"rssi":-160,"lsnr":null,"size":3,"data":"AQID"}],"stat":null}"#
809+
r#"{"rxpk":[{"time":"1970-01-01T00:00:00+00:00","tmms":1000,"tmst":16909060,"freq":868.3,"chan":1,"rfch":2,"stat":1,"modu":"FSK","datr":50000,"codr":null,"rssi":-160,"lsnr":null,"size":3,"data":"AQID"}]}"#
809810
);
810811
}
811812

0 commit comments

Comments
 (0)