Quantcast
Channel: SCN : All Content - SAP HANA Cloud Platform Developer Center
Viewing all articles
Browse latest Browse all 3285

Communicate with IoT in your WebIDE project

$
0
0

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

 

destination.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

 

In 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:

 

include.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

 

push.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


Viewing all articles
Browse latest Browse all 3285

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>