Many sensors are low energy devices; to save power, they sleep most of the time and only wake up occasionally. The sensor may not be awake when you want to send a command or other data to it.
AssetWolf can hold a queue of command messages that are sent to the asset when it connects. The standard AssetWolf portal allows you to send a command, by adding it to the queue of messages to be sent when the device connects.
If the device connects using MQTT, it wakes up, connects to the broker, and it should subscribe to receive at the same time. It publishes it "up" message to the broker, and the AssetWolf portal receives it. Then if there is something in the command queue for the device, Assetwolf sends it immediately afterwards:
Here's how to set up your asset, so as to listen for a message when it connects in.
The asset's communication device will need to make the usual connection to the broker, see here if you're not familiar with this.
When your asset wakes up, the first thing it must do is to subscribe.
It must this before publishing. This is to avoid race conditions in which the portal sends back date before the asset is ready.
Subscribe to a topic like this:
$commandTopic = "down/client/clientId/asset/assetId";
The first part, "down" is important, replace clientId and assetId with the relevant strings.
Your device should publish its data in the usual way. To recap, this is as follows:
$sensorTopic = "up/client/clientId/asset/assetId";
After publishing, the device should do a listen for a short time, this is typically 1 or 2 seconds, to allow for the server to respond and for network latency.
If your device has received an MQTT payload, it can disconnect cleanly from the broker and process the payload.