sphinx-key: delete standalone heartbeat loop

just pulse the hearbeat everytime expected_sequence % 40 == 0
This commit is contained in:
irriden
2023-08-03 23:55:08 +00:00
parent 5b8323e1db
commit 3c6ce1ffa6
2 changed files with 6 additions and 11 deletions

View File

@@ -34,7 +34,6 @@ pub enum Event {
VlsMessage(Vec<u8>),
LssMessage(Vec<u8>),
Control(Vec<u8>),
HeartBeat,
}
pub const ROOT_STORE: &str = "/sdcard/store";
@@ -147,6 +146,12 @@ pub fn make_event_loop(
let flash_db = ctrlr.persister();
let mut expected_sequence = None;
while let Ok(event) = rx.recv() {
if let Some(seq) = expected_sequence {
if seq % 40 == 0 {
log::info!("get heartbeat!");
let _ = root_handler.node().get_heartbeat();
}
}
match event {
Event::Connected => {
log::info!("GOT A Event::Connected msg!");
@@ -160,10 +165,6 @@ pub fn make_event_loop(
led_tx.send(Status::ConnectingToMqtt).unwrap();
log::info!("GOT A Event::Disconnected msg!");
}
Event::HeartBeat => {
log::info!("Beating the heart!");
let _ = root_handler.node().get_heartbeat();
}
Event::VlsMessage(msg_bytes) => {
led_tx.send(Status::Signing).unwrap();
let state1 = approver.control().get_state();

View File

@@ -193,12 +193,6 @@ fn make_and_launch_client(
log::info!(">>>>>>>>>>> blocking forever...");
log::info!("{:?}", config);
// heartbeat loop
thread::spawn(move || loop {
thread::sleep(Duration::from_secs(60));
let _ = tx.send(Event::HeartBeat);
});
make_event_loop(
mqtt_client,
rx,