Implement get_downlink_data_delay config.

This config option was present in v3 to set a delay before starting the
downlink flow (Class-A) so that an end-application can enqueue a
downlink to be used within the same uplink / downlink transaction.
However, this option was still missing in v4.
This commit is contained in:
Orne Brocaar 2023-01-31 11:28:18 +00:00
parent 7c35fff849
commit 81ce56a9a0
3 changed files with 18 additions and 0 deletions

View File

@ -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 }}

View File

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

View File

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