Wifi Scan while mesh connected

Die_32_
Posts: 58
Joined: Wed May 05, 2021 2:42 pm

Wifi Scan while mesh connected

Postby Die_32_ » Thu Oct 07, 2021 7:22 am

Hi I have multiple ESP connected via wifi-mesh.

I want to perform a Wifi scan while the ESP is mesh connected ( and If I found a specific AP tell to the ESP to connect to it ).

I'm trying to do this: https://docs.espressif.com/projects/esp ... -mesh.html
At Calling Wi-Fi API paragraph.
But the ESP "sees" only an AP:

Code: Select all

uint16_t number = 10;
		wifi_ap_record_t ap_info[10];
		uint16_t ap_count;
		memset(ap_info, 0, sizeof(ap_info));

		wifi_scan_config_t scan_config = {
			.ssid = 0,
			.bssid = 0,
			.channel = 0,
		        .show_hidden = true
		};


		//Disable self organized networking
		esp_mesh_set_self_organized(0, 0);

		//Stop any scans already in progress
		esp_wifi_scan_stop();
		//Manually start scan. Will automatically stop when run to completion
		ESP_ERROR_CHECK(esp_wifi_scan_start(&scan_config, true));
		//Process scan results

		ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&number, ap_info));
		ESP_ERROR_CHECK(esp_wifi_scan_get_ap_num(&ap_count));
		ESP_LOGI(TAG, "Total APs scanned = %u", ap_count);
		for (int i = 0; i < 10; i++) {
			ESP_LOGI(TAG, "SSID : %s\n", ap_info[i].ssid);

		}

		//Re-enable self organized networking if still connected
		esp_mesh_set_self_organized(1, 0);

		//Re-enable self organized networking if non-root and disconnected
		esp_mesh_set_self_organized(1, 1);

		//Re-enable self organized networking if root and disconnected
		esp_mesh_set_self_organized(1, 0);  //Don't select new parent
		esp_mesh_connect();                 //Manually reconnect to router
	
What am I doing wrong ?

Die_32_
Posts: 58
Joined: Wed May 05, 2021 2:42 pm

Re: Wifi Scan while mesh connected

Postby Die_32_ » Thu Oct 07, 2021 12:47 pm

I have 2 different behaviour:

1) if the node is root: I got a list of SSID's AP
2) if the node is a child connected to the root: I got only the SSID of the parent

Die_32_
Posts: 58
Joined: Wed May 05, 2021 2:42 pm

Re: Wifi Scan while mesh connected

Postby Die_32_ » Mon Oct 11, 2021 6:29 am

Anyone ?

Thanks

imark007
Posts: 2
Joined: Sat Oct 06, 2018 1:20 pm

Re: Wifi Scan while mesh connected

Postby imark007 » Wed Dec 01, 2021 12:00 pm

I have been trying to the the same thing. I am coming to the conclusion that the only way to do an active scan is to shut down all of the running mwifi related operations.

For example, I have tried adding the following lines in a function called mesh_scan_func(). This creates a scan correctly and if only a root node is connected to AP, everything starts back up successfully. However, if non-root nodes are already connected, the nodes connect to the root while the root is still trying to get IP address from the AP (router). If anyone has a solution that doesn't require shutting the mesh down, please share.

Code: Select all

    /* Set to stop self organization and stop any existing scanning */
    ESP_ERROR_CHECK(esp_mesh_set_self_organized(false, false));
    esp_wifi_scan_stop();
    /* Stop services that interfer with getting IP address from AP after scan */
    ret = mlink_notice_deinit();
    MDF_ERROR_CHECK(ret != MDF_OK, ret, "mlink_notice_deinit");
    ret = mlink_httpd_stop();
    MDF_ERROR_CHECK(ret != MDF_OK, ret, "mlink_httpd_stop");
    esp_netif_dhcpc_stop(sta_netif);
    ret = mwifi_stop();
    MDF_ERROR_CHECK(ret != MDF_OK, ret, "mwifi_stop");

Who is online

Users browsing this forum: No registered users and 217 guests