CloudLocate premium extension

Introduction

If you are using one of u-blox  IoT Communication-as-a-Service solution like MQTT Anywhere, MQTT Now, MQTT Here or MQTT Flex, the most efficient way to leverage CloudLocate is using the premium extension.

With Data Flow Manager you can build your own logic or manipulate data, by creating a flow made up by multiple nodes (premium extension), each of them implementing a basic functionality

The Flow Editor provides a simple drag and drop interface where you can quickly build powerful flows to work with payloads published by your Things, and get that data out to wherever you need it. 

CloudLocate flow

To create your first flow, just select Flows from the sidebar and click create flow on the top right corner of the screen to create a new flow. Assign it a name and then create your flow adding the CloudLocate node and any other other nodes you need. You'll find details of the input and output parameters for each node in the info tab on the right-hand side of the editor.

The following picture shows an example of how to build a flow that receives a measurement, calculates the position and sends the result by email.

The  logic behind a flow is that:

Simulate a device

After that you have created the above flow, as next step you need to simulate your device to be able to inject/publish data in the flow and trigger the execution. The easiest way to do that is to create an IP Thing (you can also create more than one to simulate a fleet): 

In the credential section of each IP Thing you can find the MQTT credentials and endpoint. Use these information to configure an MQTT client in your laptop o in your real device.

In the next steps you will get also the information about the topic to be used to publish data

In the following sections you can get more information about each node used in the sample flow in the picture

Thingstream inject node

This node is used to test the flow by injecting sample data directly to the flow from the user interface (just filling the proper fields in the configuration panel of the node). This is very helpful as a very first step, especially if you do not have an MQTT client in your PC/device

 You can position this node anywhere in your flow and use it to test without the need to deploy the flow. 

To configure this node, double-click on it:

To run this node, simply click on the filled square on the left-hand side of the node. You'll be able to review any debug output in the debug tab on the right-hand side of the editor.

Before running the flow, you will be asked to save it (the Save button is on the top right of the editor window).

{

"RequestId": "82cb34c9-88c9",

"GNSSMeasurements": {

"Payload":"tWIChjIAG/M7CcimDqBmvpr+A9pGYVEPdxhiyIqPToNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAA==",

  "DateTime": "2023-04-05T12:50:16"

 }

}

Thingstream subscribe node

Instead of using the 'thingstream  inject'  node, in a real use case you want to send the measurement from your devices. This node acts as an input to the flow.

This subscription represents the MQTT topic(s) that will trigger the flow when a message from a device  is pushed on that topic.  In other wards, all the devices shall publish the raw measurements into this topic. 

The topic selection happens during the flow deployment phase: you will be asked to create a subscription for this node. You can change the topic at any time by clicking on Manage button

CloudLocate node

This node calls the CloudLocate service to calculate a position based on incoming measurement data.  The result becomes an input to the next node in the flow.

The node accepts the input in two format:

Set email recipient (function) node

This JavaScript function node can be used to set an email address to be used by the email node by using the following code

/* 

Set the email "to" address to the 

domain owners email address.

*/

msg.to = msg.domainOwner.email;

return msg; 

You can also specify any email address if you want to send an email to a recipient other than the domain owner, like:

msg.to ="me@mydomain.com";

return msg; 

You need to add the above code in the function node by double-clicking on the node to open the configuration options and click "Done" to save your changes.

Msg.payload (debug) node

This node is used for debugging purposes.  It will output debug data to the "debug" tab on the right-hand side, so that you can immediately see if the position has been calculated

Email payload node

This node will send an email with the estimated position.  You don't need to configure the email recipient details directly in the node as they are set in the previous JavaScript function node.

Deploy and test the flow

When you have finished setting up and testing your flow with the thingstream inject node, you can deploy the flow to start using it with real devices. For detailed information about deploying Flows, have a look at the Flows documentation. The steps are listed here in summary:

You can see the topic (i.e. 'Mytest/MyTopic') that the flow is subscribed to at the top of the editor screen. To change it, use the manage button at the top-right corner and repeat the procedure

Test the CloudLocate flow

You are now almost ready to test the flow using your real device or a simulated device. 

Note: the position estimation is done real time, therefore the time to get a response depends on: i) the connectivity between the device and the CloudLocate service endpoint and ii) the way you decide to send out the estimated position (SMS, mail, MQTT) to your cloud application.

Position in the cloud

If you want to get the position directly to your cloud application, the easier way to do it is to: