-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Provisioning fix and upgrades #8209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,116 +1,120 @@ | ||
# Provisioning for Arduino | ||
|
||
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.beginProvision() | ||
### WiFi.beginProvision() | ||
|
||
WiFi.beginProvision(void ( * scheme_cb)(), wifi_prov_scheme_event_handler_t scheme_event_handler, wifi_prov_security_t security, char * pop, char * service_name, char * service_key, uint8_t * uuid); | ||
``` | ||
WiFi.beginProvision(void (*scheme_cb)(), wifi_prov_scheme_event_handler_t scheme_event_handler, wifi_prov_security_t security, char *pop, char *service_name, char *service_key, uint8_t *uuid); | ||
``` | ||
|
||
#### Parameters passed | ||
|
||
* function pointer : choose the mode of transfer | ||
* provSchemeBLE - Using BLE | ||
* provSchemeSoftAP - Using SoftAP | ||
|
||
* security : choose security type | ||
* 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. | ||
- Function pointer: Choose the mode of transfer | ||
- `provSchemeBLE` - Using BLE | ||
- `provSchemeSoftAP` - Using SoftAP | ||
|
||
- `security`: Choose the security type | ||
- `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 | ||
* BLE : | ||
- 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: | ||
- `WIFI_PROV_EVENT_HANDLER_NONE` | ||
|
||
* SoftAp : | ||
- WIFI_PROV_EVENT_HANDLER_NONE | ||
- `pop`: String used for authentication. | ||
|
||
* 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 | ||
- { 0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf, | ||
0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02, } | ||
``` | ||
{ 0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf, 0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02 } | ||
``` | ||
|
||
# NOTE | ||
- `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 | ||
* scheme = WIFI_PROV_SCHEME_SOFTAP | ||
* scheme_event_handler = WIFI_PROV_EVENT_HANDLER_NONE | ||
* security = WIFI_PROV_SECURITY_1 | ||
* pop = "abcd1234" | ||
* service_name = "PROV_XXX" | ||
* service_key = NULL | ||
* uuid = NULL | ||
**NOTE:** If none of the parameters are specified in `beginProvision`, default provisioning takes place using SoftAP with the following settings: | ||
- `scheme = WIFI_PROV_SCHEME_SOFTAP` | ||
- `scheme_event_handler = WIFI_PROV_EVENT_HANDLER_NONE` | ||
- `security = WIFI_PROV_SECURITY_1` | ||
- `pop = "abcd1234"` | ||
- `service_name = "PROV_XXX"` | ||
- `service_key = NULL` | ||
- `uuid = NULL` | ||
- `reset_provisioned = false` | ||
|
||
# Log Output | ||
* Enable debuger : [ Tools -> Core Debug Level -> Info ] | ||
## Flashing | ||
This sketch takes up a lot of space for the app and may not be able to flash with default setting on some chips. | ||
If you see Error like this: "Sketch too big" | ||
In Arduino IDE go to: Tools > Partition scheme > chose anything that has more than 1.4MB APP for example `No OTA (2MB APP/2MB SPIFFS)` | ||
|
||
# Provisioning Tools | ||
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/provisioning/wifi_provisioning.html#provisioning-tools | ||
## Log Output | ||
- To enable debugging: Go to Tools -> Core Debug Level -> Info. | ||
|
||
# Example output | ||
## Provisioning Tools | ||
[Provisioning Tools](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/provisioning/wifi_provisioning.html#provisioning-tools) | ||
|
||
## Provisioning using SoftAP | ||
## Example Output | ||
|
||
### Provisioning using SoftAP | ||
``` | ||
[I][WiFiProv.cpp:117] beginProvision(): Starting AP using SOFTAP | ||
service_name : PROV_XXX | ||
password : 123456789 | ||
pop : abcd1234 | ||
service_name: PROV_XXX | ||
password: 123456789 | ||
pop: abcd1234 | ||
|
||
Provisioning started | ||
Give Credentials of your access point using " Android app " | ||
Give Credentials of your access point using "Android app" | ||
|
||
Received Wi-Fi credentials | ||
SSID : GIONEE M2 | ||
Password : 123456789 | ||
SSID: GIONEE M2 | ||
Password: 123456789 | ||
|
||
Connected IP address : 192.168.43.120 | ||
Connected IP address: 192.168.43.120 | ||
Provisioning Successful | ||
Provisioning Ends | ||
|
||
``` | ||
|
||
## Provisioning using BLE | ||
|
||
### Provisioning using BLE | ||
``` | ||
[I][WiFiProv.cpp:115] beginProvision(): Starting AP using BLE | ||
service_name : PROV_XXX | ||
pop : abcd1234 | ||
service_name: PROV_XXX | ||
pop: abcd1234 | ||
|
||
Provisioning started | ||
Give Credentials of your access point using " Android app " | ||
Give Credentials of your access point using "Android app" | ||
|
||
Received Wi-Fi credentials | ||
SSID : GIONEE M2 | ||
Password : 123456789 | ||
SSID: GIONEE M2 | ||
Password: 123456789 | ||
|
||
Connected IP address : 192.168.43.120 | ||
Connected IP address: 192.168.43.120 | ||
Provisioning Successful | ||
Provisioning Ends | ||
|
||
``` | ||
|
||
## Credentials are available on device | ||
|
||
``` | ||
[I][WiFiProv.cpp:146] beginProvision(): Aleardy Provisioned, starting Wi-Fi STA | ||
[I][WiFiProv.cpp:150] beginProvision(): SSID : Wce***** | ||
[I][WiFiProv.cpp:152] beginProvision(): CONNECTING TO THE ACCESS POINT : | ||
Connected IP address : 192.168.43.120 | ||
### Credentials are available on the device | ||
``` | ||
[I][WiFiProv.cpp:146] beginProvision(): Already Provisioned, starting Wi-Fi STA | ||
[I][WiFiProv.cpp:150] beginProvision(): SSID: Wce***** | ||
[I][WiFiProv.cpp:152] beginProvision(): CONNECTING TO THE ACCESS POINT: | ||
Connected IP address: 192.168.43.120 | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should check if that include exists and only then include and provide the new function. When building as component and qrcode component is not additionally installed, compilation will fail: https://github.com/espressif/arduino-esp32/actions/runs/4989420314/jobs/8933324447?pr=8209#step:4:1408
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was expecting this to be available for all SoCs, I can see that is not, but do not understand why?
How can I test it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it exists from the lib-builder, because it's installed with RainMaker, but as clean IDF+Arduino-as-component it does not exist for ANY chip.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be resolved - CI passed