Skip to Content

This is first blog among the series of blogs that I intend to write which would show the enriching capabilities of the SAP Cloud Platform Internet of Things Service for Cloud Foundry environment mainly the IoT Gateway Edge which is an important part of the edge platform component of SAP Cloud Platform that extends the cloud platform to the edge. This in turn serves as a primary means of deployment of the SAP Edge Services which I will cover in detail in future blogs.

 

This blog primarily focuses on implementing a standard ‘File Adapter’ for fetching the sensor data (In this case a .csv file) and sending it to the IoT Core. In the subsequent blogs I will cover implementation of other adapters supported by IoT Gateway Edge along with creating our own custom adapter and intercepting the sensor data from these adapters before persisting them in the IoT Core.

 

In the first part, I would show how to configure the Internet of Things Gateway Edge.

In the second part we will persist the sensor data read from a .csv file to the IoT core and visualize the same in the IoT cockpit.

 

Introduction

The SAP Cloud Platform Internet of Things Service enables customers and partners to develop, customize, and operate Internet of Things business applications in the cloud.

SAP Cloud Platform Internet of Things Service (Cloud Foundry based) is part of the Leonardo Foundation.

 

 

 

Internet of Things Service for the Cloud Foundry environment

The Internet of Things Service for the Cloud Foundry environment connects devices to the SAP Cloud Platform to provide scalable ingestion of IoT data and device management. The respective services provide a secure connection to remote devices using a broad variety of IoT protocols and manage the device lifecycle from onboarding to decommissioning.

 

 

The above diagram shows a brief architectural overview of the IoT setup in the SAP Cloud Platform highlighting the IoT Gateway Edge component along with the adapters and plugins.

 

Internet Of Things Gateway

This is software component and forms an integral part of the overall IoT architecture. The IoT gateway interacts directly with the device while receiving measures from and sending commands to them along with providing adapters for the communication with various protocols.

IoT gateway can be deployed in cloud or on the edge.

IoT gateway is deployed as a managed component in cloud and currently supports MQTT and REST protocols only.

 

IoT gateway on edge

There might be a business need when these two protocols are not enough to meet the business requirement. In such a scenario we must use the IoT gateway on edge which supports a wide variety of protocols that can be managed by customer.

 

Adapters

These are the channels through which IoT gateway on edge streams normalized data up to the IoT core service.

 

Scenario 1: Implementing a standard file adapter for reading sensor data (In files) and streaming them to the core service.

 

Prerequisites:

 

  • You need an instance of the SAP Cloud Platform Internet of Things Service.
  • You need the <HOST_NAME> which you can use to access the system.
  • You need a tenant and a user with administrator role.
  • You need to install Java SE Runtime Environment 8 to run the Internet of Things Gateway Edge
  • For publishing data, you would need the data model required by the protocol.

 

 

Steps:

  • Download the zip archive (Example: IOTCHCP**_*-70002561.ZIP) to your local machine by login in to the SAP Software Center. In this particular scenario I have downloaded the SP 20 related file. Current SP level is SP23.

 

  • Unzip the archive file. Inside this archive there are two important .zip files, one the gateway-<version>.zip and the sdk-<version>.zip. For standard file adapter implementation, we would need the gateway-<version>.zip while sdk-<version>.zip would come into play when you try to implement a custom interceptor for tracking your sensor data (More on this in the later blogs).

  • Inside the gateway-<version>.zip,you will find the ‘build.bat’ and the ‘build.sh’ files along with some other script and .jar files:

  • Launch the ‘build.bat’ using CMD for windows or ‘build.sh’ using terminal for macOS. This will create the ‘config_gateway_file.xml‘ in the ‘config’ folder along with few other folders out of which there are two very important ones like ‘readFileConfig’ and ‘schemas’:

  • Open the ‘config_gateway_file.xml‘ in a text editor probably  notepad++. Replace the 127.0.0.1 for the ‘connection string’ and the address element in the ‘coreConnection’ with your host name (Something like ‘sample.cp.iot.sap’):

 

  • Save your changes.

 

  • Now go to the ‘readFileConfig’ folder and open the ‘readFile.json’ in text editor.This file content determines the how your file adapter will work after initialization.The important parameters in this file are:

 

         

  • path: This determines the location which will be used by your file adapter to pole for the sensor data either in a .csv or .json file.

 

  • mode: This determines the way in which the file adapter will check for new data.

 

  • interval: This determines the frequency at which the file adapter will check for new files.

 

  • schema: This determines the schema of the custom data model which one can create according to business requirement.

 

Note: The file adapter would build this schema first during initialization before receiving the sensor data which is collected in a file and subsequently do a 1:1 mapping based on the data type of the field.

 

  • deviceAlternateId: This will create/initialize a device with the custom alternate id mentioned in the parameter during initialization process of the adapter.

 

  • backupFolder: This will provide the location for back up of the files read by the adapter for later reference.

 

 

 

                     

Note: For Windows, Replace the directory separators “/” with “\\” in the ‘readFile.json’ before saving it.

For publishing data a data model is required by the protocol (FILE). This will be discussed in details in the second part of the blog.

 

  • Now log on to the IoT Service Cockpit with your user credentials and download the certificate-<user>.zip by clicking on the download button:

 

  • Unzip the above ‘certificate-<user>.zip’ file. Create a folder called as ‘certificates’ in the ‘config’ folder and copy the contents of the above .zip file in it.
  • Now open the ‘pswd.properties’ file in the ‘certificates’ folder and enter your user and password that you used to log in to the IoT service Cockpit and save the file subsequently:

  • Last but not the least, execute the execute the ‘gateway.bat’ in CMD for windows or ‘gateway.sh’ in the terminal for macOS to start the gateway file adapter using the ‘FILE’ protocol. Wait for the below message highlighted in red for successful registration of the gateway file adapter.

 

  • Once your initialization and subsequent registration of the gateway file adapter mentioned in the previous step is complete, you can log in to the IoT service cockpit to see the file adapter under the (Component Management -> Gateways) section with the status ‘Online’:

 

References:

SAP Help Portal

 

To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply