|
1 | | -/* |
| 1 | + /* |
2 | 2 | WiFiProv.cpp - WiFiProv class for provisioning |
3 | 3 | All rights reserved. |
4 | 4 |
|
@@ -72,13 +72,11 @@ static void get_device_service_name(prov_scheme_t prov_scheme, char *service_nam |
72 | 72 | #endif |
73 | 73 | } |
74 | 74 |
|
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 | + } |
82 | 80 | network_prov_mgr_config_t config; |
83 | 81 | #if CONFIG_BLUEDROID_ENABLED |
84 | 82 | if (prov_scheme == NETWORK_PROV_SCHEME_BLE) { |
@@ -118,11 +116,22 @@ void WiFiProvClass ::beginProvision( |
118 | 116 | if (reset_provisioned) { |
119 | 117 | log_i("Resetting provisioned data."); |
120 | 118 | 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) { |
122 | 120 | log_e("network_prov_mgr_is_wifi_provisioned failed!"); |
123 | 121 | network_prov_mgr_deinit(); |
124 | 122 | return; |
125 | 123 | } |
| 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]; |
126 | 135 | if (provisioned == false) { |
127 | 136 | #if CONFIG_BLUEDROID_ENABLED |
128 | 137 | if (prov_scheme == NETWORK_PROV_SCHEME_BLE) { |
|
0 commit comments