Capture event streams from IoT devices and perform predictive analytics using HCP – Part 4
This blog is part of a series which is related to setting up Smart Data Streaming, IoT Services & Predictive Services.
In the previous blog post, I showed how one could setup Smart Data Streaming (SDS) on HCP and capture streaming data from IoT devices which are in the edge. In this blog, I am going show how you can integrate HANA Cloud Platform IoT services with Smart Data Streaming. You can now manage the entire device life cycle using HCP IoT services and use SDS to analyze and process the incoming streams. HCP IoT services will forward all the incoming messages to SDS to process. Hence, data is not persisted in the usual HCP IoT tables for this scenario.
Setting up the SDS Project
I am just building up the scenario from the previous blogs. Some of the tables created in the earlier blog, may not be relevant anymore. Hence, I have created another table in HANA called “SENSOR01” to store the processed messages. This table will ultimately store the data passed via the HCP IoT service and SDS.
I have created a new SDS project called “devicetest” and have repeated the same steps performed in the earlier blog. The only difference is the Input Stream has different field as it has to match the schema of the message type I would declare in HCP IoT services. The other difference is that I am now using SENSOR01 table in HANA Output adapter.
Here is how the CCL file would look like for this project
Once you compile and run the project, the Server view will open up as shown below.
Make a note of the above 3 items. You will need them later. Let the project be in running state.
1) Workspace name – default
2) Project name – devicetest
3) Input Stream name – devicestream
Configure Device/Message Types in IoT services
Navigate to the HCP IoT Cockpit and use the Device Management tiles to create each of them.
Add a message type for the device
Add a device type and attach it to the message
Finally, create a new Device as shown below
Create Service Mappings in MMS
Navigate to the MMS cockpit. Ensure that you have deployed the latest version of MMS otherwise the below functionality may not work. Click on “Configure Processing Service Mappings”
Create the first mapping by clicking on the “Add Mapping” button.
From the popup, select SDS as we need to use this setting to enable IoT MMS service to forward the message to SDS.
In the Processing service screen, provide the values of the SDS host, port, user, Project and Input Stream details as shown below
Click on “Back to Mappings” and then click on “Create” button to save your changes. Now you should be able to see a new Service Mapping of type SDS as shown below
You could also use a REST client to create a service mapping. I prefer this way as it is easy. The below step is not required as its another way of creating the Service Mappings. I am using Advanced REST Client
Below is the contents of the PUT Request
You should get a message “Processing service mapping with device type [XXXXXXX] and message type [XXXXXXX] has been registered”.
Test the IoT Device
For sake of simplicity, I am going to use the Test console provided by HCP IoT services available in the MMS cockpit. Click on the tile which can be used to test HTTP API.
Provide the details in the below format to send a test message to the registered device
Now when I switch to the HANA Studio and look at the Input Stream of the SDS project which was created earlier, I should see this message flowing into SDS
Since the test data would pass all the filter conditions in the SDS project, this should be updated in the HANA table
Just to confirm that there are no tables being created by the HCP IoT Services, I can navigate to the MMS Cockpit and click on “Display Stored Data” tile
There shouldn’t be any I_IOT_<MessageType> tables created by the IoT Services.
This concludes the IoT/SDS part of this blog series. In the next part, I will focus on how to use HCP Predictive Services to analyze the data stored in the HANA Table.