Chapter 2. API Reference
• [out] provisioned: True if provisioned, else false
esp_err_t wifi_prov_mgr_start_provisioning(wifi_prov_security_t security, const char
*pop, const char *service_name, const char
*service_key)
Start provisioning service.
This starts the provisioning service according to the scheme configured at the time of initialization. For scheme
:
• wifi_prov_scheme_ble : This starts protocomm_ble, which internally initializes BLE transport and starts
GATT server for handling provisioning requests
• wifi_prov_scheme_softap : This activates SoftAP mode of Wi-Fi and starts protocomm_httpd, which
internally starts an HTTP server for handling provisioning requests (If mDNS is active it also starts ad-
vertising service with type _esp_wifi_prov._tcp)
Event WIFI_PROV_START is emitted right after provisioning starts without failure
Note This API will start provisioning service even if device is found to be already provisioned, i.e.
wifi_prov_mgr_is_provisioned() yields true
Return
• ESP_OK : Provisioning started successfully
• ESP_FAIL : Failed to start provisioning service
• ESP_ERR_INVALID_STATE : Provisioning manager not initialized or already started
Parameters
• [in] security: Specify which protocomm security scheme to use :
– WIFI_PROV_SECURITY_0 : For no security
– WIFI_PROV_SECURITY_1 : x25519 secure handshake for session establishment followed by
AES-CTR encryption of provisioning messages
• [in] pop: Pointer to proof of possession string (NULL if not needed). This is relevant only for
protocomm security 1, in which case it is used for authenticating secure session
• [in] service_name: Unique name of the service. This translates to:
– Wi-Fi SSID when provisioning mode is softAP
– Device name when provisioning mode is BLE
• [in] service_key: Key required by client to access the service (NULL if not needed). This
translates to:
– Wi-Fi password when provisioning mode is softAP
– ignored when provisioning mode is BLE
void wifi_prov_mgr_stop_provisioning(void)
Stop provisioning service.
If provisioning service is active, this API will initiate a process to stop the service and return. Once the service
actually stops, the event WIFI_PROV_END will be emitted.
If wifi_prov_mgr_deinit() is called without calling this API first, it will automatically stop the provisioning
service and emit the WIFI_PROV_END, followed by WIFI_PROV_DEINIT, before returning.
This API will generally be used along with wifi_prov_mgr_disable_auto_stop() in the scenario when the main
application has registered its own endpoints, and wishes that the provisioning service is stopped only when
some protocomm command from the client side application is received.
Calling this API inside an endpoint handler, with sufficient cleanup_delay, will allow the response / acknowl-
edgment to be sent successfully before the underlying protocomm service is stopped.
Cleaup_delay is set when calling wifi_prov_mgr_disable_auto_stop(). If not specified, it defaults to 1000ms.
For straightforward cases, using this API is usually not necessary as provisioning is stopped automatically once
WIFI_PROV_CRED_SUCCESS is emitted. Stopping is delayed (maximum 30 seconds) thus allowing the
client side application to query for Wi-Fi state, i.e. after receiving the first query and sending Wi-Fi state
connected response the service is stopped immediately.
void wifi_prov_mgr_wait(void)
Wait for provisioning service to finish.
Espressif Systems 686
Submit Document Feedback
Release v4.4