Remove incorrect code for now

This commit is contained in:
Kevin David committed 2023-01-25 22:52:45 -05:00
1 parent 6be7ac2d14
commit 355cd4846a
2 files changed
+12 -70

No files matched your search

@@ -2,55 +2,8 @@ use super::{BcCamera, Error, Result, RX_TIMEOUT};
use crate::bc::{model::*, xml::*};
impl BcCamera {
/// Get the [FloodlightStatusList] xml which contains the Floodlist status of the camera
pub fn get_floodlight_status(&self) -> Result<FloodlightStatusList> {
let connection = self.get_connection();
let msg_num = self.new_message_num();
let sub_get = connection.subscribe(msg_num)?;
let get = Bc {
meta: BcMeta {
msg_id: MSG_ID_FLOODLIGHT_STATUS_LIST,
channel_id: self.channel_id,
msg_num,
response_code: 0,
stream_type: 0,
class: 0x6414,
},
body: BcBody::ModernMsg(ModernMsg {
extension: Some(Extension {
channel_id: Some(self.channel_id),
..Default::default()
}),
payload: None,
}),
};
sub_get.send(get)?;
let msg = sub_get.rx.recv_timeout(RX_TIMEOUT)?;
if msg.meta.response_code != 200 {
return Err(Error::CameraServiceUnavaliable);
}
if let BcBody::ModernMsg(ModernMsg {
payload:
Some(BcPayloads::BcXml(BcXml {
floodlight_status_list: Some(floodlight_status_list),
..
})),
..
}) = msg.body
{
Ok(floodlight_status_list)
} else {
Err(Error::UnintelligibleReply {
reply: Box::new(msg),
why: "Expected FloodlightStatusList xml but it was not recieved",
})
}
}
/// Set the floodlight status using the [FloodlightManual] xml
pub fn set_floodlight_manual(&self, floodlight_manual: FloodlightManual) -> Result<()> {
pub fn set_floodlight_manual(&self, state: bool, duration: u16) -> Result<()> {
let connection = self.get_connection();
let msg_num = self.new_message_num();
@@ -71,7 +24,15 @@ impl BcCamera {
..Default::default()
}),
payload: Some(BcPayloads::BcXml(BcXml {
floodlight_manual: Some(floodlight_manual),
floodlight_manual: Some(FloodlightManual {
version: "1".to_string(),
channel_id: self.channel_id,
status: match state {
true => 1,
false => 0,
},
duration: duration,
}),
..Default::default()
})),
}),
@@ -93,23 +54,4 @@ impl BcCamera {
}
}
/// Set the floodlight status for a duration
pub fn floodlight_light_set(&self, state: bool, duration: u16) -> Result<()> {
let mut floodlight_state = self.get_floodlight_status()?;
for floodlight in floodlight_state.floodlight_status_list.iter_mut() {
if floodlight.channel_id == self.channel_id {
self.set_floodlight_manual(FloodlightManual {
version: "1".to_string(),
channel_id: floodlight.channel_id,
status: match state {
true => 1,
false => 0,
},
duration: duration,
})?;
}
}
Ok(())
}
}
+2 -2
View File
@@ -266,7 +266,7 @@ impl MessageHandler {
}
}
Messages::FloodlightOn => {
let res = self.camera.floodlight_light_set(true, 180);
let res = self.camera.set_floodlight_manual(true, 180);
if res.is_err() {
error!("Failed to turn on the floodlight light: {:?}", res.err());
self.abort();
@@ -276,7 +276,7 @@ impl MessageHandler {
}
}
Messages::FloodlightOff => {
let res = self.camera.floodlight_light_set(false, 180);
let res = self.camera.set_floodlight_manual(false, 180);
if res.is_err() {
error!("Failed to turn off the floodlight light: {:?}", res.err());
self.abort();