IoT Devices (KPN LoRa) Uplink Messaging Integration with SAP IoT Service on SCP using SAP API Management and Cloud Platform Integration
Business Case:
With increasing availability of smart devices, the need for communication between smart devices, applications and databases becomes critical. To achieve this communication, the use of light weight messaging formats, transport protocol and integration platforms is essential. More devices would get smarter and become connected via the internet, therefore, scalable and robust IT infrastructures that can support Internet of Things (IoT), Internet of Everything, Big Data, Artificial Intelligence would be at the heart of digital innovations for every enterprise.
The KPN LoRa offering, provides the possibilities to help enterprise, individuals, cities participate effectively in the foreseeable fourth industrial revolution, expected to be driven by Internet of Things. LoRa offers a new type of connectivity specifically for IoT applications. LoRa stands for long-range and is a new technology which can connect devices to the internet over long distances. With LoRa, sensors can easily send their data to the internet over long distances, or devices can receive commands from the internet such as on/off or open/close. Further information about the KPN LoRa offering can be found via this link: https://www.kpn.com/zakelijk/grootzakelijk/internet-of-things/en.htm
At Experis Ciber, a PoC has been performed and this write up, provides the layout on how to sync data generated by IoT devices with the SAP IoT service on SCP using the SAP Cloud Platform Integration, previously known as SAP HCI. This set-up can also be used for other IoT applications that need to sync data with SAP IoT service on SCP.
Set up:
Primarily, industry standard messaging protocols and transport protocols can be used for communication between devices, applications, databases. The KPN LoRa has the capabilities to push messages in XML or JSON format over the internet using the http/https protocol. In this set up, the XML message format has been considered, while the SAP IoT service on SCP processes messages in JSON format. The SAP API Management and Cloud Platform Integration (CPI) has been used to achieve the following:
* Connectivity via https protocol
* Security is set up via API Management flow
* Messaging and transformation between LoRa (XML message) to SAP IoT service on SCP (JSON message)
Figure: Architectural overview
Configuration
Technical details of the set up are outlined below:
1.Set up an API Flow. Follow the wizard, configure the target endpoint with the http endpoint of the CPI flow, the endpoint of the API flow is also created with the path specified in the creation process
2. Policies set up in API Flow: Include the policies below in the API flow, this will take care of the login into the CPI to trigger the iFlow.
3. IFlow in SAP Cloud Platform Integration. Create an iFlow in SAP Cloud Platform Integration tool using the Web IDE. Include these artifacts (XSLT Mappings, Service call (Request-Reply) and Content Modifiers) in the flow in the order shown below.
The artifacts show above contains different logic that have been set up in each step of flow, to achieve the final output message needed to sync data with SCPIoT service.
4. HTTP Sender Adapter: Configure the HTTP Sender Adapter as below, providing necessary details in the “Adapter Specific” tab-Authorization: UserRole
-User Role: Keep “ESBMessaging.send” (but make sure you have a user credential deployed as artifact, as the username/password in this artifact needs to be provided to your device, eg LoRa for authentication)
-Address: path to be added to the URL for LoRa to send messages
5. Service Call: Request-Reply: The service call step has been implemented to call an external application, to do the conversion of the payload from hexadecimal to text.
The response of this service call, is then included in the final call towards SCPIoT service.
6. JSON-XML Converter: The response returned from the service call is in JSON format, this is converted to XML in this step, for further processing.
7. Mapping: XSLT Mappings have been used in 3 steps of the flow, to process incoming message into expected output. XSLT Mapping primarily to accept the XML input from LoRa and create a JSON message as an output which conforms with the output expected by the IoT service on SCP. Although CPI has a default XML-JSON converter, this was not used because, the input XML cannot be transformed 1-on-1 to JSON message format the IoT service on SCP expects. -MessageType: ID of the messageType defined on IoT Service
-Field names: specified the fieldnames as it is in IoT service and use the XSLT logic below to select values from incoming XML.
-Mode: mode of communication expected can be specified as async/sync
XSLT 1: Processing of payload_hex as an output into the 1M2M service
XSLT 2: Select the element names and values of the decrypted hex payload
XSLT 3: JSON output for the preformatting of JSON IoT service input
8. Content Modifier: Configure the Content Modifiers
-To log payload at different steps
-pass the HTTP header parameters as: Content-Type and Authorization: Bearer + Token (token generated on device from IoT service on SCP)
-Format the final message towards SCPIoT service
9. Receiver HTTP Adapter: Configure the HTTP receiver adapter as below with emphasis on the “Adapter Specific” tab
-Address: URL to reach your Device (containing your deviceType and messageType) on the IoT service (the Github documentation provides a guide on creating the URL)
Once all the steps above are completed, save your iFlow and deploy, if all configurations are complete, the iFlow should deploy without errors.
Pushing Messages towards from LoRa to IoT service on HCP: Once the set-up is complete, information required to test the flow are the following:
-XML sample message
-URL (Note how the URL for LoRa is constructed to be able to send message to this flow)
-Credentials deployed on SAP CPI.
Once this is setup primarily in the KPN LoRa dashboard, messages can be pushed towards the flow in CPI and sync towards IoT service on HCP. You can also test your flow with client tools, such as SOAP UI or Firefox Rest Client Addon
Test 1: Sample Test from SOAP UI
Test 2: Sensor Data in KPN ThingPark for uplink messaging towards SCPIoT service
Message Processing in SAP CPI: Total message processing time in SCP can be as less as shown below:
Messages in IoT Service on HCP: Messages synced towards the IoT service on HCP can be viewed by navigating the “display stored messages” tab of IoT MMS
Messages Displayed in Tables: Decrypted Payload highlighted below
Conclusion: Integration would be critical for enterprise to fully explore the power of IoT and Big Data that would be generated, to power digital innovations. This article has been able to provide one of such integration capabilities. Synced data towards SCP IoT can be further mined/explored for business values, eg creating Fiori apps on top of this data.
Relatively, if the requirements are clear and necessary skills are available, this flow can be set up within a reasonable effort estimation.
We have the capabilities and technical know-how to help achieve your IoT related integration scenarios. Do reach out if you have further questions or help needed.
Written by: Abidemi Olatunbosun
Contributions from colleagues who participated in the implementation: Arnaut Kamhoot and Martijn van den Berg. http://bit.ly/2gCqqHk #SAP #SAPCloud #AI