CloudOfThingsDeviceManager

Description

The CloudOfThingsDeviceManager object communicates with the Cloud of Things and handles commands from the cloud. The updateRepositoryUrl property is updated when the corresponding command is send from the cloud. The updateManager property will receive calls to UpdateManager.check(), UpdateManager.download() and UpdateManager.install() from the cloud.

› Inherits:Object

Properties

error

This property holds the most recently occurred error or CloudOfThingsDeviceManager.NoError if no error occurred. If the same error occurs multiple times this property does not change. Use the errorOccurred() signal to detect multiple occurrences of the same error.

› Type:Error
› Signal:errorChanged()
› Attributes:Readonly

errorString

This property holds the current human readable error string corresponding to the current value in the error property. It may include additional information such as failure reasons or locations.

› Type:String
› Signal:errorStringChanged()
› Attributes:Readonly

updateManager

This property holds the UpdateManager which methods UpdateManager.check(), UpdateManager.download() and UpdateManager.install() are used to update the device if the process is started in the Cloud of Things.

› Type:UpdateManager
› Signal:updateManagerChanged()
› Attributes:Writable

updateRepositoryUrl

This property holds the URL string to the repository which should be used to update the device. This property will be updated by a command from Cloud of Things and should be assigned to a HttpRepository in the updateManager property.

› Type:String
› Signal:updateRepositoryUrlChanged()
› Attributes:Readonly

Signals

errorOccurred()

This signal is emitted whenever an error has occurred, regardless of whether the error property has changed or not. In contrast to the change notification signal of the error property this signal is also emitted several times if a certain error occurs several times in succession.

Enumerations

Error

This enumeration describes all errors which can occur in CloudOfThingsDeviceManager objects. The most recently occurred error is stored in the error property.

Name Value Description
CloudOfThingsDeviceManager.NoError 0 No error occurred or was detected.
CloudOfThingsDeviceManager.InvalidClient 1 Parent is not an CloudOfThingsClient object.
CloudOfThingsDeviceManager.InvalidUpdateManager 2 No UpdateManager set or found.
CloudOfThingsDeviceManager.MultipleDeviceManagers 3 Multiple CloudOfThingsDeviceManagers found.

Example

import InCore.Foundation 2.5
import InCore.CloudOfThings 2.5
import InCore.Http 2.5

Application {

    CloudOfThingsClient {
        id: client
        tenant: "mustercloud"
        transport {
            protocol: CloudOfThingsTransport.MQTT
            tenantForMQTT: "nb-iot"

            requestOperationsIntervalMQTT: 5 * 1000

            //log important state changes
            onConnected: console.log( "Cloud of Things client connected" )
            onErrorChanged: console.log( "oh... error occurred", errorString )
        }

        registrator {
            isRegistered: true
            password: "y0urAwes@meP4ssword"
        }

        CloudOfThingsDeviceManager {
            id: deviceManager

            updateManager: UpdateManager {

                // use this configuration to update incremental via Cloud of Things
                // else set all to true
                autoInstall: false
                autoDownload: false
                autoReboot: true

                repositories: [
                    HttpRepository { url: deviceManager.updateRepositoryUrl }
                ]

                UpdateTarget {
                    bundlePrefix: "siineos"
                    currentVersion: system.osVersion
                }
            }
        }

        //do your stuff here
        /*
        CloudOfThingsMeasurementWriter
        {
            ...
        }
        */
    }
}