openlifu.io.LIFUDFU.STM32I2CDFUviaMaster

class openlifu.io.LIFUDFU.STM32I2CDFUviaMaster(uart: LIFUUart, i2c_addr: int = 114, write_read_delay_s: float = 0.005)[source]

Bases: object

I2C DFU client that routes all I2C transactions through the USB-master module via the OW_I2C_PASSTHRU UART packet type.

The master firmware receives the passthrough request and executes the raw I2C write (and optional read) on the global I2C bus toward the slave DFU bootloader at i2c_addr (default 0x72).

Packet wire format used:

packetType = OW_I2C_PASSTHRU (0xE9)
addr       = 7-bit I2C slave address
command    = 0x00  write-only
           = 0x01  write, 5 ms delay, read back <reserved> bytes
reserved   = number of bytes to read back (command 0x01 only, max 255)
data       = raw bytes to write
_exchange(payload: bytes, read_len: int, pre_read_delay_s: float | None = None) bytes[source]

Write payload to the I2C slave and read read_len bytes back.

The firmware executes a combined write+read transaction and inserts a fixed 5 ms gap between the write and read phases internally. The optional pre_read_delay_s parameter adds an extra host-side delay before issuing the passthrough transaction (i.e. before the firmware performs the write+read). This does not change the internal 5 ms gap handled by the firmware and is rarely needed.

_write(payload: bytes) None[source]

Send a write-only passthrough packet to the I2C slave.

erase_page(address: int) None[source]

Erase the flash page containing address.

get_status() dict[source]

Send CMD_GETSTATUS and return status/state.

get_version() str[source]

Read the null-terminated bootloader version string.

manifest() None[source]

Send CMD_MANIFEST to finalise the download and lock flash.

mass_erase() None[source]

Erase the entire application flash region (sentinel addr = 0xFFFFFFFF).

reset() None[source]

Send CMD_RESET; the device reboots immediately (no response).

write_block(address: int, data: bytes) None[source]

Program one block (≤ I2C_DFU_MAX_XFER_SIZE bytes).

write_memory(address: int, data: bytes, progress_callback: Callable | None = None) None[source]

Write arbitrary-length data in I2C_DFU_MAX_XFER_SIZE-byte chunks.