osdp/messages/acu/command/
led.rs

1use crate::{
2    messages::command::{CommandType, OSDPCommand},
3    models::command::led::ReaderLEDControl,
4};
5
6impl OSDPCommand for ReaderLEDControl<'_> {
7    fn cmnd(&self) -> CommandType {
8        CommandType::LEDControl
9    }
10
11    fn build_command_data(&self) -> Vec<u8> {
12        self.led_states
13            .iter()
14            .flat_map(|lcs| {
15                let temporary_timer_bytes = lcs.temporary_timer.to_le_bytes();
16
17                [
18                    lcs.reader_number,
19                    lcs.led,
20                    lcs.temporary_control_code as u8,
21                    lcs.temporary_on_time,
22                    lcs.temporary_off_time,
23                    lcs.temporary_on_color as u8,
24                    lcs.temporary_off_color as u8,
25                    temporary_timer_bytes[0],
26                    temporary_timer_bytes[1],
27                    lcs.permanent_control_code as u8,
28                    lcs.permanent_on_time,
29                    lcs.permanent_off_time,
30                    lcs.permanent_on_color as u8,
31                    lcs.permanent_off_color as u8,
32                ]
33            })
34            .collect::<Vec<u8>>()
35    }
36}