Skip to content

Commit a32f026

Browse files
committed
Documentation updates from Promptless
1 parent ff70f5b commit a32f026

File tree

4 files changed

+457
-44
lines changed

4 files changed

+457
-44
lines changed
Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
---
2+
title: "Bluetooth provisioning with viam-agent"
3+
linkTitle: "Bluetooth provisioning"
4+
weight: 70
5+
type: "docs"
6+
description: "Learn how to use Bluetooth Low Energy (BLE) for machine provisioning as an alternative to WiFi hotspot provisioning."
7+
tags: ["fleet management", "viam-server", "viam-agent", "bluetooth", "provisioning"]
8+
images: ["/installation/thumbnails/install.png"]
9+
imageAlt: "Bluetooth provisioning"
10+
languages: []
11+
viamresources: []
12+
platformarea: ["fleet"]
13+
level: "Advanced"
14+
date: "2025-06-02"
15+
prev: "/manage/fleet/provision/end-user-setup/"
16+
# updated: "" # When the tutorial was last entirely checked
17+
# SMEs: James, Ale
18+
cost: "0"
19+
---
20+
21+
Bluetooth provisioning enables machine setup using Bluetooth Low Energy (BLE) as an alternative to WiFi hotspot provisioning. This method is particularly useful in environments with many WiFi networks, where hotspot provisioning may be less reliable, or when you want to avoid creating an open WiFi hotspot.
22+
23+
## Overview
24+
25+
When Bluetooth provisioning is enabled, `viam-agent` advertises a BLE service that mobile applications can connect to directly. This allows users to provision machines without needing to join a WiFi hotspot, providing a more streamlined setup experience on mobile devices.
26+
27+
### Key Features
28+
29+
- **Direct BLE connection**: Mobile apps connect directly to the machine via Bluetooth
30+
- **Encrypted communication**: All credential exchanges use RSA OAEP encryption
31+
- **Parallel operation**: Can work alongside WiFi hotspot provisioning
32+
- **Mobile-optimized**: Designed for optimal mobile app user experience
33+
- **Automatic adapter selection**: Automatically selects the first available Bluetooth adapter
34+
35+
## How Bluetooth Provisioning Works
36+
37+
1. **Service Advertisement**: When provisioning mode starts, `viam-agent` advertises a BLE service with a name beginning with `viam-setup-`
38+
1. **Mobile App Discovery**: Compatible mobile apps scan for and connect to the advertised BLE service
39+
1. **Secure Handshake**: The machine generates an RSA key pair and shares the public key with the mobile app
40+
1. **Credential Exchange**: The mobile app encrypts and sends WiFi credentials and/or machine credentials
41+
1. **Network Connection**: The machine attempts to connect using the provided credentials
42+
1. **Service Installation**: Once connected, `viam-agent` installs and starts `viam-server`
43+
44+
## Configuration
45+
46+
### Basic Configuration
47+
48+
To enable Bluetooth provisioning, ensure `disable_bt_provisioning` is set to `false` (the default) in your `viam-defaults.json`:
49+
50+
```json {class="line-numbers linkable-line-numbers"}
51+
{
52+
"network_configuration": {
53+
"disable_bt_provisioning": false,
54+
"disable_wifi_provisioning": false
55+
}
56+
}
57+
```
58+
59+
### Advanced Configuration
60+
61+
For machines with multiple Bluetooth adapters, specify which adapter to use:
62+
63+
```json {class="line-numbers linkable-line-numbers"}
64+
{
65+
"network_configuration": {
66+
"disable_bt_provisioning": false,
67+
"bluetooth_adapter_name": "hci0"
68+
}
69+
}
70+
```
71+
72+
### Bluetooth-Only Provisioning
73+
74+
To use only Bluetooth provisioning and disable WiFi hotspot provisioning:
75+
76+
```json {class="line-numbers linkable-line-numbers"}
77+
{
78+
"network_configuration": {
79+
"disable_bt_provisioning": false,
80+
"disable_wifi_provisioning": true,
81+
"fragment_id": "your-fragment-id"
82+
}
83+
}
84+
```
85+
86+
{{< alert title="Note" color="note" >}}
87+
When using Bluetooth-only provisioning, you must provide a `fragment_id` for mobile app configuration.
88+
{{< /alert >}}
89+
90+
## Security
91+
92+
Bluetooth provisioning implements several security measures:
93+
94+
### Encryption
95+
96+
- **RSA OAEP Encryption**: All credential data is encrypted using RSA OAEP with SHA-256
97+
- **2048-bit Keys**: Uses 2048-bit RSA keys for strong encryption
98+
- **Per-Session Keys**: New key pairs are generated for each provisioning session
99+
- **Public Key Exchange**: Public keys are shared using x509 PKIX encoding
100+
101+
### Communication Protocol
102+
103+
The BLE service uses predefined UUIDs for different characteristics:
104+
105+
- **Service UUID**: Generated from namespace `74a942f4-0f45-43f4-88ca-f87021ae36ea`
106+
- **Write Characteristics**: For receiving encrypted credentials (SSID, PSK, machine credentials)
107+
- **Read Characteristics**: For sharing status, network lists, and public keys
108+
- **Encrypted Payloads**: All sensitive data is encrypted before transmission
109+
110+
## Bluetooth Service Characteristics
111+
112+
The Bluetooth service exposes several characteristics for different functions:
113+
114+
### Write-Only Characteristics
115+
116+
- **SSID**: Receives encrypted WiFi network name
117+
- **PSK**: Receives encrypted WiFi password
118+
- **Robot Part ID**: Receives encrypted machine part identifier
119+
- **Robot Part Secret**: Receives encrypted machine secret
120+
- **App Address**: Receives encrypted cloud app address
121+
122+
### Read-Only Characteristics
123+
124+
- **Status**: Provides machine configuration and connection status
125+
- **Networks**: Lists available WiFi networks with signal strength and security info
126+
- **Public Key**: Shares the RSA public key for encryption
127+
- **Errors**: Reports any provisioning errors
128+
129+
## Mobile App Integration
130+
131+
### Supported Platforms
132+
133+
Bluetooth provisioning is designed for mobile applications using:
134+
135+
- **Flutter SDK**: Full BLE provisioning support
136+
- **TypeScript SDK**: BLE provisioning capabilities
137+
- **Viam Mobile App**: Native Bluetooth provisioning support
138+
139+
### App Development Considerations
140+
141+
When developing mobile apps with Bluetooth provisioning:
142+
143+
1. **BLE Permissions**: Ensure your app requests appropriate Bluetooth permissions
144+
1. **Service Discovery**: Scan for services with the `viam-setup-` prefix
145+
1. **Encryption Handling**: Implement RSA OAEP encryption for credential transmission
146+
1. **Error Handling**: Monitor the errors characteristic for provisioning feedback
147+
1. **Status Monitoring**: Check the status characteristic to track provisioning progress
148+
149+
## Troubleshooting
150+
151+
### Bluetooth Adapter Issues
152+
153+
**Problem**: Bluetooth provisioning not starting
154+
155+
**Solutions**:
156+
1. Check if Bluetooth is available:
157+
```sh {class="command-line" data-prompt="$"}
158+
bluetoothctl list
159+
```
160+
161+
1. Verify Bluetooth service status:
162+
```sh {class="command-line" data-prompt="$"}
163+
sudo systemctl status bluetooth
164+
```
165+
166+
1. For multiple adapters, specify the correct one:
167+
```json
168+
{
169+
"network_configuration": {
170+
"bluetooth_adapter_name": "hci0"
171+
}
172+
}
173+
```
174+
175+
### Mobile Device Connection Issues
176+
177+
**Problem**: Mobile app cannot discover the machine
178+
179+
**Solutions**:
180+
1. Ensure Bluetooth is enabled on the mobile device
181+
1. Check that the mobile app has Bluetooth permissions
182+
1. Verify the device supports Bluetooth Low Energy (BLE)
183+
1. Try restarting Bluetooth on the mobile device
184+
185+
### Encryption Errors
186+
187+
**Problem**: Credential transmission fails
188+
189+
**Solutions**:
190+
1. Check `viam-agent` logs for encryption errors:
191+
```sh {class="command-line" data-prompt="$"}
192+
sudo journalctl -u viam-agent -f
193+
```
194+
195+
1. Ensure the mobile app is using the correct public key
196+
1. Verify RSA OAEP implementation in the mobile app
197+
198+
### Configuration Issues
199+
200+
**Problem**: Bluetooth provisioning not enabled
201+
202+
**Solutions**:
203+
1. Verify `disable_bt_provisioning` is set to `false`
204+
1. Check that `disable_network_configuration` is not set to `true`
205+
1. Ensure the system has a working Bluetooth adapter
206+
207+
## Testing and Development
208+
209+
### CLI Testing Tool
210+
211+
The `viam-agent` repository includes a CLI tool for testing Bluetooth provisioning:
212+
213+
```sh {class="command-line" data-prompt="$"}
214+
# Clone the agent repository
215+
git clone https://github.com/viamrobotics/agent.git
216+
cd agent
217+
218+
# Scan for Bluetooth devices
219+
go run ./cmd/provisioning-client/ --scan
220+
221+
# Test Bluetooth provisioning
222+
go run ./cmd/provisioning-client/ --bluetooth --status
223+
224+
# Set WiFi credentials via Bluetooth
225+
go run ./cmd/provisioning-client/ --bluetooth --ssid="MyNetwork" --psk="MyPassword"
226+
227+
# Set machine credentials via Bluetooth
228+
go run ./cmd/provisioning-client/ --bluetooth --partID="part-id" --secret="secret" --appaddr="https://app.viam.com:443"
229+
```
230+
231+
### Development Environment
232+
233+
For development and testing:
234+
235+
1. **Filter Devices**: Use the `--filter` option to find specific devices:
236+
```sh {class="command-line" data-prompt="$"}
237+
go run ./cmd/provisioning-client/ --scan --filter="viam-setup"
238+
```
239+
240+
1. **Monitor Status**: Check provisioning status:
241+
```sh {class="command-line" data-prompt="$"}
242+
go run ./cmd/provisioning-client/ --bluetooth --status
243+
```
244+
245+
1. **List Networks**: View available WiFi networks:
246+
```sh {class="command-line" data-prompt="$"}
247+
go run ./cmd/provisioning-client/ --bluetooth --networks
248+
```
249+
250+
## Best Practices
251+
252+
### Configuration
253+
254+
- **Enable Both Methods**: Keep both Bluetooth and WiFi provisioning enabled for maximum compatibility
255+
- **Fragment Configuration**: Always provide a `fragment_id` when using mobile apps
256+
- **Adapter Selection**: Specify `bluetooth_adapter_name` for machines with multiple Bluetooth adapters
257+
258+
### Security
259+
260+
- **Key Management**: RSA keys are automatically generated per session - no manual key management required
261+
- **Credential Handling**: All sensitive data is encrypted before transmission
262+
- **Network Security**: Consider the security of the WiFi networks being configured
263+
264+
### User Experience
265+
266+
- **Clear Instructions**: Provide clear setup instructions for end users
267+
- **Fallback Options**: Ensure WiFi hotspot provisioning is available as a fallback
268+
- **Error Reporting**: Monitor the errors characteristic for user feedback
269+
270+
## Limitations
271+
272+
- **BLE Requirement**: Both the machine and mobile device must support Bluetooth Low Energy
273+
- **Mobile Focus**: Optimized for mobile app workflows rather than web browsers
274+
- **Linux Support**: Currently supported on Linux systems with Bluetooth adapters
275+
- **Range Limitation**: Bluetooth has a shorter range than WiFi hotspots
276+
277+
## Next Steps
278+
279+
- [Set up machine provisioning](/manage/fleet/provision/setup/)
280+
- [Configure viam-agent](/manage/reference/viam-agent/)
281+
- [End-user setup guide](/manage/fleet/provision/end-user-setup/)
282+
- [Mobile app development with Flutter SDK](https://flutter.viam.dev/)

docs/manage/fleet/provision/end-user-setup.md

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ Unless you have been told to use the captive portal, we recommend you use the Vi
2929

3030
## Set up your machine using the Viam mobile app
3131

32+
The Viam mobile app supports two connection methods for machine setup:
33+
34+
- **Bluetooth provisioning**: The app connects directly to your machine via Bluetooth Low Energy (BLE) without needing to join a WiFi network
35+
- **WiFi hotspot provisioning**: The app connects to your machine through a temporary WiFi hotspot
36+
37+
The app will automatically choose the best available method. If your machine supports Bluetooth provisioning, the app will prefer that method for a smoother setup experience.
38+
3239
{{<video webm_src="/platform/provisioning-demo.webm" mp4_src="/platform/provisioning-demo.mp4" alt="Using the Viam mobile app to provision a new machine with viam-agent." poster="/platform/provisioning-demo.jpg" max-width="300px" class="">}}
3340

3441
{{< table >}}
@@ -55,23 +62,32 @@ If you have already created a machine, select it.
5562
If you have not yet created a machine, click on **Add new smart machine** and give your machine a name.
5663
{{% /tablestep %}}
5764
{{% tablestep number=3 %}}
58-
**Follow the instructions in the app**
65+
**Turn on your machine and follow the app instructions**
5966

6067
Turn on the smart machine you are attempting to connect to.
61-
Then leave the app and navigate to your mobile device's WiFi settings and connect to the WiFi hotspot your machine has created.
62-
You may need to wait a short time for your machine to boot and create its WiFi hotspot.
68+
The app will guide you through the connection process.
69+
70+
**If using Bluetooth provisioning:**
71+
- Ensure Bluetooth is enabled on your mobile device
72+
- The app will automatically scan for and connect to your machine's Bluetooth service
73+
- Your machine will advertise a Bluetooth service with a name beginning with `viam-setup-`
74+
75+
**If using WiFi hotspot provisioning:**
76+
- Leave the app and navigate to your mobile device's WiFi settings
77+
- Connect to the WiFi hotspot your machine has created
6378
Your machine's WiFi hotspot name will begin with `viam-setup-`.
6479
Unless you have been given other instructions, the WiFi password for this hotspot network is `viamsetup`.
80+
- Return to the Viam mobile app once connected
6581

66-
Once you are connected to your machine's WiFi hotspot return to the Viam mobile app.
82+
You may need to wait a short time for your machine to boot and start its provisioning services.
6783
{{% /tablestep %}}
6884
{{% tablestep number=4 %}}
6985
**Provide the network information for the machine**
7086

7187
In the mobile app, you will be prompted to provide the network information for the machine.
7288

73-
The machine will now disable the hotspot network and attempt to connect using the provided network information.
74-
If the machine cannot establish a connection using the provided network information, the machine will create the hotspot again and prompt you to re-enter the network information until a connection is successfully established.
89+
The machine will now attempt to connect using the provided network information.
90+
If the machine cannot establish a connection using the provided network information, it will continue to be available for provisioning and prompt you to re-enter the network information until a connection is successfully established.
7591
{{% /tablestep %}}
7692
{{% tablestep number=5 %}}
7793
**Wait for machine to complete setup**
@@ -135,6 +151,34 @@ Note that any features that require internet access will not function if the con
135151
{{% /tablestep %}}
136152
{{< /table >}}
137153

154+
## Troubleshooting
155+
156+
### Bluetooth connection issues
157+
158+
If you're having trouble with Bluetooth provisioning:
159+
160+
1. **Check Bluetooth permissions**: Ensure the Viam mobile app has Bluetooth permissions enabled on your device.
161+
162+
1. **Verify Bluetooth is enabled**: Make sure Bluetooth is turned on in your mobile device settings.
163+
164+
1. **Check device compatibility**: Ensure your mobile device supports Bluetooth Low Energy (BLE).
165+
166+
1. **Restart Bluetooth**: Try turning Bluetooth off and on again on your mobile device.
167+
168+
1. **Try WiFi hotspot method**: If Bluetooth provisioning continues to have issues, you can fall back to connecting to your machine's WiFi hotspot and using that method instead.
169+
170+
### WiFi connection issues
171+
172+
If your machine cannot connect to your WiFi network:
173+
174+
1. **Check network credentials**: Verify that the WiFi network name (SSID) and password are correct.
175+
176+
1. **Check network compatibility**: Ensure your WiFi network is compatible with your machine's WiFi adapter.
177+
178+
1. **Check signal strength**: Make sure your machine is within range of your WiFi router.
179+
180+
1. **Try a different network**: If possible, try connecting to a different WiFi network to isolate the issue.
181+
138182
## Next Steps
139183

140184
You can now use your machine.

0 commit comments

Comments
 (0)