Skip to content

Commit

Permalink
Provisioning Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sweetymhaiske committed Nov 12, 2020
1 parent 9debb9f commit af09d39
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
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
18 changes: 5 additions & 13 deletions libraries/WiFi/src/WiFiProv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,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 +155,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
3 changes: 3 additions & 0 deletions libraries/WiFi/src/WiFiProv.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

#include "WiFi.h"
#include "wifi_provisioning/manager.h"
#if CONFIG_IDF_TARGET_ESP32
#include "SimpleBLE.h"
#endif
//Select the scheme using which you want to provision
typedef enum {
WIFI_PROV_SCHEME_SOFTAP,
Expand Down

0 comments on commit af09d39

Please sign in to comment.