Communicate with IoT in your WebIDE project

Communicate with IoT in your WebIDE project

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

Communicate with IoT in your WebIDE project

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”

Communicate with IoT in your WebIDE project

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

Communicate with IoT in your WebIDE project

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

Communicate with IoT in your WebIDE project

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

Communicate with IoT in your WebIDE project

4. Use the IOT library

Include the library in your controller:

Communicate with IoT in your WebIDE project

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

Communicate with IoT in your WebIDE project

5. Result

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

Communicate with IoT in your WebIDE project

Leave a Reply

Your email address will not be published. Required fields are marked *