(This post is part of a series on how to get started with packaging your IoT apps for the snappy Ubuntu Core.)
snapcraft.yaml file for my demo project:
There’s very little boilerplate in the form of summary, description, icon, vendor, and after that there are the interesting sections like
I defined two parts:
spjs is the serial-port-json-server, a go project that provides a way for a browser to communicate via websockets with a serial port on the server. I’ve forked it with a very small change to make it also serve html files from a folder on the server. Snapcraft will fetch this other repo for serial-port-json-server, will build this as a binary, and add it to the fileset of files to put inside the snap package.
glue uses the
copy snapcraft plugin to copy my html folder into the snap. This folder contains a copy of the
minecraft demo from three.js, slightly adapted so it no longer accepts input from the mouse and keyboard, and instead it uses a websocket connection to the server, to read the serial port via spjs, and get the serial data from the lines outputted by the MinIMU-9 attached to the Arduino attached to the raspi. Then it processes the pitch-yaw-roll info in the serial lines, and adjusts the 3d camera accordingly, and uses the data from the button pushes in order to move or stay still.
services section specifies that the serial-port-json-server should be managed by snappy as a system service, so it gets started on boot, and restarted if it ever crashes.