Handle off byte endian and handle ServieUnavalible in mqtt
This commit is contained in:
3 files changed
+14
-3
No files matched your search
@@ -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)?;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user