Previous
Reuse machine configuration
You can install viam-agent
as part of your manufacturing process and provision machines with a pre-defined configuration as they come online.
When the end user sets the machine up, they provide network access and viam-agent
installs viam-server
and your latest software.
Consider a company that sells machines that monitor weather conditions on a maritime craft and provide navigation advice based on those readings. The machines use the data management service to regularly capture and upload a stream of sensor readings. To parse the readings and provide tailored guidance to a ship’s captain, the company writes their own proprietary application.
By having the end customer set up the machine, the company:
This guide will show you how to install and configure viam-agent
.
Provisioning is supported and tested only on Debian 11 (Bullseye), and 12 (Bookworm) but should work on most distros using NetworkManager v1.42 (or newer) as well.
For Bullseye, the installation of viam-agent
changes the network configuration to use NetworkManager.
You can choose to let your end users complete machine setup by using a captive web portal or a mobile app.
If you choose to have a mobile app experience, you can use the Viam mobile app or create your own custom mobile app using the Flutter SDK or the TypeScript SDK to connect to viam-agent
and provision your machines.
The Viam mobile app allows end users to create a new machine in the app, and agent-provisioning
will then install viam-server
and run it with a provided configuration.
If you choose to use the Viam mobile app, you must provide a fragment for provisioning.
If you do not yet have a fragment, follow the steps to Create a configuration fragment and make a note of the fragment ID.
If you are not using Flutter or TypeScript and would like to use provisioning, please contact us.
If you choose to use the captive web portal, you can optionally create a machine in advance and provide its machine cloud credentials file at
You can get the machine cloud credentials by clicking the copy icon next to Machine cloud credentials in the part status dropdown to the right of your machine’s name on the top of the page.
agent-provisioning
1. Configure provisioning
If you are using the captive portal, this step is optional.
If you are using a mobile app, you must create a provisioning configuration file, specifying at least a fragment_id
.
Create a file called
{
"manufacturer": "<NAME>", # your company name
"model": "<NAME>", # the machine's model
"fragment_id": "<ID>", # the fragment id, required for mobile app
"hotspot_prefix": "<PREFIX>", # machine creates a hotspot during setup
"disable_dns_redirect": true, # disable if using a mobile app
"hotspot_password": "<PASSWORD>", # password for the hotspot
"networks" : []
}
{
"manufacturer": "Skywalker",
"model": "C-3PO",
"fragment_id": "2567c87d-7aef-41bc-b82c-d363f9874663",
"hotspot_prefix": "skywalker-setup",
"disable_dns_redirect": true,
"hotspot_password": "skywalker123",
"roaming_mode": false,
"offline_timeout": "3m30s",
"user_timeout": "2m30s",
"fallback_timeout": "15m"
}
This file configures some basic metadata, specifies a fragment to use to configure the machine, and provides the WiFi hotspot network name and password to use on startup.
It also configures timeouts to control how long viam-agent
waits for a valid local WiFi network to come online before creating its hotspot network, and how long to keep the hotspot active before terminating it.
2. Configure Networks (optional)
During the provisioning process, a machine connects to a network to install viam-server
.
If you provide an app to your end user or are asking them to use the Viam mobile app, the user will provide network details through that app.
If you know in advance which other networks a machine should be able to connect to, we recommend that you add WiFi settings in the operating system (for example, directly in NetworkManager).
However, if you want to add additional networks to the provisioning configuration you can add them to the networks
field value.
You must enable roaming_mode
in the agent-provisioning
configuration of the machine to allow the machine to connect to the specified networks after provisioning.
If roaming_mode
is enabled, agent-provisioning
will try to connect to each specified network in order of priority
from highest to lowest.
Name | Type | Description |
---|---|---|
type | string | The type of the network. Options: "wifi" |
ssid | string | The network’s SSID. |
psk | string | The network pass key. |
priority | int | Priority to choose the network with. Values between -999 and 999. Default: 0 . |
The following configuration defines the connection information and credentials for two WiFi networks named fallbackNetOne
and fallbackNetTwo
:
{
"manufacturer": "Skywalker",
"model": "C-3PO",
"fragment_id": "2567c87d-7aef-41bc-b82c-d363f9874663",
"hotspot_prefix": "skywalker-setup",
"disable_dns_redirect": true,
"hotspot_password": "skywalker123",
"roaming_mode": false,
"offline_timeout": "3m30s",
"user_timeout": "2m30s",
"fallback_timeout": "15m",
"roaming_mode": true,
"networks": [
{
"type": "wifi",
"ssid": "otherNetworkOne",
"psk": "myFirstPassword",
"priority": 30
},
{
"type": "wifi",
"ssid": "otherNetworkTwo",
"psk": "mySecondPassword",
"priority": 10
}
]
}
viam-agent
viam-agent
is a self-updating service manager that maintains the lifecycle for several Viam services and keeps them updated.
The following instructions will preinstall viam-agent
into an image.
Only use the following method for offline pre-installs with images. For live systems, follow the instructions on a machine’s setup tab to install viam-server
with viam-agent
.
Please note this script works only under POSIX (MacOS and Linux) at the moment.
1. Download the preinstall script
Run the following commands to download the preinstall script and make the script executable:
wget https://storage.googleapis.com/packages.viam.com/apps/viam-agent/preinstall.sh
chmod 755 preinstall.sh
2. Run the preinstall script
Run the preinstall script without options and it will attempt to auto-detect a mounted root filesystem (or for Raspberry Pi, bootfs) and also automatically determine the architecture.
sudo ./preinstall.sh
Follow the instructions.
If you created a
You can set optional arguments by defining the following environment variables:
Argument | Description |
---|---|
VIAM_JSON_PATH | The path to the machine credentials |
PROVISIONING_PATH | The path to the |
VIAM_AGENT_PATH | The path to a beta or local build of viam-agent . Used for testing. |
If you need to test the GRPC components of the provisioning service, there is a CLI client available.
Get the code from the agent-provisioning
repo and run go run ./cmd/client/
for info.
End users receive a machine, and use either a captive web portal or mobile app to complete the machine setup.
The following steps show you the end user experience using the mobile app or the captive web portal and how your configuration influences it.
For a guide you can give to end users for setting up their machine, see Setup machine.
Open the app and follow any instructions there until the app directs you to turn on the machine.
When you power on the machine that has viam-agent
installed and agent-provisioning
configured, viam-agent
creates a WiFi hotspot.
agent-provisioning
configuration is at You then use your mobile device or computer and connect to the WiFi hotspot.
viam-setup-HOSTNAME
, where HOSTNAME
is replaced with the hostname of your machine.
The WiFi password for this hotspot network is viamsetup
by default.
You can customize these values in the agent-provisioning
configuration.If you as the end user have a provisioning mobile app, go back to the app to complete setup. In the mobile app, you will be prompted to provide the network information for the machine.
The machine will then disable the hotspot network and attempt to connect using the provided network information.
If viam-agent
cannot establish a connection using the provided network information, the machine will create the hotspot again and continue going through steps (2-5) until a connection is successfully established.
If the connection is successful, viam-agent
installs viam-server
.
agent-provisioning
will use the provided network if it can connect, even if that network does not have internet access.
Note that any features that require internet access will not function if the connected WiFi network is not connected to the internet.
If you want agent-provisioning
to require that a WiFi network be connected to the internet in order to connect to it, enable roaming mode.viam-agent
then starts viam-server
with the provided configuration and the machine becomes live.
When you, as the end user, power on the machine that has viam-agent
installed and agent-provisioning
configured, agent-provisioning
creates a WiFi hotspot.
agent-provisioning
configuration is at You as the end user then use your mobile device or computer and connect to the WiFi hotspot.
viam-setup-HOSTNAME
, where HOSTNAME
is replaced with the hostname of your machine.
The WiFi password for this hotspot network is viamsetup
by default.
You can customize these values in the agent-provisioning
configuration.Once connected to the hotspot, you will be redirected to a sign-in page. If you are using a laptop or are not redirected, try opening http://viam.setup/ in a browser.
In the captive web portal, you will then be prompted to provide the network information for the machine.
If there is no machine cloud credentials file at viam-server
instance needs to connect to the Viam app.
To copy a machine cloud credentials file:
Navigate to your machine’s page on the Viam app.
Select the part status dropdown to the right of your machine’s name on the top of the page.
Click the copy icon next to Machine cloud credentials.
Paste the machine cloud credentials when prompted.
The machine will then disable the hotspot network and attempt to connect using the provided network information.
If viam-agent
cannot establish a connection using the provided network information, the machine will create the hotspot again and continue going through steps (2-5) until a connection is successfully established.
If the connection is successful, viam-agent
installs viam-server
.
agent-provisioning
will use the provided network if it can connect, even if that network does not have internet access.
Note that any features that require internet access will not function if the connected WiFi network is not connected to the internet.
If you want agent-provisioning
to require that a WiFi network be connected to the internet in order to connect to it, enable roaming mode.viam-agent
then starts viam-server
with the provided configuration and the machine becomes live.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!