Skip to content

Commit dd89395

Browse files
committed
Merge branch 'docs/update_reprovisioning_docs_in_wifi_prov_mgr_example' into 'master'
Updated reprovisioning docs in wifi prov mgr example Closes IDF-12699 See merge request espressif/esp-idf!39058
2 parents 81bb6a0 + 619caaa commit dd89395

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

examples/provisioning/wifi_prov_mgr/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,58 @@ This example can be used, as it is, for adding a provisioning service to any app
2525

2626
> Note: If you use this example code in your own project, in BLE mode, then remember to enable the BT stack and BTDM BLE control settings in your SDK configuration (e.g. by using the `sdkconfig.defaults` file from this project).
2727
28+
## Transports
29+
30+
### SoftAP Transport
31+
- After successful provisioning, the SoftAP connection is not disconnected by default
32+
- Users can directly reconnect to the device for reprovisioning
33+
- It's the user's responsibility to manage connection memory and handle it according to application requirements
34+
- **HTTP**: `POST http://<server_name>:<port>/prov-ctrl`
35+
36+
### BLE Transport
37+
- By default, BT memory is released after successful provisioning
38+
- To keep BLE active after provisioning, enable `WIFI_PROV_KEEP_BLE_ON_AFTER_PROV` in menuconfig
39+
- This configuration ensures that BLE advertising is continued even after provisioning is completed.
40+
- For both SoftAP and BLE transports:
41+
- Enable `EXAMPLE_REPROVISIONING` in menuconfig to allow reprovisioning
42+
- Use the `esp_prov.py` tool for reprovisioning
43+
- Call `wifi_prov_mgr_disable_auto_stop()` API before initiating reprovisioning (already called in this example)
44+
- **BLE**: `GATT` characteristic for protocomm communication
45+
46+
**NOTE: The underlying transport (HTTP/BLE) must be kept enabled for external commands to be processed**.
47+
48+
## Reprovisioning
49+
50+
The example supports reprovisioning of Wi-Fi credentials through both SoftAP and BLE transports. Here are the key considerations for each transport:
51+
52+
### Commands
53+
54+
**Internal API**: `wifi_prov_mgr_reset_sm_state_for_reprovision()`
55+
- This API is can be called internally by the device firmware to reset WiFi credentials and restart provisioning mode.
56+
- For demonstration purposes, this API has been called directly in firmware code, In real-world scenarios following command based reprovisioning is preferred.
57+
58+
**External Command**:
59+
- **Endpoint**: `prov-ctrl`
60+
- **Command**: `TypeCmdCtrlReprov` (protobuf)
61+
- **Transport**: HTTP/BLE as configured
62+
- External clients (like Phone apps) can send this command via the transport layer to trigger the reprovisioning.
63+
64+
**Usage from esp_prov.py**:
65+
```bash
66+
python esp_prov.py --transport ble --service_name "PROV_DEVICE" --reprov
67+
```
68+
69+
### Use Cases for Reprovisioning
70+
71+
This flexibility is particularly useful when:
72+
- Network credentials need to be updated (password changes, SSID changes)
73+
- Device needs to connect to a different network environment
74+
- Troubleshooting connectivity issues requires fresh credential configuration
75+
- Moving devices between different locations with different network setups
76+
77+
For more details on the provisioning process and APIs, refer to the [Wi-Fi Provisioning Manager component documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/provisioning/wifi_provisioning.html).
78+
79+
2880
## How to use example
2981

3082
### Hardware Required

examples/provisioning/wifi_prov_mgr/main/app_main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,12 @@ void app_main(void)
539539
}
540540

541541
/* Resetting provisioning state machine to enable re-provisioning */
542+
/* NOTE: This API is used only for demonstration purposes in this example.
543+
* In real-world firmware applications, you should NOT call this API directly.
544+
* Instead, the external provisioning entity should trigger reprovisioning by sending
545+
* a command through the provisioning control endpoint, which will internally
546+
* trigger same behaviour to reset the provisioning state.
547+
*/
542548
wifi_prov_mgr_reset_sm_state_for_reprovision();
543549

544550
/* Wait for Wi-Fi connection */

0 commit comments

Comments
 (0)