dfu_core/
detach.rs

1use super::*;
2
3const REQUEST_TYPE: u8 = 0b00100001;
4const DFU_DETACH: u8 = 0;
5
6/// Command that sends `dfuDETACH` to the device.
7#[must_use]
8pub struct Detach<T> {
9    pub(crate) descriptor: FunctionalDescriptor,
10    pub(crate) chained_command: T,
11}
12
13impl<T> Detach<T> {
14    /// Send the command `dfuDETACH` to the device.
15    pub fn detach(self) -> (T, UsbWriteControl<[u8; 0]>) {
16        log::trace!("Detaching device");
17        let detach_timeout = self.descriptor.detach_timeout;
18        let next = self.chained_command;
19        let control = UsbWriteControl::new(REQUEST_TYPE, DFU_DETACH, detach_timeout, []);
20
21        (next, control)
22    }
23}