Your submission was sent successfully! Close

Thank you for contacting us. A member of our team will be in touch shortly. Close

You have successfully unsubscribed! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates about Ubuntu and upcoming events where you can meet our team.Close

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

Guest

on 9 November 2016

Tags: IoT , Snap , snap packages

This article is more than 7 years old.


This is a guest post by Ilya Drabenia, a Technical Lead at Altoros. If you would like to contribute a guest post, please contact [email protected]

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:

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:

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.

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

Finally, you can release this snap.

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.

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:

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

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

smart start

IoT as a service

Bring an IoT device to market fast. Focus on your apps, we handle the rest. Canonical offers hardware bring up, app integration, knowledge transfer and engineering support to get your first device to market. App store and security updates guaranteed.

Get your IoT device to market fast ›

smart start logo

IoT app store

Build a platform ecosystem for connected devices to unlock new avenues for revenue generation. Get a secure, hosted and managed multi-tenant app store for your IoT devices.

Build your IoT app ecosystem ›

Newsletter signup

Get the latest Ubuntu news and updates in your inbox.

By submitting this form, I confirm that I have read and agree to Canonical's Privacy Policy.

Related posts

Japanese device manufacturer I-O DATA DEVICE’s business expansion with Ubuntu Pro for Devices

I-O DATA has entered into a partnership with Canonical, aimed at bringing the benefits of open source and Ubuntu Pro for Devices to thousands of devices...

Space pioneers: Lonestar gears up to create a data centre on the Moon

Why establish a data centre on the Moon? Find out in our blog.

A look into Ubuntu Core 24: Your first Linux-powered Matter device

Welcome to this blog series which explores innovative uses of Ubuntu Core. Throughout this series, Canonical’s Engineers will show what you can build with...