Skip to content

Commit 703995e

Browse files
committed
Provisioning Fixes
1 parent 9debb9f commit 703995e

File tree

3 files changed

+13
-15
lines changed

3 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
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: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ void WiFiProvClass :: beginProvision(prov_scheme_t prov_scheme, scheme_handler_t
114114
return;
115115
}
116116
#endif
117-
117+
config.app_event_handler.event_cb = NULL;
118+
config.app_event_handler.user_data = NULL;
118119
wifiLowLevelInit(true);
119120
if(wifi_prov_mgr_init(config) != ESP_OK){
120121
log_e("wifi_prov_mgr_init failed!");
@@ -154,28 +155,19 @@ void WiFiProvClass :: beginProvision(prov_scheme_t prov_scheme, scheme_handler_t
154155
#if CONFIG_BLUEDROID_ENABLED
155156
}
156157
#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-
}
162158
if(wifi_prov_mgr_start_provisioning(security, pop, service_name, service_key) != ESP_OK){
163159
log_e("wifi_prov_mgr_start_provisioning failed!");
164160
return;
165161
}
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-
}
170162
} else {
171-
wifi_prov_mgr_deinit();
172-
log_i("Aleardy Provisioned");
163+
log_i("Already Provisioned");
173164
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
174165
static wifi_config_t conf;
175166
esp_wifi_get_config(WIFI_IF_STA,&conf);
176167
log_i("Attempting connect to AP: %s\n",conf.sta.ssid);
177168
#endif
178-
esp_wifi_start();
169+
esp_wifi_start();
170+
wifi_prov_mgr_deinit();
179171
WiFi.begin();
180172
}
181173
}

libraries/WiFi/src/WiFiProv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
#include "WiFi.h"
2121
#include "wifi_provisioning/manager.h"
22+
#if CONFIG_IDF_TARGET_ESP32
23+
#include "SimpleBLE.h"
24+
#endif
2225
//Select the scheme using which you want to provision
2326
typedef enum {
2427
WIFI_PROV_SCHEME_SOFTAP,

0 commit comments

Comments
 (0)