Device provisioning
Devices (aka targets) can be provisioned and registered in Bosch IoT Rollouts in the following ways:
Scenario 1: Provisioning and registration
In this scenario, you first provision the device using the Management UI or the Management API. This is the step where you provide the device identification and description.
Then the provisioned device can register itself via the Direct Device Integration (DDI) API (DDI). This is the step where the device authenticates itself with its security token.
Scenario 2: Direct registration
In this scenario, the device itself, or a device-management service, directly identifies and authenticates itself with Bosch IoT Rollouts via the Direct Device Integration API (described in the current guide), or the Device Management Federation API (described in API references).
The different scenarios are explained in more detail below.
Table of contents:
Scenario 2: Direct registration via DDI API
A device which has not been provisioned via the Management UI or the Management API can access Bosch IoT Rollouts by authenticating through a gateway token.
For details about this authentication mechanism, see Authentication > Gateway security token.
Go to the Configuration UI feature.
Enter edit mode by clicking the Edit icon on the top right.
Enable the option Allow a gateway to authenticate and manage multiple targets through a gateway security token.
Click Show and copy the generated token.
Then save the new configuration by clicking the Save icon on the bottom of the page.
Now that this authorization option is enabled and you have a token, you can use it in the authorization header of your request, as presented in the code example below.
The other replacement tokens which you need to properly follow this code example are listed at Getting started > API Replacement Token.
$ curl
'https://<HOST>/<TENANT_ID>/controller/v1/testDevice1'
-i -H
'Accept: application/hal+json'
-H
'Authorization: GatewayToken <GATEWAY_TOKEN>'
{
"config"
: {
"polling"
: {
"sleep"
:
"00:05:00"
}
},
"_links"
: {
"configData"
: {
"href"
:
"https://<HOST>/<TENANT_ID>/controller/v1/device03/configData"
}
}
}
A device registered via the DDI API will be in REGISTERED state.
As a final step, add some attributes to the device. Follow the link to configData provided in the response to your last call and add the respective attributes as key value pairs. In this example, we have added two attributes, namely hwRevision and VIN.
$ curl
'https://<HOST>/<TENANT_ID>/controller/v1/testDevice1/configData'
-i -X PUT -H
'Authorization: GatewayToken <GATEWAY_TOKEN>'
-H
'Content-Type: application/json;charset=UTF-8'
-d '{
"mode"
:
"merge"
,
"data"
: {
"hwRevision"
:
"2"
,
"VIN"
:
"JH4TB2H26CC000000"
}
}'
You can verify whether the attributes were set correctly by checking the Attributes tab of the Target details view, as on the screenshot below.