Closed paulkilroy closed 3 years ago
Sorry for taking such a long time to get back. I'm quite busy at the moment. However, thanks a lot for your work! 🙂
Interesting that it breaks things. That doesn't make sense to me. I kept it in when I initially created the project, as I didn't find conclusive information about it at the time. But it makes sense to remove it.
I assume it can't auto reconnect when in AP only mode? I do want it to auto reconnect if it loses WiFi connection for whatever reason. Having to reconnect to the AP or reboot it if it loses connection would be a bad experience compared to auto reconnect. Maybe it could be set up to go into AP only/config mode if it fails to connect on the first try after a reboot. Thereafter it could either do as it does now, or just not create an AP at all until next reboot.
I'm a bit hesitant towards the delay in the main loop() as the atemSwitcher.runLoop();
method needs to be run frequently enough. I don't have access to a switcher currently, so it'd be a couple of days at least before I can test the code on an ESP8266 with an actual ATEM device.
I got to do a little bit of testing on my ESP8266, and did a few findings.
Latest version of board manager for ESP8266 requires WiFi.persistent(true)
as it's now disabled by default. See here
Also, for both ESP8266 and ESP32 i found that false should be the 5th argument to stop WiFi.begin()
from connecting. See begin
for ESP8266 and ESP32
I'll close this pr as I pushed it into a branch in my repo, as I couldn't push to your fork directly.
There were a few issues with the underlying ESP32 WiFi code to work around. Turning on verbose logging helped see a lot of extra stuff going on and out of sequence things.
1- calls to WiFi.persistent( false ) and then to true were not necessary. According to the documentation the ESP will not update the SSID/PSK in EEPROM as long as they do not change. The setting back and forth confused the ESP32 code and it would not save for some reason. I didn't look that deep, but removing the calls to WiFi.persistent(false) fixed things
2- Putting the board in AP and Station mode at the same time (AP_STA) confused the ESP32 with AutoReconnect set to true. This caused delays in connecting to the AP, serving web pages and saving -- maybe other things as well. I changed this to put it in only AP mode if it can't connect via Station, then switch back to Station after the WiFi config has been updated. Now connecting to the AP and config page is fast and reliable.
3- I needed to add a few delay()s in the saving code to get the ESP32 to switch over from AP mode to STA mode during the saving of the config. To compensate, I trimmed down the existing 4 second save and added a server.close() before it which flushed the connection (at least on the ESP32)
You code is awesome, and very easy to walk though. Thanks for making this available to the public! Let me know if this doesn't work on your ESP, my email is my git account on gmail if you want to chat directly.