Add message handle and status codes and handel encryption correctly
Co-Authored-By: twistedddx <bits@live.com>
This commit is contained in:
1 parent
25b561c976
commit
dda603a9a4
4 files changed
+13
-2
No files matched your search
+2
-1
@@ -178,7 +178,7 @@ fn bc_header(buf: &[u8]) -> IResult<&[u8], BcHeader> {
|
||||
let (buf, channel_id) = le_u8(buf)?;
|
||||
let (buf, stream_type) = le_u8(buf)?;
|
||||
let (buf, msg_num) = le_u16(buf)?;
|
||||
let (buf, (response_code, _ignored, class)) = tuple((le_u8, le_u8, le_u16))(buf)?;
|
||||
let (buf, (response_code, class)) = tuple((le_u16, le_u16))(buf)?;
|
||||
|
||||
// All modern messages are encrypted. In addition, it seems that the camera firmware checks
|
||||
// this field to see if some other messages should be encrypted. This is still somewhat fuzzy.
|
||||
@@ -195,6 +195,7 @@ fn bc_header(buf: &[u8]) -> IResult<&[u8], BcHeader> {
|
||||
channel_id,
|
||||
stream_type,
|
||||
msg_num,
|
||||
response_code,
|
||||
class,
|
||||
payload_offset,
|
||||
},
|
||||
|
||||
@@ -45,6 +45,7 @@ pub(super) struct BcHeader {
|
||||
pub channel_id: u8,
|
||||
pub stream_type: u8,
|
||||
pub msg_num: u16,
|
||||
pub response_code: u16,
|
||||
pub class: u16,
|
||||
pub payload_offset: Option<u32>,
|
||||
}
|
||||
@@ -56,6 +57,7 @@ pub struct BcMeta {
|
||||
pub msg_id: u32,
|
||||
pub channel_id: u8,
|
||||
pub stream_type: u8,
|
||||
pub response_code: u16,
|
||||
pub msg_num: u16,
|
||||
pub class: u16,
|
||||
}
|
||||
@@ -161,6 +163,7 @@ impl BcHeader {
|
||||
msg_id: self.msg_id,
|
||||
msg_num: self.msg_num,
|
||||
channel_id: self.channel_id,
|
||||
response_code: self.response_code,
|
||||
stream_type: self.stream_type,
|
||||
class: self.class,
|
||||
}
|
||||
@@ -173,6 +176,7 @@ impl BcHeader {
|
||||
msg_id: meta.msg_id,
|
||||
channel_id: meta.channel_id,
|
||||
stream_type: meta.stream_type,
|
||||
response_code: meta.response_code,
|
||||
msg_num: meta.msg_num,
|
||||
class: meta.class,
|
||||
}
|
||||
|
||||
+5
-1
@@ -133,6 +133,7 @@ impl BcCamera {
|
||||
channel_id: self.channel_id,
|
||||
msg_num: self.new_message_num(),
|
||||
stream_type: 0,
|
||||
response_code: 0x01dc,
|
||||
class: 0x6514,
|
||||
},
|
||||
body: BcBody::LegacyMsg(LegacyMsg::LoginMsg {
|
||||
@@ -149,7 +150,7 @@ impl BcCamera {
|
||||
})?;
|
||||
|
||||
let nonce;
|
||||
if let BcMeta {encrypted: true,..} = legacy_reply.meta {
|
||||
if let BcMeta {response_code: 0x01dd,..} = legacy_reply.meta {
|
||||
connection.set_encrypted(true);
|
||||
}
|
||||
match legacy_reply.body {
|
||||
@@ -190,6 +191,7 @@ impl BcCamera {
|
||||
channel_id: self.channel_id,
|
||||
msg_num: self.new_message_num(),
|
||||
stream_type: 0,
|
||||
response_code: 0,
|
||||
class: 0x6414,
|
||||
},
|
||||
BcXml {
|
||||
@@ -257,6 +259,7 @@ impl BcCamera {
|
||||
channel_id: self.channel_id,
|
||||
msg_num: self.new_message_num(),
|
||||
stream_type: 0,
|
||||
response_code: 0,
|
||||
class: 0x6414,
|
||||
},
|
||||
body: BcBody::ModernMsg(ModernMsg {
|
||||
@@ -298,6 +301,7 @@ impl BcCamera {
|
||||
channel_id: self.channel_id,
|
||||
msg_num: self.new_message_num(),
|
||||
stream_type: stream_num,
|
||||
response_code: 0,
|
||||
class: 0x6414, // IDK why
|
||||
},
|
||||
BcXml {
|
||||
|
||||
@@ -14,6 +14,7 @@ impl BcCamera {
|
||||
msg_id: MSG_ID_GET_GENERAL,
|
||||
channel_id: self.channel_id,
|
||||
msg_num: self.new_message_num(),
|
||||
response_code: 0,
|
||||
stream_type: 0,
|
||||
class: 0x6414,
|
||||
},
|
||||
@@ -91,6 +92,7 @@ impl BcCamera {
|
||||
msg_id: MSG_ID_SET_GENERAL,
|
||||
channel_id: self.channel_id,
|
||||
msg_num: self.new_message_num(),
|
||||
response_code: 0,
|
||||
stream_type: 0,
|
||||
class: 0x6414,
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user