diff --git a/crates/core/src/bc/model.rs b/crates/core/src/bc/model.rs index 7c2864c..60c91e8 100644 --- a/crates/core/src/bc/model.rs +++ b/crates/core/src/bc/model.rs @@ -10,6 +10,8 @@ pub const MSG_ID_LOGIN: u32 = 1; pub const MSG_ID_LOGOUT: u32 = 2; /// Video and Audio Streams messages have this ID pub const MSG_ID_VIDEO: u32 = 3; +/// Reboot messages have this ID +pub const MSG_ID_REBOOT: u32 = 23; /// Version messages have this ID pub const MSG_ID_VERSION: u32 = 80; /// Ping messages have this ID diff --git a/crates/core/src/bc_protocol.rs b/crates/core/src/bc_protocol.rs index a349537..ede23b4 100644 --- a/crates/core/src/bc_protocol.rs +++ b/crates/core/src/bc_protocol.rs @@ -15,6 +15,7 @@ mod login; mod logout; mod media_packet; mod ping; +mod reboot; mod stream; mod time; mod version; diff --git a/crates/core/src/bc_protocol/reboot.rs b/crates/core/src/bc_protocol/reboot.rs new file mode 100644 index 0000000..b9303ad --- /dev/null +++ b/crates/core/src/bc_protocol/reboot.rs @@ -0,0 +1,40 @@ +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 = connection.subscribe(MSG_ID_REBOOT)?; + + let msg = Bc { + meta: BcMeta { + msg_id: MSG_ID_REBOOT, + channel_id: self.channel_id, + msg_num: self.new_message_num(), + stream_type: 0, + response_code: 0, + class: 0x6414, + }, + body: BcBody::ModernMsg(ModernMsg { + ..Default::default() + }), + }; + + sub.send(msg)?; + + let msg = sub.rx.recv_timeout(RX_TIMEOUT)?; + + if let BcMeta { + response_code: 200, .. + } = msg.meta + { + Ok(()) + } else { + Err(Error::UnintelligibleReply { + reply: msg, + why: "The camera did not accept the reboot request", + }) + } + } +} diff --git a/dissector/messages.md b/dissector/messages.md index bddf73d..c200b2e 100644 --- a/dissector/messages.md +++ b/dissector/messages.md @@ -346,6 +346,25 @@ a PR to improve it. |--------------|--------------|----------------|-------------------|-------------------|---------------|---------------| | 0a bc de f0 | 00 00 00 12 | 00 00 00 00 | 1e 00 00 00 | c8 00 | 00 00 | 00 00 00 00 | +- 23: `Reboot` + + - Client + + - Header + + | Magic | Message ID | Message Length | Encryption Offset | Status Code | Message Class | Binary Offset | + |--------------|--------------|----------------|-------------------|-------------------|---------------|---------------| + | 0a bc de f0 | 00 00 00 17 | 00 00 00 00 | 00 00 00 00 | 00 00 | 64 14 | 00 00 00 00 | + + + - Camera + + - Header + + | Magic | Message ID | Message Length | Encryption Offset | Status Code | Message Class | Binary Offset | + |--------------|--------------|----------------|-------------------|-------------------|---------------|---------------| + | 0a bc de f0 | 00 00 00 17 | 00 00 00 00 | 00 00 00 00 | c8 00 | 64 14 | 00 00 00 00 | + - 25: `` (write) - Client