upload

fun upload(data: ByteArray, image: Int = 0, windowCapacity: Int = 1, memoryAlignment: Int = 1): Flow<TransferState<Unit>>

Uploads the whole image to the device.

The upload starts when the flow is collected, and is cancelled when the collection is. The upload may be paused, resumed and cancelled using the controller from TransferState.Started. If the device already has a part of the same image, the upload continues from there.

Note, that this only uploads the image. To test, confirm and reset the device after, use no.nordicsemi.android.mcumgr.ktx.dfu.FirmwareUpgradeManagerKtx.

Parameters

data

The image data.

image

The index of the image, 0 for the first core, 1 for the second, etc.

windowCapacity

The number of packets sent without waiting for the response. Use 1 if the device does not support the window upload, or a number up to the number of buffers on the device (see buf_count in the response of the params command).

memoryAlignment

The alignment of the packets, used when the window capacity is 2 or more. Each packet is trimmed to a size that is a multiple of this value.

Throws

if the upload fails.