Skip to content

Commit c559187

Browse files
Merge pull request #2645 from arduino/benjamindannegard/provisioning-document-feedback-changes
[PXCT-1437] Cloud - Provisioning documentation changes
2 parents 55090c6 + f91c324 commit c559187

File tree

2 files changed

+244
-9
lines changed
  • content/arduino-cloud

2 files changed

+244
-9
lines changed

content/arduino-cloud/02.hardware/06.device-provisioning/content.md

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ Here are the boards that are compatible with Bluetooth provisioning via a Blueto
6565

6666
- [Arduino UNO R4 WiFi](https://docs.arduino.cc/hardware/uno-r4-wifi/) (Wi-Fi firmware version 0.6.0 or later required)
6767

68+
A board that is ready for Bluetooth provisioning has a specific provisioning sketch installed and displays a pulsing LED or a Bluetooth icon on the LED matrix (for UNO R4 WiFi). Newer boards are delivered with this specific sketch already installed. If the pulsing LED is not visible, please use the USB provisioning method.
69+
6870
### Setting up Your Device With Bluetooth
6971

7072
After selecting the Bluetooth option you will see a page telling you how to connect your board. Follow the steps to connect your board via Bluetooth.
@@ -79,6 +81,8 @@ After completing these steps your device will connect to your Wi-Fi and you will
7981

8082
![Attach thing after Bluetooth](assets/attach-thing-to-bluetooth.png)
8183

84+
The Bluetooth LE interface is automatically turned off at the end of the procedure, and it remains off until the board is reset. More information about this can be found in the [How to set up the Reconfiguration Procedure](#how-to-set-up-the-reconfiguration-procedure) section.
85+
8286
Now you are ready to start using your board with the Arduino Cloud!
8387

8488
## USB Provisioning
@@ -125,11 +129,65 @@ Now your board will be updated to version 2.0, wait for the process to finish.
125129

126130
When this is done you can continue setting up the network connection for your board and it will now be using the latest provisioning method with the Arduino Cloud!
127131

128-
### Removing Saved Network Configuration
132+
## How to update the Stored Network Configuration
133+
134+
To proceed with the next steps, the Cloud-generated sketch must be uploaded to the board. If you want to update the stored network configuration, there are two ways:
135+
136+
### Update Using the Bluetooth LE Interface
137+
138+
Ensure that the Cloud sketch has enabled the BLEAgent, via `thingProperties.h`. This is enabled by default if the board has been registered with Provisioning 2.0. If you need to enable it, please have a look at [this documentation](https://docs.arduino.cc/arduino-cloud/cloud-interface/sketches).
139+
140+
You can update the network settings from the detail page of the device on the Arduino Cloud webpage or the mobile app.
141+
142+
During this process you will be asked to wipe out the current network configuration to restart the board's Bluetooth LE interface.
143+
144+
1. Power on the board.
145+
2. Open the devices page of the Mobile App or the Arduino Cloud webpage.
146+
3. Click on the device you want to update the network settings for.
147+
4. Click on the "change" button by the network section.
148+
5. If you are using the Arduino Cloud webpage, select the Bluetooth method.
149+
6. Reset the board using the method of your board. Have a look at the [How to set up the Reconfiguration Procedure](#how-to-set-up-the-reconfiguration-procedure) section of this article to find the default board reset pin. If you have changed the reset pin from the default one, please use that.
150+
7. The board will reboot, and you will see the LED pulsing.
151+
8. Connect to the board on the Arduino Cloud.
152+
9. Input the new network configuration.
153+
10. The board will validate it, and if correct, it will close the connection.
154+
155+
### Update Using the Serial Interface
156+
157+
Ensure that the SerialAgent is enabled in the Cloud sketch, via `thingProperties.h`. This is enabled by default if the board has been registered with Provisioning 2.0. If you need to enable it, please have a look at [this documentation](https://docs.arduino.cc/arduino-cloud/cloud-interface/sketches).
158+
159+
This method only works with the Arduino Cloud website. You can update the network settings from the detail page of the board on the webpage. The Serial interface, if enabled, is always ready to receive a new configuration.
160+
161+
1. Turn on the board and connect it to your PC using a USB cable.
162+
2. Open the devices page on the Arduino Cloud webpage.
163+
3. Click on the board you want to update the network settings for.
164+
4. Click on the "change" button by the network section.
165+
5. Input the new network configuration.
166+
6. The board will validate it, and if correct, it will close the connection.
129167

130-
This section will explain how to remove the stored network credentials and force the restart of the BLE interface of a board that has been provisioned with version 2.0. This can be useful to either reset the board or to update the network credentials via BLE.
168+
## How to Delete a Stored Network Configuration
131169

132-
If you want to remove the stored network credentials and force the restart of the BLE interface, so that the network credentials can be updated via BLE. Please follow these instructions depending on your board:
170+
If you want to delete the stored network configuration without updating it, there are two possible methods to do so.
171+
172+
### Board Reset Procedure
173+
174+
To proceed with the next steps, the Cloud-generated sketch must be uploaded to the board.
175+
176+
Reset the board using the method of your board. Have a look at the [How to set up the Reconfiguration Procedure](#how-to-set-up-the-reconfiguration-procedure) section of this article to find the default board reset pin. If you have changed the reset pin from the default one, please use that.
177+
178+
### Using the DeleteConfiguration Sketch
179+
180+
Open Arduino IDE and on the left side open the **Library Manager**. Search for **Arduino_NetworkConfigurator** and download it. Once it is downloaded go to **File > Examples > Arduino_NetworkConfigurator > Utility > DeleteConfiguration**, this will open a new example sketch. Select your board and port then upload this example sketch to your board. When the sketch has been uploaded you can look at the serial monitor to monitor the progress and troubleshoot if needed.
181+
182+
The sketch can also be found [here](https://github.com/arduino-libraries/Arduino_NetworkConfigurator/blob/main/examples/utility/DeleteConfiguration/DeleteConfiguration.ino).
183+
184+
### How to set up the Reconfiguration Procedure
185+
186+
As the Provisioning 2.0 ends, the Bluetooth LE interface is turned off.
187+
188+
To restart the Bluetooth LE interface to update the network settings, the [**Arduino_NetworkConfigurator**](https://github.com/arduino-libraries/Arduino_NetworkConfigurator?tab=readme-ov-file) library provides a procedure called "Reconfiguration Procedure". This procedure is based on the shorting of two pins of the board.
189+
190+
The library provides a default implementation according to the board type.
133191

134192
- `Arduino Opta`: Press and hold the user button (BTN_USER) until the led (LED_USER) turns off
135193
- `Arduino MKR WiFi 1010`: Short pin 7 to GND until the led turns off
@@ -138,8 +196,4 @@ If you want to remove the stored network credentials and force the restart of th
138196
- `Arduino Portenta H7`: Short pin 0 to GND until the led turns off
139197
- `Arduino Portenta C33`: Short pin 0 to GND until the led turns off
140198
- `Other boards`: Short pin 2 to GND until the led turns off
141-
- `Portenta Machine Control`: Currently the reset procedure is not available
142-
143-
If you would like to remove the network credentials from the board, you can use the [**Arduino_NetworkConfigurator**](https://github.com/arduino-libraries/Arduino_NetworkConfigurator?tab=readme-ov-file) library.
144-
145-
Open Arduino IDE and on the left side open the **library manager**. Search for **Arduino_NetworkConfigurator** and download it. Once it is downloaded go to **File > Examples > Arduino_NetworkConfigurator > Utility > DeleteConfiguration**, this will open a new example sketch. Select your board and port then upload this example sketch to your board. When the sketch has been uploaded you can look at the serial monitor to monitor the progress and troubleshoot if needed.
199+
- `Portenta Machine Control`: Currently the reset procedure is not available

content/arduino-cloud/03.cloud-interface/00.sketches/sketches.md

Lines changed: 182 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,188 @@ The "Secret" File contains your secret credentials, such as Wi-Fi® network SSID
129129

130130
This file will be visible as a "Secret" tab in the Cloud Editor and is named `arduino_secrets.h`, which is not visible on the Cloud platform.
131131

132-
Note that if you are using the offline IDE / Arduino CLI, you will need to manually create this file. More information is in the **Offline Sketches section** just below.
132+
Note that if you are using the offline IDE / Arduino CLI, you will need to manually create this file. More information is in the **Offline Sketches section**.
133+
134+
## thingsProperties.h and the NetworkConfigurator
135+
136+
The thingProperties.h file plays a key role in managing credential capabilities, including the NetworkConfigurator, which enables two main features:
137+
138+
- **Credentials stored on NVS**: Boards can now securely store network settings in Non-Volatile Storage (NVS), removing them from the sketch (secrets.h).
139+
- **Over-the-Air (OTA) communication**: Enables the possibility to provide network configuration settings via Bluetooth LE.
140+
141+
The `thingProperties.h` will be generated accordingly to the provisioning mechanism, so if the board has been registered using Provisioning 2.0, the `thingProperties.h` file will automatically have the NetworkConfigurator component enabled. A board registered with Provisioning 2.0 includes `Arduino_NetworkConfigurator.h` in the generated `thingProperties.h` file. For more information about device provisioning have a look [here](https://docs.arduino.cc/arduino-cloud/hardware/device-provisioning/).
142+
143+
### How the NetworkConfigurator works
144+
145+
To work, the NetworkConfigurator needs:
146+
147+
- **One or more Configurator Agents**: Objects that handle the communication between the board and the user device (PC, laptop, or Mobile phone).
148+
- **A Key-Value Storage library**: the NetworkConfigurator needs an external storage library that implements the KVStoreInterface. Arduino provides the `Arduino_KVStore` library for handling the storage and saving the NetworkConfigurator configurations.
149+
- **A ConnectionHandler**: the object responsible for the board's Internet connection management.
150+
151+
The `NetworkConfigurator` library out-of-the-box provides two Agents:
152+
153+
- `BLEAgent` for handling the Bluetooth LE communication.
154+
- `SerialAgent` for the Serial communication.
155+
156+
## thingsProperties.h Default Setup
157+
158+
Here is how the `thingsProperties.h` file changes to set up the NetworkConfigurator. This setup is automatically generated if the board has been registered with Provisioning 2.0.
159+
160+
*** Do not follow these steps if the board has not been registered with the Provisioning 2.0. For more information about device provisioning have a look [here](https://docs.arduino.cc/arduino-cloud/hardware/device-provisioning/). ***
161+
162+
### Libraries and Object Declarations
163+
164+
The following libraries are automatically included:
165+
166+
- Arduino_NetworkConfigurator library
167+
- BLEAgent.h
168+
- SerialAgent.h
169+
170+
These objects are declared in `thingsProperties.h`:
171+
172+
- `kvStore`: handles the NVM operations
173+
- `BLEAgent`: handles the Bluetooth LE interface
174+
- `SerialAgent`: handles the Serial Interface
175+
- `NetworkConfigurator`: the networkConfigurator instance
176+
177+
```arduino
178+
#include <ArduinoIoTCloud.h>
179+
#include <Arduino_ConnectionHandler.h>
180+
#include <Arduino_NetworkConfigurator.h>
181+
#include <configuratorAgents/agents/BLEAgent.h>
182+
#include <configuratorAgents/agents/SerialAgent.h>
183+
void onVariableChange();
184+
int variable;
185+
KVStore kvStore;
186+
BLEAgentClass BLEAgent;
187+
SerialAgentClass SerialAgent;
188+
WiFiConnectionHandler ArduinoIoTPreferredConnection;
189+
NetworkConfiguratorClass NetworkConfigurator(ArduinoIoTPreferredConnection);
190+
```
191+
192+
### initProperties()
193+
194+
In the initProperties function, the following instructions are added:
195+
196+
- `NetworkConfigurator.addAgent(BLEAgent);` For enabling the BLEAgent.
197+
- `NetworkConfigurator.addAgent(SerialAgent);` For enabling the SerialAgent.
198+
- `NetworkConfigurator.setStorage(kvStore);` For setting the KVStore.
199+
- `ArduinoCloud.setConfigurator(NetworkConfigurator);` For embedding the NetworkConfigurator in the ArduinoCloud.
200+
201+
```arduino
202+
NetworkConfigurator.addAgent(BLEAgent);
203+
NetworkConfigurator.addAgent(SerialAgent);
204+
NetworkConfigurator.setStorage(kvStore);
205+
ArduinoCloud.setConfigurator(NetworkConfigurator);
206+
```
207+
208+
The final `thingProperties.h` file:
209+
210+
```arduino
211+
#include <ArduinoIoTCloud.h>
212+
#include <Arduino_ConnectionHandler.h>
213+
#include <Arduino_NetworkConfigurator.h>
214+
#include <configuratorAgents/agents/BLEAgent.h>
215+
#include <configuratorAgents/agents/SerialAgent.h>
216+
void onVariableChange();
217+
int variable;
218+
KVStore kvStore;
219+
BLEAgentClass BLEAgent;
220+
SerialAgentClass SerialAgent;
221+
WiFiConnectionHandler ArduinoIoTPreferredConnection;
222+
NetworkConfiguratorClass NetworkConfigurator(ArduinoIoTPreferredConnection);
223+
void initProperties(){
224+
NetworkConfigurator.addAgent(BLEAgent);
225+
NetworkConfigurator.addAgent(SerialAgent);
226+
NetworkConfigurator.setStorage(kvStore);
227+
ArduinoCloud.setConfigurator(NetworkConfigurator);
228+
// For changing the default reset pin (2) uncomment and set your preferred pin. Use DISABLE_PIN for disabling the reset procedure.
229+
// NetworkConfigurator.setReconfigurePin(YOUR_PIN);
230+
ArduinoCloud.addProperty(variable, READWRITE, ON_CHANGE, onVariableChange);
231+
}
232+
```
233+
234+
### Disable the BLEAgent
235+
236+
To save board storage and memory, after the provisioning, the `BLEAgent` can be removed. ~30 kB of storage and ~2 kB of memory are saved for BSS and Data. The network credentials provided in the provisioning phase can no longer be changed via Bluetooth if this is disabled.
237+
238+
To disable the `BLEAgent`, just comment out or remove the lines of code that include, declare, and enable it. The final result should be the following:
239+
240+
```arduino
241+
#include <ArduinoIoTCloud.h>
242+
#include <Arduino_ConnectionHandler.h>
243+
#include <Arduino_NetworkConfigurator.h>
244+
//#include <configuratorAgents/agents/BLEAgent.h>
245+
#include <configuratorAgents/agents/SerialAgent.h>
246+
void onVariableChange();
247+
int variable;
248+
KVStore kvStore;
249+
//BLEAgentClass BLEAgent;
250+
SerialAgentClass SerialAgent;
251+
WiFiConnectionHandler ArduinoIoTPreferredConnection;
252+
NetworkConfiguratorClass NetworkConfigurator(ArduinoIoTPreferredConnection);
253+
void initProperties(){
254+
// NetworkConfigurator.addAgent(BLEAgent);
255+
NetworkConfigurator.addAgent(SerialAgent);
256+
NetworkConfigurator.setStorage(kvStore);
257+
ArduinoCloud.setConfigurator(NetworkConfigurator);
258+
// For changing the default reset pin (2) uncomment and set your preferred pin. Use DISABLE_PIN for disabling the reset procedure.
259+
// NetworkConfigurator.setReconfigurePin(YOUR_PIN);
260+
ArduinoCloud.addProperty(variable, READWRITE, ON_CHANGE, onVariableChange);
261+
}
262+
```
263+
264+
### Disable the SerialAgent
265+
266+
To save board storage and memory, after the provisioning, the SerialAgent can be removed. ~1 kB of storage is saved for BSS and Data. The network credentials provided in the provisioning phase can no longer be changed via USB if this is disabled.
267+
268+
To disable the `SerialAgent`, just comment out or remove the lines of code that include, declare, and enable it. The final result should be the following:
269+
270+
```arduino
271+
#include <ArduinoIoTCloud.h>
272+
#include <Arduino_ConnectionHandler.h>
273+
#include <Arduino_NetworkConfigurator.h>
274+
#include <configuratorAgents/agents/BLEAgent.h>
275+
//#include <configuratorAgents/agents/SerialAgent.h>
276+
void onVariableChange();
277+
int variable;
278+
KVStore kvStore;
279+
BLEAgentClass BLEAgent;
280+
//SerialAgentClass SerialAgent;
281+
WiFiConnectionHandler ArduinoIoTPreferredConnection;
282+
NetworkConfiguratorClass NetworkConfigurator(ArduinoIoTPreferredConnection);
283+
void initProperties(){
284+
NetworkConfigurator.addAgent(BLEAgent);
285+
// NetworkConfigurator.addAgent(SerialAgent);
286+
NetworkConfigurator.setStorage(kvStore);
287+
ArduinoCloud.setConfigurator(NetworkConfigurator);
288+
// For changing the default reset pin (2) uncomment and set your preferred pin. Use DISABLE_PIN for disabling the reset procedure.
289+
// NetworkConfigurator.setReconfigurePin(YOUR_PIN);
290+
ArduinoCloud.addProperty(variable, READWRITE, ON_CHANGE, onVariableChange);
291+
}
292+
```
293+
294+
### Disable the NetworkConfigurator
295+
296+
To save board storage and memory, after the provisioning, the NetworkConfigurator can be removed. ~40 kB of storage and ~2.9 kB of memory are saved for BSS and Data.
297+
298+
In this setup, the only way to handle network settings is to return to using the secrets declared in `secrets.h` file. This can be done manually by adding the `secrets.h` file with the defines needed.
299+
300+
In order to change the network settings, you must flash your sketch with the updated network settings in the `secrets.h` file. The network settings can no longer be updated using the Arduino Cloud webpage or the mobile app. The final result should be the following (`thingProperties.h` file):
301+
302+
```arduino
303+
#include <ArduinoIoTCloud.h>
304+
#include <Arduino_ConnectionHandler.h>
305+
const char SSID[] = SECRET_SSID; // Network SSID (name)
306+
const char PASS[] = SECRET_OPTIONAL_PASS; // Network password (use for WPA, or use as key for WEP)
307+
void onVariableChange();
308+
int variable;
309+
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_SSID, SECRET_OPTIONAL_PASS);
310+
void initProperties(){
311+
ArduinoCloud.addProperty(variable, READWRITE, ON_CHANGE, onVariableChange);
312+
}
313+
```
133314

134315
## Offline Sketches
135316

0 commit comments

Comments
 (0)