While the Quickstart focuses on running a sample that's located within the Zephyr file-hierarchy, it's simple enough to create a new application that's separate from Zephyr.
- Authenticated with Golioth - see Authentication
- Have a project - see Create a Project
- Have a provisioned device and credential for it - see Authorizing Devices
golioth/zephyrcodebase set up on your machine. See the Setup Zephyr page.
- A toolchain installed. In this guide, the toolchain for the ESP32 will be used.
For reference, this is the file structure of the app we're going to set up:
To make this, create a new directory for your app (we called ours
example-app). Feel free to name it whatever you'd like.
Inside this directory, create 3 files:
Here are their contents:
As you can see at the end of
prj.conf, there are some values that you'll need to fill in yourself that depend on your registered devices and environment.
Now create two directories,
src. Inside of
boards/, create a configuration file for the board you're using. In this guide, we're using an ESP32.
For the most part, you can copy these configuration files from Zephyr and Golioth samples.
Create one file,
For this example, the contents should be a simple logger.
This guide is for the ESP32, so setting up the required toolchain for other boards will be slightly different.
Look at the Zephyr documentation for your particular board to learn more about setting up the toolchain.
Set these environment values (The exact method used to do that varies between operating system and shell).
You'll also need to make sure that
west can find the
golioth/zephyr codebase on your local machine. You'll have to
source a particular file to do so.
This will set the
$ZEPHYR_BASE environment variable, as well as make sure
west can find the correct subcommands.
The exact paths may not match up with what is shown here. Look at
Setup Zephyr page for more information
about setting up the toolchain and the necessary environment variables.
Now, to build it:
And to flash it to the board (exact paths may vary)
prj.conf is set up correctly (e.g.
CONFIG_ESP32_WIFI_PASSWORD are all correct),
then you should be able to see the logs emitted by your device by running: