Introducing

In this blog i want to continue the little walktrough which we´ve started last month about SAP Cloud Platform IoT service in combination with SAP Cloud Platform IoT Application Enablement:

1 Create your virtual twin with SAP Cloud Platform Application Enablement
2 Build up an IoT App on top of SAP Cloud Platform Application Enablement (this blog)
3 Run your IoT App on SAP Cloud Platform (Cloud Foundry Environment)
4 Technical aspects and configuration for SAP CP IoT Enablement
5

Scenario Architecture

In the picture below you can see we´ve still connect our device to SAP Cloud Platform IoT services (1) and we´ve successfully build up the virtual(digital) twin of our device (2).

We want now start to develop a little app in the “neo” environment wit the SAP Web IDE (3) by the usage of the SAP IoT AE API´s:

Update/Change

As you can see in this blog by Lukas Brinkmann we´re now able to send commands from SAP CP IoT AE to IoT service an finally to our device.

Please check the “Release Notes” here for a little change of the “attribute type”:

A final example of an adjusted configuration can be found in my GitHub repository here

Futhermore you can find a python based prgramm (runs on your local pc or an Raspberry PI) which use publish/subscribe with MQTT here:

https://github.com/fableh/iot_python_scripts

If u execute the script and fire a command back to the device:

 …. we can now also se these commands in the console if we succesfully subsribed to the mqtt topic:

For more examples please visit also the SAP IoT Starte Kit, especially for the “Cloud Foundry” ennvironment for a lot of more examples:

https://github.com/SAP/iot-starterkit/tree/master/cf

 

IoT App development with SAP Web IDE Full Stack

Prerequisite: Before we can satrt the the development we need to check/create some destinations in the “neo” environment, These destinations are required to access the “iot data” from the “cloud foundry” environment. The setup of these destination is part of the onboarding process of your SAP CP IoT AE tenant.

A detailed documentation about the config can be found here.

After we have checked the destinations we can now execute the “SAP Web IDE Full Stack” in our SAP Cloud Platform Neo Environment.

For the usage of the SAP CP IoT Application Enablement features/templates you need to enable this as described here.

Now we can create a new template based “IoT Application” by using the wizard:

Afterwards we define teh basic information for our app:

Project Name CPU_usage
Namespace syc.iot.notebooks
Titel MyApp

 

 

Reference to the OData destination, which allows us to fetch the “Thing Data”:

Afterwards we can now search our property set(s):

In upcomming next screens we can now first decide which views we want to have in our app (we choose here all):

And finally we have now the chance to define for each view which properties we want to display:

After we run the application for a first test we got the following result:

But if we now want to click on our “Thing” to locate it in the map, something is missing.

Based on this it´s required to enhance our thing with some additional data.

Enhance the “Thing Data”

To specify the “location” of our thing we have two options one via the “Thing Modele Application” or via the “SAP CP IoT AE API´s”:

UI:

The API way (my choice);

 

Fetch the CSRF token

First of all we need to Fetch the CSRF Token and setting this globally in our Postman Environment:

URL: https://{{tenant_id}}.iot-sap.cfapps.eu10.hana.ondemand.com/appiot-mds/Things

Maintain your “Postman Environment” for SAP CP IoT AE:

Create the Location
URL: https://{{tenant_id}}.iot-sap.cfapps.eu10.hana.ondemand.com/location/Locations
{ "basicData": { "tenant" : "" }, "locationData": { "streetName": "Heinrich-von-Stephan-Straße", "houseNumber": "1-5", "cityName": "Göttingen", "postalCode": "37073", "country": "DE", "countryDescription": "Germany", "longitude": 9.92829, "latitude": 51.53708 } }

Response (Location ID):

https://location.cfapps.eu10.hana.ondemand.com/Locations('3C8C03C00CDE451092E293EDDF22489F')
Create the “Business Partner” for the Thing
URL: https://{{tenant_id}}.iot-sap.cfapps.eu10.hana.ondemand.com/tenant/Persons
{ "person": { "basicData": { "tenant": "", "etag": "1" }, "personName": { "formOfAddress": "0002", "formOfAddressDescription": "Mr.", "familyName": "Lehmann", "givenName": "Fabian" }, "communicationData": { "emailAddress": "[email protected]", "mobilePhoneNumber": "+49111111111", "landlinePhoneNumber": "+49222222222", "streetName": "Heinrich-von-Stephan-Straße 1-5 ", "cityName": "Göttingen", "postalCode": "37073 ", "country": "DE", "countryDescription": "Germany", "region": "03", "regionDescription": "Lower Saxony", }, "objectGroup": "" }, "employingOrganization": { "businessPartnerID": "" }, "userActive":"true" }

Response (Person ID):

https://tenant-administration.cfapps.eu10.hana.ondemand.com/Persons('9E1B3941B70E47338276B3E4C9F1220D')

 

Update the Thing with the location and person id
URL: https://{{tenant_id}}.iot-sap.cfapps.eu10.hana.ondemand.com/appiot-mds/Things('442414166D8D4F79B809054EBE3B45C4')
 { "_id": "442414166D8D4F79B809054EBE3B45C4", "_externalId": "FabiansZBook", "_alternateId": "ZBook", "_name": "FabiansZBook", "_description": { "en": "FabiansZBook" }, "_thingType": [ "iotae.sycor.syc.sap.blogs.notebooks:ZBook" ], "_location": "3C8C03C00CDE451092E293EDDF22489F", "_customer": "9E1B3941B70E47338276B3E4C9F1220D", "_objectGroup": "D34AF712DFD34A77A92E9A26652D227E" } 

 

Check the result in the SAP Web IDE “preview”

If we now enter the application again, we can see that our device is now located as defined and has assigned our “Person” as “Contact Info”:

We can now enter the different screens to see more details:

 

Summary

As u can see with SAP IoT Application Enablement, it´s really easy to develop an IoT App to visulaize your “Thing Data”. Futhermore we´ve seen how we can enhance our Thing with additional data e.g. from core applications like S/4 HANA.

In the next blog we want to cover the follwoing

  • Deploy the app to “SAP Cloud Platform Cloud Foundry Environment”.
  • Developing an second application were we visualize routes on the map.
  • Creating events via the SAP CP IoT Application Enablement API.

 

Some links

SAP Cloud Platform Application Enablement

What´s new in SAP Application Enablement

SAP CP IoT AE – Reuse Controls and Templates

IoT Application Projects in SAP Web IDE

SAP IoT Starter Kit on GitHub

Used python script to send and retrieve data

 

cheers,

Fabian