Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Murali_Shanmu
Active Contributor
0 Kudos

This blog is part of a series which is related to setting up Smart Data Streaming, IoT Services & Predictive Services.

HANA Cloud Platform - Using IoT services, SDS & Predictive services



In the previous blog post, I showed the steps required to create a Smart Data Streaming (SDS) project. In this blog, I will focus on different ways to test your project (including a REST client) and finally use a sensor device like SensorTag to stream the data to SDS which is available on HANA Cloud Platform.

Testing the SDS Project

When you compile and run a SDS project, it will automatically switch to the "Run-Test" console and you will be able to see your input stream "DEVICE_STREAM"along with other objects. Click on the Manual Input tab and then select “Select Stream” button to assign the manual input testing for DEVICE_STREAM.

Provide low values for Temperature and Light and click on "Play" icon.  You should be able to see the record flowing through the input stream in the Stream View tab.

However, if you view Apply_Filter & ESP_Connections tab, you will not see any output. The reason being, the we have set a filter to only look for records which have Temperature greater than 20 and light sensitivity greater than 40.

I will now add another record with higher values to pass through the input stream. It should show up in the Apply_Filter output stream and also successfully updated in HANA table.

I can now navigate to my HANA Table to check if the record (which I am interested in) has been inserted in to the table.

Another interesting tool is the playback tool. You can load data in a spreadsheet and request the tool to pass one record as a time in a periodic interval. I have the below csv file. The First two columns denote the stream name and operation.

Click on the Playback tab, set the rec/ms (records-per-milliseconds) value to .005 and upload the file and click on the play icon.

This will pass one record at a time in a fixed interval and you can visualize the stream view to see how the data is flowing. in the below image, you can see how only 7/10 records passed the filter condition and were captured in the HANA table.

Test Using REST Client

Before using programs to pass the sensor data to SDS project, it is always good to use the REST client to test this out.  This is all documented in SAP Help. I am using Postman REST Client to test this. The first test it to check if you can connect to the server to get version info

Operation: GET

URL: https://sds01swsc59c97a90.ap1.hana.ondemand.com/1/version/


The next step would be to acquire a SWS Token. In the below example, I am specifically requesting access to a stream in a project

Operation: POST

URL: https://sds01swsc59c97a90.ap1.hana.ondemand.com/1/authorization

Header: Authroization : HANAUSER1 user/password (Base64 encoded)

Body: [{ "privilege":"write", "resourceType":"stream", "resource":"default/devicemonitor/DEVICE_STREAM"}]

The last step is to publish the message using the SWS token

Operation: POST

URL: https://sds01swsc59c97a90.ap1.hana.ondemand.com/1/workspaces/default/projects/devicemonitor/streams/DEVICE_STREAM

Header: Authorization = SWS-Token "sws-token"="*****ddBq80Qw=="

Body: [{"ESP_OPS":"i","DEVICEID":103,"EVENT_TIME":"2016-08-23T04:45:36.123","TEMP":"78.32","LIGHT":"94.11"}]

Status 200 OK is a good sign. I should be able to see the record inserted in my HANA Table

Streaming data from a sensorTag

sensorTags are small sensor devices (approx 30-40$) which comes with bluetooth capabilities and has about a dozen inbuilt sensors like temperature, humidity, vibration etc. I have used this earlier for other demonstrations and also attached the source code in this blog Internet of Things made simpler with SAP API Management - I

The sensorTag will communicate with Raspberry PI over Bluetooth and there is a program which will stream the sensor data to REST APIs which we tested above. With this, I can now set alerts and notifications within SDS whenever sensor data goes beyond a threshold.

Streaming Lite in SDS

When it comes to using IoT gateways in the edge, another variation is to have a light version of SDS installed on the IoT gateway. You can process the data right at the source and then stream the required/transformed data to another SDS project running on HCP. You can find more info in this blog Learning how to use Streaming Lite with HANA Smart Data Streaming

When to use SDS & HCP IoT services ?

I had this question asked few times. SDS comes with a tremendous capability to process, analyze and transform incoming messages and accordingly set alerts and notifications. HCP IoT services is very good at managing the entire device lifecycle. Last month, there was a new functionality released as part of HCP IoT services, where all incoming ,messages can be passed on to a SDS project which runs on HCP.  As stated in this blog, SDS complements HCP IoT services and we could have great outcomes by combining the power of two.

In the next blog, I will focus more on how to integrate HCP IoT Services with Smart Data Streaming in HCP.

Labels in this area