Fallback to AP Mode, How To Do This?
Moderators: grovkillen, Stuntteam, TD-er
Fallback to AP Mode, How To Do This?
I need advice on how to enable my ESPEasy device to fallback to the AP-Mode when the WiFi fails to connect to my router. I'm using a recent test build: ESP_Easy_mega_20240730_collection_B_ESP32_4M316k Jul 30 202
I'm using the default AP-Mode configuration. In my testing, I allowed the STA mode to connect as usual. Then I entered/saved an invalid SSID to cause STA mode failure. Then I reboot. I expect the AP mode to be enabled after 10 minutes. But I never see it.
Reviewing serial logs, I can see the WiFi scan occur every minute. But this periodic scan goes on forever, I never see log entries that are related to AP.
Seems I have a bad setting somewhere. What could it be?
- Thomas
I'm using the default AP-Mode configuration. In my testing, I allowed the STA mode to connect as usual. Then I entered/saved an invalid SSID to cause STA mode failure. Then I reboot. I expect the AP mode to be enabled after 10 minutes. But I never see it.
Reviewing serial logs, I can see the WiFi scan occur every minute. But this periodic scan goes on forever, I never see log entries that are related to AP.
Seems I have a bad setting somewhere. What could it be?
- Thomas
Re: Fallback to AP Mode, How To Do This?
Probably not a bad setting, as I've heard this same description before...
Re: Fallback to AP Mode, How To Do This?
OK, sounds like there's a backstory about this.
Deleting the existing WiFi credentials restored the AP mode. But my application would need it to switch automatically when the WiFi Router connection is lost after a few minutes. What kind of magic do you suggest I try?
- Thomas
Deleting the existing WiFi credentials restored the AP mode. But my application would need it to switch automatically when the WiFi Router connection is lost after a few minutes. What kind of magic do you suggest I try?
- Thomas
Re: Fallback to AP Mode, How To Do This?
F5-ing on the GitHub page...
Ton did make some good suggestions via chat where the bug might be.
Not sure if I can manage to fix it this evening, but I will now fetch a new beer and move upstairs, now Lilly is asleep.
Re: Fallback to AP Mode, How To Do This?
That's unfortunate news.Nothing you can change in config, ATM.
- Thomas
Re: Fallback to AP Mode, How To Do This?
That sounds promising.Not sure if I can manage to fix it this evening, but I will now fetch a new beer and move upstairs, now Lilly is asleep.
I added a WiFiAPMode command in my rules that is executed at boot if WiFi STA fails. That at least allows AP mode to start up so I can access the device when WiFi is down. Not ideal, but workarounds sometimes need duct tape and baling wire.
- Thomas
Re: Fallback to AP Mode, How To Do This?
Adding the AP-Mode rule allowed me to try out the device at the new location. I discovered that this site uses a VLAN that isolates the local subnet IP's. So my phone is blocked from accessing ESPEasy unless I am in AP-Mode. Fortunately, with normal WiFi operation (STA-Mode) the device can still send emails, so that is a relief.
But back to the drawing board; My workaround involved adding a push button switch that turns on AP-Mode. In this situation, both STA-Mode and AP-Mode are enabled at the same time. This allows the device to continue sending emails, but with a temporary "backdoor" access via AP-Mode so I can perform firmware upgrades and rule edits.
I will only have the AP-Mode active for a short time. The same push switch that turns on AP access also has a long-press for reboot, which essentially turns it off. So far my bench testing works well, I haven't noticed any issues with this (yet).
Now the question. Is ESPEasy (ESP32) expected to perform as usual with both AP and STA modes turned on at the same time? Or am I sailing in uncharted territory?
Just want to confirm that this will be an OK thing to do.
- Thomas
But back to the drawing board; My workaround involved adding a push button switch that turns on AP-Mode. In this situation, both STA-Mode and AP-Mode are enabled at the same time. This allows the device to continue sending emails, but with a temporary "backdoor" access via AP-Mode so I can perform firmware upgrades and rule edits.
I will only have the AP-Mode active for a short time. The same push switch that turns on AP access also has a long-press for reboot, which essentially turns it off. So far my bench testing works well, I haven't noticed any issues with this (yet).
Now the question. Is ESPEasy (ESP32) expected to perform as usual with both AP and STA modes turned on at the same time? Or am I sailing in uncharted territory?
Just want to confirm that this will be an OK thing to do.
- Thomas
Re: Fallback to AP Mode, How To Do This?
STA+AP mode is a bit tricky as the combination does limit the STA interface a bit... at least on some ESP's.
For example I know some ESP's (or was it just the ESP8266, don't remember anymore) cannot use 802.11n anymore when in STA+AP mode.
Also there is a rather annoying dependency where the channel for STA is set by the AP you connect to, but you really must run both AP & STA on the same channel or else you will loose a lot of packets.
So if the AP you connect to is changing channels, you must also turn off AP mode, let STA connect to the AP and then you can start AP mode on the ESP again on the same channel as STA is running.
Then there is the power consumption, which is quite a lot more compared to running in STA mode.
Just another work-around to make your ESP node accessible when the normal WiFI network is unavailable is to start a hotspot on your mobile with the known credentials from the unavailable network.
For example I know some ESP's (or was it just the ESP8266, don't remember anymore) cannot use 802.11n anymore when in STA+AP mode.
Also there is a rather annoying dependency where the channel for STA is set by the AP you connect to, but you really must run both AP & STA on the same channel or else you will loose a lot of packets.
So if the AP you connect to is changing channels, you must also turn off AP mode, let STA connect to the AP and then you can start AP mode on the ESP again on the same channel as STA is running.
Then there is the power consumption, which is quite a lot more compared to running in STA mode.
Just another work-around to make your ESP node accessible when the normal WiFI network is unavailable is to start a hotspot on your mobile with the known credentials from the unavailable network.
Re: Fallback to AP Mode, How To Do This?
Thanks for the information. Fingers are crossed this workaround is mostly trouble-free.
- Thomas
That's a clever idea. I'll keep it in mind.Just another work-around to make your ESP node accessible when the normal WiFI network is unavailable is to start a hotspot on your mobile with the known credentials from the unavailable network.
- Thomas
Who is online
Users browsing this forum: Bing [Bot], Semrush [Bot] and 19 guests