Update the firmware

Read the firmware status and update the firmware over the API. In the WebGUI, see Update the firmware. The examples use the Python library and sign in with an application key. Replace qb2-xxxxxxxxx with the hostname or IP address of your sensor and application-key-for-qb2-xxxxxxxxx with the secret of your key.

Get the firmware status

The method GetStatus returns the installed firmware, and an installation that is running or has failed.

import blickfeld_qb2

token_factory = blickfeld_qb2.TokenFactory(application_key_secret="application-key-for-qb2-xxxxxxxxx")

with blickfeld_qb2.Channel(fqdn_or_ip="qb2-xxxxxxxxx", token=token_factory) as channel:
    service = blickfeld_qb2.system.services.Firmware(channel)

    # Read out current status
    response = service.get_status()
    print(response.status)

Output, one field per line:

FirmwareStatus(
    idle=FirmwareStatusIdle(),
    installed_firmware_info=FirmwareInfo(
        label='HENNING v3.2.4',
        version=Version(major=3, minor=2, patch=4, revision='d1c2d249'),
        allowed_downgrade_version=Version(major=3, patch=11)
    )
)

Fetch and install a firmware

The method FetchAndInstall downloads a firmware bundle and installs it on the sensor, then the sensor reboots. Without a source, as in the example, it fetches the latest release. Pass url with the address of a firmware bundle, or version, to install another one. The sensor must be able to reach the server that holds the bundle.

import blickfeld_qb2

token_factory = blickfeld_qb2.TokenFactory(application_key_secret="application-key-for-qb2-xxxxxxxxx")

# Open a secure and authenticated connection to the sensor
with blickfeld_qb2.Channel(fqdn_or_ip="qb2-xxxxxxxxx", token=token_factory) as channel:
    service = blickfeld_qb2.system.services.Firmware(channel)

    # Fetch the latest firmware bundle and install it on the sensor
    for response in service.fetch_and_install():
        print(response.status)

Output:

FirmwareStatus(installation=FirmwareStatusInstallation(progress=FirmwareStatusInstallationProgress(message='Installing')))
FirmwareStatus(installation=FirmwareStatusInstallation(progress=FirmwareStatusInstallationProgress(message='Determining slot states')))
FirmwareStatus(installation=FirmwareStatusInstallation(progress=FirmwareStatusInstallationProgress(percent=20, message='Determining slot states done.')))
FirmwareStatus(installation=FirmwareStatusInstallation(progress=FirmwareStatusInstallationProgress(percent=20, message='Checking bundle')))
FirmwareStatus(installation=FirmwareStatusInstallation(progress=FirmwareStatusInstallationProgress(percent=20, message='Verifying signature')))
FirmwareStatus(installation=FirmwareStatusInstallation(progress=FirmwareStatusInstallationProgress(percent=40, message='Verifying signature done.')))

...
FirmwareStatus(installation=FirmwareStatusInstallation(progress=FirmwareStatusInstallationProgress(percent=99, message='Updating slots done.')))
FirmwareStatus(reboot=FirmwareStatusReboot())