Skip to content

Commit b003a34

Browse files
committed
Move heartbeat_interval config option.
1 parent 6add599 commit b003a34

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/config.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub struct Configuration {
1717
pub mesh: Mesh,
1818
pub backend: Backend,
1919
pub mappings: Mappings,
20+
pub events: Events,
2021
}
2122

2223
impl Configuration {
@@ -56,8 +57,6 @@ impl Default for Logging {
5657
#[serde(default)]
5758
pub struct Mesh {
5859
pub signing_key: Aes128Key,
59-
#[serde(with = "humantime_serde")]
60-
pub heartbeat_interval: Duration,
6160
pub frequencies: Vec<u32>,
6261
pub data_rate: DataRate,
6362
pub tx_power: i32,
@@ -72,7 +71,6 @@ impl Default for Mesh {
7271
fn default() -> Self {
7372
Mesh {
7473
signing_key: Aes128Key::null(),
75-
heartbeat_interval: Duration::from_secs(300),
7674
frequencies: vec![868100000, 868300000, 868500000],
7775
data_rate: DataRate {
7876
modulation: Modulation::LORA,
@@ -155,6 +153,21 @@ pub struct DataRate {
155153
pub bitrate: u32,
156154
}
157155

156+
#[derive(Serialize, Deserialize, PartialEq, Eq)]
157+
#[serde(default)]
158+
pub struct Events {
159+
#[serde(with = "humantime_serde")]
160+
pub heartbeat_interval: Duration,
161+
}
162+
163+
impl Default for Events {
164+
fn default() -> Self {
165+
Events {
166+
heartbeat_interval: Duration::from_secs(300),
167+
}
168+
}
169+
}
170+
158171
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default)]
159172
#[allow(non_camel_case_types)]
160173
#[allow(clippy::upper_case_acronyms)]

src/heartbeat.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ use crate::packets;
1515
pub async fn setup(conf: &Configuration) -> Result<()> {
1616
// Only Relay gatewways need to report heartbeat as the Border Gateway is already internet
1717
// connected and reports status through the Concentratord.
18-
if conf.mesh.border_gateway || conf.mesh.heartbeat_interval.is_zero() {
18+
if conf.mesh.border_gateway || conf.events.heartbeat_interval.is_zero() {
1919
return Ok(());
2020
}
2121

2222
info!(
2323
"Starting heartbeat loop, heartbeat_interval: {:?}",
24-
conf.mesh.heartbeat_interval
24+
conf.events.heartbeat_interval
2525
);
2626

2727
tokio::spawn({
28-
let heartbeat_interval = conf.mesh.heartbeat_interval;
28+
let heartbeat_interval = conf.events.heartbeat_interval;
2929

3030
async move {
3131
loop {

0 commit comments

Comments
 (0)