How to use snaps when collecting IoT data with Predix Time Series

Guest

on 9 November 2016

This is a guest post by Ilya Drabenia, a Technical Lead at Altoros. If you would like to contribute a guest post, please contact ubuntu-devices@canonical.com


Snaps, designed by Canonical, are intended for packaging applications and their dependencies, along with the instructions for running these applications. In this article, we focus on how to write time-series data from your Linux environment to the Predix Time Series service using a snap.


Scenario
We will use a data generator to create a sample data stream from a device to Predix. Our previous post provides more details about this generator.

The sensor.go file:

screen-shot-2016-11-09-at-13-39-02


You can find more information, including the source code of the solution and a Go library for interacting with the Predix Time Series API, in this GitHub repository.

Packaging the generator into a snap
For creating a snap, you need to install the Snapcraft tool first. Then, declare the snap configuration that is provided below.

The snapcraft.yaml file:

screen-shot-2016-11-09-at-13-40-30

In this file, specify the name and the version of your snap. To build the snap, we also include the command for starting the application and its source code.

Then, run the snapcraft command, which compiles source code and packages it into a snap.


canonical-snaps-ge-predix-time-series-demo


After that, you can publish your snap to a snap repository.


Releasing the snap

Before releasing the snap, register an Ubuntu One account and then run the following commands:

$ snapcraft login
$ snapcraft register predix-ts-sample
Now, you should be able to push your application to a snap store


1


Finally, you can release this snap.

2


Verifying the snap

You can check that the snap was really published in the uApp Explorer app store, and the predix-ts-sample application is now located there.


3


You can install this snap on your device using the following command:

$ sudo snap install predix-ts-sample
To run the snap, enter predix-ts-sample on the command line:

4


After providing all required configuration parameters, you will see the next output:

5


Conclusions
In this tutorial, we tried working with the new package management system from Canonical that is focused on the reliability and isolated execution of snaps. Device engineers can install multiple snaps and create a whole system from reusable building blocks almost without programming. Judging from our experience with snaps, developing, as well as publishing, them is quite easy, and the process is supported by good enough documentation.

Original source here

Internet of Things

From home control to drones, robots and industrial systems, Ubuntu Core and Snaps provide robust security, app stores and reliable updates for all your IoT devices.

Newsletter signup

Select topics you’re
interested in

In submitting this form, I confirm that I have read and agree to Canonical’s Privacy Notice and Privacy Policy.

Related posts

5 key steps to take your IoT device to market

IoT businesses are notoriously difficult to get off the ground. No matter how good your product is or how good your team is, some of the biggest problems you...

Kubernetes: a secure, flexible and automated edge for IoT developers

Cloud native software such as containers and Kubernetes and IoT/edge are playing a prominent role in the digital transformation of enterprise organisations....

This is why smart displays run Ubuntu Core

First impressions count, and making sure your users can see and interact with your product in a seamless way, means selecting the right smart display...