Reflect device connectivity status in thing
The device connectivity status is derived from the Bosch IoT Hub headers.
Status feature is active by default
At the Connections UI you can get an overview of the connections configured for your service instance so far.
If you want to see the feature 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 - Devices via Bosch IoT Hub.
Open the General section.
At section Reflect device connectivity status in thing, the checkbox to Enable persisting the connection status of the device reported by Bosch IoT Hub at the thing should be on by default.
However, if someone in your team has deactivate it, click Edit to get to respective view, check the box, and 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 |
readyUntil |
string |
Timestamp until when device or the connectivity endpoint signals that it stays ready for receiving information; |
The device connectivity status is derived from the Bosch IoT Hub headers creation-time - for readySince - and ttd (time ‘til disconnect) - for readyUntil.
When activated, a feature named ConnectionStatus will be automatically created and updated.
The device connectivity status is updated whenever the device signals its readiness to receive information.
Note: 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:
Telemetry example - HTTP - set the hono-ttd
Command and control examples - HTTP - step 0 activate
Display the values in a dashboard
You can display such values in your business application, by offering the properties of the ConnectionStatus feature in a human readable format.
This example shows how the Bosch IoT Suite Console offers the data of a device which is connected.
Get notified about 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. by defining a filter which matches changes to the ConnectionStatus: exists(features/ConnectionStatus), see Protocol - event filter.
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.
Disconnected device
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.
The Developer Console would display such a device like in the next screenshot.