Skip to content

Commit a2e0e86

Browse files
Provisioning Fixes (#4522)
1 parent 9debb9f commit a2e0e86

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

libraries/WiFi/examples/WiFiProv/WiFiProv.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ void setup() {
4545
/* uint8_t uuid[16] = {0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf,
4646
0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02 };*/
4747
WiFi.onEvent(SysProvEvent);
48-
//WiFi.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, "abcd1234");
49-
WiFi.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, "abcd1234");
48+
#if CONFIG_IDF_TARGET_ESP32 && CONFIG_BLUEDROID_ENABLED
49+
WiFi.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123");
50+
#else
51+
WiFi.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123");
52+
#endif
5053
}
5154

5255
void loop() {

libraries/WiFi/src/WiFiProv.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
#include <wifi_provisioning/manager.h>
3636
#undef IPADDR_NONE
3737
#include "WiFi.h"
38+
#if CONFIG_IDF_TARGET_ESP32
39+
#include "SimpleBLE.h"
40+
#endif
3841

3942
bool wifiLowLevelInit(bool persistent);
4043

@@ -114,7 +117,8 @@ void WiFiProvClass :: beginProvision(prov_scheme_t prov_scheme, scheme_handler_t
114117
return;
115118
}
116119
#endif
117-
120+
config.app_event_handler.event_cb = NULL;
121+
config.app_event_handler.user_data = NULL;
118122
wifiLowLevelInit(true);
119123
if(wifi_prov_mgr_init(config) != ESP_OK){
120124
log_e("wifi_prov_mgr_init failed!");
@@ -154,28 +158,19 @@ void WiFiProvClass :: beginProvision(prov_scheme_t prov_scheme, scheme_handler_t
154158
#if CONFIG_BLUEDROID_ENABLED
155159
}
156160
#endif
157-
158-
if(wifi_prov_mgr_endpoint_create("custom-data") != ESP_OK){
159-
log_e("wifi_prov_mgr_endpoint_create failed!");
160-
return;
161-
}
162161
if(wifi_prov_mgr_start_provisioning(security, pop, service_name, service_key) != ESP_OK){
163162
log_e("wifi_prov_mgr_start_provisioning failed!");
164163
return;
165164
}
166-
if(wifi_prov_mgr_endpoint_register("custom-data", custom_prov_data_handler, NULL) != ESP_OK){
167-
log_e("wifi_prov_mgr_endpoint_register failed!");
168-
return;
169-
}
170165
} else {
171-
wifi_prov_mgr_deinit();
172-
log_i("Aleardy Provisioned");
166+
log_i("Already Provisioned");
173167
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
174168
static wifi_config_t conf;
175169
esp_wifi_get_config(WIFI_IF_STA,&conf);
176170
log_i("Attempting connect to AP: %s\n",conf.sta.ssid);
177171
#endif
178-
esp_wifi_start();
172+
esp_wifi_start();
173+
wifi_prov_mgr_deinit();
179174
WiFi.begin();
180175
}
181176
}

0 commit comments

Comments
 (0)