Skip to content

Deploy apps on a device#

A Toit application is made of:

  • a toit file containing the code that will be executed.

  • a YAML file containing the app specification that describes when and how often the application must run.

At this point, apps can only be deployed on a device from the Toit CLI as explained below. It is thus time to install the Toit CLI if you have not done so yet.

On online devices, deploying an app and its installation on the device are quasi-simultaneous. An app can also be deployed on an offline device, but the app will not be actually installed on the device until the device becomes online again, that is the next time it connects to the console.

Deployed app#

Use VSCode to save the following program on your computer:

// filename: hello/hello.toit

/// Prints a message on the e-Ink display of the device.

import font show *
import texture show *
import two_color show *
import pixel_display show *

sans ::= font_get "sans10"
display ::= TwoColorPixelDisplay "eink"

main:
  display.background = WHITE
  // Draw text on the display.
  context := display.context --landscape --alignment=TEXT_TEXTURE_ALIGN_CENTER --color=BLACK --font=sans
  display.text context 102 50 "Hello from Toitbox!"
  display.draw

Name this program hello.toit.

We now create an app specification named hello.yaml that runs hello.toit when the app is installed and every time the device is awoken (from deep sleep or from a reboot).

# filename: hello.yaml
# This file must be saved as yaml, and the entrypoint is the hello.toit file.

name: HelloApp
entrypoint: hello.toit
triggers:
  on_install: true
  on_boot: true

To install the application on your default device, run the CLI command

toit deploy hello.yaml

Installed app#

The app will be installed right away on an online device or a simulator, or next time the device comes online. Check the status of your app on the console or the CLI.

Verify the list of apps deployed to a particular device in the Toit console.

waiting2installconsole

A status of "Waiting to install" indicates that the app will be installed when the device gets online.

jobsdeployed

Verify that an app is installed on a device with toit device ps.

waiting2installcli

A status of "Waiting to install" indicates that the app will be installed when the device gets online.

jobsdeployedcli