|
1 | 1 | # Provisioning for Arduino
|
2 | 2 |
|
3 |
| -This sketch implements provisioning using various IDF components |
| 3 | +This sketch implements provisioning using various IDF components. |
4 | 4 |
|
5 |
| -# Description |
| 5 | +## Description |
6 | 6 |
|
7 |
| -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). |
| 7 | +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). |
8 | 8 |
|
9 |
| -# APIs introduced for provisioning |
| 9 | +## APIs introduced for provisioning |
10 | 10 |
|
11 |
| -## WiFi.onEvent() |
| 11 | +### WiFi.onEvent() |
12 | 12 |
|
13 |
| -Using this API user can register to receive WiFi Events and Provisioning Events |
| 13 | +Using this API, users can register to receive WiFi Events and Provisioning Events. |
14 | 14 |
|
15 |
| -## WiFi.beginProvision() |
| 15 | +### WiFi.beginProvision() |
16 | 16 |
|
17 |
| -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); |
| 17 | +``` |
| 18 | +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); |
| 19 | +``` |
18 | 20 |
|
19 | 21 | #### Parameters passed
|
20 | 22 |
|
21 |
| -* function pointer : choose the mode of transfer |
22 |
| - * provSchemeBLE - Using BLE |
23 |
| - * provSchemeSoftAP - Using SoftAP |
24 |
| - |
25 |
| -* security : choose security type |
26 |
| - * 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. |
| 23 | +- Function pointer: Choose the mode of transfer |
| 24 | + - `provSchemeBLE` - Using BLE |
| 25 | + - `provSchemeSoftAP` - Using SoftAP |
| 26 | + |
| 27 | +- `security`: Choose the security type |
| 28 | + - `WIFI_PROV_SECURITY_1` - Enables secure communication with a secure handshake using key exchange and proof of possession (pop), and encryption/decryption of messages. |
| 29 | + - `WIFI_PROV_SECURITY_0` - Does not provide application-level security, allowing plain text communication. |
27 | 30 |
|
28 |
| - * WIFI_PROV_SECURITY_0 - It do not provide application level security, it involve simply plain text communication. |
| 31 | +- `scheme_event_handler`: Specify the handlers according to the chosen mode |
| 32 | + - BLE: |
| 33 | + - `WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM` - Used when the application doesn't need BT and BLE after provisioning is finished. |
| 34 | + - `WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BLE` - Used when the application doesn't need BLE to be active after provisioning is finished. |
| 35 | + - `WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BT` - Used when the application doesn't need BT to be active after provisioning is finished. |
29 | 36 |
|
30 |
| -* scheme_event_handler : specify the handlers according to the mode chosen |
31 |
| - * BLE : |
32 |
| - - 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 |
33 |
| - - 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 |
34 |
| - - 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 |
| 37 | + - SoftAP: |
| 38 | + - `WIFI_PROV_EVENT_HANDLER_NONE` |
35 | 39 |
|
36 |
| - * SoftAp : |
37 |
| - - WIFI_PROV_EVENT_HANDLER_NONE |
| 40 | +- `pop`: String used for authentication. |
38 | 41 |
|
39 |
| -* pop : It is the string that is used to provide the authentication. |
| 42 | +- `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. |
40 | 43 |
|
41 |
| -* 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. |
| 44 | +- `service_key`: Specify the service key. If the chosen mode of provisioning is BLE, the `service_key` is always NULL. |
42 | 45 |
|
43 |
| -* service_key : Specify service key, if chosen mode of provisioning is BLE then service_key is always NULL |
| 46 | +- `uuid`: Users can specify their own 128-bit UUID while provisioning using BLE. If not specified, the default value is: |
44 | 47 |
|
45 |
| -* uuid : user can specify there own 128 bit UUID while provisioning using BLE, if not specified then default value taken is |
46 |
| - - { 0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf, |
47 |
| - 0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02, } |
| 48 | +``` |
| 49 | +{ 0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf, 0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02 } |
| 50 | +``` |
48 | 51 |
|
49 |
| -# NOTE |
| 52 | +- `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. |
50 | 53 |
|
51 |
| -* If none of the parameters are specified in beginProvision then default provisioning takes place using SoftAP with |
52 |
| - * scheme = WIFI_PROV_SCHEME_SOFTAP |
53 |
| - * scheme_event_handler = WIFI_PROV_EVENT_HANDLER_NONE |
54 |
| - * security = WIFI_PROV_SECURITY_1 |
55 |
| - * pop = "abcd1234" |
56 |
| - * service_name = "PROV_XXX" |
57 |
| - * service_key = NULL |
58 |
| - * uuid = NULL |
| 54 | +**NOTE:** If none of the parameters are specified in `beginProvision`, default provisioning takes place using SoftAP with the following settings: |
| 55 | +- `scheme = WIFI_PROV_SCHEME_SOFTAP` |
| 56 | +- `scheme_event_handler = WIFI_PROV_EVENT_HANDLER_NONE` |
| 57 | +- `security = WIFI_PROV_SECURITY_1` |
| 58 | +- `pop = "abcd1234"` |
| 59 | +- `service_name = "PROV_XXX"` |
| 60 | +- `service_key = NULL` |
| 61 | +- `uuid = NULL` |
| 62 | +- `reset_provisioned = false` |
59 | 63 |
|
60 |
| -# Log Output |
61 |
| -* Enable debuger : [ Tools -> Core Debug Level -> Info ] |
| 64 | +## Flashing |
| 65 | +This sketch takes up a lot of space for the app and may not be able to flash with default setting on some chips. |
| 66 | +If you see Error like this: "Sketch too big" |
| 67 | +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)` |
62 | 68 |
|
63 |
| -# Provisioning Tools |
64 |
| -https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/provisioning/wifi_provisioning.html#provisioning-tools |
| 69 | +## Log Output |
| 70 | +- To enable debugging: Go to Tools -> Core Debug Level -> Info. |
65 | 71 |
|
66 |
| -# Example output |
| 72 | +## Provisioning Tools |
| 73 | +[Provisioning Tools](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/provisioning/wifi_provisioning.html#provisioning-tools) |
67 | 74 |
|
68 |
| -## Provisioning using SoftAP |
| 75 | +## Example Output |
69 | 76 |
|
| 77 | +### Provisioning using SoftAP |
70 | 78 | ```
|
71 | 79 | [I][WiFiProv.cpp:117] beginProvision(): Starting AP using SOFTAP
|
72 |
| - service_name : PROV_XXX |
73 |
| - password : 123456789 |
74 |
| - pop : abcd1234 |
| 80 | + service_name: PROV_XXX |
| 81 | + password: 123456789 |
| 82 | + pop: abcd1234 |
75 | 83 |
|
76 | 84 | Provisioning started
|
77 |
| -Give Credentials of your access point using " Android app " |
| 85 | +Give Credentials of your access point using "Android app" |
78 | 86 |
|
79 | 87 | Received Wi-Fi credentials
|
80 |
| - SSID : GIONEE M2 |
81 |
| - Password : 123456789 |
| 88 | + SSID: GIONEE M2 |
| 89 | + Password: 123456789 |
82 | 90 |
|
83 |
| -Connected IP address : 192.168.43.120 |
| 91 | +Connected IP address: 192.168.43.120 |
84 | 92 | Provisioning Successful
|
85 | 93 | Provisioning Ends
|
86 |
| -
|
87 | 94 | ```
|
88 | 95 |
|
89 |
| -## Provisioning using BLE |
90 |
| - |
| 96 | +### Provisioning using BLE |
91 | 97 | ```
|
92 | 98 | [I][WiFiProv.cpp:115] beginProvision(): Starting AP using BLE
|
93 |
| - service_name : PROV_XXX |
94 |
| - pop : abcd1234 |
| 99 | + service_name: PROV_XXX |
| 100 | + pop: abcd1234 |
95 | 101 |
|
96 | 102 | Provisioning started
|
97 |
| -Give Credentials of your access point using " Android app " |
| 103 | +Give Credentials of your access point using "Android app" |
98 | 104 |
|
99 | 105 | Received Wi-Fi credentials
|
100 |
| - SSID : GIONEE M2 |
101 |
| - Password : 123456789 |
| 106 | + SSID: GIONEE M2 |
| 107 | + Password: 123456789 |
102 | 108 |
|
103 |
| -Connected IP address : 192.168.43.120 |
| 109 | +Connected IP address: 192.168.43.120 |
104 | 110 | Provisioning Successful
|
105 | 111 | Provisioning Ends
|
106 |
| -
|
107 | 112 | ```
|
108 | 113 |
|
109 |
| -## Credentials are available on device |
110 |
| - |
111 |
| -``` |
112 |
| -[I][WiFiProv.cpp:146] beginProvision(): Aleardy Provisioned, starting Wi-Fi STA |
113 |
| -[I][WiFiProv.cpp:150] beginProvision(): SSID : Wce***** |
114 |
| -[I][WiFiProv.cpp:152] beginProvision(): CONNECTING TO THE ACCESS POINT : |
115 |
| -Connected IP address : 192.168.43.120 |
| 114 | +### Credentials are available on the device |
116 | 115 | ```
|
| 116 | +[I][WiFiProv.cpp:146] beginProvision(): Already Provisioned, starting Wi-Fi STA |
| 117 | +[I][WiFiProv.cpp:150] beginProvision(): SSID: Wce***** |
| 118 | +[I][WiFiProv.cpp:152] beginProvision(): CONNECTING TO THE ACCESS POINT: |
| 119 | +Connected IP address: 192.168.43.120 |
| 120 | +``` |
0 commit comments