Implement ping command (not used yet)

This commit is contained in:
George Hilliard committed 2020-05-09 15:52:06 -05:00
1 parent 4aaec0d72c
commit 8908c7f62e
2 files changed
+24

No files matched your search

+1
View File
@@ -5,6 +5,7 @@ pub(super) const MAGIC_HEADER: u32 = 0xabcdef0;
pub const MSG_ID_LOGIN: u32 = 1;
pub const MSG_ID_VIDEO: u32 = 3;
pub const MSG_ID_PING: u32 = 93;
pub const EMPTY_LEGACY_PASSWORD: &str = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
+23
View File
@@ -192,6 +192,29 @@ impl BcCamera {
Ok(())
}
pub fn ping(&self) -> Result<()> {
let connection = self.connection.as_ref().expect("Must be connected to ping");
let sub_ping = connection.subscribe(MSG_ID_PING)?;
let ping = Bc {
meta: BcMeta {
msg_id: MSG_ID_PING,
client_idx: 0,
encrypted: true,
class: 0x6414,
},
body: BcBody::ModernMsg(ModernMsg {
..Default::default()
}),
};
sub_ping.send(ping)?;
sub_ping.rx.recv_timeout(self.rx_timeout)?;
Ok(())
}
pub fn start_video(&self, data_out: &mut dyn Write) -> Result<()> {
let connection = self.connection.as_ref().expect("Must be connected to start video");
let sub_video = connection.subscribe(MSG_ID_VIDEO)?;