Skip to content

Provisioning Fixes #4522

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 1 commit into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions libraries/WiFi/examples/WiFiProv/WiFiProv.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ void setup() {
/* uint8_t uuid[16] = {0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf,
0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02 };*/
WiFi.onEvent(SysProvEvent);
//WiFi.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, "abcd1234");
WiFi.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, "abcd1234");
#if CONFIG_IDF_TARGET_ESP32 && CONFIG_BLUEDROID_ENABLED
WiFi.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123");
#else
WiFi.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123");
#endif
}

void loop() {
Expand Down
21 changes: 8 additions & 13 deletions libraries/WiFi/src/WiFiProv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
#include <wifi_provisioning/manager.h>
#undef IPADDR_NONE
#include "WiFi.h"
#if CONFIG_IDF_TARGET_ESP32
#include "SimpleBLE.h"
#endif

bool wifiLowLevelInit(bool persistent);

Expand Down Expand Up @@ -114,7 +117,8 @@ void WiFiProvClass :: beginProvision(prov_scheme_t prov_scheme, scheme_handler_t
return;
}
#endif

config.app_event_handler.event_cb = NULL;
config.app_event_handler.user_data = NULL;
wifiLowLevelInit(true);
if(wifi_prov_mgr_init(config) != ESP_OK){
log_e("wifi_prov_mgr_init failed!");
Expand Down Expand Up @@ -154,28 +158,19 @@ void WiFiProvClass :: beginProvision(prov_scheme_t prov_scheme, scheme_handler_t
#if CONFIG_BLUEDROID_ENABLED
}
#endif

if(wifi_prov_mgr_endpoint_create("custom-data") != ESP_OK){
log_e("wifi_prov_mgr_endpoint_create failed!");
return;
}
if(wifi_prov_mgr_start_provisioning(security, pop, service_name, service_key) != ESP_OK){
log_e("wifi_prov_mgr_start_provisioning failed!");
return;
}
if(wifi_prov_mgr_endpoint_register("custom-data", custom_prov_data_handler, NULL) != ESP_OK){
log_e("wifi_prov_mgr_endpoint_register failed!");
return;
}
} else {
wifi_prov_mgr_deinit();
log_i("Aleardy Provisioned");
log_i("Already Provisioned");
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
static wifi_config_t conf;
esp_wifi_get_config(WIFI_IF_STA,&conf);
log_i("Attempting connect to AP: %s\n",conf.sta.ssid);
#endif
esp_wifi_start();
esp_wifi_start();
wifi_prov_mgr_deinit();
WiFi.begin();
}
}
Expand Down