use cmds::{CommandClass, Message};
use error::{Error, ErrorKind};
#[derive(Debug, Clone)]
pub struct Basic;
impl Basic {
pub fn set(node_id: u8, value: u8) -> Message {
Message::new(node_id, CommandClass::BASIC, 0x01, vec!(value))
}
pub fn get(node_id: u8) -> Message {
Message::new(node_id, CommandClass::BASIC, 0x02, vec!())
}
pub fn report<M>(msg: M) -> Result<u8, Error>
where M: Into<Vec<u8>> {
let msg = msg.into();
if msg.len() != 6 {
return Err(Error::new(ErrorKind::UnknownZWave, "Message is to short"));
}
if msg[3] != CommandClass::BASIC as u8 || msg[4] != 0x03 {
return Err(Error::new(ErrorKind::UnknownZWave, "Answer contained wrong command class"));
}
Ok(msg[5])
}
}