Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP_ATMod does not reconnect to APs when using ESP8266 Arduino Core versions 3.0 or above #11

Closed
PixlRainbow opened this issue Nov 16, 2021 · 11 comments
Labels

Comments

@PixlRainbow
Copy link

This is caused by a new breaking change to the ESP Arduino Core which was implemented this year (2021).
Persistence is now disabled by default in the new Core and WiFi also no longer reconnects at boot even if autoconnect is enabled.

enableWiFiAtBootTime() can be added to restore the legacy behaviour.
Alternatively, you can just call WiFi.begin() with no parameters just after you set WiFi defaults to initiate an attempt to connect to the last AP, if it exists.

@JiriBilek
Copy link
Owner

JiriBilek commented Nov 16, 2021

Thanks for the observation. I have to study it more as I want the library to be able to run with both cores. For that reason the enableWiFiAtBootTime() function is not an option, unfortunately.

Edit: According to the source there is a chance to use enableWiFiAtBootTime(). I will have to test it thoroughly.

@PixlRainbow
Copy link
Author

another related issue is that the current implementation of AT+CWJAP differs from the behaviour documented in the official AT command firmware, not sure if this is intentional.
Executing AT+CWJAP with no parameters should initiate an attempt to reconnect to the last AP with saved configuration, but in ATMod it is treated as invalid command.

@JiriBilek
Copy link
Owner

JiriBilek commented Oct 16, 2022

Executing AT+CWJAP with no parameters should initiate an attempt to reconnect to the last AP with saved configuration, but in ATMod it is treated as invalid command.

I try to make the commands as much as possible equal to the standard AT firmware from Espressif.

The older versions of AT-firmware (e.g. ESP8266_NONOS_SDK_V2.2.1_18_06_08) don't implement this feature so I didn't implement it either.
The new version of AT-firmware (ESP8266-IDF-AT_V2.2.1.0) recognizes simple AT+CWJAP and reconnects, but on the other side the commands AT+CWJAP_CUR and AT+CWJAP_DEF don't work. I assume that AT+CWJAP in newer firmwares works like AT+CWJAP_DEF in the older ones.

It would be easy to make AT+CWJAP get the credentials from the previous AT+CWJAP_DEF and connect but I am not sure this is what you want.

@JAndrassy : I haven't looked to your code yet, are you using AT+CWJAP_DEF for setting persistent connections? I assume so, because my firmware reconnects using AT+CWJAP_DEF after reset.

Edit: the ESP8266-IDF-AT_V2.2.1.0 firmware connects using TLS 1.2 so that it can be used instead of my fw (much to my regret 😊).

@JAndrassy
Copy link
Contributor

JAndrassy commented Oct 16, 2022

the ESP8266-IDF-AT_V2.2.1.0 is very bad and they don't create new versions of AT 2 for esp8266.
AT2 has AT+SYSSTORE to control CUR/DEF

CWMODE should start remembered STA or SoftAP. but in esp8266 arduino I discovered problems yesterday. I investigate it.

@JAndrassy
Copy link
Contributor

CWMODE should start remembered STA or SoftAP. but in esp8266 arduino I discovered problems yesterday. I investigate it.

the problem is only with core 3. setting WiFi.mode or using enableSTA() doesn't join the AP and enableAP() doesn't start the SoftAP. enableWiFiAtBootTime() doesn't change that. I ask the esp8266 core devs if that is intended.

@JAndrassy
Copy link
Contributor

JAndrassy commented Oct 16, 2022

I tested it again and STA joins AP at start even without enableWiFiAtBootTime(). but I removed mode from setup() in the SoftAP PR.

@PixlRainbow which version of ESP_ATMod do you use?

@PixlRainbow
Copy link
Author

I haven't used ATMod in a year, the last version I used was d6ad63f

@JAndrassy
Copy link
Contributor

CWMODE should start remembered STA or SoftAP. but in esp8266 arduino I discovered problems yesterday. I investigate it.

the problem is only with core 3. setting WiFi.mode or using enableSTA() doesn't join the AP and enableAP() doesn't start the SoftAP. enableWiFiAtBootTime() doesn't change that. I ask the esp8266 core devs if that is intended.

after proper testing:
STA) the STA requires WiFi.begin() (without parameters) to join AP after setting mode to WIFI_STA even in 2.7.4
SoftAP) the SoftAP starts good after setting mode to WIFI_AP in 2.7.4 and git master, but fails to properly start in 3.0.2

@JiriBilek
Copy link
Owner

Juraj,
I am a bit lost. Could you please post your tests (AT commands) so that I can reproduce the problem?

@JAndrassy
Copy link
Contributor

Juraj, I am a bit lost. Could you please post your tests (AT commands) so that I can reproduce the problem?

It is not a problem with start at boot but with start of persistent SoftAP or STA rejoining AP after mode is switched. In normal AT fw setting mode starts SoftAP/rejoins AP. In arduino core, setting mode to AP starts the SoftAP too, but setting mode to STA doesn't rejoin AP. This is first problem. I will create a PR for ESP_ATMod to add WiFi.begin() in AT_CWMODE .

The second problem is that in core 3.0.2 there is some error with SoftAP started with setting mode . The SoftAP starts, but stations can't connect. This will be solved with release of core 3.1.0

To replicate you have to first setup persistent settings for STA and AP with AT+CWSAP and AT+CWJAP and set mode to STA with AT+CWMODE=1. Then reset.
After reset use AT+CWMODE_CUR=2 to turn off STA. then start it back with AT+CWMODE_CUR=1. STA starts again and should rejoin AP with persistent settings (maybe even with last CUR settings (I didn't test that)). Previous AT+CWMODE_CUR=1 turned SoftAP off. Entering AT+CWMODE_CUR=2 starts SoftAP with last (persistent) settings.

@JAndrassy
Copy link
Contributor

correction AT+CWMODE=1 (or 3) doesn't rejoin AP in standard AT firmware. so current implementation of cmd_AT_CWMODE is OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants