mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-01-12 07:52:45 +00:00
Send ThingsBoard telemetry (f_port, f_cnt, ...) even if object is None.
This commit is contained in:
parent
d98518c5f9
commit
e2bdef757c
@ -117,8 +117,12 @@ impl IntegrationTrait for Integration {
|
|||||||
info!(dev_eui = %di.dev_eui, server = %self.server, "Sending device telemetry");
|
info!(dev_eui = %di.dev_eui, server = %self.server, "Sending device telemetry");
|
||||||
self.send_attributes(vars, &attributes).await?;
|
self.send_attributes(vars, &attributes).await?;
|
||||||
|
|
||||||
if let Some(obj) = &pl.object {
|
let mut telemetry: BTreeMap<String, Value> = if let Some(obj) = &pl.object {
|
||||||
let mut telemetry = struct_to_telemetry(obj);
|
struct_to_telemetry(obj)
|
||||||
|
} else {
|
||||||
|
BTreeMap::new()
|
||||||
|
};
|
||||||
|
|
||||||
telemetry.insert("f_port".to_string(), Value::Integer(pl.f_port.into()));
|
telemetry.insert("f_port".to_string(), Value::Integer(pl.f_port.into()));
|
||||||
telemetry.insert("f_cnt".to_string(), Value::Integer(pl.f_cnt.into()));
|
telemetry.insert("f_cnt".to_string(), Value::Integer(pl.f_cnt.into()));
|
||||||
telemetry.insert("dr".to_string(), Value::Integer(pl.dr.into()));
|
telemetry.insert("dr".to_string(), Value::Integer(pl.dr.into()));
|
||||||
@ -145,9 +149,6 @@ impl IntegrationTrait for Integration {
|
|||||||
|
|
||||||
info!(dev_eui = %di.dev_eui, server = %self.server, "Sending device telemetry");
|
info!(dev_eui = %di.dev_eui, server = %self.server, "Sending device telemetry");
|
||||||
self.send_telemetry(vars, &telemetry).await?;
|
self.send_telemetry(vars, &telemetry).await?;
|
||||||
} else {
|
|
||||||
info!(dev_eui = %di.dev_eui, "No telemetry to send, object is None");
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -336,7 +337,7 @@ pub mod test {
|
|||||||
"test-token".to_string(),
|
"test-token".to_string(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// uplink
|
// uplink with decoded payload
|
||||||
let mut mock_attr = server.mock(|when, then| {
|
let mut mock_attr = server.mock(|when, then| {
|
||||||
when.method(POST)
|
when.method(POST)
|
||||||
.path("/api/v1/test-token/attributes")
|
.path("/api/v1/test-token/attributes")
|
||||||
@ -424,6 +425,69 @@ pub mod test {
|
|||||||
mock_telm.assert();
|
mock_telm.assert();
|
||||||
mock_telm.delete();
|
mock_telm.delete();
|
||||||
|
|
||||||
|
// uplink without decoded payload
|
||||||
|
let mut mock_attr = server.mock(|when, then| {
|
||||||
|
when.method(POST)
|
||||||
|
.path("/api/v1/test-token/attributes")
|
||||||
|
.header("Content-Type", "application/json")
|
||||||
|
.body(r#"{"application_id":"00000000-0000-0000-0000-000000000000","application_name":"test-app","dev_eui":"0102030405060708","device_name":"test-device","foo":"bar"}"#);
|
||||||
|
|
||||||
|
then.status(200);
|
||||||
|
});
|
||||||
|
let mut mock_telm = server.mock(|when, then| {
|
||||||
|
when.method(POST)
|
||||||
|
.path("/api/v1/test-token/telemetry")
|
||||||
|
.header("Content-Type", "application/json")
|
||||||
|
.body(r#"{"dr":2,"f_cnt":20,"f_port":10,"rssi":-55,"snr":2.5}"#);
|
||||||
|
|
||||||
|
then.status(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
i.uplink_event(
|
||||||
|
&vars,
|
||||||
|
&integration::UplinkEvent {
|
||||||
|
device_info: Some(integration::DeviceInfo {
|
||||||
|
application_name: "test-app".to_string(),
|
||||||
|
application_id: Uuid::nil().to_string(),
|
||||||
|
device_name: "test-device".to_string(),
|
||||||
|
dev_eui: "0102030405060708".to_string(),
|
||||||
|
tags: [("foo".to_string(), "bar".to_string())]
|
||||||
|
.iter()
|
||||||
|
.cloned()
|
||||||
|
.collect(),
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
f_port: 10,
|
||||||
|
f_cnt: 20,
|
||||||
|
dr: 2,
|
||||||
|
rx_info: vec![
|
||||||
|
gw::UplinkRxInfo {
|
||||||
|
rssi: -60,
|
||||||
|
snr: 1.0,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
gw::UplinkRxInfo {
|
||||||
|
rssi: -55,
|
||||||
|
snr: 2.5,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
gw::UplinkRxInfo {
|
||||||
|
rssi: -70,
|
||||||
|
snr: 1.0,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
],
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
mock_attr.assert();
|
||||||
|
mock_attr.delete();
|
||||||
|
mock_telm.assert();
|
||||||
|
mock_telm.delete();
|
||||||
|
|
||||||
// location
|
// location
|
||||||
let mut mock_telm = server.mock(|when, then| {
|
let mut mock_telm = server.mock(|when, then| {
|
||||||
when.method(POST)
|
when.method(POST)
|
||||||
|
Loading…
Reference in New Issue
Block a user