Skip to main content

zigbee_core/aps/frame/command/
switch_key.rs

1use zigbee_macros::impl_byte;
2
3impl_byte! {
4    /// Switch-Key Command Frame (4.4.10.5, Figure 4-14, command id 0x09)
5    #[derive(Debug, Clone, Copy, PartialEq, Eq)]
6    pub struct SwitchKey {
7        /// Sequence number of the network key to activate
8        pub sequence_number: u8,
9    }
10}
11
12#[cfg(test)]
13mod tests {
14    use byte::TryRead;
15    use byte::TryWrite;
16
17    use crate::aps::frame::command::Command;
18
19    #[test]
20    fn round_trip_switch_key() {
21        let frame_buf = [
22            0x09, // command id: SwitchKey
23            0x07, // sequence number
24        ];
25
26        let (cmd, _) = Command::try_read(&frame_buf, ()).unwrap();
27
28        let mut got_buf = [0u8; _];
29        cmd.try_write(&mut got_buf, ()).unwrap();
30
31        assert_eq!(frame_buf, got_buf);
32    }
33}