Skip to content

Commit e2c2c2b

Browse files
author
Zhang Jun Hao
committed
feat(example): set authmode threshold to WPA2 when password set
1 parent 65a1809 commit e2c2c2b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

examples/wifi/getting_started/station/main/station_example_main.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ void wifi_init_sta(void)
8686
.password = EXAMPLE_ESP_WIFI_PASS
8787
},
8888
};
89+
90+
/* Setting a password implies station will connect to all security modes including WEP/WPA.
91+
* However these modes are deprecated and not advisable to be used. Incase your Access point
92+
* doesn't support WPA2, these mode can be enabled by commenting below line */
93+
94+
if (strlen((char *)wifi_config.sta.password)) {
95+
wifi_config.sta.threshold.authmode = WIFI_AUTH_WPA2_PSK;
96+
}
97+
8998
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) );
9099
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) );
91100
ESP_ERROR_CHECK(esp_wifi_start() );

0 commit comments

Comments
 (0)