Heartbeat / Watchdog
Points have a field called lastActive
. If you want to see when a device has been active without sending any data, you can implement that feature on the device, by sending a heartbeat payload to the heartbeat topic.
Heartbeat
Topic
"POINT/HEARTBEAT"
Payload
{
"pointId": "XXXX",
"tenantId": "XXXXXX",
"tenantKey": "XXXXXXXXX",
"watchdog": false,
"beat": "529"
}
Watchdog
You can use the watchdog functionality to round trip a watchdog signal through D4. When used it will es If watchdog is enabled (set true), the same msg will be broadcasted back again to a topic that you can subscribe to.
Payload
{
"pointId": "XXXX",
"tenantId": "XXXXXX",
"tenantKey": "XXXXXXXXX",
"watchdog": true,
"beat": "529"
}
Return Topic
"POINT/d4-mqtt-TENANT_ID/POINT_ID/WD"
Example
Bash
Replace with suitable values
export POINTID=pointid
export TENANTID=tenantid
export TENANTKEY=tenantid
export MQTTUNAME=mqttusername
export MQTTPWORD=mqttpassword
Requirements
mosquitto_pub + mosquitto_sub (Comes with mosquitto CLI. Tested with 1.6.9)
Send
echo "
{
\"pointId\":\"${POINTID}\",
\"tenantId\":\"${TENANTID}\",
\"tenantKey\":\"${TENANTKEY}\",
\"watchdog\": true,
\"beat\": \"234\"
}
" | tr -d '\n' | mosquitto_pub -l -h mqtt.dimensionfour.io -t POINT/HEARTBEAT -u ${MQTTUNAME} -P ${MQTTPWORD}
Receive
mosquitto_sub -h mqtt.dimensionfour.io -t POINT/${MQTTUNAME}/${POINTID}/WD -u ${MQTTUNAME} -P ${MQTTPWORD}