Skip to content

Commit dcb6504

Browse files
committed
fix softap issues on fw upgrade
1 parent 5455dfc commit dcb6504

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/configServer.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "obsimprov.h"
4242
#include <WiFi.h>
4343
#include <WiFiMulti.h>
44+
#include <esp_wifi.h>
4445
#include <esp_arduino_version.h>
4546

4647
using namespace httpsserver;
@@ -698,7 +699,13 @@ bool CreateWifiSoftAP() {
698699
log_i("Initialize SoftAP");
699700
String apName = OBS_ID;
700701
String APPassword = "12345678";
701-
softAccOK = WiFi.softAP(apName.c_str(), APPassword.c_str(), 1, 0, 1);
702+
703+
// without this sometimes during firmware upgrades when upgrading esp-idf
704+
// the wifi SoftAP will not accept clients
705+
esp_wifi_restore();
706+
707+
softAccOK = WiFi.softAP(apName.c_str(), APPassword.c_str(), 1, 0, 2);
708+
702709
delay(2000); // Without delay I've seen the IP address blank
703710
/* Soft AP network parameters */
704711
IPAddress apIP(172, 20, 0, 1);
@@ -827,6 +834,13 @@ void startServer(ObsConfig *obsConfig) {
827834
obsDisplay->showTextOnGrid(1, 1,
828835
theObsConfig->getProperty<String>(ObsConfig::PROPERTY_WIFI_SSID));
829836

837+
// We don't really need persistent wifi config from the ESP
838+
// - it will even potentially leave wifi credentials on ESPs.
839+
// additionally it can break softAP during ESP-Framework upgrades.
840+
// The main purpose seems to be to slightly speed up wifi
841+
// config which is not so relevant for us.
842+
WiFi.persistent(false);
843+
830844
tryWiFiConnect();
831845

832846
if (WiFiClass::status() != WL_CONNECTED) {

0 commit comments

Comments
 (0)