From 50f6765f3ac1243bbc7498e76687529ed9b0bf04 Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Sat, 2 Dec 2023 08:39:23 +0100 Subject: [PATCH] Pull creating telegram consumers out of main loop --- src/scheduler.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scheduler.rs b/src/scheduler.rs index 5b884ac..8a66cec 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -8,11 +8,11 @@ pub fn main_loop( read_interval: f64, ) { let interval = time::Duration::from_millis((read_interval * 1_000.0).round() as u64); + let mut consumer = dsmr::sender::DelegatingConsumer::new(&api_settings.hosts); loop { { let port = dsmr::reader::connect_to_meter(&serial_settings); - let mut consumer = dsmr::sender::DelegatingConsumer::new(&api_settings.hosts); dsmr::reader::read_from_serial_port(port, &mut consumer);