From dd9327152590f902bfec14d9a76f0b9591e3d888 Mon Sep 17 00:00:00 2001 From: Satoshi Konno Date: Sat, 10 Dec 2022 04:25:28 +0900 Subject: [PATCH] Update uechopost not to wait when the specified request message does not require the response messages --- examples/uechopost/uechopost.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/examples/uechopost/uechopost.rs b/examples/uechopost/uechopost.rs index c5939db1..a24f00f6 100644 --- a/examples/uechopost/uechopost.rs +++ b/examples/uechopost/uechopost.rs @@ -173,15 +173,25 @@ fn main() { continue; } - let rx = ctrl.post_message(&node, &mut req_msg); - match rx.recv_timeout(Duration::from_secs(1)) { - Ok(res_msg) => { - println!("{}", res_msg); + match req_msg.esv() { + Esv::WriteRequest | Esv::NotificationRequest => { + ctrl.send_message(&node, &mut req_msg); } - Err(e) => { - eprintln!("{}", e); + Esv::WriteRequestResponseRequired | Esv::ReadRequest | Esv::WriteReadRequest => { + let rx = ctrl.post_message(&node, &mut req_msg); + match rx.recv_timeout(Duration::from_secs(1)) { + Ok(res_msg) => { + println!("{}", res_msg); + } + Err(e) => { + eprintln!("{}", e); + } + }; } - }; + _ => { + eprintln!("ESV ({:X}) is not request", req_msg.esv() as u8); + } + } ctrl.stop(); return;