Altova MobileTogether Designer

The OnMQTTReceive page event is available for all pages (top pages and sub pages). It is triggered when the solution receives a message because of a Subscribe to MQTT Topic action that has been defined on the page. When a message is received, the contents of the message are stored in the $MT_MQTT page source and the actions defined here, on the OnMQTTReceive page event, are executed.


Actions to perform when an MQTT message is received

You can define what actions to execute when an MQTT message is received. Do this by dragging and dropping actions into the event's main pane (screenshot below).


Note that the information contained in the message will automatically be passed to the $MT_MQTT page source. This information will comprise two pieces of data: (i) the MQTT message, which will be stored as a text string, (ii) the name of the topic under which that message was sent. Now you could, for example, add the new message to an XML file that contains all the messages that were received for topics on that page. The screenshot below shows a sequence of actions does this, by appending a new Message node to the $XML1 page source and deleting any older message if a limit of one message has been set for the $XML1  page source.

Double-click to expand/collapse

Note the following points:


The actions defined on this event will be triggered each time a message is received for any and all subscriptions defined on the page.

The data currently in the $MT_MQTT page source will contain the data of the message that triggers the page event.

If you want the MQTT actions that you set on this page to be the same as those on another page, then consider defining these actions once at the solution (or project) level. MQTT actions at the project level will be triggered if no OnMQTTReceive action has been defined at the page level. The actions at the project level, therefore, act as a fallback set of actions.


© 2018-2024 Altova GmbH