Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9d547a8

Browse filesBrowse files
Provisioning fixes for: 1.Space 2.Provisioned (#4291)
1 parent 1fd5cd7 commit 9d547a8
Copy full SHA for 9d547a8

File tree

Expand file treeCollapse file tree

4 files changed

+43
-38
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+43
-38
lines changed

‎libraries/WiFi/examples/WiFiProv/README.md

Copy file name to clipboardExpand all lines: libraries/WiFi/examples/WiFiProv/README.md
+12-12Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ A function with following signature
2424

2525
## WiFi.beginProvision()
2626

27-
WiFi.beginProvision(scheme prov_scheme, 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);
27+
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);
2828

2929
#### Parameters passed
3030

31-
* prov_scheme : choose the mode of transfer
32-
* WIFI_PROV_SCHEME_BLE - Using BLE
33-
* WIFI_PROV_SCHEME_SOFTAP - Using SoftAP
31+
* function pointer : choose the mode of transfer
32+
* provSchemeBLE - Using BLE
33+
* provSchemeSoftAP - Using SoftAP
3434

3535
* security : choose security type
3636
* 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.
@@ -48,7 +48,7 @@ WiFi.beginProvision(scheme prov_scheme, wifi_prov_scheme_event_handler_t scheme_
4848

4949
* pop : It is the string that is used to provide the authentication.
5050

51-
* service_name : Specify service name for the device, if it is not specified then default chosen name via SoftAP is WIFI_XXX and via BLE is BLE_XXX where XXX are the last 3 bytes of the MAC address.
51+
* 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.
5252

5353
* service_key : Specify service key, if chosen mode of provisioning is BLE then service_key is always NULL
5454

@@ -63,7 +63,7 @@ WiFi.beginProvision(scheme prov_scheme, wifi_prov_scheme_event_handler_t scheme_
6363
* scheme_event_handler = WIFI_PROV_EVENT_HANDLER_NONE
6464
* security = WIFI_PROV_SECURITY_1
6565
* pop = "abcd1234"
66-
* service_name = "WiFi_XXX"
66+
* service_name = "PROV_XXX"
6767
* service_key = NULL
6868
* uuid = NULL
6969

@@ -79,7 +79,7 @@ https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/provis
7979

8080
```
8181
[I][WiFiProv.cpp:117] beginProvision(): Starting AP using SOFTAP
82-
service_name : WIFI_XXX
82+
service_name : PROV_XXX
8383
password : 123456789
8484
pop : abcd1234
8585
@@ -100,7 +100,7 @@ Provisioning Ends
100100

101101
```
102102
[I][WiFiProv.cpp:115] beginProvision(): Starting AP using BLE
103-
service_name : BLE_XXX
103+
service_name : PROV_XXX
104104
pop : abcd1234
105105
106106
Provisioning started
@@ -119,8 +119,8 @@ Provisioning Ends
119119
## Credentials are available on device
120120

121121
```
122-
[I][WiFiProv.cpp:125] beginProvision(): Aleardy Provisioned, starting Wi-Fi STA
123-
[I][WiFiProv.cpp:126] beginProvision(): CONNECTING ACCESS POINT CREDENTIALS :
124-
[I][WiFiProv.cpp:126] beginProvision(): SSID : GIONEE M2
125-
122+
[I][WiFiProv.cpp:146] beginProvision(): Aleardy Provisioned, starting Wi-Fi STA
123+
[I][WiFiProv.cpp:150] beginProvision(): SSID : Wce*****
124+
[I][WiFiProv.cpp:152] beginProvision(): CONNECTING TO THE ACCESS POINT :
125+
Connected IP address : 192.168.43.120
126126
```

‎libraries/WiFi/examples/WiFiProv/WiFiProv.ino

Copy file name to clipboardExpand all lines: libraries/WiFi/examples/WiFiProv/WiFiProv.ino
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void setup() {
5656
/* uint8_t uuid[16] = {0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf,
5757
0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02 };*/
5858
WiFi.onEvent(SysProvEvent);
59-
WiFi.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, "abcd1234", "BLE_XXX", NULL, NULL);
59+
WiFi.beginProvision(provSchemeBLE, WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, "abcd1234", "PROV_XXX", NULL, NULL);
6060
}
6161

6262
void loop() {

‎libraries/WiFi/src/WiFiProv.cpp

Copy file name to clipboardExpand all lines: libraries/WiFi/src/WiFiProv.cpp
+22-19Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@
2727
#include <esp_event_loop.h>
2828
#include <esp32-hal.h>
2929

30-
#include <nvs_flash.h>
3130
#include <wifi_provisioning/scheme_ble.h>
3231
#include <wifi_provisioning/scheme_softap.h>
3332
#include <wifi_provisioning/manager.h>
3433
#undef IPADDR_NONE
3534
#include "WiFi.h"
3635

36+
wifi_prov_mgr_config_t config;
37+
scheme_t prov_scheme;
3738
extern esp_err_t postToSysQueue(system_prov_event_t *);
3839
static const uint8_t custom_service_uuid[16] = { 0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf,
3940
0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02, };
4041

41-
#define SERV_NAME_PREFIX_BLE "BLE_"
42-
#define SERV_NAME_PREFIX_WIFI "WIFI_"
42+
#define SERV_NAME_PREFIX_PROV "PROV_"
4343

4444
bool WiFiProvClass::prov_enable = true;
4545

@@ -48,6 +48,18 @@ bool WiFiProvClass::isProvEnabled()
4848
return prov_enable;
4949
}
5050

51+
void provSchemeBLE()
52+
{
53+
prov_scheme = WIFI_PROV_SCHEME_BLE;
54+
config.scheme = wifi_prov_scheme_ble;
55+
}
56+
57+
void provSchemeSoftAP()
58+
{
59+
prov_scheme = WIFI_PROV_SCHEME_SOFTAP;
60+
config.scheme = wifi_prov_scheme_softap;
61+
}
62+
5163
static void prov_event_handler(void *user_data, wifi_prov_cb_event_t event, void *event_data)
5264
{
5365
if (!event) {
@@ -87,33 +99,23 @@ static void prov_event_handler(void *user_data, wifi_prov_cb_event_t event, void
8799
}
88100
}
89101

90-
static void get_device_service_name(scheme prov_scheme, char *service_name, size_t max)
102+
static void get_device_service_name(char *service_name, size_t max)
91103
{
92104
uint8_t eth_mac[6];
93105
WiFi.macAddress(eth_mac);
94-
if(prov_scheme == WIFI_PROV_SCHEME_BLE) {
95-
snprintf(service_name, max, "%s%02X%02X%02X",SERV_NAME_PREFIX_BLE, eth_mac[3], eth_mac[4], eth_mac[5]);
96-
} else {
97-
snprintf(service_name, max, "%s%02X%02X%02X",SERV_NAME_PREFIX_WIFI, eth_mac[3], eth_mac[4], eth_mac[5]);
98-
}
106+
snprintf(service_name, max, "%s%02X%02X%02X",SERV_NAME_PREFIX_PROV, eth_mac[3], eth_mac[4], eth_mac[5]);
99107
}
100108

101-
void WiFiProvClass :: beginProvision(scheme prov_scheme, wifi_prov_event_handler_t scheme_event_handler, wifi_prov_security_t security, const char * pop, const char *service_name, const char *service_key, uint8_t * uuid)
109+
void WiFiProvClass :: beginProvision(void (*scheme_cb)(), wifi_prov_event_handler_t scheme_event_handler, wifi_prov_security_t security, const char * pop, const char *service_name, const char *service_key, uint8_t * uuid)
102110
{
103111
prov_enable = true;
104112
bool provisioned = false;
105-
wifi_prov_mgr_config_t config;
113+
scheme_cb();
106114
config.scheme_event_handler = scheme_event_handler;
107115
config.app_event_handler = {
108116
.event_cb = prov_event_handler,
109117
.user_data = NULL
110118
};
111-
112-
if(prov_scheme == WIFI_PROV_SCHEME_BLE) {
113-
config.scheme = wifi_prov_scheme_ble;
114-
} else {
115-
config.scheme = wifi_prov_scheme_softap;
116-
}
117119

118120
wifi_prov_mgr_init(config);
119121
WiFi.mode(WIFI_MODE_AP);
@@ -129,7 +131,7 @@ void WiFiProvClass :: beginProvision(scheme prov_scheme, wifi_prov_event_handler
129131

130132
if(service_name == NULL) {
131133
char service_name_temp[12];
132-
get_device_service_name(prov_scheme,service_name_temp,sizeof(service_name_temp));
134+
get_device_service_name(service_name_temp,sizeof(service_name_temp));
133135
service_name = (const char *)service_name_temp;
134136
}
135137

@@ -150,12 +152,13 @@ void WiFiProvClass :: beginProvision(scheme prov_scheme, wifi_prov_event_handler
150152
wifi_prov_mgr_deinit();
151153
WiFi.mode(WIFI_MODE_STA);
152154
log_i("Aleardy Provisioned, starting Wi-Fi STA");
153-
log_i("CONNECTING ACCESS POINT CREDENTIALS : ");
154155
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
155156
wifi_config_t conf;
156157
esp_wifi_get_config(WIFI_IF_STA,&conf);
157158
log_i("SSID : %s\n",conf.sta.ssid);
158159
#endif
160+
log_i("CONNECTING TO THE ACCESS POINT : ");
161+
WiFi.begin();
159162
}
160163
}
161164

‎libraries/WiFi/src/WiFiProv.h

Copy file name to clipboardExpand all lines: libraries/WiFi/src/WiFiProv.h
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,18 @@
1919

2020
#include "wifi_provisioning/manager.h"
2121
#include "wifi_provisioning/scheme_ble.h"
22-
#include "esp_wifi.h"
2322
#include "nvs_flash.h"
2423
#include "SimpleBLE.h"
2524
//Select the scheme using which you want to provision
26-
enum scheme
25+
typedef enum
2726
{
2827
WIFI_PROV_SCHEME_BLE,
29-
WIFI_PROV_SCHEME_SOFTAP,
30-
WIFI_PROV_SCHEME_CONSOLE
31-
};
28+
WIFI_PROV_SCHEME_SOFTAP
29+
}scheme_t;
30+
31+
extern void provSchemeSoftAP();
32+
extern void provSchemeBLE();
33+
3234
//Provisioning class
3335
class WiFiProvClass
3436
{
@@ -42,7 +44,7 @@ class WiFiProvClass
4244

4345
bool isProvEnabled();
4446

45-
void beginProvision(scheme prov_scheme = WIFI_PROV_SCHEME_SOFTAP, wifi_prov_event_handler_t scheme_event_handler = WIFI_PROV_EVENT_HANDLER_NONE, wifi_prov_security_t security = WIFI_PROV_SECURITY_1, const char * pop = "abcd1234", const char * service_name = NULL, const char * service_key = NULL, uint8_t *uuid = NULL);
47+
void beginProvision(void (*scheme_cb)() = provSchemeSoftAP, wifi_prov_event_handler_t scheme_event_handler = WIFI_PROV_EVENT_HANDLER_NONE, wifi_prov_security_t security = WIFI_PROV_SECURITY_1, const char * pop = "abcd1234", const char * service_name = NULL, const char * service_key = NULL, uint8_t *uuid = NULL);
4648
};
4749

4850
/*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.