Configure Edge Device Administration Demo – Technical Blog Series
June 5, 2018
Thanks for joining me today on the ClearBlade Technical Blog Series. Today we are going to look at device administration in the ClearBlade IoT Platform and how you can easily configure your systems for specific use cases.
As you build your IoT solutions you need to do things like define and organize devices into types like pumps, batteries, etc. Very often you’ll want each type to have its own schema, with pressure and RPMs as attributes for one device type and voltage and amperage for another type.
With each device assigned a type you then need the ability to edit the desired device type and potentially interact with it. Interaction could be viewing its status history, clearing old information about a device, or sending new information to the device.
- Installing and Configuring IPM Package
- Type Creation
- Creating & Interacting with your Device
- ClearBlade Sandbox Account (Create)
Part 1: Configuring the IPM Package
1. Start by going to IoT Package Manager (IPM) and pull down the example that has the pieces put together for you. Here you’ll find all kinds of solutions waiting to be leveraged. For the purposes of this demonstration, you’ll want to use the “device-administrator” package. You’ll notice there is a setup and description of the package below. To get started, grab the repository url by clicking copy at the top next to the URL.
2. Click into the Device Admin package then select and copy the URL of the package
3. You want to install this as a new package by opening the ClearBlade platform developer console and going to the home page. From the home page click “Install”, paste in the IPM package URL, and click “Fetch!”.
4. Make sure all the assets are selected to import and click “Import”. If done correctly you’ll now see “device-administrator” under the “Systems” tab.
5. To configure this IPM package you’ll need to first edit the “devadmConstants” library by clicking “Code” under “device-administrator” and selecting “devadmConstants” under “Libraries”. In the code editor, ensure the platform url is correctly configured to your instance of the ClearBlade edge platform.
In order to do the advanced activities of device table column management you need to leverage developer APIs. This means you need to actually provide your credentials to those APIs by entering your email and password where prompted in the editor. If you have more that one system in your platform, we recommend creating a service account developer that only has rights to this particular system. Click “Save” when you are done.
6. After the constants are set, you’ll want to create two new users. Create needed users by opening the “Code” tab, click “devadmSetup” under “Services”. You can change the passwords for the users here then click “Save and Test”. Once the service is finished, a pop up saying “Success!” will appear along with the usernames of the two new users you created with roles for editing the portal, and more importantly being an actual device administrator.
7. Now begin working with the device administrator by clicking on the “Portals” and opening the “devadm Device Administrator”
8. Log into the portal using the user credential you just created. For this demo our default is the “email@example.com” account with password “clearblade”.
9. From the “Device Administrator” page, click the menu icon and select a default device named “pump101-battery”.
10. With the device selected we can learn more about it from the portal screen, first we see its type is battery and then it has several attributes available to be set such as voltage, and amperage. To update the device simply change the value of voltage and click “Update”.
11. We can explore further regarding the messages this device has sent historically. As this is a fresh installation (there is no history) so instead you will use the UI to publish new messages. To issue a command, switch to the “Control” topic, and provide the expected payload. This IPM package generally expects JSON objects, but that could be altered to match the speed and performance needs you have.
12. Click “Publish” and notice that the message history is being built up.
13. Switch back to the “Status” topic and send several messages related to the new status of this battery. As part of administration responsibilities you can delete messages by selecting a message and clicking the trash can.
Part 2. Type Creation
1. Click the menu bar and click “Manage Device Types” from the fly-out.
2. The left box displays a list of device types. Click on the existing “battery” type and you can see the schema design that the device was using. Click the plus icon on the type list to create a new device type for your solution. In the new field set the name of the type to “pump” and click “Save”.
3. Select the newly create type called “pump” to view its currently empty schema. In the type schema pane, click the plus icon three times and provide new fields called “pressure -> float”, “temperature->integer” and “brand -> string”. Ensure the checkboxes are checked, otherwise the field will not be included in the schema. Now, click “Update” to confirm the new schema
Now you’ve created a new pump type and need to go create a new device type.
Part 3. Creating a Device
1. Click the menu bar and click on “Devices” to go back to the home details page.
2. To create a new device click the plus icon and simply provide a name, type, and brand then click “Create”.
3. Click on the menu bar to select the newly created item and now provide the information into each field then click “Update” to save the new state.
Part 4. Interacting with your Device
If you go back to the ClearBlade platform you can review the results of this device in the administration interface.
1. The first place to review is the click on the “Devices” tab to see your newly created pump101 with the associated attributes.
2. Next, click on the “Data” tab to see the types collection updated with the pump type.
3. Finally, click on the “Messaging” tab to see the historical messages our devices have sent.