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: 
hofmann
Active Contributor

rui.nogueira2posted already his IoT sample app (Fish import and export), implemented using Java and REST. gregor.wolf4 posted a version using HANA XS and exposing the service as OData via XSOData. I am publishing now my version that exposes the IoT service as OData using Java and Olingo. Please note: there is now the SAP HCP IoT service available. Please use this service for any IoT related project and do not implement your own IoT service for receiving sensor data from devices. Nevertheless, Rui`s example is easy to implement and shows how the different parts play together: client, server, user.


When I first came across Rui`s blog I noticed that he uses REST and goes through some effort to persist the data. I thought that it would be nice to adopt this to make use of OData. In the end, I did not adjusted his code, it merely served as an orientation. I wrote my own IoT server and client app. The result is a simple, clean and easy to read JEE app that uses JPA and Olingo for exposing the JPA entities and a Java client that does not need to be run on an IoT device. My user dashboard is very simple, implemented in D3.js, and only shows one sensor`s measurement data.


The source code can be found on GitHub: https://github.com/tobiashofmann/fish-with-odata

  • iotclient, containing the client app
  • iotserver, containing the server and user dashboard


Both are maven projects. It should not be a problem to transform them into Eclipse projects via mvn eclipse:eclipse. The client is a Java app that reads current weather data from openweathermap.org. To make this work, you`ll need an API key (free). In case you do not want this, I added a jMeter test that creates random temperature data (as seen in above picture).


Sensor and Measurements are implemented using JPA. The relationship between both is that one sensor can have many measurement assigned, but a measurement can only be assigned to one sensor. In the Snesor class, this is done via @OneToMany

Run server


mvn clean pre-integration-test

This will download the HCP SDK, install the server, run it on port 7080 and deploy the WAR file. After some while, the IoT server is ready.

Run client


mvn package
java –jar target\fishodataclient-1.0.0.jar

As an alternative, a jMeter test is included in the server: fish-with-odata\iotserver\test\jmeter\ LoadData.jmx

More information can be found in my personal blog.

Labels in this area