esp_wifi_scan_start() does not return mesh Information Elements
Posted: Tue Jun 09, 2020 12:55 am
Environment
- Hardware: Custom board (similar to LyraT)
- Core (if using chip or module): ESP32-Wrover-B 16MB
- MDF version: 3ece464
- IDF Version: `6c9c253ed`
- Development Env: Make
- Operating System: MacOS
- Power Supply: external 3.3V
---------
I'm trying to encorporate a scanning function into a project based off the Wireless Debug and Manual Networking examples. However, I seem to be unable to manually detect any nearby mesh devices.
I have 30 active mesh devices and one device which I'm trying to detect them with using my scanning function.
I initialize the WiFI mesh as per the MWifi example. Following the call to mwifi_start() I do the following:
Upon completion of the scan, the MDF_EVENT_MWIFI_SCAN_DONE occurs:
The scan handler function then iterates over each Information Element and prints its attributes to the serial port:
if (ie_len == sizeof(mesh_assoc_t)) Should trigger for each mesh Information Element, however it never does. So I removed it to try to get more results. In my console, I can see Information Elements for nearby routers interspersed with IEs without any SSID:
If these IEs with no SSID are meant to be other mesh devices then
A: there doesn't seem to be enough of these IEs to represent the number of devices I have active and
B: these entries contain no mesh data like "ID".
I don't understand why I'm not getting any mesh Information Elements. Any ideas if this is a bug with ESP-MDF or I am doing something I am doing wrong?
Any help would be massivly appreciated, Thanks.
- Hardware: Custom board (similar to LyraT)
- Core (if using chip or module): ESP32-Wrover-B 16MB
- MDF version: 3ece464
- IDF Version: `6c9c253ed`
- Development Env: Make
- Operating System: MacOS
- Power Supply: external 3.3V
---------
I'm trying to encorporate a scanning function into a project based off the Wireless Debug and Manual Networking examples. However, I seem to be unable to manually detect any nearby mesh devices.
I have 30 active mesh devices and one device which I'm trying to detect them with using my scanning function.
I initialize the WiFI mesh as per the MWifi example. Following the call to mwifi_start() I do the following:
Code: Select all
//Disable self organized networking
esp_mesh_set_self_organized(0, 0);
//Stop any scans already in progress
esp_wifi_scan_stop();
// Remove any scan results that have been obtained (just in case)
esp_mesh_flush_scan_result();
//Manually start scan. Will automatically stop when run to completion
wifi_scan_config_t scan_config = {
.show_hidden = true,
.scan_type = WIFI_SCAN_TYPE_ACTIVE,
};
esp_wifi_scan_start(&scan_config, true);
Code: Select all
case MDF_EVENT_MWIFI_SCAN_DONE: {
// Get event info
mesh_event_scan_done_t *scan_done = (mesh_event_scan_done_t *) event_info;
// Number of APs that have been found
MDF_LOGW("<MESH_EVENT_SCAN_DONE>number:%d", scan_done->number);
// Process the the Information Elements (IE) that have been retrieved, passing the function the number of IEs
mesh_scan_done_handler(scan_done->number);
break;
}
Code: Select all
/**
* @brief Scan local APs to identify existing mesh networks and their IDs
*/
void mesh_scan_done_handler(int num) {
int ie_len = 0; // length of Information Element (IE)
mesh_assoc_t assoc; // Mesh networking IE
wifi_ap_record_t ap_record; // Description of the WiFi AP (SSID, RSSI, Channel etc.)
mesh_type_t my_type = MESH_IDLE;
for (int i=0; i<num; i++) {
// Reset variables ready to read next mesh IE
ie_len = 0;
memset(&ap_record, 0, sizeof(wifi_ap_record_t));
memset(&assoc, 0, sizeof(mesh_assoc_t));
esp_mesh_scan_get_ap_ie_len(&ie_len);
esp_mesh_scan_get_ap_record(&ap_record, &assoc);
// check if this is a mesh IE
if (ie_len == sizeof(mesh_assoc_t)) {
MDF_LOGW("<MESH>[%d]%s, layer:%d/%d, assoc:%d/%d, %d, "MACSTR", channel:%u, rssi:%d, ID<"MACSTR"><%s>",
i, ap_record.ssid, assoc.layer, assoc.layer_cap, assoc.assoc,
assoc.assoc_cap, assoc.layer2_cap, MAC2STR(ap_record.bssid),
ap_record.primary, ap_record.rssi, MAC2STR(assoc.mesh_id), assoc.encrypted ? "IE Encrypted" : "IE Unencrypted");
}
else {
MDF_LOGI("Router, ssid: %s, bssid: " MACSTR ", channel: %u, rssi: %d",
ap_record.ssid, MAC2STR(ap_record.bssid),
ap_record.primary, ap_record.rssi);
}
}
}
Code: Select all
W (8360) [mupgrade_subsystem, 220]: <MESH>[17]BTWifi-with-FON, layer:0/0, assoc:0/0, 0, 6a:a2:22:79:c3:22, channel:11, rssi:-59, ID<00:00:00:00:00:00><IE Unencrypted>
W (8376) [mupgrade_subsystem, 220]: <MESH>[18]BTWifi-X, layer:0/0, assoc:0/0, 0, 6a:a2:22:79:c3:23, channel:11, rssi:-59, ID<00:00:00:00:00:00><IE Unencrypted>
W (8585) [mupgrade_subsystem, 220]: <MESH>[32], layer:0/0, assoc:0/0, 0, 24:6f:28:f0:6f:4d, channel:11, rssi:-55, ID<00:00:00:00:00:00><IE Unencrypted>
W (8599) [mupgrade_subsystem, 220]: <MESH>[33], layer:0/0, assoc:0/0, 0, 24:6f:28:f0:84:69, channel:11, rssi:-61, ID<00:00:00:00:00:00><IE Unencrypted>
A: there doesn't seem to be enough of these IEs to represent the number of devices I have active and
B: these entries contain no mesh data like "ID".
I don't understand why I'm not getting any mesh Information Elements. Any ideas if this is a bug with ESP-MDF or I am doing something I am doing wrong?
Any help would be massivly appreciated, Thanks.