Skip to Content
Technical Articles

Communicate with IoT in your WebIDE project

This blog is outdated. HAT will no longer support the described functionality. There is now an alternative feature in SAP Web IDE Full-Stack called “IoT Enablement”. You can refer to the blog post here: https://blogs.sap.com/2018/01/15/how-to-build-an-iot-app-on-top-of-sap-cloud-platform-iot-application-enablement/

Hi all,

I recently posted blogs about the HANA Car: HCP IoT HANA Car v1.0 . The HANA Car is connected to IoT on HCP. To control the car I’ve created a Java Web application with a Java Servlet and UI5 web part as described here: HANA Car v1.0 – Java Webapp .

This was a good first working demo but I didn’t like the use of the Java servlet. Therefore I’ve searched and found a way to push messages from javascript (UI5) in the WebIDE to the IoT services without a Java Servlet .

Follow the next step to communicate from your WebIDE project with the IoT service:

1. Create the destination for the IoT service in you HCP cockpit

/wp-content/uploads/2016/04/destination_926621.png

The URL for iotmms:

https://iotmmsp935700trial.hanatrial.ondemand.com/com.sap.iotservices.mms/v1/api

URL for iotrdms:

https://iotrdmsiotservices-p935700trial.hanatrial.ondemand.com/com.sap.iotservices.dms/v1/api

2. Inject Internet of Things API library

Open your UI5 project in the WebIDE. Go to the folder where you want to implement the IoT library. Right click and click on “Inject Internet of Things API library”

iot right click.png

You’ll now have a new file “IOT.js” in the folder where you’ve added the library.

iot lib.png

Change the namespace of the IOT library to the namespace of your project:

iot namespace.png

3. Configure neo-app.json

Configure the destination of iotmms in the neo-app.json. The following configuration will redirect every request to iotmms. It will also replace “iotmms” to “http”.

neo app.png

4. Use the IOT library

Include the library in your controller:

/wp-content/uploads/2016/04/include_926633.png

Call the function “pushData” and pass the following parameters:

  • Device ID
  • Method (“http” or “ws”)
  • Sender name ( you can choose this, I used “HANA Car Control”)
  • Messagetype ID
  • Messages
  • response function
  • error function

/wp-content/uploads/2016/04/push_926628.png

5. Result

Now I can control my HANA car from my WebIDE project. No need for a Java Servlet 🙂

10-04-2016 19-41-29.png

Good luck!

Kind regards,

Wouter

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