Skip to Content

In this blog post we are going to learn how to quickly populate your SAP Cloud platform with relevant data when data is still not available and you want to focus on developing your IoT applications with SAP.  We will do this by generating data with IoTIFY’s Network Simulator and sending it to the Internet of Things service in SAP Cloud Platform.

This is a first contact post to show the ease of combining IoTIFY’s tools for IoT development and SAP Cloud platform. In subsequent posts we’ll probably dive deeper into more practical applications with SAP Cloud platform and enhanced IoTIFY network simulation templates.

In order to follow this tutorial it is important that you have a IoTIFY account and a SAP Cloud Platform free trial account. Also it’s necessary that you have previously deployed the IoT service in the cloud platform. If you’re not familiar with this procedure you can follow it here:

https://blogs.sap.com/2016/02/01/little-known-ways-to-try-hcp-iot-services-using-simulator-part-2/

So, enter the SAP Cloud Platform homepage and let’s get started…

 

  1. In the home page of SAP Cloud Platform it’s important to copy the account name because we’re going to need it later.
  2. To open the IoT services dashboard we go to the left panel and click services. In the services list we search Internet of Things Services.
  3. Once inside we need to click Go To Service. This is going to take us to the IoT Service Cockpit

  1. In the IoT Services Cockpit the first thing that we’re going to do is create a new Message Type. Click the Message Types tile.

  1. The message is going to have the following attributes::
    1. Name: NetworkSimulationMessage
    2. temperature: double
    3. latitude: float
    4. longitude: float
    5. humidity: double
  2. Then we click on Create. It’s important that we copy the ID of the message because we’re going to use it later. Then we go back to the cockpit

  1. We click on the Device Types tile and go to the + sign to create a new Device Type. This new Device Type is going to have the following attributes:
    1. Name: NetworkSimulationDeviceType
    2. AssignmentName: MFD
    3. Message Type: NetworkSimulationMessage
    4. Direction: From Device

  1. We click on Create. It’s important that we also copy the ID of the message type because we’re going to use it later. Then we go back to the cockpit

 

  1. Go to the Devices tile and create a new Device with the following attributes:
    1. Name: NetworkSimulationDevice
    2. DeviceType: NetworkSimulationDeviceType

  1. Once you create the Device a pop up is going to emerge and show you the oAuth access token, it is important that you copy this token because we’re going to use it later.

  1. Once you copy the token, copy the device ID too and proceed to close the pop up. Then you can go back to the cockpit. Until now what we have done is create the template of the message and the tokens for the device. Now we’re going to use this to send a test message to be sure that we have all up and running.
  2. Click on the Send and View messages tile
  3. Go to the Messaging through HTTP tile. In this tile we’ll create the URL to do the POST and create the body of the message that we’ll send.
  4. In the Data Endpoint section we need to change the last part of the string for the device ID that we copied in step 11.
    1. https://iotmmsi850231trial.hanatrial.ondemand.com/com.sap.iotservices.mms/v1/api/http/data/<device_ID>
  5. In the Message section we need to create the body of the message that we’ll send. It’s important that the order of the body messages attributes follows the same order we created in the message type in step 5. The Message Type string is the ID that we copied in step 8. At this stage, we will content by typing out random values manually.

{

    "mode": "sync",

    "messageType": "71a6d731a4c62acdfab4",

    "messages": [

        {

            "temperature": 23.5,

            "latitude": 10.4709293,

            "longitude": 66.8747017,

            "humidity": 30

        }

    ]

}
  1. After you finish the configuration press the send button.
  2. If all the configuration is OK we should receive a 200 code indicating that the message was received by the platform. In this case we already have the URL to post the message and the body template to send.
  3. Go back to the previous page and press the Display Stored Messages tile.
  4. In this list we can see the physical tables generated by our devices. Specifically we’re interested in the table called T_IOT_<Message_ID>. This message ID is the one we configured in step 5, and we should see here all the messages that we generated in the previous point.
  5. I sent 4 messages using the tool that we previously saw in step 17.

Now that we have setup and configured our service it’s time to go toiotify.io and configure the Network Simulation environment to send random generated messages to our IoT service.

  1. Open the IoTIFY web page and create or use an existing account. .
  2. Go to Network tab and create a new template.
  3. In this page we need to configure the network simulation parameters. To do so fill the blanks as follows:
    1. Name: NetworkSimulationSAP
    2. Connection Type: HTTP
    3. Protocol: Https
    4. Host: iotmms<HCPuser>.hanatrial.ondemand.com (We copied this user ID in step 1)
    5. Path: com.sap.iotservices.mms/v1/api/http/data/<device_ID> (we copied this device ID in step 5)
    6. Method: Post
    7. Additional Header:
      1. Content-Type: application/JSON; charset=utf-8
      2.  Authorization: Bearer <Device oAuth> (We copied this token is step 10. It’s important that you leave a blank space between the word Bearer and the token)
  4. On the Specify Message Contents section we’re going to paste the message that we generated in step 15 with some changes to it. The great advantage of generating Network Traffic with IoTify is that you can put practically any function to generate data inside the body of the message. In this first example we’ll use the following random generation function. In subsequent blog posts we will show how to get the most out of SAP Cloud Platform with simple functions in IoTIFY:
    1. “temperature”: “{{chance.floating({min: 0, max: 35, fixed: 2})}}”
    2. “latitude”: “{{chance.latitude()}}”
    3. “longitude”: “{{chance.longitude()}}”
    4. “humidity”: “{{chance.integer({min: 10, max:90})}}”
  5. When you click save the page is going to send us to the next step of the configuration. In this step we need to configure how many messages we want to send and from how many clients. Use this example at first:
    1. NetworkTemplate: NetworkSimulation
    2. Name: NetworkSimulation1
    3. Number of Clients: 100
    4. Repeat Message: 20
    5. Every: 10
  6. This is going to simulate 100 devices sending information every 10 seconds. This is going to repeat 20 times to a total of 2000 send messages.
  7. Once the simulation it’s done we can see the stored messages in our IoT service. The table should have 2000 new messages with random information in the attributes:

And that’s all! I hope you enjoyed the tutorial!

 

Nicolas Araque

SAP Presales Specialist

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