Using the App Template

These instructions only apply to AuterionOS version 2.5 and earlier. Developers targeting AOS 2.7 and newer should use the new app workflow instead: Getting Started

Introduction

This documentation explains how to develop an application for AuterionOS. An application is a set of Docker containers that can interact together and with Auterion software. Tools are provided in order for you to build, deploy and run your application on top of AuterionOS for development, and then package it into an update archive to deploy it to Skynode-powered vehicles. Attached to this documentation there are four example applications written in C++ and Python that use mavlink (MavSDK) to get flight controller telemetry or interact with Auterion Payload Manager. At the end of the documentation you will find a section listing the most important commands to know in order to interact with an application installed on your device.

Have a look at the Examples if you like to see code first

Build your own application

An application is composed of:

  • app.yml: A YAML file that describes your application

  • src: A folder that contains application source code and Dockerfile

  • Makefile: One makefile that contains build and install instructions

  • tools: A folder that contains tools needed in order to build and deploy your application

App.yml

The app.yml is the file that describes and configures your application. This file follows the Compose file format and should define every service that composes your application. A minimal app.yml should contain at least:

version: '3.7'
services:
  service1:
    image: service1
    container_name: service1
    restart: unless-stopped
    network_mode: host
    volumes:
      - '/data/app/myapp/data:/data'

Where service1 is the name of your docker container and myapp is the name of your application.

For a multiple containers application, app.yml should contain at least:

version: '3.7'
services:
  service1:
    image: service1
    container_name: service1
    restart: unless-stopped
    network_mode: host
    volumes:
      - '/data/app/myapp/data:/data'
  service2:
    image: service2
    container_name: service2
    restart: unless-stopped
    network_mode: host
    volumes:
      - '/data/app/myapp/data:/data'

Where service1 is the name of your first docker container, service2 is the name of your second docker container and myapp is the name of your application.

Network

By adding network_mode: host to your service definition in app.yml you will be able to expose your service to the network.

Volumes

By adding - '/persistent/shared_container_dir:/shared_container_dir' to the list of volumes of your service definition in app.yml, you will be able to access to the WiFi and LTE configuration files.

By adding the following volumes to the list of volumes of your service definition in app.yml, you will be able to access pictures taken by Auterion Payload Manager:

- '/data/shared_photos:/shared_photos'
- '/data/photos:/data/photos'
- '/dev/media:/dev/media'

The "src" folder

You are actually free to architecture your application as you want. One way to architecture your src folder is:

/src
    /service1
        /Dockerfile
        /src
    /service2
        /Dockerfile
        /src

You can learn more about Dockerfile on docs.docker.com

Makefile

In order to drive the build and deployment processes you can define a Makefile with the following rules:

appName ?= myapp
toolsPath = ./tools

ifneq ($(artifactPath),)
artifactPath=$(artifactPath)
else
artifactPath=./output/$(appName).auterionos
endif

build-myapp-service1:
	docker build ./src/service1 -t service1

build-myapp-service2:
	docker build ./src/service2 -t service2

build: build-myapp-service1 build-myapp-service2
	mkdir -p output
	docker save service1 service2 | gzip > output/$(appName).image
	$(toolsPath)/package_app.sh --app=$(appName)

install:
	$(toolsPath)/update.py --artifact $(artifactPath)

Where service1 is the name of your first docker container, service2 is the name of your second docker container and myapp is the name of your application.

The build target will build every service and generate the application artifact in output/<myapp>.auterionos. The install target will upload and install the artifact on your device (via USB-C).

Tools

The tools folder is important because it contains the scripts you will need to package an application and to deploy it to your device. You will need to copy the following scripts from tools and copy them to the root of your application workspace:

  • tools/package_app.sh

  • tools/mender-artifact

Packaging Apps into AuterionOS

Example Applications

A good way to start developing applications for AuterionOS is to experiment with the example applications provided by Auterion.

Troubleshooting

In case your deployment fails you can find useful information in the following logs:

  • /var/log/apache2/error.log

  • /data/<APP_NAME>.log

Packaging artifacts fails

In case you cannot package an artifact or build an application, you can execute the script ./setup/sanity_check.sh in order to verify that your setup is configured correctly. This script will give you additional information in order to fix your setup issue.

Packaging artifacts requires sudo

Depending on which Linux distribution the development environment is installed, the make command may need to be executed with sudo. The package script uses mounts in order to copy files in the artifact, which may require elevated privileges.

Last updated