This sketch implements provisioning using various IDF components
This sketch implements provisioning using various IDF components.
# Description
## Description
This example allows Arduino user to choose either BLE or SOFTAP as a mode of transport, over which the provisioning related communication is to take place, between the device (to be provisioned) and the client (owner of the device).
This example allows Arduino users to choose either BLE or SOFTAP as the mode of transport for provisioning-related communication between the device (to be provisioned) and the client (owner of the device).
# APIs introduced for provisioning
## APIs introduced for provisioning
## WiFi.onEvent()
### WiFi.onEvent()
Using this API user can register to receive WiFi Events and Provisioning Events
Using this API, users can register to receive WiFi Events and Provisioning Events.
* WIFI_PROV_SECURITY_1 - It allows secure communication which consists of secure handshake using key exchange and proof of possession (pop) and encryption/decryption of messages.
-`WIFI_PROV_SECURITY_1` - Enables secure communication with a secure handshake using key exchange and proof of possession (pop), and encryption/decryption of messages.
-`WIFI_PROV_SECURITY_0` - Does not provide application-level security, allowing plain text communication.
* WIFI_PROV_SECURITY_0 - It do not provide application level security, it involve simply plain text communication.
-`scheme_event_handler`: Specify the handlers according to the chosen mode
- BLE:
-`WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM` - Used when the application doesn't need BT and BLE after provisioning is finished.
-`WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BLE` - Used when the application doesn't need BLE to be active after provisioning is finished.
-`WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BT` - Used when the application doesn't need BT to be active after provisioning is finished.
* scheme_event_handler : specify the handlers according to the mode chosen
- SoftAP:
* BLE :
- `WIFI_PROV_EVENT_HANDLER_NONE`
- WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM - This scheme event handler is used when application doesn't need BT and BLE after provisioning is finised
- WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BLE - This scheme event handler is used when application doesn't need BLE to be active after provisioning is finised
- WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BT - This scheme event handler is used when application doesn't need BT to be active after provisioning is finised
* SoftAp :
-`pop`: String used for authentication.
- WIFI_PROV_EVENT_HANDLER_NONE
* pop : It is the string that is used to provide the authentication.
-`service_name`: Specify the service name for the device. If not specified, the default chosen name is `PROV_XXX`, where XXX represents the last 3 bytes of the MAC address.
* service_name : Specify service name for the device, if it is not specified then default chosen name is PROV_XXX where XXX are the last 3 bytes of the MAC address.
-`service_key`: Specify the service key. If the chosen mode of provisioning is BLE, the `service_key` is always NULL.
* service_key : Specify service key, if chosen mode of provisioning is BLE then service_key is always NULL
-`uuid`: Users can specify their own 128-bit UUID while provisioning using BLE. If not specified, the default value is:
* uuid : user can specify there own 128 bit UUID while provisioning using BLE, if not specified then default value taken is
-`reset_provisioned`: Resets previously provisioned data before initializing. Using this prevents problem when the device automatically connects to previously connected WiFi and therefore cannot be found.
* If none of the parameters are specified in beginProvision then default provisioning takes place using SoftAP with
**NOTE:** If none of the parameters are specified in `beginProvision`, default provisioning takes place using SoftAP with the following settings:
log_i("If QR code is not visible, copy paste the below URL in a browser.\n%s?data=%s","https://espressif.github.io/esp-jumpstart/qrcode.html",payload);
log_i("If you are using Arduino as IDF component, install ESP Rainmaker:\nhttps://github.com/espressif/esp-rainmaker");