forked from espressif/arduino-esp32
Provisioning Fixes (#4522)
This commit is contained in:
@ -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() {
|
||||
|
@ -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);
|
||||
|
||||
@ -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!");
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user