Skip to content

Commit

Permalink
Workaround unsecure AP bug on restart. (#1343)
Browse files Browse the repository at this point in the history
  • Loading branch information
h2zero authored Dec 5, 2022
1 parent 4bbdead commit b9e6c4f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions main/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1273,12 +1273,24 @@ void setup_wifimanager(bool reset_settings) {
InfoIndicatorON();
ErrorIndicatorON();
Log.notice(F("Connect your phone to WIFI AP: %s with PWD: %s" CR), WifiManager_ssid, WifiManager_password);

//fetches ssid and pass and tries to connect
//if it does not connect it starts an access point with the specified name
//and goes into a blocking loop awaiting configuration
if (!wifiManager.autoConnect(WifiManager_ssid, WifiManager_password)) {
Log.warning(F("failed to connect and hit timeout" CR));
delay(3000);

# ifdef ESP32
/* Workaround for bug in arduino core that causes the AP to become unsecure on reboot */
esp_wifi_set_mode(WIFI_MODE_AP);
esp_wifi_start();
wifi_config_t conf;
esp_wifi_get_config(WIFI_IF_AP, &conf);
conf.ap.ssid_hidden = 1;
esp_wifi_set_config(WIFI_IF_AP, &conf);
# endif

//reset and try again
watchdogReboot(3);
delay(5000);
Expand Down

0 comments on commit b9e6c4f

Please sign in to comment.