@@ -72,13 +72,11 @@ static void get_device_service_name(prov_scheme_t prov_scheme, char *service_nam
7272#endif
7373}
7474
75- void WiFiProvClass ::beginProvision (
76- prov_scheme_t prov_scheme, scheme_handler_t scheme_handler, network_prov_security_t security, const char *pop, const char *service_name,
77- const char *service_key, uint8_t *uuid, bool reset_provisioned
78- ) {
79- bool provisioned = false ;
80- static char service_name_temp[32 ];
81-
75+ void WiFiProvClass ::initProvision (prov_scheme_t prov_scheme, scheme_handler_t scheme_handler, bool reset_provisioned) {
76+ if (this ->provInitDone ) {
77+ log_i (" provInit was already done!" );
78+ return ;
79+ }
8280 network_prov_mgr_config_t config;
8381#if CONFIG_BLUEDROID_ENABLED
8482 if (prov_scheme == NETWORK_PROV_SCHEME_BLE) {
@@ -118,11 +116,22 @@ void WiFiProvClass ::beginProvision(
118116 if (reset_provisioned) {
119117 log_i (" Resetting provisioned data." );
120118 network_prov_mgr_reset_wifi_provisioning ();
121- } else if (network_prov_mgr_is_wifi_provisioned (&provisioned) != ESP_OK) {
119+ } else if (network_prov_mgr_is_wifi_provisioned (&( this -> provisioned ) ) != ESP_OK) {
122120 log_e (" network_prov_mgr_is_wifi_provisioned failed!" );
123121 network_prov_mgr_deinit ();
124122 return ;
125123 }
124+ this ->provInitDone = true ;
125+ }
126+
127+ void WiFiProvClass ::beginProvision (
128+ prov_scheme_t prov_scheme, scheme_handler_t scheme_handler, network_prov_security_t security, const char *pop, const char *service_name,
129+ const char *service_key, uint8_t *uuid, bool reset_provisioned
130+ ) {
131+ if (!this ->provInitDone ) {
132+ WiFiProvClass ::initProvision (prov_scheme, scheme_handler, reset_provisioned);
133+ }
134+ static char service_name_temp[32 ];
126135 if (provisioned == false ) {
127136#if CONFIG_BLUEDROID_ENABLED
128137 if (prov_scheme == NETWORK_PROV_SCHEME_BLE) {
0 commit comments