tonyp7 / esp32-wifi-manager

Captive Portal for ESP32 that can connect to a saved wireless network or start an access point where you can connect to existing wifis.
MIT License
664 stars 217 forks source link

wifi manager NVS does not work in dual CPU mode on esp32 #21

Closed snahmad closed 5 years ago

snahmad commented 5 years ago

Hi,

Can you test your wifi manager start and stop in freeRTOS dual core mode.

Thanks, Naeem

snahmad commented 5 years ago

NVS is now working but wifi_manager_lock_json_buffer crash when running on dual core mode and running
wifi manager in separate task schedule to run on cpu_1. Can you try yourself please.

snahmad commented 5 years ago

You wifi manager did not deinit calls before destroy I put now it is working.

I will share code later.

tonyp7 commented 5 years ago

Hi Naeem, can you share just the code on how you initialize each task on a specific core? wifi_manager_lock_json_buffer is a wrapper for xSemaphoreTake and should be 100% thread-safe.

snahmad commented 5 years ago
ESP_ERROR_CHECK(esp_wifi_stop() );
ESP_LOGI(TAG, "wifi_init_sta deinit sta");
ESP_ERROR_CHECK(esp_wifi_deinit() );

I added these deinit before exit

void wifi_manager( void * pvParameters )

tonyp7 commented 5 years ago

I don't think you can stop wifi abruptly without properly cleaning up objects and memory.

I created wifi_manager_destroy to keep track of the allocated object and because it is good practice but realistically today there is no easy way to stop the manager "cleanly" this should be an added feature.

snahmad commented 5 years ago

It is working for me before esp_restart. otherwise it get heap corruption

snahmad commented 5 years ago

Hi tony,

I start with default hard code name for DEFAULT_AP_SSID and DEFAULT_AP_PASSWORD.

How I need to stop wifi and change SSID and password programmatically either via serial or over the air using Http post comands.

Is it possible. I guess I need to stop and restart wifi after setting new ssid and password.

snahmad commented 5 years ago

I don't think you can stop wifi abruptly without properly cleaning up objects and memory.

I created wifi_manager_destroy to keep track of the allocated object and because it is good practice but realistically today there is no easy way to stop the manager "cleanly" this should be an added feature.

It is working in latest verison = 3.2. I try with version =3.1. got crash.