sap hcp iot part 1
TRANSCRIPT
SAP HANA CLOUD PLATFORM – IOT SERVICES Getting Started with the IoT Services
Aaron Williams / PM SAP HCP & SAP IOT Twitter: @aarondonw, SCN: Aaron Williams Description This will walk you through getting your SAP HCP IoT services up and running. And then see the data stored in the tables. For this example, you will not need an IoT device. System prerequisites • Have an SAP HCP Trial Account
Target group • Application developers • People interested in the SAP HANA Cloud
Platform- IoT Services
Target group requirements • Basic programming language, ideally in Java. • Basic knowledge in using an Eclipse
development environment.
30 min
Getting Started with the IoT Services
2
Step 1: Set up- Enabling the IoT Services and Installing the Message Management Service
Explanation Screenshot
USE Google Chrome or Firefox browser
1. Sign up for a SAP HCP Account
2. Go to the cockpit
3. Go to services
4. Scroll down until you see, Internet of Things Services (Beta) and click “Enable” (far right)
You now have enabled the IoT services for your account. The “IoT-User” role has now been assigned
RDMS (Remote Device Management Service and MMS (Message Management Service) have been enabled.
Getting Started with the IoT Services
3
Next we will install the Message Management Service
5. Go to the IoT Services Cockpit by clicking “Go to Service”
6. Select install Message Management Service
7. Enter in your: account ID (pxxx…trial) user name (pxxx…) password and press install Note: your accountID is probably your p# with the world trial on it Your User Name is most likely your p#
We have now deployed the IoT Services application and the MMS. Finally we need to add the IoT-MMS-User Role to our UserID
Getting Started with the IoT Services
4
8. From the HCP-Cockpit, select Java Applications and click on iotmms. This will take us to the Java Application Overview screen.
9. On the left hand side, select Roles.
We now see the predefined IoT-MMS-User Role at the top
10. Make sure that the IoT-MMS-User Role is selected and below click on “Assign”
11. Add in your User ID and press assign.
Note: this is your User ID, not the account name. The User ID is probably “p12…78” without the word trial.
Now we have added the service, installed the MMS, and assigned our user to the IoT MMS User role. Next we will add in a device.
Getting Started with the IoT Services
5
Step 2: Register Devices, Device Types, and Message Types
Explanation Screenshot
1. Go to the HCP Cockpit, then select Java Applications and click on the iotmms application.
2. On the Overview Page click the Application URL
You will now be on the IoT Services MMS page. This is a good page to bookmark
3. Click “View registered devices and device types”
4. Click on Device Types
Getting Started with the IoT Services
6
5. Click the Plus (+) symbol at the bottom to add a new device type
6. Name your device type and press create
Now we will create a Message Type from the new device
7. Click the back arrow (top left) and then click the message types tile.
8. Click the plus at the bottom
Getting Started with the IoT Services
7
9. Name the new messageType, for the device type choose the one you just created, and for the direction choose from device. Then press the plus symbol to add in four message types and their data types. And then press create (bottom right corner) Humidity: double Temperature: double Brightness: double timestamp: long
10. Press the back arrow (top left) to return to the IoT Services Cockpit. Then press the Devices tile
11. Once again, press the plus button at the bottom, to create a new device. Give it a name, select the device type that you created earlier, and press Create (bottom right)
Important: After you create the device, a pop up will appear with a token value. Copy that and save it somewhere, you will need it soon. If you, lose it, click into the Authorization tab and you can generate a new token
We now have everything set up, so lets send some data.
Getting Started with the IoT Services
8
12. Go to the IoT Services- Message Management Services
To get there: From the HCP Cockpit, click Java Applications (from the left hand side) then iotmms from the list of applications and you should see this
13. Click on the Send and Receive Messages via HTTP tile. Then click on HTTP Client under Sample Client
The Sample Client is a very simple post client, but it will allow us to get some data into our system easily
14. Under HTTP endpoint you will see something like this:
https://iotmms[youraccount]trial.hanatrial.ondemand.com/com.sap.iotservices.mms/v1/api/http/data/[deviceID] Change [device ID]to your device’s ID ( it is a GUID), Example: https://iotmmsi02376trial.hanatrial.ondemand.com/com.sap.iotservices.mms/v1/internal/http/data/78873a3a-e7b0-47df-acd3-b0e8ca67067e Where 78873a3a-e7b0-47df-acd3-b0e8ca67067e is my device’s ID
Note: the GUID is the device ID not the token. Also if you look at the URL to the left and compare it to the one that is in the Sample Client, you will see “internal” in the Sample Client and “api” to the left. This is because the Sample Client is internal to HCP, while Postman is run outside.
15. In message to post, replace the text with this:
{"mode":"sync", "messageType":"1", "messages":[{"Brightness":23, "Humidity":25.7, "Temperature": 76.5, "timestamp":1431450313}]}
For this step, we are sending O-Data. This means that numbers (float, int, double, etc) are not placed in double quotes, while strings and the Key of the Key/Value pair are in quotes.
Getting Started with the IoT Services
9
It should look something like this:
16. Press Post, if everything was correct you should see this. If you get an error, make sure that the spelling is correct, and that you have values that make sense. Ie. Putting in double quotes around the values.
17. Push the back arrow twice to get back to the IoT Services Message Manage Service. Then press Display Stored Messages tile
18. Select the table contains your device and you will see the data that you sent
Bonus: Using Postman
Postman is a Chrome extension that is an easy REST client. It is much more powerful than the simple client that is on the web page.
Getting Started with the IoT Services
10
1. Google “Chrome Postman” and install it.
You will need to be running Google’s Chrome browser
2. Copy the HTTP endpoint that you just tested and put it on the URL line of postman. In the drop down, choose POST
3. Open the Headers and add:
Content-Type : application/JSON; charset=utf-8 Authorization : Bearer [Token for you device]
4. Click raw and copy and paste the payload from the Sample Client.
5. Press Send
6. You should get this message back.
The status tells you what happened, in this case it was ok, but you could get error messages too. Time tells you how long the round trip was.
Getting Started with the IoT Services
11
Citations/ Acknowledgements This is was based upon a post by Michael Ameling and the IoT Services Starter Kit. I also got a lot of help from Philip Mugglestone of the Hana Academy team.
© 2014 SAP SE or an SAP affiliate company. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an SAP affiliate company. SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. Please see http://www.sap.com/corporate-en/legal/copyright/index.epx#trademark for additional trademark information and notices.