Skip to main content

zigbee_core/aps/frame/command/
confirm_key.rs

1use zigbee_macros::impl_byte;
2use zigbee_types::IeeeAddress;
3
4impl_byte! {
5    /// Confirm-Key Command Frame (4.4.10.9, Table 4-27, command id 0x10)
6    #[derive(Debug, Clone, Copy, PartialEq, Eq)]
7    pub struct ConfirmKey {
8        /// Status of the verify-key operation (0x00 = success)
9        pub status: u8,
10        /// Standard key type (0x04 = Trust Center Link Key)
11        pub key_type: u8,
12        /// IEEE address of the destination (the joining node)
13        pub destination_address: IeeeAddress,
14    }
15}
16
17#[cfg(test)]
18mod tests {
19    use byte::TryRead;
20    use byte::TryWrite;
21
22    use crate::aps::frame::command::Command;
23
24    #[test]
25    fn round_trip_confirm_key() {
26        let frame_buf = [
27            0x10, // command id: ConfirmKey
28            0x00, // status: success
29            0x04, // key_type: TC Link Key
30            // destination_address (8 bytes LE)
31            0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
32        ];
33
34        let (cmd, _) = Command::try_read(&frame_buf, ()).unwrap();
35
36        let mut got_buf = [0u8; _];
37        cmd.try_write(&mut got_buf, ()).unwrap();
38
39        assert_eq!(frame_buf, got_buf);
40    }
41}