embassy-usb

Crates

git

Versions

default

Flavors

Handler

Trait Handler 

Source
pub trait Handler {
    // Required methods
    fn start(&mut self);
    fn write(&mut self, data: &[u8]) -> Result<(), Status>;
    fn finish(&mut self) -> Result<(), Status>;
    fn system_reset(&mut self);
}
Expand description

Handler trait for DFU bootloader mode.

Implement this trait to handle firmware download operations.

Required Methods§

Source

fn start(&mut self)

Called when a firmware download starts.

This is called when the first DFU_DNLOAD request is received.

Source

fn write(&mut self, data: &[u8]) -> Result<(), Status>

Called to write a chunk of firmware data.

Returns Ok(()) on success, or a Status error on failure.

Source

fn finish(&mut self) -> Result<(), Status>

Called when the firmware download is complete.

This is called when a zero-length DFU_DNLOAD is received, indicating the end of the firmware data. This is where you would typically mark the firmware as ready to boot.

Returns Ok(()) on success, or a Status error on failure.

Source

fn system_reset(&mut self)

Called at the end of the DFU procedure.

This is typically where you would perform a system reset to boot the new firmware after a successful download.

Implementors§