Actually implement reboot
This commit is contained in:
1 parent
a86565f68b
commit
f4bcde6ffc
1 file changed
+17
-8
@@ -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",
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user