Skip to content

Commit 86d38ed

Browse files
authored
Update WiFiSTA.cpp
1 parent 04e9534 commit 86d38ed

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

Diff for: libraries/WiFi/src/WiFiSTA.cpp

+16-3
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,15 @@ IPv6Address WiFiSTAClass::localIPv6()
655655
bool WiFiSTAClass::_smartConfigStarted = false;
656656
bool WiFiSTAClass::_smartConfigDone = false;
657657

658-
659-
bool WiFiSTAClass::beginSmartConfig() {
658+
/**
659+
* @brief
660+
*
661+
* @param type Select type of SmartConfig. Default type is SC_TYPE_ESPTOUCH
662+
* @param crypt_key When using type SC_TYPE_ESPTOUTCH_V2 crypt key needed, else ignored. Lenght should be 16 chars.
663+
* @return true if configuration is successful.
664+
* @return false if configuration fails.
665+
*/
666+
bool WiFiSTAClass::beginSmartConfig(smartconfig_type_t type, char* crypt_key) {
660667
esp_err_t err;
661668
if (_smartConfigStarted) {
662669
return false;
@@ -668,7 +675,13 @@ bool WiFiSTAClass::beginSmartConfig() {
668675
esp_wifi_disconnect();
669676

670677
smartconfig_start_config_t conf = SMARTCONFIG_START_CONFIG_DEFAULT();
671-
err = esp_smartconfig_set_type(SC_TYPE_ESPTOUCH);
678+
679+
if (type == SC_TYPE_ESPTOUCH_V2){
680+
conf.esp_touch_v2_enable_crypt = true;
681+
conf.esp_touch_v2_key = crypt_key;
682+
}
683+
684+
err = esp_smartconfig_set_type(type);
672685
if (err != ESP_OK) {
673686
log_e("SmartConfig Set Type Failed!");
674687
return false;

0 commit comments

Comments
 (0)