For deployment on your device, it is necessary to install programs as applications. 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.
To benefit from the modularity of Toit, we recommend writing and deploying separate apps for the different sensors. This ensures that a failure to access one sensor does not prevent the other apps from collecting data generated by the other sensors for example. It is also easier and safer to update apps independently from each other.
This section describes possible app specifications.
# Example of an app specification file. name: <App name> entrypoint: <toit entrypoint> triggers: on_boot: <bool> on_install: <bool> on_interval: "<duration>" cron: - "*/5 7 * * *" - "0 */2 * * *" on_pubsub_topic: - "<type:name>" pubsub: subscriptions: "<type:name>"
The app name on the device. This name is the primary human identifier of an app.
The Toit file where the
mainfunction of the program is located. The entrypoint can be the name of the Toit file, such as
hello.toitToit if it is saved in the same folder as its configuration file, or a relative path to the Toit file including the Toit file, such as
The events triggering the execution of the application.
Runs the application every time the device boots. This includes reboots, or when the device wakes up from a scheduled deep sleep.
Runs the application when it is installed.
Runs the application every
duration. If the application is already running when the trigger fires the event is ignored and the program is not run again.
The input is an interval of time in either hours, minutes, or seconds such as:
Is a list of crons, each defining a schedule on when the application should start. In the example above, the application will be triggered every 5 minutes of the 7th hour, as well as every 2 hours on minute 00. Note that the time on devices is in UTC. Timezones are not supported.
If the application is already running when the trigger fires, the event is ignored.
Runs the application when a message from the defined pubsub topic
<type>:<name>is received on the device. The on_pubsub_topic can only trigger on topics that the device is subscribed to (see below for subscribing to a topic). Also read PubSub and tutorials) for additional information and an example of app specification file with a PubSub subscription.
The PubSub subscriptions.