diff --git a/chirpstack/src/cmd/configfile.rs b/chirpstack/src/cmd/configfile.rs index 9fde489c..4dc1201b 100644 --- a/chirpstack/src/cmd/configfile.rs +++ b/chirpstack/src/cmd/configfile.rs @@ -166,6 +166,17 @@ pub fn run() { # must be less than the (first) receive-window. deduplication_delay="{{ network.deduplication_delay }}" + # Get downlink data delay. + # + # This is the time that ChirpStack waits between forwarding data to the + # integration(s) and reading data from the queue. A higher value means that + # an end-application has more time to schedule a downlink queue item which + # can be processed within the same uplink / downlink transaction. + # Please note that this value has influence on the uplink / downlink + # roundtrip time. Setting this value too high means ChirpStack will be + # unable to respond to the device within its receive-window. + get_downlink_data_delay="{{ network.get_downlink_data_delay }}" + # Mac-commands disabled. mac_commands_disabled={{ network.mac_commands_disabled }} diff --git a/chirpstack/src/config.rs b/chirpstack/src/config.rs index f46c7cf4..0d090478 100644 --- a/chirpstack/src/config.rs +++ b/chirpstack/src/config.rs @@ -156,6 +156,8 @@ pub struct Network { pub device_session_ttl: Duration, #[serde(with = "humantime_serde")] pub deduplication_delay: Duration, + #[serde(with = "humantime_serde")] + pub get_downlink_data_delay: Duration, pub mac_commands_disabled: bool, pub adr_plugins: Vec, pub scheduler: Scheduler, @@ -169,6 +171,7 @@ impl Default for Network { enabled_regions: vec!["eu868".into()], device_session_ttl: Duration::from_secs(60 * 60 * 24 * 31), deduplication_delay: Duration::from_millis(200), + get_downlink_data_delay: Duration::from_millis(100), mac_commands_disabled: false, adr_plugins: vec![], scheduler: Default::default(), diff --git a/chirpstack/src/uplink/data.rs b/chirpstack/src/uplink/data.rs index 47fcd83c..35df0fd4 100644 --- a/chirpstack/src/uplink/data.rs +++ b/chirpstack/src/uplink/data.rs @@ -983,6 +983,10 @@ impl Data { async fn start_downlink_data_flow(&mut self) -> Result<()> { trace!("Starting downlink data flow"); + + let conf = config::get(); + tokio::time::sleep(conf.network.get_downlink_data_delay).await; + if let lrwn::Payload::MACPayload(pl) = &self.uplink_frame_set.phy_payload.payload { downlink::data::Data::handle_response( self.uplink_frame_set.clone(),