From f4bcde6ffc80d482772ca308316b0c79604c4070 Mon Sep 17 00:00:00 2001 From: QuantumEntangledAndy Date: Tue, 3 Aug 2021 18:29:15 +0700 Subject: [PATCH] Actually implement reboot --- crates/core/src/bc_protocol/reboot.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/crates/core/src/bc_protocol/reboot.rs b/crates/core/src/bc_protocol/reboot.rs index 8b16f4f..ce6fe47 100644 --- a/crates/core/src/bc_protocol/reboot.rs +++ b/crates/core/src/bc_protocol/reboot.rs @@ -1,15 +1,15 @@ -use super::{BcCamera, Result, RX_TIMEOUT}; +use super::{BcCamera, Error, Result, RX_TIMEOUT}; use crate::bc::model::*; impl BcCamera { /// Reboot the camera pub fn reboot(&self) -> Result<()> { let connection = self.connection.as_ref().expect("Must be connected to ping"); - let sub_ping = connection.subscribe(MSG_ID_PING)?; + let sub = connection.subscribe(MSG_ID_REBOOT)?; - let ping = Bc { + let msg = Bc { meta: BcMeta { - msg_id: MSG_ID_PING, + msg_id: MSG_ID_REBOOT, channel_id: self.channel_id, msg_num: self.new_message_num(), stream_type: 0, @@ -21,10 +21,19 @@ impl BcCamera { }), }; - sub_ping.send(ping)?; + sub.send(msg)?; + let msg = sub.rx.recv_timeout(RX_TIMEOUT)?; - sub_ping.rx.recv_timeout(RX_TIMEOUT)?; - - Ok(()) + if let BcMeta { + response_code: 200, .. + } = msg.meta + { + Ok(()) + } else { + Err(Error::UnintelligibleReply { + reply: msg, + why: "The camera did not except the TalkConfig xml", + }) + } } }