diff --git a/crates/core/src/bc/de.rs b/crates/core/src/bc/de.rs index 2029f6a..eb22a3e 100644 --- a/crates/core/src/bc/de.rs +++ b/crates/core/src/bc/de.rs @@ -198,7 +198,7 @@ fn bc_modern_msg<'a>( fn bc_header(buf: &[u8]) -> IResult<&[u8], BcHeader> { let (buf, _magic) = - error_context("Magic invalid", verify(le_u32, |x| *x == MAGIC_HEADER))(buf)?; + error_context("Magic invalid", verify(le_u32, |x| *x == MAGIC_HEADER || *x == MAGIC_HEADER_REV))(buf)?; let (buf, msg_id) = error_context("MsgID missing", le_u32)(buf)?; let (buf, body_len) = error_context("BodyLen missing", le_u32)(buf)?; let (buf, channel_id) = error_context("ChannelID missing", le_u8)(buf)?; diff --git a/crates/core/src/bc/model.rs b/crates/core/src/bc/model.rs index f7d6996..54b5cb6 100644 --- a/crates/core/src/bc/model.rs +++ b/crates/core/src/bc/model.rs @@ -3,7 +3,11 @@ use crate::Credentials; pub use super::xml::{BcPayloads, BcXml, Extension}; use std::collections::HashSet; -pub(super) const MAGIC_HEADER: u32 = 0xabcdef0; +pub(super) const MAGIC_HEADER: u32 = 0x0abcdef0; +/// Sometimes will get the BE magic header even though all other numbers are LE? +/// Seems to happens with certain messages like snap that produce jpegs, so perhaps it +/// it is meant to be a hint as to the endianess of the binary payload +pub(super) const MAGIC_HEADER_REV: u32 = 0x0fedcba0; /// Login messages have this ID pub const MSG_ID_LOGIN: u32 = 1; diff --git a/src/mqtt/event_cam.rs b/src/mqtt/event_cam.rs index 47ac601..7e34d3a 100644 --- a/src/mqtt/event_cam.rs +++ b/src/mqtt/event_cam.rs @@ -381,11 +381,15 @@ impl SnapThread { tries = 1; info } - Err(neolink_core::Error::UnintelligibleReply { .. }) => { + Err(neolink_core::Error::UnintelligibleReply { reply, why }) => { + log::debug!("Reply: {:?}, why: {:?}", reply, why); // Try again later tries += 1; continue; } + Err(neolink_core::Error::CameraServiceUnavaliable) => { + futures::future::pending().await + } Err(e) => return Err(e.into()), }; self.tx.send(Messages::Snap(snapshot)).await?; @@ -414,6 +418,9 @@ impl BatteryLevelThread { tries += 1; continue; } + Err(neolink_core::Error::CameraServiceUnavaliable) => { + futures::future::pending().await + } Err(e) => return Err(e.into()), }; self.tx