Due to various reasons, the devices registered with WSO2 IoT Server might not be able to communicate with the server continuously. When the device is not actively communicating with the server, you need to know of it to take necessary actions, such as checking if the device has any malfunctions and repairing it or checking if the device was stolen.
To get a clear understanding, let's look at how this works in WSO2 IoT Server.
If the device and the server are actively communicating, the device is shown as active.Click here to see how the status is displayed.
If the server is unable to communicate with the device within a defined time period, the device is shown as unreachable.Click here to see how the status is displayed.
If the server is still unable to communicate with the device after a defined time period, the device is shown as inactive.Click here to see how the status is displayed.
- If the device starts to communicate with the device after some time, the device status is updated back to active.
The device's status has the following lifecycle:
The device monitoring task is not applicable for all IoT devices. Therefore, you can choose to enable or disable it for your device type. Let's take a look at how you can configure WSO2 IoT Server and your device type to monitor the device status.
<IOTS_HOME>/conf/cdm-config.xmlfile and make sure the
DeviceStatusTaskConfigis enabled. This configuration is enabled by default.
DeviceStatusTaskConfigis enabled (or enabled on a node that is in a clustered setup) it will run the status monitoring task in the server. If the configuration is disabled, the server will not monitor the status of the devices.
Configure the device type to go into the unreachable state and then to the inactive state after a specified time.
Navigate to the
<IOTS_HOME>/repository/deployment/server/devicetypedirectory, open the
<DEVICE_TYPE>.xmlfile, and configure the fields given below:
The default configuration in the
android.xmlfile is shown below:
If the value is set to true, it enables the status monitoring task for the device type. Else it will not monitor the status of the device type.
For the task to run on the specified device type it must be enabled on the server as shown in step 1 above.
Define how often this task should run for the specified device type. The value needs to be given in seconds.
Make sure to have the value above 60 seconds.
Define after how long the device needs to be marked as unreachable. The value needs to be given in seconds.
Define after how long the device needs to be marked as inactive. The value needs to be given in seconds.
Additionally to the above configurations, for the device monitoring task to actively function, you need to have pending operations on the device end. When there are pending operations the device communicates with the server to send the operation details to the server and through it, the server keeps track that the device is active.