Skip to content

Commit e65b8e6

Browse files
committed
Add heartbeat interval constant
1 parent 7744fd2 commit e65b8e6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/connections/handlers.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ use crate::connections::stream_buffer::StreamBuffer;
1616

1717
use super::wrappers::encoded_data::IncomingStreamData;
1818

19+
/// Interval for sending heartbeat packets to the radio (in seconds).
20+
/// Needs to be less than this: https://github.com/meshtastic/firmware/blob/eb372c190ec82366998c867acc609a418130d842/src/SerialConsole.cpp#L8
21+
pub const SERIAL_HEARTBEAT_INTERVAL: u64 = 5 * 60; // 5 minutes
22+
1923
pub fn spawn_read_handler<R>(
2024
cancellation_token: CancellationToken,
2125
read_stream: R,
@@ -212,7 +216,7 @@ where
212216
debug!("Started heartbeat handler");
213217

214218
loop {
215-
tokio::time::sleep(std::time::Duration::from_secs(5 * 60)).await;
219+
tokio::time::sleep(std::time::Duration::from_secs(SERIAL_HEARTBEAT_INTERVAL)).await;
216220

217221
let mut write_stream = write_stream.lock().await;
218222

@@ -235,6 +239,8 @@ where
235239
},
236240
));
237241
}
242+
243+
log::info!("Sent heartbeat packet");
238244
}
239245

240246
// debug!("Heartbeat handler finished");

0 commit comments

Comments
 (0)