diff --git a/src/bc/de.rs b/src/bc/de.rs index 1ce15db..c2c7ea5 100644 --- a/src/bc/de.rs +++ b/src/bc/de.rs @@ -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, }, diff --git a/src/bc/model.rs b/src/bc/model.rs index a508192..05d12fb 100644 --- a/src/bc/model.rs +++ b/src/bc/model.rs @@ -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, } @@ -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, } diff --git a/src/bc_protocol.rs b/src/bc_protocol.rs index 586d781..6b29054 100644 --- a/src/bc_protocol.rs +++ b/src/bc_protocol.rs @@ -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 { diff --git a/src/bc_protocol/time.rs b/src/bc_protocol/time.rs index 98f4d92..c87ab2d 100644 --- a/src/bc_protocol/time.rs +++ b/src/bc_protocol/time.rs @@ -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, },