Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit efe966d

Browse filesBrowse files
authored
Avoid starting AP Mode even when the password is too short (espressif#7832)
* Avoid starting AP Mode even when the password is too short * Check SoftAP return code in case of failure
1 parent b31c936 commit efe966d
Copy full SHA for efe966d

File tree

2 files changed

+12
-7
lines changed
Filter options

2 files changed

+12
-7
lines changed

‎libraries/WiFi/examples/WiFiAccessPoint/WiFiAccessPoint.ino

Copy file name to clipboardExpand all lines: libraries/WiFi/examples/WiFiAccessPoint/WiFiAccessPoint.ino
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ void setup() {
3232
Serial.println("Configuring access point...");
3333

3434
// You can remove the password parameter if you want the AP to be open.
35-
WiFi.softAP(ssid, password);
35+
// a valid password must have more than 7 characters
36+
if (!WiFi.softAP(ssid, password)) {
37+
log_e("Soft AP creation failed.");
38+
while(1);
39+
}
3640
IPAddress myIP = WiFi.softAPIP();
3741
Serial.print("AP IP address: ");
3842
Serial.println(myIP);

‎libraries/WiFi/src/WiFiAP.cpp

Copy file name to clipboardExpand all lines: libraries/WiFi/src/WiFiAP.cpp
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,6 @@ void wifi_softap_config(wifi_config_t *wifi_config, const char * ssid=NULL, cons
136136
bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel, int ssid_hidden, int max_connection, bool ftm_responder)
137137
{
138138

139-
if(!WiFi.enableAP(true)) {
140-
// enable AP failed
141-
log_e("enable AP first!");
142-
return false;
143-
}
144-
145139
if(!ssid || *ssid == 0) {
146140
// fail SSID missing
147141
log_e("SSID missing!");
@@ -154,6 +148,13 @@ bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel,
154148
return false;
155149
}
156150

151+
// last step after checking the SSID and password
152+
if(!WiFi.enableAP(true)) {
153+
// enable AP failed
154+
log_e("enable AP first!");
155+
return false;
156+
}
157+
157158
wifi_config_t conf;
158159
wifi_config_t conf_current;
159160
wifi_softap_config(&conf, ssid, passphrase, channel, WIFI_AUTH_WPA2_PSK, ssid_hidden, max_connection, ftm_responder);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.