Merge pull request #87 from stakwork/fix/fake-heartbeat

Fix/fake heartbeat
This commit is contained in:
Evan Feenstra
2023-06-27 13:17:12 -07:00
committed by GitHub
3 changed files with 18 additions and 7 deletions

10
Cargo.lock generated
View File

@@ -1189,7 +1189,7 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
[[package]]
name = "lss-connector"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git#b84522dd596606aea9899969fe0d3f68d4eb6632"
source = "git+https://github.com/stakwork/sphinx-rs.git#ef1df1371273293aaa353a477c0a6272eda96270"
dependencies = [
"anyhow",
"log",
@@ -1757,7 +1757,7 @@ dependencies = [
[[package]]
name = "sphinx-auther"
version = "0.1.12"
source = "git+https://github.com/stakwork/sphinx-rs.git#b84522dd596606aea9899969fe0d3f68d4eb6632"
source = "git+https://github.com/stakwork/sphinx-rs.git#ef1df1371273293aaa353a477c0a6272eda96270"
dependencies = [
"anyhow",
"base64",
@@ -1769,7 +1769,7 @@ dependencies = [
[[package]]
name = "sphinx-crypter"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git#b84522dd596606aea9899969fe0d3f68d4eb6632"
source = "git+https://github.com/stakwork/sphinx-rs.git#ef1df1371273293aaa353a477c0a6272eda96270"
dependencies = [
"anyhow",
"chacha20poly1305",
@@ -1780,7 +1780,7 @@ dependencies = [
[[package]]
name = "sphinx-glyph"
version = "0.1.2"
source = "git+https://github.com/stakwork/sphinx-rs.git#b84522dd596606aea9899969fe0d3f68d4eb6632"
source = "git+https://github.com/stakwork/sphinx-rs.git#ef1df1371273293aaa353a477c0a6272eda96270"
dependencies = [
"anyhow",
"hex",
@@ -1832,7 +1832,7 @@ dependencies = [
[[package]]
name = "sphinx-signer"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git#b84522dd596606aea9899969fe0d3f68d4eb6632"
source = "git+https://github.com/stakwork/sphinx-rs.git#ef1df1371273293aaa353a477c0a6272eda96270"
dependencies = [
"anyhow",
"bip39",

View File

@@ -13,7 +13,7 @@ use sphinx_signer::sphinx_glyph::control::{
};
use sphinx_signer::sphinx_glyph::error::Error as GlyphError;
use sphinx_signer::sphinx_glyph::topics;
use sphinx_signer::{self, RootHandler};
use sphinx_signer::{self, Handler, RootHandler};
use std::sync::mpsc;
use std::sync::Arc;
use std::thread;
@@ -32,6 +32,7 @@ pub enum Event {
VlsMessage(Vec<u8>),
LssMessage(Vec<u8>),
Control(Vec<u8>),
HeartBeat,
}
pub const ROOT_STORE: &str = "/sdcard/store";
@@ -148,6 +149,9 @@ pub fn make_event_loop(
led_tx.send(Status::ConnectingToMqtt).unwrap();
log::info!("GOT A Event::Disconnected msg!");
}
Event::HeartBeat => {
let _ = root_handler.node().get_heartbeat();
}
Event::VlsMessage(msg_bytes) => {
led_tx.send(Status::Signing).unwrap();
let state1 = approver.control().get_state();

View File

@@ -159,7 +159,8 @@ fn make_and_launch_client(
log::info!("PUBKEY {} TOKEN {}", &pubkey_str, &token);
let client_id = random_word(8);
let mqtt_client = conn::mqtt::make_client(&config.broker, &client_id, &pubkey_str, &token, tx)?;
let mqtt_client =
conn::mqtt::make_client(&config.broker, &client_id, &pubkey_str, &token, tx.clone())?;
// let mqtt_client = conn::mqtt::start_listening(mqtt, connection, tx)?;
// this blocks forever... the "main thread"
@@ -168,6 +169,12 @@ 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,