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

Connect to new AP while already connected error #131

Open
3 tasks done
pablacho opened this issue Apr 24, 2021 · 0 comments
Open
3 tasks done

Connect to new AP while already connected error #131

pablacho opened this issue Apr 24, 2021 · 0 comments

Comments

@pablacho
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am using the latest version of esp32-wifi-manager
  • I have searched open and closed issues to ensure it has not already been reported

Description

While connected to an access point, it is not possible to change to another one unless I disconnect from the first one

Steps to Reproduce

  1. Connect module to wifi SSID "A"
  2. Find the server page inside "A" network, shows connected to wifi SSID "A"
  3. Try to change credentials to connect to SSID "B"

System Configuration

FreeRTOS with custom app running, forked esp32-wifi-manager with changes due to app, recently rebased and issue started right after.
The mod only affects information loaded by user and stored in NVM. The issue seems to be here:

			case WM_ORDER_CONNECT_STA:
				ESP_LOGI(TAG, "MESSAGE: ORDER_CONNECT_STA");

				/* very important: precise that this connection attempt is specifically requested.
				 * Param in that case is a boolean indicating if the request was made automatically
				 * by the wifi_manager.
				 * */
				if((BaseType_t)msg.param == CONNECTION_REQUEST_USER) {
					xEventGroupSetBits(wifi_manager_event_group, WIFI_MANAGER_REQUEST_STA_CONNECT_BIT);
				}
				else if((BaseType_t)msg.param == CONNECTION_REQUEST_RESTORE_CONNECTION) {
					xEventGroupSetBits(wifi_manager_event_group, WIFI_MANAGER_REQUEST_RESTORE_STA_BIT);
				}

				uxBits = xEventGroupGetBits(wifi_manager_event_group);
				if( ! (uxBits & WIFI_MANAGER_WIFI_CONNECTED_BIT) ){
					/* update config to latest and attempt connection */
					ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, wifi_manager_get_wifi_sta_config()));

					/* if there is a wifi scan in progress abort it first
					   Calling esp_wifi_scan_stop will trigger a SCAN_DONE event which will reset this bit */
					if(uxBits & WIFI_MANAGER_SCAN_BIT){
						esp_wifi_scan_stop();
					}
					ESP_ERROR_CHECK(esp_wifi_connect());
				}

				/* callback */
				if(cb_ptr_arr[msg.code]) (*cb_ptr_arr[msg.code])(NULL);

				break;

while connected, WIFI_MANAGER_WIFI_CONNECTED_BIT is set so it never enters and the web application just hangs as never gets an OK/NOK answer.

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

No branches or pull requests

1 participant