1use cmds::{CommandClass, Message};
2use error::{Error, ErrorKind};
3
4
5#[derive(Debug, Clone)]
6pub struct Basic;
7
8impl Basic {
9 pub fn set(node_id: u8, value: u8) -> Message {
12 Message::new(node_id, CommandClass::BASIC, 0x01, vec!(value))
13 }
14
15 pub fn get(node_id: u8) -> Message {
18 Message::new(node_id, CommandClass::BASIC, 0x02, vec!())
19 }
20
21 pub fn report<M>(msg: M) -> Result<u8, Error>
23 where M: Into<Vec<u8>> {
24 let msg = msg.into();
26
27 if msg.len() != 6 {
29 return Err(Error::new(ErrorKind::UnknownZWave, "Message is to short"));
30 }
31
32 if msg[3] != CommandClass::BASIC as u8 || msg[4] != 0x03 {
34 return Err(Error::new(ErrorKind::UnknownZWave, "Answer contained wrong command class"));
35 }
36
37 Ok(msg[5])
39 }
40}