One of the most important features of the internet of things is its massive data component (many devices sending and consuming information). The harmonization of all this information, coming from thousands of different places and nodes, is the first step in intelligence a company builds in favor of business.

To demonstrate the fundamental value of the IoT as a generator of new business models, any Proof of concept, demonstration project or first project iteration should utilize value data to get a clear picture of the scenario and IoT ecosystem in play. Sending random information from IoT endpoints would be asking business, back-end and predictive analytic teams too much imagination for a simple concept that should make sense and should be taken care of seemingly.

In this sense, we will carry out a series of blog posts where we will learn how to develop an end-to-end scenario on a real-life application with SAP Leonardo components, in a very efficient way by using smart endpoint simulation provided by iotify.io and utilizing the power of SAP in the field.

We will use IoTIFY to create massive amounts of real-time data for N number of trucks delivering goods from city to city with simple and short lines of code. This real-time data for each simulated truck will include GPS coordinates, temperature, speed, etc.

Integrating it with SAP Leonardo components will allow us to prototype a complete and end-to-end IoT solution very efficiently and with real life expected data and analytics.

Overview & Agenda for this blog post:

  • Section 1: Configuring the IoT service with SAP Cloud Platform
  • Section 2: Generating smart traffic in real time with IoTIFY Smart Network Traffic Generator

 

Section 1: Configuring the IoT service with SAP Cloud Platform

Let’s start by fine-tuning the IoT service on the SAP Cloud Platform. For that, we have to go to the main page and carry out the following steps

 

  1. Once on the SCP home page, it is important to remember the name of the account we are on. We will be using this a lot in the following steps. In the case of this tutorial, our account id is: i850231trial
  2. Then, in the taskbar on the left we go to Services. In the list of services, we look for Internet of Things Services
  3. Once inside, we click on: Go To Service
  4. Once in the service, we click on Message Type and we create the following message
  5. The message will have the following attributes
    1. Name: SmartTruck
    2. ID string
    3. Start: string
    4. End: string
    5. Loadper: integer
    6. Latitude: float
    7. Longitude: float
    8. Speed: double
    9. Insidetemp: double
    10. Outsidetemp: double
  6. We click on create, we save the ID of the message and we go to the cockpit menu.
  7. We now select Device Types and we create a new type of device with the following attributes:
    1. Name: TruckDevice
    2. AssignmentName: SmartTruck
    3. Message Type: SmartTruck
    4. Direction: From Device
  8. We click on create, we copy the ID of the Device Type and we go back to the Cockpit menu.
  9. Next step is to create a Device. In order to do that, we click on Devices and we proceed to create a new device with the following attributes:
    1. Name: DeviceTruck
    2. DeviceType: TruckDevice
  10. Once the Device is created, a pop up window will appear with a Token. It is very important to save that token somewhere we can access it later. It will be used later on.
  11. Close the pop up window, copy the ID of the Device and go back to the Cockpit menu.
  12. We now go to Send and view messages
  13. We then go to Messaging through HTTP. In this section we will have to create both the URL and the message to be sent, it’s a validation step.
    1. In Data Endpoint we will change the last part of the string with what we obtained as Device ID in one of the previous steps.
    2. https://iotmmsi850231trial.hanatrial.ondemand.com/com.sap.iotservices.mms/v1/api/http/data/<device_ID>
  14. In Message, we will create a standalone example message to be sent. It should be noted that the attributes of the message should coincide with the attributes of the message type we created on a previous step. The MessageType should be the same MessageType ID we obtained previously too.
    {
        "mode": "sync",
        "messageType": "bb5b6644d677a6bf6c42",
        "messages": [
            {
                "ID": "FROF5QOSOY",
                "start": "Berlin,DE",
                "end": "Nuremberg,DE",
                "loadper": 64,
                "latitude": 52.519755,
                "longitude": 13.404025,
                "speed": 6,
                "insidetemp": 11.471803869858926,
                "outsidetemp": 12.408207353298506
            }
        ]
    }
    
  15. Once the configuration of the message and the Data Endpoint are complete, we will click on Send.
  16. If everything is correct, we should receive a response code 200. This will mean we have correctly configured everything up to now.

 

Section 2: Generating smart traffic in real time with IoTIFY Smart Network Traffic Generator

  1. In this step, we will go to iotify.io and create an account if we still don’t have one. The free account offered by IoTIFY is enough to carry out this tutorial.
  2. Once within IoTIFY, we will go to the Network tab and we will create a new network template.
    1. We will configure the template as follows:
    2. Name: SmartTruckSimulation
    3. Connection Type: HTTP
    4. Protocol: Https
    5. Host: iotmms<AccountName>.hanatrial.ondemand.com
    6. Path: com.sap.iotservices.mms/v1/api/http/data/<device_ID>
    7. Method: Post
    8. Aditional Header:
      1. Content-Type: application/JSON; charset=utf-8
      2. Authorization: Bearer <Device oAuth> (Note that there is an empty space in between Bearer and the Device oAuth)
  3. Please note that <AccountName>, <device_ID> and <Device oAuth> must be replaced by the values we obtained in the previous steps. The following image shows how this would look like:

In the specify message contents we will copy the message we generated in the Send and Receive messages over at SAP Cockpit.

The advantage of generating traffic with IoTIFY is that IoTIFY will allow us to create smart traffic based on whatever open source JS functions. This means that the data we send over to the IoT Service will have a meaning.

In our case, we will be simulating GPS positions for Refrigerator Trucks driving around real streets. The formulas used are based on open source JS libraries.

https://iotify.help/ has many examples of data that can be sent and guides to help you create your custom data.

{
        "mode": "async",
      "messageType": "bb5b6644d677a6bf6c42",
      "messages": [
        {
            "ID": "{{(last.messages && last.messages[0].ID) ||  chance.string({length:10 , pool:'1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ' }) }}",
          "start": "{{ (last.messages && last.messages[0].start) ||  chance.pickone(['Munich,DE', 'Leipzig,DE','Nuremberg,DE','Hanover,DE','Berlin,DE','Dortmund,DE','Stuttgart,DE']) }}",
          "end": "{{ (last.messages && last.messages[0].end) || chance.pickone(['Munich,DE', 'Leipzig,DE','Nuremberg,DE','Hanover,DE','Berlin,DE','Dortmund,DE','Stuttgart,DE']) }}",
          "loadper": "{{ (last.messages && last.messages[0].loadPer) || chance.integer({min: 60, max:100}) }}",
          "_$path": "{{JSON.stringify(drive({start: (this.start), end: (this.end), accuracy:50}))}}",
          "latitude": "{{JSON.parse(this._$path).latitude}}",
          "longitude": "{{JSON.parse(this._$path).longitude}}",
          "speed": "{{JSON.parse(this._$path).speed}}",
          "insidetemp": "{{chance.normal({mean:10, dev:3})}}",
          "outsidetemp": "{{chance.normal({mean:11, dev:1})}}"
        }
      ]
}

 

If we click on preview, it will show us an example of message to be sent. You can see that IoTIFY will send data according to the formulas you put up. It will also inform us if it managed to establish a successful connection with the IoT Service at SAP Cloud Platform.

 

  1. Once saved, it will take us to the simulate screen to configure the simulation. We will have to complete it with the following info.
    1. NetworkTemplate: SmartTruckSimulation
    2. Name: SmartTruckSimulationV1
    3. Number of Clients: 20
    4. Repeat Message: 2000
    5. Every: 30
  2. Note that Number of Clients represents the number of endpoints for the simulation. In this case it means that we will be simulating in real time 20 trucks going around from city to city sending information every 30 seconds. These messages will be sent by each client a total of 2000 times, meaning the simulation will end at 30 seconds x 2000 = 1000 minutes = Over 16h. 16h seems like a long simulation, we hope our trucks get to their destination!

Once we click on start generation we can get back to the table that contains the messages over at the SAP IoT Service to see the messages arriving in real time.

From this table, we will need to copy part of the link shown when clicking on OData API (top right). This will allow us to fork to this database in subsequent steps. We should end up with a link similar to:

https://iotmmsi850231trial.hanatrial.ondemand.com/com.sap.iotservices.mms/v1/api/http/app.svc/SYSTEM.T_IOT_BB5B6644D677A6BF6C42

From the previous link we only need to copy until app.svc to get the link to the service. It should look like the following link:

https://iotmmsi850231trial.hanatrial.ondemand.com/com.sap.iotservices.mms/v1/api/http/app.svc

Now that we have confirmed that we are receiving real time data from IoTIFY in our SAP Cloud Platform, we will proceed to visualize it in the next blog post of this series.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply