@ESP_igrr, no, I am not setting the channel.
I now added it and it made no difference. Actually, regardless of the channel I set (1,6,11) it always connects on channel 6.
BTW, I was setting the config on first boot, but not on deep sleep wakeup. Setting it every time made no difference.
About nvs. Are you saying that
esp_wifi_set_storage(WIFI_STORAGE_FLASH) will not save the channel, and I need to repeat the
esp_wifi_set_config() after each wakeup? What I am doing is this:
Code: Select all
if (reset_reason != DEEPSLEEP_RESET) {
esp_wifi_set_storage(WIFI_STORAGE_FLASH); // (1) was not doing this before
esp_wifi_set_mode(WIFI_MODE_STA);
wifi_config_t wifi_config = {
.sta = {
.ssid = AP_SSID,
.password = AP_PASS,
.bssid_set = 0,
.channel = 11
},
};
esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config);
esp_wifi_set_auto_connect(1); // (2) was not doing this before
}
(1) All the examples use
WIFI_STORAGE_RAM, so this will not save it - right?
(2) No example does this. Is it needed? Is it the default? Is it remembered after wakeup?
If I do not issue an explicit
esp_wifi_connect then I do not get a connection.
I still see connection to channel 6, and it still takes about 830ms from connect to GOT_IP.
Is there an example of doing this correctly?
TIA,
I will keep reading.
[later]
I grabbed the template example
https://github.com/espressif/esp-idf-te ... ain/main.c.
I added logging to the event handler. I get the same 800+ms wifi connect time and setting the channel has no effect.
I then disabled
dhcp and
added tcpip_adapter_set_ip_info() which had no effect.
Code: Select all
I (1451) wifi: wifi firmware version: 195794b
I (1451) wifi: config NVS flash: enabled
I (1451) wifi: config nano formating: disabled
I (1461) wifi: Init dynamic tx buffer num: 32
I (1461) wifi: Init dynamic rx buffer num: 32
I (1461) wifi: wifi driver task: 3ffbdda0, prio:21, stack:4096
I (1471) wifi: Init static rx buffer num: 10
I (1471) wifi: Init dynamic rx buffer num: 32
I (1471) wifi: Init rx ampdu len mblock:7
I (1481) wifi: Init lldesc rx ampdu entry mblock:4
I (1481) wifi: wifi power manager task: 0x3ffc3168 prio: 19 stack: 2560
I (1491) wifi: wifi timer task: 3ffc41e8, prio:21, stack:3584
I (1501) wifi: mode : sta (30:ae:a4:05:d8:c8)
0.079181 Event 2
I (1621) wifi: n:6 0, o:1 0, ap:255 255, sta:6 0, prof:1
I (2281) wifi: state: init -> auth (b0)
I (2291) wifi: state: auth -> assoc (0)
I (2301) wifi: state: assoc -> run (10)
I (2321) wifi: connected with eyal, channel 6
0.892986 Event 4
0.893265 Event 7
I am still unclear as to the use of nvs for saving the channel. I read all the doco I could find and even
nvs_flash_init() is not described clearly: does it initialize access to nvs (like unix 'mount') or does it clear it (like unix 'mkfs')?
Does
esp_wifi_set_storage(WIFI_STORAGE_RAM) mean "set config in memory but do not save to flash"? If so, then one must first write to flash at lease once (I do not see the examples doing this)?
My test app is here https://github.com/makehackvoid/ESP8266 ... f/template
... I will keep reading...