CloudOfThingsDeviceRegistrator¶
Description¶
The CloudOfThingsDeviceRegistrator object deals with the device registration of Cloud of Things. Every device communication with Cloud of Things has to be registered. This can be done by the device itself during a process called bootstrap. With initial bootstrap credentials the device registeres itself and create unique credentials after it is accepted in the device management of Cloud of Things. A reconnect is performed and the device can be used to communicate, send measurements, etc. It is also possible to register a bulk of devices, then no bootstrap is needed. See <link> Cloud of Things for further information.
› Inherits: | Object |
---|
Properties¶
bootstrapPassword¶
This property holds the bootstrap password.
› Type: | String |
---|---|
› Signal: | bootstrapPasswordChanged() |
› Attributes: | Writable |
bootstrapUser¶
This property holds the bootstrap user name. Only necessary if no pre registration is possible and isRegistered equals false
.
› Type: | String |
---|---|
› Signal: | bootstrapUserChanged() |
› Attributes: | Writable |
isRegistered¶
This property holds whether the device is registered for example in a bulk registration (isRegistered equals true
) or it has to register itself (isRegistered equals false
).
› Type: | Boolean |
---|---|
› Default: | false |
› Signal: | isRegisteredChanged() |
› Attributes: | Writable |
password¶
This property holds the password for registered devices.
› Type: | String |
---|---|
› Signal: | passwordChanged() |
› Attributes: | Writable |
state¶
This property holds the state of registration.
› Type: | State |
---|---|
› Default: | CloudOfThingsDeviceRegistrator.Unregistered |
› Signal: | stateChanged() |
› Attributes: | Writable |
Enumerations¶
State¶
This enumeration describes the state of the registration of the Cloud of Things Client. This object is used to register new devices in Cloud of Things and deal with the bootstrap.
Name | Value | Description |
---|---|---|
CloudOfThingsDeviceRegistrator.Unregistered |
0 |
Initial state, no other information found. |
CloudOfThingsDeviceRegistrator.WaitingForAccept |
1 |
The device is known to Cloud of Things, but it is waiting for accept. |
CloudOfThingsDeviceRegistrator.Reconnecting |
2 |
After the device is accepted, a reconnect is performed to use the new credentials. |
CloudOfThingsDeviceRegistrator.Registered |
3 |
The device is known to Cloud of Things and working. |
Example¶
import InCore.Foundation 2.5
import InCore.CloudOfThings 2.5
Application {
//settings object which store credentials if available
Settings {
id: settings
category: "deviceCredentials"
property bool isPreregistered: false
property bool devicePassword
}
CloudOfThingsClient {
id: client
tenant: "mustercloud"
transport {
tenantForMQTT: "nb-iot"
//log important state changes
onConnected: console.log( "Cloud of Things client connected" )
onErrorChanged: console.log( "error occurred", errorString )
}
registrator {
isRegistered: settings.isPreregistered
//bootstrap credentials - used if device is not yet registered
bootstrapUser: "deviceBootstrap"
bootstrapPassword: "b@@tstrapP4ssword"
//password if device is registered - otherwise ignored
password: settings.devicePassword
}
//do your stuff here
/*
CloudOfThingsMeasurementWriter
{
...
}
*/
}
}