ImageManager

Image command-group manager. This manager can read the image state of a device, test or confirm images, and perform image uploads to the spare image slot. Once initialized, an ImageManager can perform multiple image uploads, but can only handle performing one at a time.

It is important to note that image upload is only one step in a firmware upgrade. To perform a full firmware upgrade use FirmwareUpgradeManager.

See also

Constructors

Link copied to clipboard
constructor(@NotNull transport: @NotNull McuMgrTransport)
Construct an image manager.

Types

Link copied to clipboard
open inner class CoreDownload : Download
Core Download Implementation
Link copied to clipboard
open inner class ImageUpload : Upload
Image Upload Implementation
Link copied to clipboard
Callback for upload command.
Link copied to clipboard
Link copied to clipboard

Properties

Link copied to clipboard
val STATE_NONE: Int = 0
Link copied to clipboard
val STATE_PAUSED: Int = 2
Link copied to clipboard

Functions

Link copied to clipboard
open fun buildPacket(@NotNull scheme: @NotNull McuMgrScheme, op: Int, flags: Int, groupId: Int, sequenceNum: Int, commandId: Int, @Nullable payloadMap: @Nullable Map<String, Any>): @NotNull Array<Byte>
Build a Mcu Manager packet based on the transport scheme.
Link copied to clipboard
open fun cancelUpload()
Cancel an image upload.
Link copied to clipboard
@NotNull
open fun confirm(hash: @Nullable Array<Byte>): @NotNull McuMgrImageStateResponse
Confirm an image on the device (synchronous).
open fun confirm(hash: @Nullable Array<Byte>, @NotNull callback: @NotNull McuMgrCallback<McuMgrImageStateResponse>)
Confirm an image on the device (asynchronous).
Link copied to clipboard
open fun continueUpload()
Continue a paused image upload.
Link copied to clipboard
@NotNull
open fun coreDownload(@NotNull callback: @NotNull DownloadCallback): @NotNull TransferController
Start core download.
Link copied to clipboard
@NotNull
open fun coreErase(): @NotNull McuMgrImageResponse
Erase a core dump from the device (synchronous).
open fun coreErase(@NotNull callback: @NotNull McuMgrCallback<McuMgrImageResponse>)
Erase a core dump from the device (asynchronous).
Link copied to clipboard
@NotNull
open fun coreList(): @NotNull McuMgrImageResponse
Core list (synchronous).
open fun coreList(@NotNull callback: @NotNull McuMgrCallback<McuMgrImageResponse>)
Core list (asynchronous).
Link copied to clipboard
@NotNull
open fun coreLoad(offset: Int): @NotNull McuMgrCoreLoadResponse
Core load (synchronous).
open fun coreLoad(offset: Int, @NotNull callback: @NotNull McuMgrCallback<McuMgrCoreLoadResponse>)
Core load (asynchronous).
Link copied to clipboard
@NotNull
open fun dateToString(@Nullable date: @Nullable Date, @Nullable timeZone: @Nullable TimeZone): @NotNull String
Format a Date and a TimeZone into a String which McuManager will accept.
Link copied to clipboard
@NotNull
open fun erase(): @NotNull McuMgrImageResponse
Erase the secondary slot of the main image (synchronous).
@NotNull
open fun erase(slot: Int): @NotNull McuMgrImageResponse
Erase the given slot of the main image (synchronous).
open fun erase(@NotNull callback: @NotNull McuMgrCallback<McuMgrImageResponse>)
Erase the secondary slot of the main image (asynchronous).
open fun erase(slot: Int, @NotNull callback: @NotNull McuMgrCallback<McuMgrImageResponse>)
Erase the given slot of the main image (asynchronous).
Link copied to clipboard
open fun getGroupId(): Int
Get the group ID for this manager.
Link copied to clipboard
open fun getMtu(): Int
Returns the upload MTU.
Link copied to clipboard
@NotNull
open fun getScheme(): @NotNull McuMgrScheme
Get the transporter's scheme.
Link copied to clipboard
@NotNull
open fun getTransporter(): @NotNull McuMgrTransport
Get the transporter.
Link copied to clipboard
open fun getUploadState(): Int
Get the current upload state (STATE_NONE, STATE_UPLOADING, STATE_PAUSED).
Link copied to clipboard
@NotNull
open fun imageUpload(imageData: @NotNull Array<Byte>, @NotNull callback: @NotNull UploadCallback): @NotNull TransferController
@NotNull
open fun imageUpload(imageData: @NotNull Array<Byte>, image: Int, @NotNull callback: @NotNull UploadCallback): @NotNull TransferController
Start image upload.
Link copied to clipboard
@NotNull
open fun list(): @NotNull McuMgrImageStateResponse
List the images on a device (synchronous).
open fun list(@NotNull callback: @NotNull McuMgrCallback<McuMgrImageStateResponse>)
List the images on a device (asynchronous).
Link copied to clipboard
open fun pauseUpload()
Pause an in progress upload.
Link copied to clipboard
@NotNull
open fun <T : McuMgrResponse?> send(data: @NotNull Array<Byte>, @NotNull respType: @NotNull Class<T>): @NotNull T
@NotNull
open fun <T : McuMgrResponse?> send(data: @NotNull Array<Byte>, timeout: Long, @NotNull respType: @NotNull Class<T>): @NotNull T
Send data synchronously using the transporter.
open fun <T : McuMgrResponse?> send(data: @NotNull Array<Byte>, @NotNull respType: @NotNull Class<T>, @NotNull callback: @NotNull McuMgrCallback<T>)
open fun <T : McuMgrResponse?> send(data: @NotNull Array<Byte>, timeout: Long, @NotNull respType: @NotNull Class<T>, @NotNull callback: @NotNull McuMgrCallback<T>)
Send data asynchronously using the transporter.
@NotNull
open fun <T : McuMgrResponse?> send(op: Int, commandId: Int, @Nullable payloadMap: @Nullable Map<String, Any>, @NotNull respType: @NotNull Class<T>): @NotNull T
@NotNull
open fun <T : McuMgrResponse?> send(op: Int, commandId: Int, @Nullable payloadMap: @Nullable Map<String, Any>, timeout: Long, @NotNull respType: @NotNull Class<T>): @NotNull T
@NotNull
open fun <T : McuMgrResponse?> send(op: Int, flags: Int, sequenceNum: Int, commandId: Int, @NotNull respType: @NotNull Class<T>, @Nullable payloadMap: @Nullable Map<String, Any>): @NotNull T
@NotNull
open fun <T : McuMgrResponse?> send(op: Int, flags: Int, sequenceNum: Int, commandId: Int, @Nullable payloadMap: @Nullable Map<String, Any>, timeout: Long, @NotNull respType: @NotNull Class<T>): @NotNull T
Send synchronous Mcu Manager command.
open fun <T : McuMgrResponse?> send(op: Int, commandId: Int, @Nullable payloadMap: @Nullable Map<String, Any>, @NotNull respType: @NotNull Class<T>, @NotNull callback: @NotNull McuMgrCallback<T>)
open fun <T : McuMgrResponse?> send(op: Int, commandId: Int, @Nullable payloadMap: @Nullable Map<String, Any>, timeout: Long, @NotNull respType: @NotNull Class<T>, @NotNull callback: @NotNull McuMgrCallback<T>)
open fun <T : McuMgrResponse?> send(op: Int, flags: Int, sequenceNum: Int, commandId: Int, @Nullable payloadMap: @Nullable Map<String, Any>, @NotNull respType: @NotNull Class<T>, @NotNull callback: @NotNull McuMgrCallback<T>)
open fun <T : McuMgrResponse?> send(op: Int, flags: Int, sequenceNum: Int, commandId: Int, @Nullable payloadMap: @Nullable Map<String, Any>, timeout: Long, @NotNull respType: @NotNull Class<T>, @NotNull callback: @NotNull McuMgrCallback<T>)
Send an asynchronous Mcu Manager command.
Link copied to clipboard
open fun setUploadMtu(mtu: Int): Boolean
Sets the upload MTU.
Link copied to clipboard
@NotNull
open fun slots(): @NotNull McuMgrImageSlotResponse
Reads slot information (synchronous).
open fun slots(@NotNull callback: @NotNull McuMgrCallback<McuMgrImageSlotResponse>)
Reads slot information (asynchronous).
Link copied to clipboard
@NotNull
open fun startDownload(@NotNull download: @NotNull Download): @NotNull TransferController
@NotNull
open fun startDownload(@NotNull download: @NotNull StreamDownload): @NotNull TransferController
Start an download.
Link copied to clipboard
@NotNull
open fun startUpload(@NotNull upload: @NotNull StreamUpload): @NotNull TransferController
@NotNull
open fun startUpload(@NotNull upload: @NotNull Upload): @NotNull TransferController
Start an upload.
Link copied to clipboard
@Nullable
open fun stringToDate(@Nullable dateString: @Nullable String): @Nullable Date
Parse a date string returned by a McuMgr response.
Link copied to clipboard
@NotNull
open fun test(hash: @NotNull Array<Byte>): @NotNull McuMgrImageStateResponse
Test an image on the device (synchronous).
open fun test(hash: @NotNull Array<Byte>, @NotNull callback: @NotNull McuMgrCallback<McuMgrImageStateResponse>)
Test an image on the device (asynchronous).
Link copied to clipboard
@NotNull
open fun upload(data: @NotNull Array<Byte>, offset: Int): @NotNull McuMgrImageUploadResponse
Send a packet of given data from the specified offset to the device (synchronous).
open fun upload(data: @NotNull Array<Byte>, @NotNull callback: @NotNull ImageManager.ImageUploadCallback): Boolean
Begin an image upload.
@NotNull
open fun upload(data: @NotNull Array<Byte>, offset: Int, image: Int): @NotNull McuMgrImageUploadResponse
Send a packet of given data from the specified offset to the given core (image) on the device (synchronous).
open fun upload(data: @NotNull Array<Byte>, offset: Int, @NotNull callback: @NotNull McuMgrCallback<McuMgrImageUploadResponse>)
Send a packet of given data from the specified offset to the device (asynchronous).
open fun upload(data: @NotNull Array<Byte>, offset: Int, image: Int, @NotNull callback: @NotNull McuMgrCallback<McuMgrImageUploadResponse>)
Send a packet of given data from the specified offset to the given core (image) on the device (asynchronous).
Link copied to clipboard
fun ImageManager.windowUpload(data: ByteArray, image: Int, windowCapacity: Int, memoryAlignment: Int, callback: UploadCallback): TransferController