Skip to content

Commit

Permalink
Implement get_downlink_data_delay config.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brocaar committed Jan 31, 2023
1 parent 7c35fff commit 81ce56a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions chirpstack/src/cmd/configfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
3 changes: 3 additions & 0 deletions chirpstack/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(),
Expand Down
4 changes: 4 additions & 0 deletions chirpstack/src/uplink/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 81ce56a

Please sign in to comment.