Reflect device connectivity status in thing
At the Connections/Integrations tab you get an overview of the connections configured for your service instance so far.
If you want to reflect the device connectivity status - which can be derived from header information of devices connected via Bosch IoT Hub - in your things, proceed as follows:
- Select your connection - this must be of type Bosch IoT Hub
- Click Edit
- Check the box to Enable persisting the connection status of the device reported by Bosch IoT Hub at the thing
- Click Save to close the dialog
By activating this checkbox, the Things service will create and update a new feature for all things using this connection.
The feature is named by default ConnectionStatus
.
Property name | Type | Description |
---|---|---|
readySince | string | Timestamp when the device or the connectivity endpoint signals that the device is connected and stays connected at least for some time, and is ready for receiving information. |
readyUntil | string | Timestamp until when device or the connectivity endpoint signals that it stays ready for receiving information; if it signals that it stays connected and is ready until further notice, then this timestamp is symbolically set to a timestamp that is at least 1 year ahead of now. |
The device connectivity status is derived from the Bosch IoT Hub headers creation-time
- for readySince - and ttd
(time ‘til disconnect) - for readyUntil.
Readiness to receive information
When activated, the feature named ConnectionStatus
will be automatically created and updated.
The device connectivity status is updated whenever the device signals its readiness to receive information.
It is not sufficient to send telemetry or events from a device to update the connectivity status, instead the device must actively register a subscriber.
Examples:
- https://docs.bosch-iot-suite.com/device-management/Telemetry-example.html - see set the hono-ttd
- https://docs.bosch-iot-suite.com/device-management/Command-and-control---one-way.html - see step 0 activate
Example
This is an example of a device, which is connected for 10 seconds:
{
"thingId": "com.acme:coffee-brewer",
"policyId": "com.acme:coffee-brewer",
"attributes": {
"manufacturer": "ACME demo corp."
},
"features": {
"ConnectionStatus": {
"definition": ["org.eclipse.ditto:ConnectionStatus:1.0.0"],
"properties": {
"status": {
"readySince": "2019-11-05T12:29:30Z",
"readyUntil": "2019-11-05T12:29:40Z"
}
}
}
}
}
Short connection periods
If your device is capable of receiving commands only for a short period (e.g. when communicating with the Bosch IoT Hub via HTTP), the readySince and readyUntil values will probably be very close together.
In case you need to send a command to the device during that short time interval, you should
subscribe to events e.g. defining a filter which matches changes to the ConnectionStatus:
exists(features/ConnectionStatus)
Whenever your application gets notified about such a change, it can determine whether a device is now connected and
able to receive commands.
Long connection periods
In case your device communicates via MQTT and gives the signal to be ready for retrieving messages, the readySince
value is set to the current time, when the Things service received the event or telemetry, and the readyUntil value is set
to a distant future date: 9999-12-31T23:59:59Z
.
Once such a device disconnects or loses its connection, the readyUntil value will be set to the date when the disconnection happened. So, you will be able to see when the device was last connected.