Actually implement reboot

This commit is contained in:
QuantumEntangledAndy committed 2021-08-03 18:29:15 +07:00
1 parent e3ac3089aa
commit 4de0185fc2
1 file changed
+17 -8
+17 -8
View File
@@ -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",
})
}
}
}