Added reboot to neolink-core

This commit is contained in:
QuantumEntangledAndy committed 2021-08-02 15:20:20 +07:00
1 parent 4680ec4c2b
commit 5d4488ad33
4 files changed
+62

No files matched your search

+2
View File
@@ -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
+1
View File
@@ -15,6 +15,7 @@ mod login;
mod logout;
mod media_packet;
mod ping;
mod reboot;
mod stream;
mod time;
mod version;
+40
View File
@@ -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",
})
}
}
}
+19
View File
@@ -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: `<VideoInput>` (write)
- Client