Updater

public protocol Updater : Peripheral

Updater peripheral interface for Drone and RemoteControl devices.

Allows to:

  • list and download available updates for the device from remote server.
  • list locally available updates and apply them to the connected device.

This peripheral is always available even when the device is not connected, so that remote firmware updates may be downloaded at all times (unless internet connection is unavailable).

Updating requires the device to be connected; however, this peripheral provides the ability to apply several firmware updates in a row (mainly used in the presence of trampoline updates), and will maintain proper state across device reboot/reconnection after each update is applied.

This peripheral can be retrieved by:

device.getPeripheral(Peripherals.updater)
  • All firmwares that are required to be downloaded to update the device to the latest available version.

    The array is ordered by firmware application order: first firmwares in the list must be downloaded and applied before subsequent ones in order to update the device.

    Declaration

    Swift

    var downloadableFirmwares: [FirmwareInfo] { get }
  • Whether the device is currently up-to-date.

    Declaration

    Swift

    var isUpToDate: Bool { get }
  • Tells why it is currently impossible to download remote firmwares.

    If the returned set is not empty, then all firmware download methods (downloadNextFirmware(), downloadAllFirmwares()) won’t do anything but return false.

    Declaration

    Swift

    var downloadUnavailabilityReasons: Set<UpdaterDownloadUnavailabilityReason> { get }
  • Current firmware download operation state, if any is ongoing.

    Declaration

    Swift

    var currentDownload: UpdaterDownload? { get }
  • All firmwares that are required to be applied to update the device to the latest available version.

    The array is ordered by firmware application order: first firmwares in the list must be applied before subsequent ones in order to update the device.

    Declaration

    Swift

    var applicableFirmwares: [FirmwareInfo] { get }
  • Tells why it is currently impossible to apply firmware updates.

    If the returned set is not empty, then all update methods (updateToNextFirmware(), updateToLatestFirmware()) won’t do anything but return false.

    In case updating becomes unavailable for some reason while an update operation is ongoing (.uploading or .processing), then the update will be forcefully canceled.

    Declaration

    Swift

    var updateUnavailabilityReasons: Set<UpdaterUpdateUnavailabilityReason> { get }
  • Current update operation state, if any is ongoing.

    Declaration

    Swift

    var currentUpdate: UpdaterUpdate? { get }
  • Ideal version.

    This version is not necessarily local. It is the version that the drone will reach if all downloadable firmwares are downloaded and if all applicable updates are applied. This version is nil if there is no downloadable firmwares and no applicable firmwares.

    Note

    This version might differ from the greater version of all downloadable and applicable firmwares if, and only if, the ideal firmware is local but cannot be applied because an intermediate, not downloaded, firmware is required first.

    Declaration

    Swift

    var idealVersion: FirmwareVersion? { get }
  • Requests download of the next downloadable firmware that should be applied to update the device towards the latest available version.

    This method does nothing but return false if downloadUnavailabilityReasons is not empty, or if there is no downloadableFirmwares.

    Declaration

    Swift

    @discardableResult
    func downloadNextFirmware() -> Bool

    Return Value

    true if the download started

  • Requests download of all downloadable firmware that should be applied to update the device to the latest available version.

    This method does nothing but return false if downloadUnavailabilityReasons is not empty, or if there is no downloadableFirmwares.

    Declaration

    Swift

    @discardableResult
    func downloadAllFirmwares() -> Bool

    Return Value

    true if the download started

  • Cancels an ongoing firmware(s) download operation.

    Declaration

    Swift

    @discardableResult
    func cancelDownload() -> Bool

    Return Value

    true if an ongoing firmware download operation has been canceled

  • Requests device update to the next currently applicable firmware version.

    This method does nothing but return false if updateUnavailabilityReasons is not empty, or if there is no applicableFirmwares. This is equivalent to calling:

    updateToNextFirmware(reboot: true)
    

    Declaration

    Swift

    @discardableResult
    func updateToNextFirmware() -> Bool

    Return Value

    true if the update started

  • Requests device update to the next currently applicable firmware version.

    This method does nothing but return false if updateUnavailabilityReasons is not empty, or if there is no applicableFirmwares. If reboot parameter is set to false, the update state will remain .waitingForReboot until device is manually rebooted.

    Declaration

    Swift

    @discardableResult
    func updateToNextFirmware(reboot: Bool) -> Bool

    Parameters

    reboot

    true to make the device reboot automatically at the end of the process

    Return Value

    true if the update started

  • Requests device update to the latest applicable firmware version.

    This method will update the device by applying all applicableFirmwares in order, until the device is up-to-date. After each firmware is applied, the device will reboot. The application has the responsibility to ensure to reconnect to the device after the update, so that this peripheral may proceed automatically with the next firmware update, if any.

    This method does nothing but return false if updateUnavailabilityReasons is not empty, or if there is no applicableFirmwares.

    Declaration

    Swift

    @discardableResult
    func updateToLatestFirmware() -> Bool

    Return Value

    true if the update started

  • Cancels an ongoing firmware(s) update operation.

    Declaration

    Swift

    @discardableResult
    func cancelUpdate() -> Bool

    Return Value

    true if an ongoing firmware update operation has been canceled