diff --git a/crates/core/src/bc_protocol/floodlight_status.rs b/crates/core/src/bc_protocol/floodlight_status.rs index d682a40..27f87ef 100644 --- a/crates/core/src/bc_protocol/floodlight_status.rs +++ b/crates/core/src/bc_protocol/floodlight_status.rs @@ -77,18 +77,25 @@ impl BcCamera { }; sub_set.send(get).await?; - let msg = sub_set.recv().await?; - if let BcMeta { - response_code: 200, .. - } = msg.meta + if let Ok(reply) = + tokio::time::timeout(tokio::time::Duration::from_micros(500), sub_set.recv()).await { - Ok(()) + let msg = reply?; + if let BcMeta { + response_code: 200, .. + } = msg.meta + { + Ok(()) + } else { + Err(Error::UnintelligibleReply { + reply: std::sync::Arc::new(Box::new(msg)), + why: "The camera did not accept the Floodlight manual state", + }) + } } else { - Err(Error::UnintelligibleReply { - reply: std::sync::Arc::new(Box::new(msg)), - why: "The camera did not accept the Floodlight manual state", - }) + // Some cameras seem to just not send a reply on success, so after 500ms we return Ok + Ok(()) } } } diff --git a/crates/core/src/bc_protocol/ledstate.rs b/crates/core/src/bc_protocol/ledstate.rs index 472a8ea..7acca2e 100644 --- a/crates/core/src/bc_protocol/ledstate.rs +++ b/crates/core/src/bc_protocol/ledstate.rs @@ -83,18 +83,25 @@ impl BcCamera { }; sub_set.send(get).await?; - let msg = sub_set.recv().await?; - - if let BcMeta { - response_code: 200, .. - } = msg.meta + if let Ok(reply) = + tokio::time::timeout(tokio::time::Duration::from_micros(500), sub_set.recv()).await { - Ok(()) + let msg = reply?; + + if let BcMeta { + response_code: 200, .. + } = msg.meta + { + Ok(()) + } else { + Err(Error::UnintelligibleReply { + reply: std::sync::Arc::new(Box::new(msg)), + why: "The camera did not except the LEDState xml", + }) + } } else { - Err(Error::UnintelligibleReply { - reply: std::sync::Arc::new(Box::new(msg)), - why: "The camera did not except the LEDState xml", - }) + // Some cameras seem to just not send a reply on success, so after 500ms we return Ok + Ok(()) } } diff --git a/crates/core/src/bc_protocol/pirstate.rs b/crates/core/src/bc_protocol/pirstate.rs index aa340e8..bbd223b 100644 --- a/crates/core/src/bc_protocol/pirstate.rs +++ b/crates/core/src/bc_protocol/pirstate.rs @@ -94,21 +94,28 @@ impl BcCamera { }; sub_set.send(get).await?; - let msg = sub_set.recv().await?; - if msg.meta.response_code != 200 { - return Err(Error::CameraServiceUnavaliable); - } - - if let BcMeta { - response_code: 200, .. - } = msg.meta + if let Ok(reply) = + tokio::time::timeout(tokio::time::Duration::from_micros(500), sub_set.recv()).await { - Ok(()) + let msg = reply?; + if msg.meta.response_code != 200 { + return Err(Error::CameraServiceUnavaliable); + } + + if let BcMeta { + response_code: 200, .. + } = msg.meta + { + Ok(()) + } else { + Err(Error::UnintelligibleReply { + reply: std::sync::Arc::new(Box::new(msg)), + why: "The camera did not except the RfAlarmCfg xml", + }) + } } else { - Err(Error::UnintelligibleReply { - reply: std::sync::Arc::new(Box::new(msg)), - why: "The camera did not except the RfAlarmCfg xml", - }) + // Some cameras seem to just not send a reply on success, so after 500ms we return Ok + Ok(()) } }