mirror of
https://github.com/stakwork/sphinx-key.git
synced 2025-12-17 15:24:32 +01:00
Log MQTT connection states
This commit is contained in:
@@ -50,18 +50,40 @@ pub fn start_listening(
|
|||||||
// must start pumping before subscribe or publish will work
|
// must start pumping before subscribe or publish will work
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
info!("MQTT Listening for messages");
|
info!("MQTT Listening for messages");
|
||||||
|
loop {
|
||||||
while let Some(msg) = connection.next() {
|
match connection.next() {
|
||||||
match msg {
|
Some(msg) => {
|
||||||
Err(e) => info!("MQTT Message ERROR: {}", e),
|
match msg {
|
||||||
Ok(msg) => {
|
Err(e) => match e.to_string().as_ref() {
|
||||||
if let Event::Received(msg) = msg {
|
"ESP_FAIL" => {
|
||||||
tx.send(msg.data().to_vec()).expect("could send to TX");
|
error!("THE ESP BROKE!");
|
||||||
|
},
|
||||||
|
_ => error!("Unknown error: {}", e),
|
||||||
|
},
|
||||||
|
Ok(msg) => {
|
||||||
|
match msg {
|
||||||
|
Event::BeforeConnect => warn!("RECEIVED BEFORE CONNECT MESSAGE"),
|
||||||
|
Event::Connected(flag) => {
|
||||||
|
if flag {
|
||||||
|
warn!("RECEIVED CONNECTED = TRUE MESSAGE");
|
||||||
|
} else {
|
||||||
|
warn!("RECEIVED CONNECTED = FALSE MESSAGE");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Event::Disconnected => warn!("RECEIVED DISCONNECTION MESSAGE"),
|
||||||
|
Event::Subscribed(_mes_id) => warn!("RECEIVED SUBSCRIBED MESSAGE"),
|
||||||
|
Event::Unsubscribed(_mes_id) => warn!("RECEIVED UNSUBSCRIBED MESSAGE"),
|
||||||
|
Event::Published(_mes_id) => warn!("RECEIVED PUBLISHED MESSAGE"),
|
||||||
|
Event::Received(msg) => tx.send(msg.data().to_vec()).expect("could send to TX"),
|
||||||
|
Event::Deleted(_mes_id) => warn!("RECEIVED DELETED MESSAGE"),
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
None => break,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info!("MQTT connection loop exit");
|
//info!("MQTT connection loop exit");
|
||||||
});
|
});
|
||||||
|
|
||||||
// log::info!("lock mqtt mutex guard");
|
// log::info!("lock mqtt mutex guard");
|
||||||
|
|||||||
Reference in New Issue
Block a user